int main (int argc, char **argv) { init_sdl (); gui_init (argc, argv); real_main (argc, argv); return 0; }
// // FUNCTION: ServiceStart // // PURPOSE: Actual code of the service // that does the work. // VOID ServiceStart (DWORD dwArgc, LPSTR *lpszArgv) { if (real_main(1)!=0) { LogEvent(NULL, EVENTLOG_ERROR_TYPE, 2100, NULL, "shibd startup failed, check shibd.log for further details"); return; } LogEvent(NULL, EVENTLOG_INFORMATION_TYPE, 7700, NULL, "shibd started successfully."); if (!ReportStatusToSCMgr(SERVICE_RUNNING, NO_ERROR, 0)) return; real_main(0); }
int main (int argc, char *argv[]) { gfxHeight = 240; hwScaled = 1; real_main (argc, argv); return 0; }
int main(int argc, char** argv) { saveybot::RealMain real_main(argc, argv); return real_main(); //Json::Value config_root, config; //std::string errs; ////printout(saveybot::Communicator::config_file_name, "\n"); //parse_json(saveybot::Communicator::config_file_name, &config_root, // &errs); //config = config_root["discord"]; ////MyClient client(config["token"].asString(), 2); //MyClient client(std::string(config["token"].asString())); //client.run(); }
int main() { int argc, i; char *argv[16]; char prompt[] = "args> "; char cmdline[128], c, *cl, **ap; oskit_clientos_init(); printf("%s", prompt); for (i = 0; i < sizeof cmdline - 1; i++) { c = getchar(); switch (c) { case '\b': case '\?': if (i > 0) { printf("\b \b"); i--; } i--; continue; case ctrl('U'): while (i > 0) { printf("\b \b"); i--; } i--; continue; case ctrl('R'): cmdline[i] = 0; printf("^R\n%s%s", prompt, cmdline); i--; continue; case '\n': case ctrl('M'): putchar('\n'); break; default: cmdline[i] = c; putchar(c); continue; } break; } cmdline[i] = 0; cl = cmdline; argv[0] = "memtest"; argc = 1; for (ap = &argv[1]; (*ap = strsep(&cl, " \t")) != 0; ) if (**ap) { ap++; if (++argc == sizeof(argv)/sizeof(argv[0])) break; } return real_main(argc, argv); }
int main(int argc, char* argv[]) { int res; // init xml parser // LIBXML_TEST_VERSION (void) argc, (void) argv; res = real_main(); // cleanup xml parser // xmlCleanupParser(); return res; }
int main(int argc, char **argv) { FILE *f; char buffer[FILENAME_MAX], *cp, *verstr; int len; if (getenv("PKG_NOWRAP") != NULL) goto nowrap; f = fopen(PKG_WRAPCONF_FNAME, "r"); if (f == NULL) goto nowrap; cp = fgets(buffer, 256, f); fclose(f); if (cp == NULL) goto nowrap; len = strlen(cp); if (cp[len - 1] == '\n') cp[len - 1] = '\0'; while (strchr(SEPARATORS, *cp) != NULL) cp++; verstr = cp; cp = strpbrk(cp, SEPARATORS); if (cp == NULL) goto nowrap; *cp = '\0'; for (cp = verstr; *cp != '\0'; cp++) if (isdigit(*cp) == 0) goto nowrap; if (atoi(verstr) < PKG_INSTALL_VERSION) goto nowrap; cp++; while (*cp != '\0' && strchr(SEPARATORS, *cp) != NULL) cp++; if (*cp == '\0') goto nowrap; bcopy(cp, buffer, strlen(cp) + 1); cp = strpbrk(buffer, SEPARATORS); if (cp != NULL) *cp = '\0'; if (!isdir(buffer)) goto nowrap; cp = strrchr(argv[0], '/'); if (cp == NULL) cp = argv[0]; else cp++; strlcat(buffer, "/", sizeof(buffer)); strlcat(buffer, cp, sizeof(buffer)); setenv("PKG_NOWRAP", "1", 1); execve(buffer, argv, environ); nowrap: unsetenv("PKG_NOWRAP"); return(real_main(argc, argv)); }
static int wrapper_main(int argc, char **argv, char **envp) { /* Call the real main function. * Note that we call our reimplementation of the exit function, * because returning would cause glibc to invoke the exit_group * system call, which is not allowed in SECCOMP mode. */ int n; n = real_main(argc, argv, envp); exit(n); return EXIT_FAILED; }
/* * Amiga-specific main entry */ int main (int argc, char *argv[]) { fromWB = argc == 0; init_libs (); #ifdef USE_SDL init_sdl (); #endif real_main (argc, argv); return 0; }
int main (int argc, char** argv) { int (*real_main)(int argc, char** argv); int temp; temp = 0; real_main = 0x400506; temp += 123; temp ++; char* temp2 = malloc (temp); free (temp2); strlen ("asdf"); bzero (temp2, temp); return real_main (argc, argv); }
int main (int argc, char **argv) { int rc; if (!chimp_core_startup (getenv ("CHIMP_PATH"), (void *)&rc)) { fprintf (stderr, "error: unable to initialize chimp core\n"); return 1; } rc = real_main(argc, argv); chimp_core_shutdown (); return rc; }
int main (int argc, char **argv) { #ifdef BLOMCALL // Set up blomcalls BEFORE creating ANY threads if (blomcall_init()) { write_log ("bcalls enabled\n"); } #endif init_sdl (); gui_init (argc, argv); real_main (argc, argv); #ifdef BLOMCALL blomcall_destroy(); #endif return 0; }
/* The rts entry point from a compiled program using a Haskell main function. * This gets called from a tiny main function which gets linked into each * compiled Haskell program that uses a Haskell main function. * * We expect the caller to pass ZCMain_main_closure for * main_closure. The reason we cannot refer to this symbol directly * is because we're inside the rts and we do not know for sure that * we'll be using a Haskell main function. */ int hs_main(int argc, char *argv[], StgClosure *main_closure) { /* We do this dance with argc and argv as otherwise the SEH exception stuff (the BEGIN/END CATCH below) on Windows gets confused */ progargc = argc; progargv = argv; progmain_closure = main_closure; #if defined(mingw32_HOST_OS) BEGIN_CATCH #endif real_main(); #if defined(mingw32_HOST_OS) END_CATCH #endif return 0; /* not reached, but keeps gcc -Wall happy */ }
int main(int argc, char**argv, char **envp) { int i; #ifdef __x86_64__ /* FIXME: this doesn't belong here. */ extern void set_fs(); set_fs(); #endif get_task_size(); /* Take a copy of our argc/argv and environment below we blow them away */ real_argc = argc; real_argv = (char**) xmalloc((sizeof(char*)*argc) + 1); for (i = 0; i < argc; i++) { real_argv[i] = (char*) xmalloc(strlen(argv[i]) + 1); memcpy(real_argv[i], argv[i], strlen(argv[i]) + 1); } real_argv[i] = (char*) xmalloc(sizeof('\0')); *real_argv[i] = '\0'; for(i = 0; envp[i]; i++); /* count environment variables */ real_environ = xmalloc((sizeof(char*)*i)+1); for(i = 0; envp[i]; i++) { *real_environ++ = strdup(envp[i]); #ifdef USE_GTK if (strncmp(envp[i], "DISPLAY=", 8) == 0) { strncpy(display_environ, envp[i]+8, sizeof(display_environ)-1); display_environ[sizeof(display_environ)-1] = '\0'; } else if (strncmp(envp[i], "XAUTHORITY=", 11) == 0) { strncpy(xauthority_environ, envp[i]+11, sizeof(xauthority_environ)-1); xauthority_environ[sizeof(xauthority_environ)-1] = '\0'; } #endif } *real_environ = '\0'; environ = real_environ; real_fd = open_self(); relocate_stack(); /* Now hope for the best! */ real_main(real_argc, real_argv); }
/* * Amiga-specific main entry */ int main (int argc, char *argv[]) { fromWB = argc == 0; if (fromWB) set_logfile ("T:E-UAE.log"); init_libs (); #ifdef USE_SDL init_sdl (); #endif real_main (argc, argv); if (fromWB) set_logfile (0); return 0; }
void amiga_main(void) { write_log("amiga_main\n"); uae_register_emulation_thread(); keyboard_settrans(); int argc = 1; char *argv[4] = { strdup("fs-uae"), NULL, }; real_main(argc, argv); #ifdef FILESYS write_log("real_main returned\n"); write_log("calling filesys_flush_cache\n"); filesys_flush_cache (); #endif write_log("flushing all file streams\n"); fflush(NULL); }
int main(int argc, char* argv[]) { TESTNGPPST_RCP rcp = TESTNGPPST_SET_RESOURCE_CHECK_POINT(); int code = 0; try { code = real_main(argc, argv); TESTNGPPST_VERIFY_RESOURCE_CHECK_POINT(rcp); } catch(std::exception& error) { std::cerr << error.what() << std::endl; } catch(...) { std::cerr << "unknown exception" << std::endl; } return code; }
/** @brief Fake main(), spliced in before the real call to main() by * __libc_start_main (see below). * We get serialized commands from our invoking process over an fd specified * by an environment variable (kFdEnvVar). The environment variable is a list * of key=value pairs (see move_commands_to_env); we use them to construct a * jail, then enter it. */ static int fake_main(int argc, char **argv, char **envp) { char *fd_name = getenv(kFdEnvVar); int fd = -1; struct minijail *j; if (geteuid() != getuid() || getegid() != getgid()) /* If we didn't do this check, an attacker could set kFdEnvVar * for any setuid program that uses libminijail to cause it to * get capabilities or a uid it did not expect. */ /* TODO(wad) why would libminijail interact here? */ return MINIJAIL_ERR_PRELOAD; if (!fd_name) return MINIJAIL_ERR_PRELOAD; fd = atoi(fd_name); if (fd < 0) return MINIJAIL_ERR_PRELOAD; // Even if the process cannot use that fd, avoid divulging stuff. unsetenv(kFdEnvVar); j = minijail_new(); if (!j) die("preload: out of memory"); if (minijail_from_fd(fd, j)) die("preload: failed to parse minijail from parent"); close(fd); /* TODO(ellyjones): this trashes existing preloads, so one can't do: * LD_PRELOAD="/tmp/test.so libminijailpreload.so" prog; the * descendants of prog will have no LD_PRELOAD set at all. */ unset_in_env(envp, kLdPreloadEnvVar); /* Strip out flags meant for the parent. */ minijail_preenter(j); minijail_enter(j); minijail_destroy(j); dlclose(libc_handle); return real_main(argc, argv, envp); }
static int exec_real_main(int argc, char *argv[]) { int i, j; /* win32 stdio seems to be fully buffered by default */ setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); /* check if regular arguments are in allowed list */ for (i = 1; i < argc; i++) { char *p = argv[i]; if (p[0] != '-') continue; for (j = 1; p[j]; j++) { if (!strchr("qvhV", p[j])) usage(1, argv[0]); if (p[j] == 'h') usage(0, argv[0]); } } /* call actual main() */ return real_main(argc, argv); }
int main(void) { io_debug_conn = always_debug; return real_main(); }
int main(int argc, char *argv[]) { int i=1; while ((argc > i) && ((*argv[i] == '-') || (*argv[i] == '/'))) { if (_stricmp("install", argv[i]+1) == 0) { if (argc > ++i) lpszInstall = argv[i++]; } else if (_stricmp("remove", argv[i]+1) == 0) { if (argc > ++i) lpszRemove = argv[i++]; } else if (_stricmp( "console", argv[i]+1) == 0) { i++; bConsole = TRUE; } else if (_stricmp( "check", argv[i]+1) == 0) { i++; bConsole = TRUE; shar_checkonly=true; } else if (_stricmp( "config", argv[i]+1) == 0) { if (argc > ++i) shar_config = argv[i++]; } else if (_stricmp( "schemadir", argv[i]+1) == 0) { if (argc > ++i) shar_schemadir = argv[i++]; } else { goto dispatch; } } if (bConsole) { // Install break handler, then run the C routine twice, once to setup, once to start running. SetConsoleCtrlHandler(&BreakHandler,TRUE); if (real_main(1)!=0) { LogEvent(NULL, EVENTLOG_ERROR_TYPE, 2100, NULL, "shibd startup failed, check shibd.log for further details"); return -1; } return real_main(0); } else if (lpszInstall) { CmdInstallService(lpszInstall); return 0; } else if (lpszRemove) { CmdRemoveService(lpszRemove); return 0; } // if it doesn't match any of the above parameters // the service control manager may be starting the service // so we must call StartServiceCtrlDispatcher dispatch: // this is just to be friendly printf("%s -install <name> to install the named service\n", argv[0]); printf("%s -remove <name> to remove the named service\n", argv[0]); printf("%s -console to run as a console app for debugging\n", argv[0]); printf("%s -check to run as a console app and check configuration\n", argv[0]); printf("\t-config <file> to specify the config file to use\n"); printf("\t-schemadir <dir> to specify where schemas are\n"); printf("\nService starting.\nThis may take several seconds. Please wait.\n" ); SERVICE_TABLE_ENTRY dispatchTable[] = { { "SHIBD", (LPSERVICE_MAIN_FUNCTION)service_main }, { NULL, NULL } }; if (!StartServiceCtrlDispatcher(dispatchTable)) LogEvent(NULL, EVENTLOG_ERROR_TYPE, 2100, NULL, "StartServiceCtrlDispatcher failed."); return 0; }
int main (int argc, char **argv) { real_main (argc, argv); return 0; }
int main(int argc, char *argv[]) { return real_main(argc, argv); }
void main(void) { zephyr_getchar_init(); real_main(); }
// The UAE 68k thread's main function long UAE::EmulationThreadFunc(void *obj) { real_main(argcCopy,argvCopy); return 0; }
int main (int argc, TCHAR **argv) { real_main (argc, argv); return 0; }
int main (void) { int i; int allocateOK; ximg = NULL; d = XOpenDisplay (NULL); if (!d) fputs ("Couldn't open display\n", stderr), exit (1); screen = DefaultScreen (d); gc = DefaultGC (d, screen); /* Find a visual */ vis.screen = screen; vlist = XGetVisualInfo (d, VisualScreenMask, &vis, &match); if (!vlist) fputs ("No matched visuals\n", stderr), exit (1); vis = vlist[0]; XFree (vlist); // That's not a fair comparison colormap_size is depth in bits! // if (vis.colormap_size < COLORS) // printf("Colormap is too small: %i.\n",vis.colormap_size); // , exit (1); printf("Colour depth: %i\n",vis.colormap_size); win = XCreateSimpleWindow (d, DefaultRootWindow (d), 0, 0, WIN_W, WIN_H, 0, WhitePixel (d, screen), BlackPixel (d, screen)); int xclass=get_xvisinfo_class(vis); // printf("class = %i\n",xclass); stylee = ( vis.depth > 8 ? styleeTrueColor : styleePrivate ); // printf("stylee=%i\n",stylee); if ( get_xvisinfo_class(vis) % 2 == 1) { /* The odd numbers can redefine colors */ // printf("%i\n",get_xvisinfo_class(vis)); colormap = DefaultColormap (d, screen); Visual *defaultVisual=DefaultVisual(d,screen); /* Allocate cells */ allocateOK = (XAllocColorCells (d, colormap, 1, NULL, 0, color, COLORS) != 0); // printf("Allocated OK? %i\n",allocateOK); if (allocateOK) { // printf("Allocated OK\n"); // This doesn't work for installed colormap! /* Modify the colorcells */ for (i = 0; i < COLORS; i++) xrgb[i].pixel = color[i]; XStoreColors (d, colormap, xrgb, COLORS); } else { colormap = XCreateColormap(d,win,defaultVisual,AllocNone); // redocolors(); } // black = XBlackPixel(d,screen); // white = XWhitePixel(d,screen); } else if ( get_xvisinfo_class(vis) == TrueColor) { colormap = DefaultColormap (d, screen); // printf("TrueColor %i = %i\n",xclass,TrueColor); /* This will lookup the color and sets the xrgb[i].pixel value */ // for (i = 0; i < COLORS; i++) // XAllocColor (d, colormap, &xrgb[i]); } else fprintf (stderr, "Not content with visual class %d.\n", get_xvisinfo_class(vis) ), exit (1); /* Find out if MITSHM is supported and useable */ printf ("MITSHM: "); if (XShmQueryVersion (d, &mitshm_major_code, &mitshm_minor_code, &shared_pixmaps)) { int (*handler) (Display *, XErrorEvent *); ximg = XShmCreateImage (d, vis.visual, vis.depth, XShmPixmapFormat (d), NULL, &shminfo, WIN_W, WIN_H); shminfo.shmid = shmget (IPC_PRIVATE, ximg->bytes_per_line * ximg->height, IPC_CREAT | 0777); shminfo.shmaddr = (char *)shmat (shminfo.shmid, 0, 0); ximg->data = (char *)shminfo.shmaddr; handler = XSetErrorHandler (mitshm_handler); XShmAttach (d, &shminfo); /* Tell the server to attach */ XSync (d, 0); XSetErrorHandler (handler); shmctl (shminfo.shmid, IPC_RMID, 0); /* Mark this shm segment for deletion at once. The segment will * automatically become released when both the server and this * client have detached from it. * (Process termination automagically detach shm segments) */ if (!can_use_mitshm) { shmdt (shminfo.shmaddr); ximg = NULL; } } if (ximg == NULL) { can_use_mitshm = 0; /* XInitImage(ximg); */ ximg = XCreateImage (d, vis.visual, vis.depth, ZPixmap, 0, (char *)malloc (WIN_W * WIN_H), WIN_W, WIN_H, 8, 0); } if (can_use_mitshm) printf ("YES!\n"); else printf ("NO, using fallback instead.\n"); // DrawFractal (ximg,xrgb); XSelectInput (d, win, ButtonPressMask | ExposureMask); XMapWindow (d, win); real_main(); // XNextEvent (d, &ev); // switch (ev.type) { // case ButtonPress: // should_quit = 1; // break; // case Expose: // if (can_use_mitshm) // XShmPutImage (d, win, gc, img, 0, 0, 0, 0, WIN_W, WIN_H, True); // else // XPutImage (d, win, gc, img, 0, 0, 0, 0, WIN_W, WIN_H); // break; // default: // break; // } if (get_xvisinfo_class(vis) % 2 == 1 || get_xvisinfo_class(vis) == TrueColor) { unsigned long color[COLORS]; if (allocateOK) { for (i = 0; i < COLORS; i++) color[i] = xrgb[i].pixel; XFreeColors (d, colormap, color, COLORS, 0); } /* Allocated colors freed */ } else { XUninstallColormap (d, colormap); } if (can_use_mitshm) { XShmDetach (d, &shminfo); /* Server detached */ XDestroyImage (ximg); /* Image struct freed */ shmdt (shminfo.shmaddr); /* We're detached */ } else XDestroyImage (ximg); /* Image struct freed */ XDestroyWindow (d, win); /* Window removed */ XCloseDisplay (d); /* Display disconnected */ /* So you can see how your computer compares to your friend's */ getrusage (RUSAGE_SELF, &resource_utilization); float seconds=(float)resource_utilization.ru_utime.tv_sec +(float)resource_utilization.ru_utime.tv_usec*0.000000001; printf("CPU seconds per frame: %f\n",seconds/(float)frameno); // printf ("CPU seconds consumed: %ds and %dµs\n", // (int) resource_utilization.ru_utime.tv_sec, // (int) resource_utilization.ru_utime.tv_usec); return 0; }
void main() { real_main(); }
/*! Normal entry point for all platforms, including Windows console applications */ int main(int argc, char** argv) #endif { int ret; #if !FOUNDATION_PLATFORM_ANDROID && !FOUNDATION_PLATFORM_PNACL _environment_main_args(argc, (const char* const*)argv); #elif FOUNDATION_PLATFORM_PNACL FOUNDATION_UNUSED(instance); #endif ret = main_initialize(); if (ret < 0) return ret; #if FOUNDATION_PLATFORM_POSIX //Set signal handlers { struct sigaction action; memset(&action, 0, sizeof(action)); #if FOUNDATION_COMPILER_CLANG # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wdisabled-macro-expansion" #endif //Signals we process globally action.sa_handler = sighandler; sigaction(SIGKILL, &action, 0); sigaction(SIGTERM, &action, 0); sigaction(SIGQUIT, &action, 0); sigaction(SIGINT, &action, 0); sigaction(SIGABRT, &action, 0); //Ignore sigpipe action.sa_handler = SIG_IGN; sigaction(SIGPIPE, &action, 0); #if FOUNDATION_COMPILER_CLANG # pragma clang diagnostic pop #endif } #endif #if FOUNDATION_PLATFORM_ANDROID if ((ret = android_initialize()) < 0) return ret; #endif #if FOUNDATION_PLATFORM_TIZEN if ((ret = tizen_initialize()) < 0) return ret; #endif #if FOUNDATION_PLATFORM_WINDOWS SetConsoleCtrlHandler(_main_console_handler, TRUE); #endif thread_set_main(); foundation_startup(); #if FOUNDATION_PLATFORM_WINDOWS || FOUNDATION_PLATFORM_LINUX || FOUNDATION_PLATFORM_PNACL system_post_event(FOUNDATIONEVENT_START); #endif #if FOUNDATION_PLATFORM_APPLE # if FOUNDATION_PLATFORM_MACOSX if (!(environment_application()->flags & APPLICATION_UTILITY)) { delegate_start_main_ns_thread(); extern int NSApplicationMain(int argc, char* argv[]); ret = NSApplicationMain(argc, argv); # elif FOUNDATION_PLATFORM_IOS { delegate_start_main_ns_thread(); extern int UIApplicationMain(int argc, char* argv[], void* principalClassName, void* delegateClassName); ret = UIApplicationMain(argc, (char**)argv, 0, 0); # endif //NSApplicationMain and UIApplicationMain never returns though return ret; } #endif #if !FOUNDATION_PLATFORM_IOS # if FOUNDATION_PLATFORM_TIZEN tizen_start_main_thread(); ret = tizen_app_main(argc, argv); # else { string_t name; const application_t* app = environment_application(); { string_const_t vstr = string_from_version_static(app->version); string_const_t aname = app->short_name; if (!aname.length) aname = string_const(STRING_CONST("unknown")); name = string_allocate_format(STRING_CONST("%.*s-%.*s"), (int)aname.length, aname.str, (int)vstr.length, vstr.str); } if (app->dump_callback) crash_guard_set(app->dump_callback, name.str, name.length); if (system_debugger_attached()) ret = main_run(0); else ret = crash_guard(main_run, 0, app->dump_callback, name.str, name.length); string_deallocate(name.str); } # endif main_finalize(); #if FOUNDATION_PLATFORM_ANDROID android_finalize(); #endif #if FOUNDATION_PLATFORM_TIZEN tizen_finalize(); #endif return ret; #endif } #if FOUNDATION_PLATFORM_ANDROID /*! Android native glue entry point */ void android_main(struct android_app * app) { if (!app) return; android_entry(app); real_main(); } #endif #if FOUNDATION_PLATFORM_PNACL /*! PNaCl glue entry points */ PP_EXPORT int32_t PPP_InitializeModule(PP_Module module_id, PPB_GetInterface get_browser) { return pnacl_module_initialize(module_id, get_browser); } PP_EXPORT const void* PPP_GetInterface(const char* interface_name) { return pnacl_module_interface(interface_name, string_length(interface_name)); } PP_EXPORT void PPP_ShutdownModule() { pnacl_module_finalize(); }
int main (int argc, char **argv) { #ifdef GEKKO printf("\x1b[2;0H"); //initialize libfat library if (fatInitDefault()) printf("FAT subsytem initialized\n\n"); else { printf("Couldn't initialize FAT subsytem\n\n"); sleep(3); exit(0); } DIR *dp; dp = opendir ("sd:/"); if (dp) sdismount = 1; else sdismount = 0; if (sdismount) printf("SD FAT subsytem initialized\n\n"); else printf("Couldn't initialize SD fat subsytem\n\n"); if (sdismount) closedir (dp); usbismount = InitUSB(); default_prefs (&currprefs, 0); cfgfile_load (&currprefs, SMBFILENAME, 0); printf("\n"); if (currprefs.smb_enable) networkisinit = InitNetwork(); if (networkisinit && currprefs.smb_enable) ConnectShare(); sleep(2); if (!(log_quiet = !currprefs.write_logfile)) set_logfile("/uae/uae.log"); #endif write_log("main started\n"); init_sdl (); write_log("sdl inited\n"); gui_init (argc, argv); write_log("Starting real main\n"); real_main (argc, argv); #ifdef GEKKO if (smbismount) CloseShare (); DeInitUSB(); fatUnmount(0); #endif return 0; }