int main(int argc, char **argv) { glutInit(&argc, argv); if (argc > 1 && !strcmp(argv[1], "-f")) fullscreen = GL_TRUE; glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE); if (fullscreen) { glutGameModeString("640x480:16@60"); glutEnterGameMode(); } else { glutInitWindowSize(400, 400); glutCreateWindow("GLUT-based OpenGL skyfly"); } glutDisplayFunc(draw); glutReshapeFunc(reshape); glutVisibilityFunc(visible); glutKeyboardFunc(keyboard); glutMouseFunc(mouse); glutMotionFunc(motion); glutPassiveMotionFunc(motion); glutSpecialFunc(special); init_misc(); if (!rgbmode) init_cmap(); init_skyfly(); glutMainLoop(); return 0; /* ANSI C requires main to return int. */ }
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved); switch (fdwReason) { case DLL_PROCESS_ATTACH: init_cxx_funcs(); init_lockit(); init_exception(hinstDLL); init_locale(hinstDLL); init_io(hinstDLL); init_misc(hinstDLL); break; case DLL_PROCESS_DETACH: if (lpvReserved) break; free_io(); free_locale(); free_lockit(); free_misc(); break; } return TRUE; }
void init_sys_tasks(SimulationController& sc ) throw() { init_random_sequence(); init_basic_tasks( sc ); init_world_tasks( sc ); init_misc( sc ); init_edge_models( sc ); init_transmission_models( sc ); init_communication_models( sc ); init_distance_estimates( sc ); init_taggings( sc ); init_node_movements( sc ); init_logging( sc ); init_xml( sc ); }
void init_texmacs () { //cout << "Initialize -- Succession status table\n"; init_succession_status_table (); //cout << "Initialize -- Succession standard DRD\n"; init_std_drd (); //cout << "Initialize -- Main paths\n"; init_main_paths (); //cout << "Initialize -- User dirs\n"; init_user_dirs (); //cout << "Initialize -- User preferences\n"; load_user_preferences (); //cout << "Initialize -- Guile\n"; init_guile (); //cout << "Initialize -- Environment variables\n"; init_env_vars (); //cout << "Initialize -- Miscellaneous\n"; init_misc (); //cout << "Initialize -- Deprecated\n"; init_deprecated (); }
int main(int arg_c, char **arg_v) { int i, xx; char s[25]; FILE *f; struct sigaction sv; struct chanset_t *chan; #ifdef DEBUG struct rlimit cdlim; #endif #ifdef STOP_UAC int nvpair[2]; #endif /* Make sure it can write core, if you make debug. Else it's pretty * useless (dw) * * Only allow unlimited size core files when compiled with DEBUG defined. * This is not a good idea for normal builds -- in these cases, use the * default system resource limits instead. */ #ifdef DEBUG cdlim.rlim_cur = RLIM_INFINITY; cdlim.rlim_max = RLIM_INFINITY; setrlimit(RLIMIT_CORE, &cdlim); #endif #ifdef DEBUG_CONTEXT /* Initialise context list */ for (i = 0; i < 16; i++) Context; #endif /* Include patch.h header for patch("...") */ #include "patch.h" argc = arg_c; argv = arg_v; /* Version info! */ egg_snprintf(ver, sizeof ver, "eggdrop v%s", egg_version); egg_snprintf(version, sizeof version, "Eggdrop v%s (C) 1997 Robey Pointer (C) 2010 Eggheads", egg_version); /* Now add on the patchlevel (for Tcl) */ sprintf(&egg_version[strlen(egg_version)], " %u", egg_numver); strcat(egg_version, egg_xtra); /* For OSF/1 */ #ifdef STOP_UAC /* Don't print "unaligned access fixup" warning to the user */ nvpair[0] = SSIN_UACPROC; nvpair[1] = UAC_NOPRINT; setsysinfo(SSI_NVPAIRS, (char *) nvpair, 1, NULL, 0); #endif /* Set up error traps: */ sv.sa_handler = got_bus; sigemptyset(&sv.sa_mask); #ifdef SA_RESETHAND sv.sa_flags = SA_RESETHAND; #else sv.sa_flags = 0; #endif sigaction(SIGBUS, &sv, NULL); sv.sa_handler = got_segv; sigaction(SIGSEGV, &sv, NULL); #ifdef SA_RESETHAND sv.sa_flags = 0; #endif sv.sa_handler = got_fpe; sigaction(SIGFPE, &sv, NULL); sv.sa_handler = got_term; sigaction(SIGTERM, &sv, NULL); sv.sa_handler = got_hup; sigaction(SIGHUP, &sv, NULL); sv.sa_handler = got_quit; sigaction(SIGQUIT, &sv, NULL); sv.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sv, NULL); sv.sa_handler = got_ill; sigaction(SIGILL, &sv, NULL); sv.sa_handler = got_alarm; sigaction(SIGALRM, &sv, NULL); /* Initialize variables and stuff */ now = time(NULL); chanset = NULL; egg_memcpy(&nowtm, localtime(&now), sizeof(struct tm)); lastmin = nowtm.tm_min; srandom((unsigned int) (now % (getpid() + getppid()))); init_mem(); init_language(1); if (argc > 1) for (i = 1; i < argc; i++) do_arg(argv[i]); printf("\n%s\n", version); #ifndef CYGWIN_HACKS /* Don't allow eggdrop to run as root * This check isn't useful under cygwin and has been * reported to cause trouble in some situations. */ if (((int) getuid() == 0) || ((int) geteuid() == 0)) fatal("ERROR: Eggdrop will not run as root!", 0); #endif #ifndef REPLACE_NOTIFIER init_threaddata(1); #endif init_userent(); init_misc(); init_bots(); init_modules(); if (backgrd) bg_prepare_split(); init_tcl(argc, argv); init_language(0); #ifdef STATIC link_statics(); #endif strncpyz(s, ctime(&now), sizeof s); strcpy(&s[11], &s[20]); putlog(LOG_ALL, "*", "--- Loading %s (%s)", ver, s); chanprog(); if (!encrypt_pass) { printf(MOD_NOCRYPT); bg_send_quit(BG_ABORT); exit(1); } i = 0; for (chan = chanset; chan; chan = chan->next) i++; putlog(LOG_MISC, "*", "=== %s: %d channels, %d users.", botnetnick, i, count_users(userlist)); #ifdef TLS ssl_init(); #endif cache_miss = 0; cache_hit = 0; if (!pid_file[0]) egg_snprintf(pid_file, sizeof pid_file, "pid.%s", botnetnick); /* Check for pre-existing eggdrop! */ f = fopen(pid_file, "r"); if (f != NULL) { fgets(s, 10, f); xx = atoi(s); i = kill(xx, SIGCHLD); /* Meaningless kill to determine if pid * is used */ if (i == 0 || errno != ESRCH) { printf(EGG_RUNNING1, botnetnick); printf(EGG_RUNNING2, pid_file); bg_send_quit(BG_ABORT); exit(1); } } /* Move into background? */ if (backgrd) { bg_do_split(); } else { /* !backgrd */ xx = getpid(); if (xx != 0) { FILE *fp; /* Write pid to file */ unlink(pid_file); fp = fopen(pid_file, "w"); if (fp != NULL) { fprintf(fp, "%u\n", xx); if (fflush(fp)) { /* Let the bot live since this doesn't appear to be a botchk */ printf(EGG_NOWRITE, pid_file); fclose(fp); unlink(pid_file); } else fclose(fp); } else printf(EGG_NOWRITE, pid_file); } } use_stderr = 0; /* Stop writing to stderr now */ if (backgrd) { /* Ok, try to disassociate from controlling terminal (finger cross) */ #ifdef HAVE_SETPGID setpgid(0, 0); #endif /* Tcl wants the stdin, stdout and stderr file handles kept open. */ freopen("/dev/null", "r", stdin); freopen("/dev/null", "w", stdout); freopen("/dev/null", "w", stderr); #ifdef CYGWIN_HACKS FreeConsole(); #endif } /* Terminal emulating dcc chat */ if (!backgrd && term_z) { int n = new_dcc(&DCC_CHAT, sizeof(struct chat_info)); getvhost(&dcc[n].sockname, AF_INET); dcc[n].sock = STDOUT; dcc[n].timeval = now; dcc[n].u.chat->con_flags = conmask; dcc[n].u.chat->strip_flags = STRIP_ALL; dcc[n].status = STAT_ECHO; strcpy(dcc[n].nick, "HQ"); strcpy(dcc[n].host, "llama@console"); /* HACK: Workaround not to pass literal "HQ" as a non-const arg */ dcc[n].user = get_user_by_handle(userlist, dcc[n].nick); /* Make sure there's an innocuous HQ user if needed */ if (!dcc[n].user) { userlist = adduser(userlist, dcc[n].nick, "none", "-", USER_PARTY); dcc[n].user = get_user_by_handle(userlist, dcc[n].nick); } setsock(STDOUT, 0); /* Entry in net table */ dprintf(n, "\n### ENTERING DCC CHAT SIMULATION ###\n\n"); dcc_chatter(n); } then = now; online_since = now; autolink_cycle(NULL); /* Hurry and connect to tandem bots */ add_help_reference("cmds1.help"); add_help_reference("cmds2.help"); add_help_reference("core.help"); add_hook(HOOK_SECONDLY, (Function) core_secondly); add_hook(HOOK_MINUTELY, (Function) core_minutely); add_hook(HOOK_HOURLY, (Function) core_hourly); add_hook(HOOK_REHASH, (Function) event_rehash); add_hook(HOOK_PRE_REHASH, (Function) event_prerehash); add_hook(HOOK_USERFILE, (Function) event_save); add_hook(HOOK_BACKUP, (Function) backup_userfile); add_hook(HOOK_DAILY, (Function) event_logfile); add_hook(HOOK_DAILY, (Function) event_resettraffic); add_hook(HOOK_LOADED, (Function) event_loaded); call_hook(HOOK_LOADED); debug0("main: entering loop"); while (1) { mainloop(1); } }
int main(int argc, char **argv) { char **t; int t0; #ifdef USE_LOCALE setlocale(LC_ALL, ""); #endif #ifdef WINNT /* Do not use __try if compiling with MinGW */ #ifndef MINGW __try { #endif /* MINGW */ /* Start NT if we are compiling with MinGW, don't otherwise */ #ifdef MINGW nt_init(); #else //nt_init(); #endif /* MINGW */ fork_init(); /* Do not use __except if compiling with MinGW */ #ifndef MINGW }__except(1) { dprintf("damn 0x%08x\n",GetExceptionCode()); return 1; }; #endif /* MINGW */ #endif /* WINNT */ global_permalloc(); /* * Provisionally set up the type table to allow metafication. * This will be done properly when we have decided if we are * interactive */ typtab['\0'] |= IMETA; typtab[STOUC(Meta) ] |= IMETA; typtab[STOUC(Marker)] |= IMETA; for (t0 = (int)STOUC(Pound); t0 <= (int)STOUC(Nularg); t0++) typtab[t0] |= ITOK | IMETA; for (t = argv; *t; *t = metafy(*t, -1, META_ALLOC), t++); #ifndef WINNT if (!(zsh_name = strrchr(argv[0], '/'))) #else if (!(zsh_name = strrchr(argv[0], '/')) && !(zsh_name = strrchr(argv[0], '\\')) && !(zsh_name = strchr(argv[0],':')) // !(argv[0][1] ==':') ) #endif /* WINNT */ zsh_name = argv[0]; else zsh_name++; if (*zsh_name == '-') zsh_name++; fdtable_size = OPEN_MAX; fdtable = zcalloc(fdtable_size); emulate(zsh_name, 1); /* initialises most options */ opts[LOGINSHELL] = (**argv == '-'); opts[MONITOR] = 1; /* may be unset in init_io() */ opts[PRIVILEGED] = (getuid() != geteuid() || getgid() != getegid()); opts[USEZLE] = 1; /* may be unset in init_io() */ parseargs(argv); /* sets INTERACTIVE, SHINSTDIN and SINGLECOMMAND */ SHTTY = -1; init_io(); setupvals(); init_signals(); global_heapalloc(); run_init_scripts(); init_misc(); for (;;) { do loop(1,0); while (tok != ENDINPUT); if (!(isset(IGNOREEOF) && interact)) { #if 0 if (interact) fputs(islogin ? "logout\n" : "exit\n", shout); #endif zexit(lastval, 0); continue; } noexitct++; if (noexitct >= 10) { stopmsg = 1; zexit(lastval, 0); } zerrnam("zsh", (!islogin) ? "use 'exit' to exit." : "use 'logout' to logout.", NULL, 0); } return 0; /* WINNT change, patch I think */ }