int main() { NS_InitEmbedding(NULL, NULL); InvokeTestTarget *test = new InvokeTestTarget(); /* here we make the global 'check for alloc failure' checker happy */ if(!test) return 1; InvokeTestTargetInterface* proxy; NS_GetProxyForObject(NS_UI_THREAD_EVENTQ, kTheCID, test, PROXY_SYNC | PROXY_ALWAYS, (void**)(&proxy)); char* buffer; proxy->PassTwoStrings("", "a", "b", &buffer); NS_RELEASE(test); extern int x_main(); x_main(); return NS_OK; }
int main(int argc, char *argv[]) { int i; int h=0, v=0; char *log_filename=NULL; char *arg; struct passwd *password; password=getpwuid(getuid()); strcpy(name, password->pw_name); strcpy(server_name, "localhost"); port=DEFAULT_SOCK_PORT; /* no we don't use GNU's getopt or even the "standard" getopt */ /* yes we do have reasons ;) */ i=1; while(i<argc) { if(!strcmp("-b", argv[i]) || !strcmp("--bgcol", argv[i])) { use_solid_color_behind_units=1; i++; } else if(!strcmp("-h", argv[i]) || !strcmp("--help", argv[i])) { h=1; break; } else if((arg=get_option_text(argv, &i, argc, 'l', "log"))) { if(*arg) log_filename=arg; else { fprintf(stderr, "Error: filename not specified.\n"); h=1; break; } } else if((arg=get_option_text(argv, &i, argc, 'n', "name"))) { if(*arg) { strncpy(name, arg, MAX_LENGTH_NAME); name[MAX_LENGTH_NAME-1]='\0'; } else { fprintf(stderr, "Error: playername not specified.\n"); h=1; break; } } else if((arg=get_option_text(argv, &i, argc, 'p', "port"))) { if(*arg) port=atoi(arg); else { fprintf(stderr, "Error: port not specified.\n"); h=1; break; } } else if((arg=get_option_text(argv, &i, argc, 's', "server"))) { if(*arg) strcpy(server_name, arg); else { fprintf(stderr, "Error: server not specified.\n"); h=1; break; } } else if(!strcmp("-v", argv[i]) || !strcmp("--version", argv[i])) { v=1; break; } else { fprintf(stderr, "Error: unknown option '%s'\n", argv[i]); h=1; break; } } if(h) { fprintf(stderr, "This is the Freeciv client\n"); fprintf(stderr, usage, argv[0]); fprintf(stderr, " -b, --bgcol\t\t\tUse solid colors behind units\n"); fprintf(stderr, " -h, --help\t\t\tPrint a summary of the options\n"); fprintf(stderr, " -l, --log F\t\t\tUse F as logfile\n"); fprintf(stderr, " -n, --name N\t\t\tUse N as name\n"); fprintf(stderr, " -p, --port N\t\t\tconnect to port N\n"); fprintf(stderr, " -s, --server S\t\tConnect to the server at S\n"); fprintf(stderr, " -v, --version\t\t\tPrint the version number\n"); exit(0); } if(v) { fprintf(stderr, "%s\n", FREECIV_NAME_VERSION); exit(0); } log_init(log_filename); log_set_level(LOG_NORMAL); game_init(); if(connect_to_server(server_name, port)==-1) { log(LOG_FATAL, "failed to connect to %s %d", server_name, port); exit(1); } { struct packet_req_join_game request; strcpy(request.name, name); send_packet_req_join_game(&aconnection, &request); } if(!client_state) /*kill*/ client_state=CLIENT_PRE_GAME_STATE; x_main(argc, argv); return 0; }
int main(int argc, char **argv) { gint i; gboolean daemon_mode = TRUE; const char *display_name = NULL; for(i = 1; i < argc; i++) { if(!strcmp(argv[i], "--debug")) daemon_mode = FALSE; else if (!strncmp(argv[1], "--display=", 10)) display_name = argv[1] + 10; } if(daemon_mode) { switch(fork()) { case -1: g_error("Unable to fork(): %s", strerror(errno)); exit(errno); /* NOTREACHED */ break; case 0: /* we're the child, try to close all fds and reopen properly */ { gchar *xsession_errors; setsid(); for(i = getdtablesize() - 1; i >= 0; i--) close(i); xsession_errors = g_build_filename(g_get_home_dir(), ".xsession-errors", NULL); open("/dev/null", O_RDONLY); /* stdin */ i = open(xsession_errors, O_CREAT|O_APPEND, 600); /* stdout */ if(i >= 0) { if (dup(i)) /* stderr */ g_printerr("Failed to dup() stdout for stderr\n"); } g_free(xsession_errors); } break; default: /* we're the parent, bail */ _exit(0); } } __g_dpy = XOpenDisplay(display_name); if (!__g_dpy) { g_printerr("Unable to open display %s\n", display_name ? display_name : ":0"); return EXIT_FAILURE; } signal(SIGHUP, sighandler); signal(SIGUSR1, sighandler); __g_transd = transd_new(__g_dpy); running = TRUE; x_main(__g_dpy, __g_transd); transd_free(__g_transd); XCloseDisplay(__g_dpy); return EXIT_SUCCESS; }