//TODO sensible defaults Log::Log(void) : TextWindow(0, 0, 80, 24, NULL) { conf = Conf::Instance(); /* Xerox */ #define REGISTER_G_LOG_HANDLER(name) \ g_log_set_handler((name), (GLogLevelFlags)(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \ | G_LOG_FLAG_RECURSION), \ glib_log_handler_, NULL) SetBorder(new Border()); max_lines = conf->GetLogMaxLines(); MoveResize(conf->GetLogDimensions()); /* Register the glib log handlers. */ REGISTER_G_LOG_HANDLER(NULL); REGISTER_G_LOG_HANDLER("GLib"); REGISTER_G_LOG_HANDLER("GModule"); REGISTER_G_LOG_HANDLER("GLib-GObject"); REGISTER_G_LOG_HANDLER("GThread"); /* Redirect the debug messages to stderr */ g_set_print_handler(glib_print_); g_set_printerr_handler(glib_printerr_); /* Set the purple debug callbacks */ purple_debug_set_ui_ops(¢erim_debug_ui_ops); }
__export gint hm_debug_log_facility_init(const gchar *folder_path, const gchar *name) { int err; log_mutex = g_mutex_new(); if (G_UNLIKELY(!log_mutex)) return -E_NEWMUTEX; err = hm_debug_create_log_file(folder_path, name); if (G_UNLIKELY(err)) { g_mutex_free(log_mutex); log_mutex = NULL; return err; } hm_debug_set_fps_nonblock(); g_log_set_handler( G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_WARNING |G_LOG_LEVEL_ERROR, hm_debug_log_to_file, NULL ); g_set_printerr_handler(hm_debug_log_assertion); hm_debug_log_set_exit_handler(); return 0; }
void log_handlers_init(void) { log_buffer = g_string_sized_new(2048); g_set_print_handler(handler_print); g_set_printerr_handler(handler_printerr); g_log_set_default_handler(handler_log, NULL); }
static void test_ot_util_usage_error (void) { g_autoptr(GError) error = NULL; g_autoptr(GOptionContext) context = g_option_context_new ("[TEST]"); GPrintFunc old_printerr = g_set_printerr_handler (util_usage_error_printerr); ot_util_usage_error (context, "find_me", &error); g_assert_nonnull (strstr (printerr_str->str, "[TEST]")); g_assert_nonnull (strstr (error->message, "find_me")); g_clear_error (&error); g_set_printerr_handler (old_printerr); g_string_free (printerr_str, TRUE); printerr_str = NULL; }
int main (int argc, char *argv[]) { GtkWidget *box, *scroll, *menu; GtkAccelGroup *accel = NULL; gtk_init(&argc, &argv); editor_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); // If the user quits the app g_signal_connect(G_OBJECT(editor_window), "delete_event", G_CALLBACK(delete_event), NULL); g_signal_connect(G_OBJECT(editor_window), "destroy", G_CALLBACK(gtk_main_quit), NULL); gtk_window_set_title(GTK_WINDOW(editor_window), "Text Editor (Insert file name)"); gtk_window_set_default_size(GTK_WINDOW(editor_window), 600, 500); // Create a container where the menus and text widget go box = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(editor_window), box); // Create an accelerator for the item factory, keyboard shortcuts //accel = gtk_accel_group_new(); //gtk_window_add_accel_group(GTK_WINDOW(editor_window), accel); // Create a menu bar above the text view widget menu = create_menu(accel); extend_menu(menu); // Put the menu in the menu container gtk_box_pack_start(GTK_BOX(box), menu, FALSE, FALSE, 0); //* Put a scroll window widget scroll = gtk_scrolled_window_new(NULL, NULL); gtk_box_pack_start(GTK_BOX(box), scroll, TRUE, TRUE, 0); // Create the text view widget editor_view = gtk_text_view_new(); gtk_container_add(GTK_CONTAINER(scroll), editor_view); // Get a buffer for the text view where everything gets stored editor_buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(editor_view)); gtk_widget_show_all(editor_window); // Error checking g_set_printerr_handler(err_msg); // load the file if a filename is specified if (argc > 1) load_file(g_strdup(argv[1])); // Start the main loop gtk_main(); return 0; // for stupid compilers }
int main (int argc, char **argv) { guint owner_id; GMainLoop *loop; GOptionContext *context; g_autoptr(GError) error = NULL; setlocale (LC_ALL, ""); g_setenv ("GIO_USE_VFS", "local", TRUE); g_set_prgname (argv[0]); flatpak_migrate_from_xdg_app (); g_set_printerr_handler (printerr_handler); context = g_option_context_new ("- permission store"); g_option_context_add_main_entries (context, entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("Option parsing failed: %s", error->message); return 1; } if (opt_version) { g_print ("%s\n", PACKAGE_STRING); exit (EXIT_SUCCESS); } if (opt_verbose) g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, message_handler, NULL); g_set_prgname (argv[0]); owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, "org.freedesktop.impl.portal.PermissionStore", G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT | (opt_replace ? G_BUS_NAME_OWNER_FLAGS_REPLACE : 0), on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL); loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); g_bus_unown_name (owner_id); return 0; }
int main (int argc, char *argv[]) { guint owner_id; g_autoptr(GError) error = NULL; GDBusConnection *session_bus; GOptionContext *context; setlocale (LC_ALL, ""); /* Avoid even loading gvfs to avoid accidental confusion */ g_setenv ("GIO_USE_VFS", "local", TRUE); g_set_printerr_handler (printerr_handler); context = g_option_context_new ("- desktop portal"); g_option_context_add_main_entries (context, entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("Option parsing failed: %s", error->message); return 1; } if (opt_verbose) g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, message_handler, NULL); g_set_prgname (argv[0]); load_installed_portals (); loop = g_main_loop_new (NULL, FALSE); session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); if (session_bus == NULL) { g_printerr ("No session bus: %s", error->message); return 2; } owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, "org.freedesktop.portal.Desktop", G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT | (opt_replace ? G_BUS_NAME_OWNER_FLAGS_REPLACE : 0), on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL); g_main_loop_run (loop); g_bus_unown_name (owner_id); return 0; }
static void prepare_logging () { GLogLevelFlags flags = G_LOG_FLAG_FATAL | G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO; openlog ("gnome-keyring-daemon", LOG_PID, LOG_AUTH); g_log_set_handler (NULL, flags, log_handler, NULL); g_log_set_handler ("Glib", flags, log_handler, NULL); g_log_set_handler ("Gtk", flags, log_handler, NULL); g_log_set_handler ("Gnome", flags, log_handler, NULL); g_log_set_default_handler (log_handler, NULL); g_set_printerr_handler (printerr_handler); }
EXPORT int check_plugin_init(int prio) { int argc = 0; char **argv = { NULL }; g_set_print_handler(simple_errprint); g_set_printerr_handler(simple_errprint); g_log_set_default_handler(g_log_default_handler, NULL); g_test_init(&argc, &argv, NULL); add_recode_tests(); g_test_run(); ekg_exit(); g_assert_not_reached(); }
int main(int ac, char* av[]) { GError* err = NULL; xr_servlet_def* servlets[3] = { __TTest1Servlet_def(), __TTest2Servlet_def(), NULL }; g_set_print_handler(dbg); g_set_printerr_handler(dbg); //xr_debug_enabled = XR_DEBUG_CALL; xr_server_simple("server.pem", 100, "*:4444", servlets, &err); if (err) g_print("error: %s\n", err->message); xr_fini(); return !!err; }
/* * setup_log_capture: * * Installs own logging handlers to capture and channelize all diagnostic output * during testing. */ void setup_log_capture (void) { (void) g_log_set_default_handler (check_log_handler, NULL); (void) g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, check_log_handler, NULL); (void) g_log_set_handler ("buzztrax", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, check_log_handler, NULL); (void) g_log_set_handler ("GStreamer", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, check_log_handler, NULL); (void) g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, check_log_handler, NULL); (void) g_log_set_handler ("GLib-GObject", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, check_log_handler, NULL); (void) g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, check_log_handler, NULL); (void) g_set_printerr_handler (check_print_handler); #ifndef GST_DISABLE_GST_DEBUG // gst_init() will add the log handler unconditionally: // - if we do this before gst_init() we don't actually remove the def log // handler // - if we do this after gst_init() we get debug output from gst_init() itself // on the default handler // - we want a flag to tell gst to not register the default handler // gst_debug_set_active() is not the same // A workaround for now is to set GST_DEBUG_FILE=/dev/null which our handler // is not using and doing the // gst_debug_remove_log_function (gst_debug_log_default); // after gst_init() from bt_check_init(). gst_debug_add_log_function (check_gst_log_handler, NULL, NULL); #endif }
int main (int argc, char **argv) { gint i, start = 1, mode = MODE_NORMAL; struct rspamd_config *cfg; rspamd_logger_t *logger = NULL; if (argc > 2 && *argv[1] == '-') { start = 2; if (argv[1][1] == 'g') { mode = MODE_GMIME; } } cfg = rspamd_config_new (); cfg->libs_ctx = rspamd_init_libs (); cfg->log_type = RSPAMD_LOG_CONSOLE; rspamd_set_logger (cfg, g_quark_from_static_string ("mime"), &logger, NULL); (void) rspamd_log_open (logger); g_log_set_default_handler (rspamd_glib_log_function, logger); g_set_printerr_handler (rspamd_glib_printerr_function); rspamd_config_post_load (cfg, RSPAMD_CONFIG_INIT_LIBS|RSPAMD_CONFIG_INIT_URL|RSPAMD_CONFIG_INIT_NO_TLD); for (i = start; i < argc; i ++) { if (argv[i]) { rspamd_process_file (cfg, argv[i], mode); } } rspamd_printf ("Total time parsing: %.4f seconds\n", total_time); rspamd_log_close (logger); REF_RELEASE (cfg); return 0; }
static void init_gst() { static bool gst_inited = false; if (gst_inited) return; ALOGI("%s, %lu, begin", __func__, time(0)); gint level = 0xff; g_set_print_handler(print_func); // g_print g_set_printerr_handler(print_func); // g_printerr g_log_set_handler("k2player", (GLogLevelFlags)level, log_func, NULL); g_log_set_default_handler(log_func, NULL); if (!g_thread_supported ()) { g_thread_init (NULL); } gst_debug_set_active(true); #if 0 GST_DEBUG_CATEGORY_STATIC (my_category);// define category (statically) #define GST_CAT_DEFAULT my_category // set as default GST_DEBUG_CATEGORY_INIT (my_category, "my category", 0, "This is my very own"); gst_debug_category_set_threshold(my_category, GST_LEVEL_TRACE); #endif ALOGI("%s, %lu, gst_init", __func__, time(0)); int argc = 1; char *argvs[] = {(char *)"k2player", NULL}; char **argv = argvs; gst_init (&argc, &argv); ALOGI("%s, %lu, gst_static_init", __func__, time(0)); gst_static_plugins(); gst_inited = true; ALOGI("%s, %lu, end", __func__, time(0)); }
gint main (gint argc, gchar **argv, gchar **env) { GError *error = NULL; GOptionContext *context; GOptionGroup *og; struct rspamd_config *cfg; GQuark process_quark; gchar **nargv, **targv; const gchar *cmd_name; const struct rspamadm_command *cmd; gint i, nargc, targc; ucl_vars = g_hash_table_new_full (rspamd_strcase_hash, rspamd_strcase_equal, g_free, g_free); process_quark = g_quark_from_static_string ("rspamadm"); cfg = rspamd_config_new (); cfg->libs_ctx = rspamd_init_libs (); rspamd_main = g_malloc0 (sizeof (*rspamd_main)); rspamd_main->cfg = cfg; rspamd_main->pid = getpid (); rspamd_main->type = process_quark; rspamd_main->server_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), "rspamadm"); cfg->log_level = G_LOG_LEVEL_WARNING; cfg->log_type = RSPAMD_LOG_CONSOLE; rspamd_set_logger (cfg, process_quark, rspamd_main); (void) rspamd_log_open (rspamd_main->logger); g_log_set_default_handler (rspamd_glib_log_function, rspamd_main->logger); g_set_printerr_handler (rspamd_glib_printerr_function); rspamd_config_post_load (cfg, FALSE); /* Setup logger */ if (verbose) { cfg->log_level = G_LOG_LEVEL_DEBUG; } else { cfg->log_level = G_LOG_LEVEL_INFO; } gperf_profiler_init (cfg, "rspamadm"); setproctitle ("rspamdadm"); /* Now read options and store everything till the first non-dash argument */ nargv = g_malloc0 (sizeof (gchar *) * (argc + 1)); nargv[0] = g_strdup (argv[0]); for (i = 1, nargc = 1; i < argc; i ++) { if (argv[i] && argv[i][0] == '-') { /* Copy to nargv */ nargv[nargc] = g_strdup (argv[i]); nargc ++; } else { break; } } context = g_option_context_new ("command - rspamd administration utility"); og = g_option_group_new ("global", "global options", "global options", NULL, NULL); g_option_context_set_help_enabled (context, FALSE); g_option_group_add_entries (og, entries); g_option_context_set_summary (context, "Summary:\n Rspamd administration utility version " RVERSION "\n Release id: " RID); g_option_context_set_main_group (context, og); targv = nargv; targc = nargc; if (!g_option_context_parse (context, &targc, &targv, &error)) { fprintf (stderr, "option parsing failed: %s\n", error->message); g_error_free (error); exit (1); } g_strfreev (nargv); if (show_version) { rspamadm_version (); exit (EXIT_SUCCESS); } if (show_help) { rspamadm_usage (context); exit (EXIT_SUCCESS); } if (list_commands) { rspamadm_commands (); exit (EXIT_SUCCESS); } cmd_name = argv[nargc]; if (cmd_name == NULL) { cmd_name = "help"; } cmd = rspamadm_search_command (cmd_name); if (cmd == NULL) { fprintf (stderr, "Invalid command name: %s\n", cmd_name); exit (EXIT_FAILURE); } if (nargc < argc) { nargv = g_malloc0 (sizeof (gchar *) * (argc - nargc + 1)); nargv[0] = g_strdup_printf ("%s %s", argv[0], cmd_name); for (i = 1; i < argc - nargc; i ++) { nargv[i] = g_strdup (argv[i + nargc]); } targc = argc - nargc; targv = nargv; cmd->run (targc, targv); g_strfreev (nargv); } else { cmd->run (0, NULL); } rspamd_log_close (rspamd_main->logger); REF_RELEASE (rspamd_main->cfg); g_free (rspamd_main); return 0; }
int main(int argc, char *argv[]) { GtkWidget *box, *scroll, *widget; GtkAccelGroup *accel; gtk_init(&argc, &argv); /* gtk initializer can take filename as an argument*/ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); /* if the user quits the app */ g_signal_connect(G_OBJECT(window), "delete_event",G_CALLBACK(delete_event), window); g_signal_connect(G_OBJECT(window), "destroy",G_CALLBACK(gtk_main_quit), NULL); gtk_window_set_title(GTK_WINDOW(window), "Text Editor (Insert file name)"); gtk_window_set_default_size(GTK_WINDOW(window), 600, 500); /* window size y & x values */ box = gtk_vbox_new(FALSE, 0); /* create a container where the menus n text widget goes */ /* false if u dont want extra padding in the box, 0 for spacing */ /* add the box wid in the window */ gtk_container_add(GTK_CONTAINER(window), box); /* create an accerelator for the item factory, keyboard shortcuts */ accel = gtk_accel_group_new(); gtk_window_add_accel_group(GTK_WINDOW(window), accel); /* Create a menu above the text view widget */ main_menu = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<TextView>", accel); gtk_item_factory_create_items(main_menu,sizeof(menu_def) / sizeof(*menu_def),menu_def, NULL); /* Return the actual menu bar created by the item factory. */ widget = gtk_item_factory_get_widget(main_menu, "<TextView>"); /* put the menu in the menu container */ gtk_box_pack_start(GTK_BOX(box), widget, FALSE, FALSE, 0); scroll = gtk_scrolled_window_new(NULL, NULL); /* put a scroll window widget */ /* put the scroll window in the text container */ gtk_box_pack_start(GTK_BOX(box), scroll, TRUE, TRUE, 0); /* create the text view widget */ view = gtk_text_view_new(); /* create a buffer for the text view where everything gets stored */ buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)); /* put the text widget in the scroll window */ gtk_container_add(GTK_CONTAINER(scroll), view); gtk_widget_show_all(window); /* show all widgets in the window */ /* error checking */ g_set_printerr_handler(err_msg); /* load the file if a filename is specified */ if(argc > 1) load_file(g_strdup(argv[1])); /* the main loop where the app waits for mouse n keyboard events */ gtk_main(); return 0; }
int main(int argc, char *argv[]) { int ret = -1; int lockfd = -1; gboolean foreground = FALSE; gboolean force_local_mode = FALSE; gboolean wrote_pidfile = FALSE; memdb_t *memdb = NULL; dfsm_t *dcdb = NULL; dfsm_t *status_fsm = NULL; qb_log_init("pmxcfs", LOG_DAEMON, LOG_DEBUG); /* remove default filter */ qb_log_filter_ctl(QB_LOG_SYSLOG, QB_LOG_FILTER_REMOVE, QB_LOG_FILTER_FILE, "*", LOG_DEBUG); qb_log_tags_stringify_fn_set(log_tags_stringify); qb_log_ctl(QB_LOG_STDERR, QB_LOG_CONF_ENABLED, QB_TRUE); update_qb_log_settings(); g_set_print_handler(glib_print_handler); g_set_printerr_handler(glib_print_handler); g_log_set_default_handler(glib_log_handler, NULL); GOptionContext *context; GOptionEntry entries[] = { { "debug", 'd', 0, G_OPTION_ARG_NONE, &cfs.debug, "Turn on debug messages", NULL }, { "foreground", 'f', 0, G_OPTION_ARG_NONE, &foreground, "Do not daemonize server", NULL }, { "local", 'l', 0, G_OPTION_ARG_NONE, &force_local_mode, "Force local mode (ignore cluster.conf, force quorum)", NULL }, { NULL }, }; context = g_option_context_new (""); g_option_context_add_main_entries (context, entries, NULL); GError *err = NULL; if (!g_option_context_parse (context, &argc, &argv, &err)) { cfs_critical("option parsing failed: %s", err->message); g_error_free (err); qb_log_fini(); exit (1); } g_option_context_free(context); if (optind < argc) { cfs_critical("too many arguments"); qb_log_fini(); exit(-1); } if (cfs.debug) { update_qb_log_settings(); } struct utsname utsname; if (uname(&utsname) != 0) { cfs_critical("Unable to read local node name"); qb_log_fini(); exit (-1); } for (int i=0; i < sizeof(utsname.nodename); i++) { if (utsname.nodename[i] =='.') utsname.nodename[i] = 0; } cfs.nodename = g_strdup(utsname.nodename); if (!(cfs.ip = lookup_node_ip(cfs.nodename))) { cfs_critical("Unable to get local IP address"); qb_log_fini(); exit(-1); } struct group *www_data = getgrnam("www-data"); if (!www_data) { cfs_critical("Unable to get www-data group ID"); qb_log_fini(); exit (-1); } cfs.gid = www_data->gr_gid; g_thread_init(NULL); umask(027); mkdir(VARLIBDIR, 0755); if ((lockfd = open(LOCKFILE, O_RDWR|O_CREAT|O_APPEND)) == -1) { cfs_critical("unable to create lock '%s': %s", LOCKFILE, strerror (errno)); goto err; } for (int i = 10; i >= 0; i--) { if (flock(lockfd, LOCK_EX|LOCK_NB) != 0) { if (!i) { cfs_critical("unable to aquire pmxcfs lock: %s", strerror (errno)); goto err; } if (i == 10) cfs_message("unable to aquire pmxcfs lock - trying again"); sleep(1); } } cfs_status_init(); gboolean create = !g_file_test(DBFILENAME, G_FILE_TEST_EXISTS); if (!(memdb = memdb_open (DBFILENAME))) { cfs_critical("memdb_open failed - unable to open database '%s'", DBFILENAME); goto err; } // automatically import cluster.conf from host if (create && !force_local_mode) { char *cdata = NULL; gsize clen = 0; if (g_file_get_contents(HOST_CLUSTER_CONF_FN, &cdata, &clen, NULL)) { guint32 mtime = time(NULL); memdb_create(memdb, "/cluster.conf", 0, mtime); if (memdb_write(memdb, "/cluster.conf", 0, mtime, cdata, clen, 0, 1) < 0) { cfs_critical("memdb_write failed - unable to import cluster.conf"); goto err; } } } // does cluster.conf exist? gpointer conf_data = NULL; int len = memdb_read(memdb, "cluster.conf", &conf_data); if (len >= 0) { if (force_local_mode) { cfs_message("forcing local mode (althought cluster.conf exists)"); cfs_set_quorate(1, TRUE); } else { if (!(dcdb = dcdb_new(memdb))) goto err; dcdb_sync_cluster_conf(memdb, 1); } } else { cfs_debug("using local mode (cluster.conf does not exist)"); cfs_set_quorate(1, TRUE); } if (conf_data) g_free(conf_data); cfs_plug_memdb_t *config = cfs_plug_memdb_new("memdb", memdb, dcdb); cfs_plug_base_t *bplug = cfs_plug_base_new("", (cfs_plug_t *)config); create_symlinks(bplug, cfs.nodename); root_plug = (cfs_plug_t *)bplug; system("umount -f " CFSDIR " >/dev/null 2>&1"); char *fa[] = { "-f", "-odefault_permissions", "-oallow_other", NULL}; struct fuse_args fuse_args = FUSE_ARGS_INIT(sizeof (fa)/sizeof(gpointer) - 1, fa); struct fuse_chan *fuse_chan = fuse_mount(CFSDIR, &fuse_args); if (!fuse_chan) { cfs_critical("fuse_mount error: %s", strerror(errno)); goto err; } if (!(fuse = fuse_new(fuse_chan, &fuse_args, &fuse_ops, sizeof(fuse_ops), NULL))) { cfs_critical("fuse_new error: %s", strerror(errno)); goto err; } fuse_set_signal_handlers(fuse_get_session(fuse)); if (!foreground) { pid_t cpid = fork(); if (cpid == -1) { cfs_critical("failed to daemonize program - %s", strerror (errno)); goto err; } else if (cpid) { write_pidfile(cpid); qb_log_fini(); _exit (0); } else { int nullfd; chroot("/"); if ((nullfd = open("/dev/null", O_RDWR, 0)) != -1) { dup2(nullfd, 0); dup2(nullfd, 1); dup2(nullfd, 2); if (nullfd > 2) close (nullfd); } // do not print to the console after this point qb_log_ctl(QB_LOG_STDERR, QB_LOG_CONF_ENABLED, QB_FALSE); setsid(); } } else { write_pidfile(getpid()); } wrote_pidfile = TRUE; cfs_loop_t *corosync_loop = cfs_loop_new(fuse); cfs_service_t *service_quorum = NULL; cfs_service_t *service_confdb = NULL; cfs_service_t *service_dcdb = NULL; cfs_service_t *service_status = NULL; if (dcdb) { service_quorum = service_quorum_new(); cfs_loop_add_service(corosync_loop, service_quorum, QB_LOOP_HIGH); service_confdb = service_confdb_new(); cfs_loop_add_service(corosync_loop, service_confdb, QB_LOOP_MED); service_dcdb = service_dfsm_new(dcdb); cfs_service_set_timer(service_dcdb, DCDB_VERIFY_TIME); cfs_loop_add_service(corosync_loop, service_dcdb, QB_LOOP_MED); status_fsm = cfs_status_dfsm_new(); service_status = service_dfsm_new(status_fsm); cfs_loop_add_service(corosync_loop, service_status, QB_LOOP_LOW); } cfs_loop_start_worker(corosync_loop); server_start(memdb); ret = fuse_loop_mt(fuse); cfs_message("teardown filesystem"); server_stop(); fuse_unmount(CFSDIR, fuse_chan); fuse_destroy(fuse); cfs_debug("set stop event loop flag"); cfs_loop_stop_worker(corosync_loop); cfs_loop_destroy(corosync_loop); cfs_debug("worker finished"); if (service_dcdb) service_dfsm_destroy(service_dcdb); if (service_confdb) service_confdb_destroy(service_confdb); if (service_quorum) service_quorum_destroy(service_quorum); if (service_status) service_dfsm_destroy(service_status); sleep(1); /* do not restart too fast */ ret: if (status_fsm) dfsm_destroy(status_fsm); if (dcdb) dfsm_destroy(dcdb); if (memdb) memdb_close(memdb); if (wrote_pidfile) unlink(CFS_PID_FN); cfs_message("exit proxmox configuration filesystem (%d)", ret); cfs_status_cleanup(); qb_log_fini(); exit(ret); err: goto ret; }
static gboolean feed(ChupaDecomposer *decomposer, ChupaFeeder *feeder, ChupaData *data, GError **error) { GOFileSaver *saver; GOFileOpener *opener = NULL; GOIOContext *io_context; WorkbookView *view = NULL; Workbook *workbook; GODoc *document; GsfInput *source; GsfOutput *output; GInputStream *input; ChupaData *next_data; const gchar *filename; GPrintFunc old_print_error_func; ChupaMetadata *metadata; filename = chupa_data_get_filename(data); source = chupa_data_input_new(data); io_context = go_io_context_new(command_context); old_print_error_func = g_set_printerr_handler(printerr_to_log_delegator); view = wb_view_new_from_input(source, filename, opener, io_context, NULL); g_object_unref(source); g_set_printerr_handler(old_print_error_func); if (go_io_error_occurred(io_context)) { go_io_error_display(io_context); } if (!view) { g_set_error(error, CHUPA_DECOMPOSER_ERROR, CHUPA_DECOMPOSER_ERROR_FEED, "[decomposer][excel][feed][error][%s]" ": failed to create workbook", filename); g_object_unref(io_context); return FALSE; } workbook = wb_view_get_workbook(view); document = wb_view_get_doc(view); saver = find_file_saver(filename, view, workbook, document, error); if (!saver) { g_object_unref(workbook); g_object_unref(io_context); return FALSE; } output = gsf_output_memory_new(); if (!output) { g_set_error(error, CHUPA_DECOMPOSER_ERROR, CHUPA_DECOMPOSER_ERROR_FEED, "[decomposer][excel][feed][%s][error]" ": failed to create output", filename); g_object_unref(workbook); g_object_unref(io_context); return FALSE; } wbv_save_to_output(view, saver, output, io_context); if (go_io_error_occurred(io_context)) { go_io_error_display(io_context); g_object_unref(workbook); g_object_unref(io_context); g_object_unref(output); return FALSE; } metadata = chupa_metadata_new(); chupa_metadata_merge_original_metadata(metadata, chupa_data_get_metadata(data)); collect_metadata(metadata, document); g_object_unref(workbook); g_object_unref(io_context); input = chupa_memory_input_stream_new(GSF_OUTPUT_MEMORY(output)); g_object_unref(output); chupa_metadata_set_content_length(metadata, gsf_output_size(output)); next_data = chupa_data_new(input, metadata); g_object_unref(metadata); g_object_unref(input); chupa_feeder_accepted(feeder, next_data); chupa_data_finished(next_data, NULL); g_object_unref(next_data); return TRUE; }
void mono_init_virt () { const char *error; #ifndef MONO_AGENT char * cfg_mono_root_path; char * cfg_mono_cfg_dir; char * cfg_mono_path; char * cfg_mono_trace; /*g_log_set_always_fatal (G_LOG_LEVEL_ERROR); g_log_set_fatal_mask (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR);*/ #ifndef VIRT_MINT if (virtuoso_cfg_getstring ("Mono", "MONO_TRACE", &cfg_mono_trace) != -1) mono_jit_trace_calls = strcmp (cfg_mono_trace, "On") ? FALSE : TRUE; #endif if (virtuoso_cfg_getstring ("Mono", "MONO_PATH", &cfg_mono_path) != -1) setenv ("MONO_PATH", cfg_mono_path, 1); if (virtuoso_cfg_getstring ("Mono", "MONO_ROOT", &cfg_mono_root_path) != -1) setenv ("MONO_ROOT", cfg_mono_root_path, 1); if (virtuoso_cfg_getstring ("Mono", "MONO_CFG_DIR", &cfg_mono_cfg_dir) != -1) setenv ("MONO_CFG_DIR", cfg_mono_cfg_dir, 1); if (virtuoso_cfg_getstring ("Mono", "virtclr.dll", &VIRTCLR_NAME) == -1) VIRTCLR_NAME = "virtclr.dll"; #endif #ifdef WIN32 /* mono initialization on win32 has to be done sooner than later */ #ifdef VIRT_MINT virtuoso_domain = mono_interp_init ("virtuoso"); #else virtuoso_domain = mono_jit_init ("virtuoso"); #endif if (cfg_mono_root_path) mono_assembly_setrootdir (cfg_mono_root_path); #endif #ifndef VIRT_MINT mono_jit_trace_calls = FALSE; #endif { char *path = getenv ("MONO_ROOT"); if (path) mono_assembly_setrootdir (path); } /* mono_debug_init (1); */ #ifndef WIN32 setlocale(LC_ALL, ""); #endif g_log_set_always_fatal (G_LOG_LEVEL_ERROR); g_log_set_fatal_mask (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR); g_set_printerr_handler (dummy_print); #ifndef WIN32 #ifdef VIRT_MINT virtuoso_domain = mono_interp_init ("virtuoso"); #else virtuoso_domain = mono_jit_init ("virtuoso"); #endif mono_config_parse (NULL); #ifdef OLD_KIT if (NULL != (error = mono_verify_corlib ())) #elif !defined (OLD_KIT_1_1_5) if (NULL != (error = mono_check_corlib_version ())) #endif { log_error ("Mono Corlib not in sync with this runtime: %s", error); exit (-1); } #ifndef VIRT_MINT #ifdef OLD_KIT_1_1_5 mono_thread_attach_aborted_cb = virt_mono_throw_unhandled_exception; #else mono_thread_set_attach_aborted_cb (virt_mono_throw_unhandled_exception); #endif #endif #endif mono_add_internal_call ("VInvoke::LoadAssemblyFromVirtuoso(string)", ves_icall_VInvoke_LoadAssemblyFromVirtuoso); #ifndef MONO_AGENT mono_set_port (); #endif #ifndef MONO_AGENT #ifdef OLD_KIT_1_1_4 log_debug ("Mono config path [%s]", mono_cfg_dir); #else log_debug ("Mono config path [%s]", mono_get_config_dir ()); #endif #endif #ifndef WIN32 setlocale (LC_ALL, "C"); #endif #ifndef OLD_KIT_1_1_5 mono_thread_manage (); mono_thread_set_main (mono_thread_current()); #endif }
/** * owr_init: * * Initializes the OpenWebRTC library. Creates a new #GMainContext and starts * the main loop used in the OpenWebRTC library. Either this function or * owr_init_with_main_context() must be called before doing anything else. */ void owr_init() { gboolean owr_main_context_is_external; GstBus *bus; g_return_if_fail(!owr_initialized); #ifdef __ANDROID__ g_set_print_handler((GPrintFunc)g_print_android_handler); g_set_printerr_handler((GPrintFunc)g_printerr_android_handler); g_log_set_default_handler((GLogFunc)g_log_android_handler, NULL); gst_debug_add_log_function((GstLogFunction)gst_log_android_handler, NULL, NULL); #endif /* Hack to make sure that all symbols that we need are included in the resulting library/binary */ _owr_require_symbols(); gst_init(NULL, NULL); owr_initialized = TRUE; GST_PLUGIN_STATIC_REGISTER(alaw); GST_PLUGIN_STATIC_REGISTER(app); GST_PLUGIN_STATIC_REGISTER(audioconvert); GST_PLUGIN_STATIC_REGISTER(audioresample); GST_PLUGIN_STATIC_REGISTER(audiotestsrc); GST_PLUGIN_STATIC_REGISTER(coreelements); GST_PLUGIN_STATIC_REGISTER(erdtls); GST_PLUGIN_STATIC_REGISTER(mulaw); GST_PLUGIN_STATIC_REGISTER(opengl); GST_PLUGIN_STATIC_REGISTER(openh264); GST_PLUGIN_STATIC_REGISTER(opus); GST_PLUGIN_STATIC_REGISTER(rtp); GST_PLUGIN_STATIC_REGISTER(rtpmanager); GST_PLUGIN_STATIC_REGISTER(srtp); GST_PLUGIN_STATIC_REGISTER(videoconvert); GST_PLUGIN_STATIC_REGISTER(videocrop); GST_PLUGIN_STATIC_REGISTER(videofilter); GST_PLUGIN_STATIC_REGISTER(videoparsersbad); GST_PLUGIN_STATIC_REGISTER(videorate); GST_PLUGIN_STATIC_REGISTER(videorepair); GST_PLUGIN_STATIC_REGISTER(videoscale); GST_PLUGIN_STATIC_REGISTER(videotestsrc); GST_PLUGIN_STATIC_REGISTER(volume); GST_PLUGIN_STATIC_REGISTER(vpx); #ifdef __APPLE__ #if !TARGET_IPHONE_SIMULATOR GST_PLUGIN_STATIC_REGISTER(applemedia); GST_PLUGIN_STATIC_REGISTER(osxaudio); #endif #elif defined(__ANDROID__) GST_PLUGIN_STATIC_REGISTER(androidvideosource); GST_PLUGIN_STATIC_REGISTER(opensles); #elif defined(__linux__) GST_PLUGIN_STATIC_REGISTER(pulseaudio); GST_PLUGIN_STATIC_REGISTER(video4linux2); #endif #if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR) GST_PLUGIN_STATIC_REGISTER(ercolorspace); #endif gst_element_register(NULL, "nicesrc", GST_RANK_NONE, GST_TYPE_NICE_SRC); gst_element_register(NULL, "nicesink", GST_RANK_NONE, GST_TYPE_NICE_SINK); owr_main_context_is_external = !!owr_main_context; if (!owr_main_context_is_external) owr_main_context = g_main_context_new(); owr_pipeline = gst_pipeline_new("OpenWebRTC"); bus = gst_pipeline_get_bus(GST_PIPELINE(owr_pipeline)); g_main_context_push_thread_default(owr_main_context); bus_watch_id = gst_bus_add_watch(bus, (GstBusFunc)bus_call, NULL); g_main_context_pop_thread_default(owr_main_context); gst_object_unref(bus); gst_element_set_state(owr_pipeline, GST_STATE_PLAYING); #ifdef OWR_DEBUG g_signal_connect(owr_pipeline, "deep-notify", G_CALLBACK(gst_object_default_deep_notify), NULL); #endif if (owr_main_context_is_external) return; owr_main_loop = g_main_loop_new(owr_main_context, FALSE); owr_main_thread = g_thread_new("owr_main_loop", owr_run, NULL); }