/* This is where execution begins [windowed apps] */ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int sw) { char **argv; int argc; char *cmdline; char *bufp; size_t nLen; /* Grab the command line */ bufp = GetCommandLine(); nLen = SDL_strlen(bufp) + 1; cmdline = SDL_stack_alloc(char, nLen); if (cmdline == NULL) { return OutOfMemory(); } SDL_strlcpy(cmdline, bufp, nLen); /* Parse it into argv and argc */ argc = ParseCommandLine(cmdline, NULL); argv = SDL_stack_alloc(char *, argc + 1); if (argv == NULL) { return OutOfMemory(); } ParseCommandLine(cmdline, argv); /* Run the main program */ console_main(argc, argv); /* Hush little compiler, don't you cry... */ return 0; }
int main() { pj_turn_srv *srv; pj_turn_listener *listener; pj_status_t status; status = pj_init(); if (status != PJ_SUCCESS) return err("pj_init() error", status); pjlib_util_init(); pjnath_init(); pj_caching_pool_init(&g_cp, NULL, 0); pj_turn_auth_init(REALM); status = pj_turn_srv_create(&g_cp.factory, &srv); if (status != PJ_SUCCESS) return err("Error creating server", status); status = pj_turn_listener_create_udp(srv, pj_AF_INET(), NULL, TURN_PORT, 1, 0, &listener); if (status != PJ_SUCCESS) return err("Error creating UDP listener", status); #if PJ_HAS_TCP status = pj_turn_listener_create_tcp(srv, pj_AF_INET(), NULL, TURN_PORT, 1, 0, &listener); if (status != PJ_SUCCESS) return err("Error creating listener", status); #endif status = pj_turn_srv_add_listener(srv, listener); if (status != PJ_SUCCESS) return err("Error adding listener", status); puts("Server is running"); pj_log_set_level(LOG_LEVEL); console_main(srv); pj_turn_srv_destroy(srv); pj_caching_pool_destroy(&g_cp); pj_shutdown(); return 0; }
/* This is where execution begins [windowed apps] */ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) { HINSTANCE handle; char **argv; int argc; char *cmdline; char *bufp; /* AllocConsole(); */ /* Start up DDHELP.EXE before opening any files, so DDHELP doesn't keep them open. This is a hack.. hopefully it will be fixed someday. DDHELP.EXE starts up the first time DDRAW.DLL is loaded. */ handle = LoadLibrary(TEXT("DDRAW.DLL")); if ( handle != NULL ) { FreeLibrary(handle); } /* Grab the command line (use alloca() on Windows) */ bufp = GetCommandLine(); cmdline = (char *)alloca(strlen(bufp)+1); if ( cmdline == NULL ) { return OutOfMemory(); } strcpy(cmdline, bufp); /* Parse it into argv and argc */ argc = ParseCommandLine(cmdline, NULL); argv = (char **)alloca((argc+1)*(sizeof *argv)); if ( argv == NULL ) { return OutOfMemory(); } ParseCommandLine(cmdline, argv); /* Run the main program (after a little SDL initialization) */ return(console_main(argc, argv)); }
virtual int console_run(int argc, char_t** argv, char_t** env) { int err = 0, err2 = 0; if (!(err = before_read_cgi_environment(argc, argv, env))) { if (!(err = read_cgi_environment(argc, argv, env))) { if (!(err = before_read_cgi_content(argc, argv, env))) { if (!(err = begin_read_cgi_content(argc, argv, env))) { if (!(err = console_main(argc, argv, env))) { } if ((err2 = end_read_cgi_content(argc, argv, env)) && (!err)) { err = err2; } } if ((err2 = after_read_cgi_content(argc, argv, env)) && (!err)) { err = err2; } } } if ((err2 = after_read_cgi_environment(argc, argv, env)) && (!err)) { err = err2; } } return err; }
/* This is where execution begins [windowed apps] */ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) { char **argv; int argc; char *cmdline; /* Grab the command line */ TCHAR *text = GetCommandLine(); #if UNICODE cmdline = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)(text), (SDL_wcslen(text)+1)*sizeof(WCHAR)); #else cmdline = SDL_strdup(text); #endif if (cmdline == NULL) { return OutOfMemory(); } /* Parse it into argv and argc */ argc = ParseCommandLine(cmdline, NULL); argv = SDL_stack_alloc(char *, argc + 1); if (argv == NULL) { return OutOfMemory(); } ParseCommandLine(cmdline, argv); /* Run the main program */ console_main(argc, argv); SDL_stack_free(argv); SDL_free(cmdline); /* Hush little compiler, don't you cry... */ return 0; }
int main(int argc, char *argv[]) { struct pj_getopt_option long_options[] = { { "realm", 1, 0, 'r'}, { "username", 1, 0, 'u'}, { "password", 1, 0, 'p'}, { "fingerprint",0, 0, 'F'}, { "tcp", 0, 0, 'T'}, { "help", 0, 0, 'h'}, { "stun-srv", 1, 0, 'S'}, { "nameserver", 1, 0, 'N'} }; int c, opt_id; char *pos; pj_status_t status; while((c=pj_getopt_long(argc,argv, "r:u:p:S:N:hFT", long_options, &opt_id))!=-1) { switch (c) { case 'r': o.realm = pj_optarg; break; case 'u': o.user_name = pj_optarg; break; case 'p': o.password = pj_optarg; break; case 'h': usage(); return 0; case 'F': o.use_fingerprint = PJ_TRUE; break; case 'T': o.use_tcp = PJ_TRUE; break; case 'S': o.stun_server = pj_optarg; break; case 'N': o.nameserver = pj_optarg; break; default: printf("Argument \"%s\" is not valid. Use -h to see help", argv[pj_optind]); return 1; } } if (pj_optind == argc) { puts("Error: TARGET is needed"); usage(); return 1; } if ((pos=pj_ansi_strchr(argv[pj_optind], ':')) != NULL) { o.srv_addr = argv[pj_optind]; *pos = '\0'; o.srv_port = pos+1; } else { o.srv_addr = argv[pj_optind]; } if ((status=init()) != 0) goto on_return; //if ((status=create_relay()) != 0) // goto on_return; console_main(); on_return: client_shutdown(); return status ? 1 : 0; }
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) #endif { HINSTANCE handle; char **argv; int argc; char *cmdline; #ifdef _WIN32_WCE wchar_t *bufp; int nLen; #else char *bufp; #endif #ifndef NO_STDIO_REDIRECT FILE *newfp; #endif /* Start up DDHELP.EXE before opening any files, so DDHELP doesn't keep them open. This is a hack.. hopefully it will be fixed someday. DDHELP.EXE starts up the first time DDRAW.DLL is loaded. */ handle = LoadLibrary(TEXT("DDRAW.DLL")); if ( handle != NULL ) { FreeLibrary(handle); } #ifndef NO_STDIO_REDIRECT _getcwd( stdoutPath, sizeof( stdoutPath ) ); strcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE ); /* Redirect standard input and standard output */ newfp = freopen(stdoutPath, TEXT("w"), stdout); #ifndef _WIN32_WCE if ( newfp == NULL ) { /* This happens on NT */ #if !defined(stdout) stdout = fopen(stdoutPath, TEXT("w")); #else newfp = fopen(stdoutPath, TEXT("w")); if ( newfp ) { *stdout = *newfp; } #endif } #endif /* _WIN32_WCE */ _getcwd( stderrPath, sizeof( stderrPath ) ); strcat( stderrPath, DIR_SEPERATOR STDERR_FILE ); newfp = freopen(stderrPath, TEXT("w"), stderr); #ifndef _WIN32_WCE if ( newfp == NULL ) { /* This happens on NT */ #if !defined(stderr) stderr = fopen(stderrPath, TEXT("w")); #else newfp = fopen(stderrPath, TEXT("w")); if ( newfp ) { *stderr = *newfp; } #endif } #endif /* _WIN32_WCE */ setvbuf(stdout, NULL, _IOLBF, BUFSIZ); /* Line buffered */ setbuf(stderr, NULL); /* No buffering */ #endif /* !NO_STDIO_REDIRECT */ #ifdef _WIN32_WCE nLen = wcslen(szCmdLine)+128+1; bufp = (wchar_t *)alloca(nLen*2); wcscpy (bufp, TEXT("\"")); GetModuleFileName(NULL, bufp+1, 128-3); wcscpy (bufp+wcslen(bufp), TEXT("\" ")); wcsncpy(bufp+wcslen(bufp), szCmdLine,nLen-wcslen(bufp)); nLen = wcslen(bufp)+1; cmdline = (char *)alloca(nLen); if ( cmdline == NULL ) { return OutOfMemory(); } WideCharToMultiByte(CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL); #else /* Grab the command line (use alloca() on Windows) */ bufp = GetCommandLine(); cmdline = (char *)alloca(strlen(bufp)+1); if ( cmdline == NULL ) { return OutOfMemory(); } strcpy(cmdline, bufp); #endif /* Parse it into argv and argc */ argc = ParseCommandLine(cmdline, NULL); argv = (char **)alloca((argc+1)*(sizeof *argv)); if ( argv == NULL ) { return OutOfMemory(); } ParseCommandLine(cmdline, argv); /* Run the main program (after a little SDL initialization) */ return(console_main(argc, argv)); }