int main() { //init win32 socket #ifdef __WIN32__ static WSADATA wsa_data; int result = WSAStartup((WORD)(1<<8|1), &wsa_data); //初始化WinSocket动态连接库 if( result != 0 ) // 初始化失败 return -1; #endif #ifndef __WIN32__ signal( SIGPIPE, SIG_IGN ); //ignore send,recv SIGPIPE error #endif NEW( websrv, sizeof(webserver) ); memset( websrv, 0, sizeof(webserver) ); server_create( websrv, "config.xml" ); server_start( websrv ); do_console(); server_stop( websrv ); server_end( websrv ); DEL( websrv ); #ifdef __WIN32__ WSACleanup(); #endif memory_end(); return 0; }
int main(int argc, char *argv[]) { int ret=0; char product_name[128] = {0}; signal(SIGPIPE, SIG_IGN); strcat(product_name, "Triclouds_CVR_Daemon"); #ifdef _OPEN_SECURED_CONN ssl_server_init("cacert.pem","privkey.pem"); printf("\n ==== start secure CVR tunnel deamon service at port %d ====\n",secure_service_port); #endif printf("\n ==== start CVR tunnel deamon service at port %d ====\n",service_port); // start Tunnel server service ret = tunnel_server_init(); // start process commands #ifndef TEST_TUNNEL while(!do_exit) sleep(1); #else if (ret>=0) do_console(); #endif tunnel_server_exit(); printf("exit CVR tunnel deamon service\n"); return 0; }
/* MAIN */ int main(int argc, char **argv) { pid_t pid; struct sigaction sa; if (argc < 1) { fprintf(stderr,"Usage: echocon program args...\n"); exit(-1); } if (geteuid() != 0) { fprintf(stderr,"You must be root in order to run %s\n",argv[0]); exit(-1); } if (fork()) exit(0); /* decouple from terminal */ pid = setsid(); if (pid == -1) { fprintf(stderr,"setsid failed: %d,%d\n",pid,errno); exit(-1); } setjmp(env); settitle("consoled"); if ((console = open("/dev/console",O_RDWR,0)) < 0) { fprintf(stderr,"could not open /dev/console\n"); exit(-1); } if (openpty(&master,&slave,0,0,0) < 0) { fprintf(stderr,"out of ptys\n"); return -1; } /* child signal handler */ sa.sa_handler = pchild; sa.sa_flags = SA_NOCLDSTOP; sa.sa_mask = 0xffffffff; if (sigaction(SIGCHLD,&sa,NULL) != 0) { fprintf(stderr,"sigaction child failed\n"); exit(-1); } /* kill consoled, kills it children and exits. */ sa.sa_handler = wrapup; sa.sa_flags = 0; sa.sa_mask = 0xffffffff; if (sigaction(SIGHUP,&sa,NULL) != 0) { fprintf(stderr,"sigaction child failed\n"); exit(-1); } sa.sa_handler = wrapup; sa.sa_flags = 0; sa.sa_mask = 0xffffffff; #if 0 if (sigaction(SIGTERM,&sa,NULL) != 0) { fprintf(stderr,"sigaction child failed\n"); exit(-1); } #endif progpid = start_login(slave); if (progpid == -1) { fprintf(stderr,"start login failed\n"); exit(-1); } close(slave); do_console(master,console); /* Never reached */ assert(0); return 0; }
int main(int argc, char *argv[]) { int fd; int i; struct context ctx; if (0 != parse_options(argc, argv)) { usage(); return 1; } if ((fd = serialOpen(device_name)) < 0) { fprintf(stderr, "Failed to open %s\n", device_name); return 1; } ctx.fd = fd; if (opt_flash) { if (0 != check_for_bootloader(fd, opt_timeout)) { fprintf(stderr, "No bootloader detected\n"); return 1; } else { printf("Bootloader detected\n"); } for (i=0;i<FLASH_SIZE_KB/FLASH_PAGE_SIZE;i++) { printf("Erasing page %d\n", i); if (0 != erase_page(fd, i)) { fprintf(stderr, "Erasing page failed\n"); return 1; } } if (0 != read_hexfile(flash_filename, handle_record_00, handle_record_04, &ctx)) { fprintf(stderr, "Failed to read %s\n", flash_filename); return 1; } if (0 != reset(fd)) { fprintf(stderr, "Reset failed\n"); return 1; } } if (opt_console) { atexit(do_exit); printf("Connected to %s, ctrl-c to exit\n", device_name); do_console(fd); } serialClose(fd); return 0; }