static void tcmu_conf_set_options(struct tcmu_config *cfg) { /* set log_level option */ TCMU_PARSE_CFG_INT(cfg, log_level); TCMU_CONF_CHECK_LOG_LEVEL(log_level); tcmu_set_log_level(cfg->log_level); /* add your new config options */ }
int main(int argc, char **argv) { GMainLoop *loop; GIOChannel *libtcmu_gio; struct tcmulib_context *ctx; while (1) { int c; int option_index = 0; c = getopt_long(argc, argv, "dhV", long_options, &option_index); if (c == -1) break; switch (c) { case 'd': tcmu_set_log_level(TCMU_CONF_LOG_DEBUG); break; case 'V': printf("tcmu-synthesizer %s\n", TCMUR_VERSION); exit(1); default: case 'h': usage(); exit(1); } } if (tcmu_setup_log()) { fprintf(stderr, "Could not setup tcmu logger.\n"); exit(1); } ctx = tcmulib_initialize(&syn_handler, 1); if (!ctx) { tcmu_err("tcmulib_initialize failed\n"); tcmu_destroy_log(); exit(1); } tcmulib_register(ctx); /* Set up event for libtcmu */ libtcmu_gio = g_io_channel_unix_new(tcmulib_get_master_fd(ctx)); g_io_add_watch(libtcmu_gio, G_IO_IN, tcmulib_callback, ctx); loop = g_main_loop_new(NULL, FALSE); g_main_loop_run(loop); g_main_loop_unref(loop); tcmu_destroy_log(); return 0; }