void init() { map_init(); mgr_init(); fs_init(); pthread_create(&thread, NULL, server_mgr, NULL); thread_init(); }
bool api_init(void) { bool ret = true; if (api_c_refs == 0) ret = mgr_init(); if (ret) api_c_refs++; return ret; }
int main(int argc, char* argv[]) { if (SDL_Init(SDL_INIT_EVERYTHING) == -1) return 1; SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 ); SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 ); SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 ); SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 1 ); SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); SDL_ShowCursor(SDL_DISABLE); screen = SDL_SetVideoMode(160*scale, 144*scale, 32, SDL_SWSURFACE | SDL_OPENGL);// | SDL_FULLSCREEN); if (screen == NULL) return 1; SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 255, 255)); SDL_WM_SetCaption("GameYob", NULL); mgr_init(); initInput(); setMenuDefaults(); readConfigFile(); initGFX(); if (argc >= 2) { char* filename = argv[1]; mgr_loadRom(filename); } else { printf("Give me a gameboy rom pls\n"); return 1; } for (;;) { mgr_runFrame(); mgr_updateVBlank(); } return 0; }
/* * ======== api_init ======== * Purpose: * Module initialization used by Bridge API. */ bool api_init(void) { bool ret = true; bool fdrv, fdev, fcod, fchnl, fmsg, fio; bool fmgr, fproc, fnode, fdisp, fstrm, frmm; if (api_c_refs == 0) { /* initialize driver and other modules */ fdrv = drv_init(); fmgr = mgr_init(); fproc = proc_init(); fnode = node_init(); fdisp = disp_init(); fstrm = strm_init(); frmm = rmm_init(); fchnl = chnl_init(); fmsg = msg_mod_init(); fio = io_init(); fdev = dev_init(); fcod = cod_init(); ret = fdrv && fdev && fchnl && fcod && fmsg && fio; ret = ret && fmgr && fproc && frmm; if (!ret) { if (fdrv) drv_exit(); if (fmgr) mgr_exit(); if (fstrm) strm_exit(); if (fproc) proc_exit(); if (fnode) node_exit(); if (fdisp) disp_exit(); if (fchnl) chnl_exit(); if (fmsg) msg_exit(); if (fio) io_exit(); if (fdev) dev_exit(); if (fcod) cod_exit(); if (frmm) rmm_exit(); } } if (ret) api_c_refs++; return ret; }
int main(int argc, char *argv[]) { pthread_t rx_thr; pthread_t ui_thr; pthread_t daemon_thr; char rx_thr_name[] = "rx_thread"; char ui_thr_name[] = "ui_thread"; char daemon_thr_name[] = "run_daemon"; errno = 0; if(argc != 2) { fprintf(stderr,"Usage: nm_mgr <manager eid>\n"); return 1; } /* Indicate that the threads should run once started. */ g_running = 1; /* Initialize the DTNMP Manager. */ if(mgr_init(argv) != 0) { DTNMP_DEBUG_ERR("main","Can't init DTNMP Manager.", NULL); exit(EXIT_FAILURE); } DTNMP_DEBUG_INFO("main","Manager EID: %s", argv[1]); /* Register signal handlers. */ /* DOn't use signal handlers until we deprecate the UI thread... */ /* isignal(SIGINT, mgr_signal_handler); isignal(SIGTERM, mgr_signal_handler);*/ /* Spawn threads for receiving msgs, user interface, and db connection. */ if(pthread_create(&rx_thr, NULL, mgr_rx_thread, (void *)rx_thr_name)) { DTNMP_DEBUG_ERR("main","Can't create pthread %s, errnor = %s", rx_thr_name, strerror(errno)); exit(EXIT_FAILURE); } if(pthread_create(&ui_thr, NULL, ui_thread, (void *)ui_thr_name)) { DTNMP_DEBUG_ERR("main","Can't create pthread %s, errnor = %s", ui_thr_name, strerror(errno)); exit(EXIT_FAILURE); } #ifdef HAVE_MYSQL if(pthread_create(&daemon_thr, NULL, db_mgt_daemon, (void *)daemon_thr_name)) { DTNMP_DEBUG_ERR("main","Can't create pthread %s, errnor = %s", daemon_thr_name, strerror(errno)); exit(EXIT_FAILURE); } #endif if (pthread_join(rx_thr, NULL)) { DTNMP_DEBUG_ERR("main","Can't join pthread %s. Errnor = %s", rx_thr_name, strerror(errno)); exit(EXIT_FAILURE); } if (pthread_join(ui_thr, NULL)) { DTNMP_DEBUG_ERR("main","Can't join pthread %s. Errnor = %s", ui_thr_name, strerror(errno)); exit(EXIT_FAILURE); } #ifdef HAVE_MYSQL if (pthread_join(daemon_thr, NULL)) { DTNMP_DEBUG_ERR("main","Can't join pthread %s. Errnor = %s", daemon_thr_name, strerror(errno)); exit(EXIT_FAILURE); } #endif DTNMP_DEBUG_ALWAYS("main","Shutting down manager.", NULL); mgr_cleanup(); DTNMP_DEBUG_INFO("main","Exiting Manager after cleanup.", NULL); exit(0); }