-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.c
46 lines (40 loc) · 854 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "device.h"
#include "server.h"
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
void sig_handler(int signo)
{
if(signo == SIGPIPE)
{
printf("Recv SIGPIPE From Browser.\n");
write_log(1,"sig_handler()","Recv SIGPIPE From Browser.");
}
}
void str_err(const char* name)
{
fprintf(stderr,"%s: %s\n",name,strerror(errno));
exit(1);
}
int main(int argc,char** argv)
{
if(argc < 3)
{
fprintf(stderr,"Usage: %s [dev] [port]\n",argv[0]);
exit(1);
}
signal(SIGPIPE,sig_handler);
camera_fd = open(argv[1],O_RDWR|O_NONBLOCK);
install_dev();
//cam_on();
init_socket(atoi(argv[2]));
start_listen(10);
uninit_socket();
//cam_off();
uninstall_dev();
return 0;
}