/* * Default startup routine. * Call it from main() * Look at squat.c */ int main_stub(int argc, char *argv[]) { void *self = 0; char *name = 0; struct app_t *app = 0; struct api_t *api = 0; app_getopt opts; opts.argc = argc; opts.argv = argv; if(lt_dlinit()) return E_DL; self = lt_dlopen(NULL); if(NULL == self) return E_DL; /* Get '-a' ie. '--app' */ name = get_app_opt(argc, argv); /* Reflection? */ if(name) api = lt_dlsym(self, name); else api = lt_dlsym(self, "sipware"); if(NULL == api) return E_APP; /* * As the matter of fact we got api, not app */ app = api->data; /* * Try to boot */ if(app->data) { struct module_t *m = app->data; if(m->boot) ctx = m->boot(NULL, app, &opts); else ctx = app_boot(NULL, app, &opts); } else ctx = app_boot(NULL, app, &opts); if(NULL == ctx) return E_CTX; /* Set log using command line arg */ app_set_log(app,app_opt_check(app, 'd', argc, argv), CTX_STDERR); /* Module path */ set_path(app->ctx, app_opt_check(app, 'P', argc, argv)); if(NULL == get_path(app->ctx)) return E_CONF; /* Config file */ set_cfg_file(app->ctx, app_opt_check(app, 'f', argc, argv)); if(NULL == get_cfg_file(app->ctx)) return E_CONF; /* Init parsers subsystem */ if(!parser_sys_init(app->ctx)) return E_SYS; log(ctx,4,"Ok %s\n", app->name); /* Search for '-D' on command line */ { char *dbg_ptr; dbg_ptr = app_opt_check(app, 'D', argc, argv); log(ctx,6,"Ok\n"); /* * Need better way to syslog (facility,prio,...) * Hardcoded for now */ if(dbg_ptr) { ctx->cfg->basic->debug = atoi(dbg_ptr); ctx->cfg->basic->prio = LOG_NOTICE; CLR_BIT(app->type, APP_DAEMON); openlog(NULL, LOG_PID|LOG_NDELAY, LOG_NOTICE); set_print_log(ctx, syslog); log(ctx, 0, "Daemon or not? %d\n", ctx->cfg->basic->debug); } else { dbg_ptr = app_opt_check(app, 'd', argc, argv); if(dbg_ptr) { ctx->cfg->basic->debug = atoi(dbg_ptr); ctx->cfg->basic->prio = atoi(dbg_ptr); set_print_log(ctx, lprint); log(ctx, 0, "daemon or not2? %d\n", ctx->cfg->basic->debug); } else { ctx->cfg->basic->debug = 1; ctx->cfg->basic->prio = 1; } } } /* Will start module->preload */ if(app_preload(app, argc, argv)) return E_APP; /* Start module->main */ if(app_start(app, argc, argv)) return E_APP; if(app_finish(app, 0)) log(ctx,0,"finish problem.\n"); else log(ctx,0,"finish ok.\n"); return E_NONE; }
static int fbsplash_load() { fb_fd = -1; last_pos = 0; /* Kick start our TTF library */ if (TTF_Init() < 0) { printk("Couldn't initialise TTF.\n"); } /* Find out the FB size */ if (get_fb_settings(0)) { printk("Couldn't get fb settings.\n"); return 1; } arg_vc = get_active_vt(); arg_mode = 's'; /* Read theme config file */ if (arg_theme == NULL) arg_theme = DEFAULT_THEME; config_file = get_cfg_file(arg_theme); if (!config_file) { printk("Couldn't load config file %s.\n", arg_theme); return 1; } else printk("Using configuration file %s.\n", config_file); parse_cfg(config_file); /* Prime the font cache with glyphs so we don't need to allocate them later */ TTF_PrimeCache("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 -.", global_font, TTF_STYLE_NORMAL); boot_message = rendermessage; fb_fd = open_fb(); if (fb_fd == -1) { printk("Couldn't open framebuffer device.\n"); return 1; } if (fb_fix.visual == FB_VISUAL_DIRECTCOLOR) set_directcolor_cmap(fb_fd); fbsplash_fd = open(SPLASH_DEV, O_WRONLY); /* Don't worry if it fails */ do_getpic(FB_SPLASH_IO_ORIG_USER, 1, 'v'); /* Don't worry if it fails */ if (do_getpic(FB_SPLASH_IO_ORIG_USER, 0, 's') == -1) no_silent_image = 1; /* We do care if this fails. */ /* These next two touch the kernel and are needed even for silent mode, to * get the colours right (even on 32-bit depth displays funnily enough. */ do_config(FB_SPLASH_IO_ORIG_USER); cmd_setstate(1, FB_SPLASH_IO_ORIG_USER); /* copy the silent pic to base_image for safe keeping */ if (!no_silent_image) { base_image_size = silent_img.width * silent_img.height * (silent_img.depth >> 3); base_image = malloc(base_image_size); if (!base_image) { printk("Couldn't get enough memory for framebuffer image.\n"); return 1; } memcpy(base_image, (void*)silent_img.data, base_image_size); }