/* Returns the product version string */ inline const QString& product() { static QString result; #ifdef MEEGO return result; #else if (result.isNull()) { struct system_config *sc = 0; if( sysinfo_init(&sc) == 0 ) { uint8_t *data = 0; unsigned long size = 0; if( sysinfo_get_value(sc, "/component/product", &data, &size) == 0 ) { result = QString::fromLatin1 ((const char*)data, size); free(data); } } sysinfo_finish(sc); // this prevents that this block runs twice: if (result.isNull()) result = ""; qDebug ("Product is \"%s\"", qPrintable(result)); } return result; #endif }
QmSystemInformationPrivate::QmSystemInformationPrivate() { #if HAVE_SYSINFO systemConfig = 0; if (sysinfo_init(&systemConfig) != 0) { /* Failed to initialize the system configuration object */ if (systemConfig) { sysinfo_finish(systemConfig), systemConfig = 0; } } #endif /* HAVE_SYSINFO */ }
void init(const char *_cmd) { x11_init(); checkotherwm(); cmd = _cmd; /* Setup the motion struct */ motion = xcalloc(1, sizeof(struct motion)); motion->type = NoMotion; sysinfo_init(); clients_init(); bars_init(settings()->barfont); launcher_init(); /* Select wvents to handle */ XSelectInput(dpy, root, WM_EVENT_MASK); /* Setup cursors */ cursors_init(); cursor_set(root, NormalCursor); /* Setup key bindings */ keys = settings()->keys; key_init(); key_grab_all(keys); /* Init atoms and EWMH */ atoms_init(); ewmh_init(wm_name); /* Init program lists */ program_init(getenv("PATH")); /* Create monitors */ create_monitors(); /* Init ewmh desktop functionality */ ewmh_root_set_number_of_desktops( monitor_count(mons) * N_WORKSPACES); ewmh_root_set_current_desktop(0); get_windows(); set_environment(); }
/* Need to make this a function main called from a GO main wrapper */ int ipmi_sim_main(int argc, const char *argv[]) { sys_data_t sysinfo; misc_data_t data; int err, rv = 1; int i; poptContext poptCtx; struct timeval tv; console_info_t stdio_console; struct sigaction act; os_hnd_fd_id_t *conid; lmc_data_t *mc; int print_version = 0; poptCtx = poptGetContext(argv[0], argc, argv, poptOpts, 0); while ((i = poptGetNextOpt(poptCtx)) >= 0) { switch (i) { case 'd': debug++; break; case 'n': nostdio = 1; break; case 'v': print_version = 1; break; } } poptFreeContext(poptCtx); printf("IPMI Simulator version %s\n", PVERSION); data.os_hnd = ipmi_posix_setup_os_handler(); if (!data.os_hnd) { fprintf(stderr, "Unable to allocate OS handler\n"); exit(1); } err = os_handler_alloc_waiter_factory(data.os_hnd, 0, 0, &data.waiter_factory); if (err) { fprintf(stderr, "Unable to allocate waiter factory: 0x%x\n", err); exit(1); } err = data.os_hnd->alloc_timer(data.os_hnd, &data.timer); if (err) { fprintf(stderr, "Unable to allocate timer: 0x%x\n", err); exit(1); } sysinfo_init(&sysinfo); sysinfo.info = &data; sysinfo.alloc = balloc; sysinfo.free = bfree; sysinfo.get_monotonic_time = ipmi_get_monotonic_time; sysinfo.get_real_time = ipmi_get_real_time; sysinfo.alloc_timer = ipmi_alloc_timer; sysinfo.start_timer = ipmi_start_timer; sysinfo.stop_timer = ipmi_stop_timer; sysinfo.free_timer = ipmi_free_timer; sysinfo.add_io_hnd = ipmi_add_io_hnd; sysinfo.io_set_hnds = ipmi_io_set_hnds; sysinfo.io_set_enables = ipmi_io_set_enables; sysinfo.remove_io_hnd = ipmi_remove_io_hnd; sysinfo.gen_rand = sys_gen_rand; sysinfo.debug = debug; sysinfo.log = sim_log; sysinfo.csmi_send = smi_send; sysinfo.clog = sim_chan_log; sysinfo.calloc = ialloc; sysinfo.cfree = ifree; sysinfo.lan_channel_init = lan_channel_init; sysinfo.ser_channel_init = ser_channel_init; data.sys = &sysinfo; err = pipe(sigpipeh); if (err) { perror("Creating signal handling pipe"); exit(1); } act.sa_handler = handle_sigchld; sigemptyset(&act.sa_mask); act.sa_flags = 0; err = sigaction(SIGCHLD, &act, NULL); if (err) { perror("setting up sigchld sigaction"); exit(1); } err = data.os_hnd->add_fd_to_wait_for(data.os_hnd, sigpipeh[0], sigchld_ready, &data, NULL, &conid); if (err) { fprintf(stderr, "Unable to sigchld pipe wait: 0x%x\n", err); exit(1); } data.emu = ipmi_emu_alloc(&data, sleeper, &sysinfo); /* Set this up for console I/O, even if we don't use it. */ stdio_console.data = &data; stdio_console.outfd = 1; stdio_console.pos = 0; stdio_console.echo = 1; stdio_console.shutdown_on_close = 1; stdio_console.telnet = 0; stdio_console.tn_pos = 0; if (nostdio) { stdio_console.out.printf = dummy_printf; stdio_console.out.data = &stdio_console; } else { stdio_console.out.printf = emu_printf; stdio_console.out.data = &stdio_console; } stdio_console.next = NULL; stdio_console.prev = NULL; data.consoles = &stdio_console; err = ipmi_mc_alloc_unconfigured(&sysinfo, 0x20, &mc); if (err) { if (err == ENOMEM) fprintf(stderr, "Out of memory allocation BMC MC\n"); exit(1); } sysinfo.mc = mc; sysinfo.chan_set = ipmi_mc_get_channelset(mc); sysinfo.startcmd = ipmi_mc_get_startcmdinfo(mc); sysinfo.cpef = ipmi_mc_get_pef(mc); sysinfo.cusers = ipmi_mc_get_users(mc); sysinfo.sol = ipmi_mc_get_sol(mc); if (read_config(&sysinfo, config_file, print_version)) exit(1); if (print_version) exit(0); if (!sysinfo.name) { fprintf(stderr, "name not set in config file\n"); exit(1); } err = persist_init("ipmi_sim", sysinfo.name, statedir); if (err) { fprintf(stderr, "Unable to initialize persistence: %s\n", strerror(err)); exit(1); } read_persist_users(&sysinfo); err = sol_init(&sysinfo); if (err) { fprintf(stderr, "Unable to initialize SOL: %s\n", strerror(err)); goto out; } err = read_sol_config(&sysinfo); if (err) { fprintf(stderr, "Unable to read SOL configs: %s\n", strerror(err)); goto out; } err = load_dynamic_libs(&sysinfo, 0); if (err) goto out; if (!command_file) { FILE *tf; command_file = malloc(strlen(BASE_CONF_STR) + 6 + strlen(sysinfo.name)); if (!command_file) { fprintf(stderr, "Out of memory\n"); goto out; } strcpy(command_file, BASE_CONF_STR); strcat(command_file, "/"); strcat(command_file, sysinfo.name); strcat(command_file, ".emu"); tf = fopen(command_file, "r"); if (!tf) { free(command_file); command_file = NULL; } else { fclose(tf); } } if (command_file) read_command_file(&stdio_console.out, data.emu, command_file); if (command_string) ipmi_emu_cmd(&stdio_console.out, data.emu, command_string); if (!sysinfo.bmc_ipmb || !sysinfo.ipmb_addrs[sysinfo.bmc_ipmb]) { sysinfo.log(&sysinfo, SETUP_ERROR, NULL, "No bmc_ipmb specified or configured."); goto out; } sysinfo.console_fd = -1; if (sysinfo.console_addr_len) { int nfd; int val; nfd = socket(sysinfo.console_addr.s_ipsock.s_addr.sa_family, SOCK_STREAM, IPPROTO_TCP); if (nfd == -1) { perror("Console socket open"); goto out; } err = bind(nfd, (struct sockaddr *) &sysinfo.console_addr, sysinfo.console_addr_len); if (err) { perror("bind to console socket"); goto out; } err = listen(nfd, 1); if (err == -1) { perror("listen to console socket"); goto out; } val = 1; err = setsockopt(nfd, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val)); if (err) { perror("console setsockopt reuseaddr"); goto out; } sysinfo.console_fd = nfd; err = data.os_hnd->add_fd_to_wait_for(data.os_hnd, nfd, console_bind_ready, &data, NULL, &conid); if (err) { fprintf(stderr, "Unable to add console wait: 0x%x\n", err); goto out; } } if (!nostdio) { init_term(); err = write(1, "> ", 2); err = data.os_hnd->add_fd_to_wait_for(data.os_hnd, 0, user_data_ready, &stdio_console, NULL, &stdio_console.conid); if (err) { fprintf(stderr, "Unable to add input wait: 0x%x\n", err); goto out; } } post_init_dynamic_libs(&sysinfo); act.sa_handler = shutdown_handler; act.sa_flags = SA_RESETHAND; for (i = 0; shutdown_sigs[i]; i++) { err = sigaction(shutdown_sigs[i], &act, NULL); if (err) { fprintf(stderr, "Unable to register shutdown signal %d: %s\n", shutdown_sigs[i], strerror(errno)); } } tv.tv_sec = 1; tv.tv_usec = 0; err = data.os_hnd->start_timer(data.os_hnd, data.timer, &tv, tick, &data); if (err) { fprintf(stderr, "Unable to start timer: 0x%x\n", err); goto out; } data.os_hnd->operation_loop(data.os_hnd); rv = 0; out: shutdown_handler(0); exit(rv); }