int main (int argc, char *argv[]) { GType type; GeditApp *app; gint status; const gchar *dir; #ifdef OS_OSX type = GEDIT_TYPE_APP_OSX; #else #ifdef G_OS_WIN32 if (!gedit_w32_load_private_dll ()) { return 1; } type = GEDIT_TYPE_APP_WIN32; #else type = GEDIT_TYPE_APP_X11; #endif #endif /* NOTE: we should not make any calls to the gedit api before the * private library is loaded */ gedit_dirs_init (); /* Setup locale/gettext */ setlocale (LC_ALL, ""); dir = gedit_dirs_get_gedit_locale_dir (); bindtextdomain (GETTEXT_PACKAGE, dir); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); app = g_object_new (type, "application-id", "org.gnome.gedit", "flags", G_APPLICATION_HANDLES_COMMAND_LINE | G_APPLICATION_HANDLES_OPEN, NULL); /* https://honk.sigxcpu.org/con/GTK__and_the_application_id.html */ g_set_prgname("org.gnome.gedit"); status = g_application_run (G_APPLICATION (app), argc, argv); /* Break reference cycles caused by the PeasExtensionSet * for GeditAppActivatable which holds a ref on the GeditApp */ g_object_run_dispose (G_OBJECT (app)); g_object_add_weak_pointer (G_OBJECT (app), (gpointer *) &app); g_object_unref (app); if (app != NULL) { gedit_debug_message (DEBUG_APP, "Leaking with %i refs", G_OBJECT (app)->ref_count); } #ifdef G_OS_WIN32 gedit_w32_unload_private_dll (); #endif return status; }
int main (int argc, char **argv) { guint owner_id; GBytes *introspection_bytes; g_autoptr(GError) error = NULL; g_autofree char *path = NULL; GDBusConnection *session_bus; GOptionContext *context; setlocale (LC_ALL, ""); /* Avoid even loading gvfs to avoid accidental confusion */ g_setenv ("GIO_USE_VFS", "local", TRUE); context = g_option_context_new ("- document 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\n", error->message); return 1; } if (opt_daemon) { pid_t pid; ssize_t read_res; daemon_event_fd = eventfd (0, EFD_CLOEXEC); pid = fork (); if (pid != 0) { guint64 counter; read_res = read (daemon_event_fd, &counter, sizeof (counter)); if (read_res != 8) exit (1); exit (counter - 1); } } if (opt_verbose) g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, message_handler, NULL); g_set_prgname (argv[0]); loop = g_main_loop_new (NULL, FALSE); path = g_build_filename (g_get_user_data_dir (), "xdg-app/db", TABLE_NAME, NULL); db = xdg_app_db_new (path, FALSE, &error); if (db == NULL) { g_printerr ("Failed to load db: %s\n", error->message); do_exit (2); } session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); if (session_bus == NULL) { g_printerr ("No session bus: %s\n", error->message); do_exit (3); } permission_store = xdg_app_permission_store_proxy_new_sync (session_bus,G_DBUS_PROXY_FLAGS_NONE, "org.freedesktop.XdgApp", "/org/freedesktop/XdgApp/PermissionStore", NULL, &error); if (permission_store == NULL) { g_print ("No permission store: %s\n", error->message); do_exit (4); } /* We want do do our custom post-mainloop exit */ g_dbus_connection_set_exit_on_close (session_bus, FALSE); g_signal_connect (session_bus, "closed", G_CALLBACK (session_bus_closed), NULL); if (set_one_signal_handler(SIGHUP, exit_handler, 0) == -1 || set_one_signal_handler(SIGINT, exit_handler, 0) == -1 || set_one_signal_handler(SIGTERM, exit_handler, 0) == -1 || set_one_signal_handler(SIGPIPE, SIG_IGN, 0) == -1) { do_exit (5); } introspection_bytes = g_resources_lookup_data ("/org/freedesktop/portal/Documents/org.freedesktop.portal.Documents.xml", 0, NULL); g_assert (introspection_bytes != NULL); introspection_data = g_dbus_node_info_new_for_xml (g_bytes_get_data (introspection_bytes, NULL), NULL); owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, "org.freedesktop.portal.Documents", 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); xdp_fuse_exit (); g_bus_unown_name (owner_id); g_dbus_node_info_unref (introspection_data); do_exit (final_exit_status); return 0; }
int ostree_main (int argc, char **argv, OstreeBuiltin *builtins) { OstreeBuiltin *builtin; GError *error = NULL; int cmd_argc; char **cmd_argv = NULL; gboolean am_root; gboolean have_repo_arg; const char *binname = NULL; const char *slash = NULL; const char *cmd = NULL; const char *repo = NULL; GFile *repo_file = NULL; int arg_off; /* avoid gvfs (http://bugzilla.gnome.org/show_bug.cgi?id=526454) */ g_setenv ("GIO_USE_VFS", "local", TRUE); g_type_init (); g_set_prgname (argv[0]); if (argc < 2) return usage (argv, builtins, 1); am_root = getuid () == 0; have_repo_arg = g_str_has_prefix (argv[1], "--repo="); if (!have_repo_arg && am_root) repo = "/sysroot/ostree/repo"; else if (have_repo_arg) repo = argv[1] + strlen ("--repo="); else repo = NULL; if (repo) repo_file = g_file_new_for_path (repo); slash = strrchr (argv[0], '/'); if (slash) binname = slash+1; else binname = argv[0]; if (g_str_has_prefix (binname, "ostree-")) { cmd = strchr (binname, '-'); g_assert (cmd); cmd += 1; arg_off = 1; if (have_repo_arg) arg_off += 1; } else if (!have_repo_arg) { arg_off = 2; cmd = argv[arg_off-1]; } else { arg_off = 3; cmd = argv[arg_off-1]; } builtin = builtins; while (builtin->name) { if (g_strcmp0 (cmd, builtin->name) == 0) break; builtin++; } if (!builtin->name) { ot_lfree char *msg = g_strdup_printf ("Unknown command '%s'", cmd); set_error_print_usage (&error, builtins, msg, argv); goto out; } if (repo == NULL && !(builtin->flags & OSTREE_BUILTIN_FLAG_NO_REPO)) { set_error_print_usage (&error, builtins, "Command requires a --repo argument", argv); goto out; } prep_builtin_argv (cmd, argc-arg_off, argv+arg_off, &cmd_argc, &cmd_argv); if (!builtin->fn (cmd_argc, cmd_argv, repo_file, &error)) goto out; out: g_free (cmd_argv); g_clear_object (&repo_file); if (error) { g_printerr ("%s\n", error->message); g_clear_error (&error); return 1; } return 0; }
int main (int argc, char *argv[]) { static const char *summary = NULL; char *body; static const char *type = NULL; static char *app_name = NULL; static char *icon_str = NULL; static char *icons = NULL; static char **n_text = NULL; static char **hints = NULL; static gboolean do_version = FALSE; static gboolean hint_error = FALSE; static glong expire_timeout = NOTIFY_EXPIRES_DEFAULT; GOptionContext *opt_ctx; NotifyNotification *notify; GError *error = NULL; gboolean retval; static const GOptionEntry entries[] = { {"urgency", 'u', 0, G_OPTION_ARG_CALLBACK, g_option_arg_urgency_cb, N_("Specifies the urgency level (low, normal, critical)."), N_("LEVEL")}, {"expire-time", 't', 0, G_OPTION_ARG_INT, &expire_timeout, N_ ("Specifies the timeout in milliseconds at which to expire the " "notification."), N_("TIME")}, {"app-name", 'a', 0, G_OPTION_ARG_STRING, &app_name, N_("Specifies the app name for the icon"), N_("APP_NAME")}, {"icon", 'i', 0, G_OPTION_ARG_FILENAME, &icons, N_("Specifies an icon filename or stock icon to display."), N_("ICON[,ICON...]")}, {"category", 'c', 0, G_OPTION_ARG_FILENAME, &type, N_("Specifies the notification category."), N_("TYPE[,TYPE...]")}, {"hint", 'h', 0, G_OPTION_ARG_FILENAME_ARRAY, &hints, N_ ("Specifies basic extra data to pass. Valid types are int, double, string and byte."), N_("TYPE:NAME:VALUE")}, {"version", 'v', 0, G_OPTION_ARG_NONE, &do_version, N_("Version of the package."), NULL}, {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &n_text, NULL, NULL}, {NULL} }; body = NULL; g_type_init (); g_set_prgname (argv[0]); g_log_set_always_fatal (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL); opt_ctx = g_option_context_new (N_("<SUMMARY> [BODY] - " "create a notification")); g_option_context_add_main_entries (opt_ctx, entries, GETTEXT_PACKAGE); retval = g_option_context_parse (opt_ctx, &argc, &argv, &error); g_option_context_free (opt_ctx); if (!retval) { fprintf (stderr, "%s\n", error->message); g_error_free (error); exit (1); } if (do_version) { g_printf ("%s %s\n", g_get_prgname (), VERSION); exit (0); } if (n_text != NULL && n_text[0] != NULL && *n_text[0] != '\0') summary = n_text[0]; if (summary == NULL) { fprintf (stderr, "%s\n", N_("No summary specified.")); exit (1); } if (n_text[1] != NULL) { body = g_strcompress (n_text[1]); if (n_text[2] != NULL) { fprintf (stderr, "%s\n", N_("Invalid number of options.")); exit (1); } } if (icons != NULL) { char *c; /* XXX */ if ((c = strchr (icons, ',')) != NULL) *c = '\0'; icon_str = icons; } if (!notify_init ("notify-send")) exit (1); notify = notify_notification_new (summary, body, icon_str); notify_notification_set_category (notify, type); notify_notification_set_urgency (notify, urgency); notify_notification_set_timeout (notify, expire_timeout); notify_notification_set_app_name (notify, app_name); g_free (body); /* Set hints */ if (hints != NULL) { gint i = 0; gint l; char *hint = NULL; char **tokens = NULL; while ((hint = hints[i++])) { tokens = g_strsplit (hint, ":", -1); l = g_strv_length (tokens); if (l != 3) { fprintf (stderr, "%s\n", N_("Invalid hint syntax specified. " "Use TYPE:NAME:VALUE.")); hint_error = TRUE; } else { retval = notify_notification_set_hint_variant (notify, tokens[0], tokens[1], tokens[2], &error); if (!retval) { fprintf (stderr, "%s\n", error->message); g_error_free (error); hint_error = TRUE; } } g_strfreev (tokens); if (hint_error) break; } } if (!hint_error) notify_notification_show (notify, NULL); g_object_unref (G_OBJECT (notify)); notify_uninit (); exit (hint_error); }
int main(int argc, char **argv){ GMainLoop *main_loop; GSocketService *service; GInetAddress *iaddr; GSocketAddress *saddr; AppData *app_data; GError *error = NULL; // Init g_set_prgname(argv[0]); g_mem_set_vtable(glib_mem_profiler_table); g_type_init(); // Start the daemon start_daemon(g_get_prgname(), LOG_LOCAL0); syslog(LOG_NOTICE, "-----------------------------------\n"); syslog(LOG_NOTICE, "Daemon has been started\n"); // atexit(cleanup); // Initialize App Data structire app_data = g_slice_new0(AppData); app_data->queue = g_queue_new(); app_data->hosts = NULL; app_data->running_backups = NULL; // For global access to app_data app_data_aux_ptr = app_data; // Read configuration if (!read_config(app_data)){ syslog(LOG_ERR, "Failed to read config file \"%s\"", CONFIG_FILE); exit(-1); } // If no hosts configured in config file, try reading from MySQL if (g_list_length(app_data->hosts) == 0){ syslog(LOG_NOTICE, "No hosts configured in /etc/busy/busy.conf, now reading hosts from MySQL"); app_data->hosts = db_read_hosts(app_data->mysql); } if (g_list_length(app_data->hosts) == 0){ syslog(LOG_ERR, "Absolutely no hosts configured! Please configure at least one host either in %s or use the Web frontend", CONFIG_FILE); //~ syslog(LOG_ERR, "I won't waste any more cpu time now and exit"); //~ exit(0); } else { GList *p; for (p = app_data->hosts; p != NULL; p = p->next){ Host *host = p->data; host_dump(host); syslog(LOG_NOTICE, "%s %f", host_get_name(host), host_get_max_age(host)); } } // Setup listener for incoming TCP (localhost port 4000) service = g_socket_service_new(); iaddr = g_inet_address_new_from_string("127.0.0.1"); saddr = g_inet_socket_address_new(iaddr, 4000); g_socket_listener_add_address(G_SOCKET_LISTENER(service), saddr, G_SOCKET_TYPE_STREAM, G_SOCKET_PROTOCOL_TCP, NULL, NULL, &error); g_object_unref(iaddr); g_object_unref(saddr); g_socket_service_start(service); g_signal_connect(service, "incoming", (GCallback)on_incoming, app_data); // Call wakeup and archive function once wakeup(app_data); do_archive(app_data); // Check preiodically for backups, queue and archives, g_timeout_add_seconds(WAKEUP_INTERVAL, (GSourceFunc)wakeup, app_data); g_timeout_add_seconds(10, (GSourceFunc)do_backup, app_data); g_timeout_add_seconds(6 * 3600, (GSourceFunc)do_archive, app_data); // Run main loop main_loop = g_main_loop_new(NULL, FALSE); g_main_loop_run(main_loop); return (EXIT_SUCCESS); }
int main( int argc, char** argv ) { int status = EXIT_SUCCESS; GOptionContext *context; GError *error = NULL; gchar *help; gint errors; NAObjectItem *item; NAIExporter *exporter; #if !GLIB_CHECK_VERSION( 2,36, 0 ) g_type_init(); #endif setlocale( LC_ALL, "" ); console_init_log_handler(); context = init_options(); if( argc == 1 ){ g_set_prgname( argv[0] ); help = g_option_context_get_help( context, FALSE, NULL ); g_print( "\n%s", help ); g_free( help ); exit( status ); } if( !g_option_context_parse( context, &argc, &argv, &error )){ g_printerr( _( "Syntax error: %s\n" ), error->message ); g_error_free (error); exit_with_usage(); } g_option_context_free( context ); if( version ){ na_core_utils_print_version(); exit( status ); } errors = 0; if( !id || !strlen( id )){ g_printerr( _( "Error: a menu or action id is mandatory.\n" )); errors += 1; } item = get_item( id ); if( !item ){ errors += 1; } if( !format || !strlen( format )){ format = "Desktop1"; } exporter = na_exporter_find_for_format( pivot, format ); if( !exporter ){ /* i18n: %s stands for the id of the export format, and is not translatable */ g_printerr( _( "Error: %s: unknown export format.\n" ), format ); errors += 1; } if( errors ){ exit_with_usage(); } export_item( item, format ); exit( status ); }
int main (int argc, char **argv) { GOptionContext *context; gboolean ok; GError *error = NULL; DBusGConnection *bus; DBusGProxy *shell_proxy = NULL; DBusGProxy *player_proxy = NULL; gboolean is_playing; #ifdef ENABLE_NLS /* initialize i18n */ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif /* setup */ setlocale (LC_ALL, ""); g_type_init (); g_set_prgname ("rhythmbox-client"); /* parse arguments */ context = g_option_context_new (NULL); g_option_context_add_main_entries (context, args, NULL); ok = g_option_context_parse (context, &argc, &argv, &error); if (annoy (&error)) exit (1); rb_debug_init (debug); /* get dbus connection and proxy for rhythmbox shell */ bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); if (annoy (&error)) exit (1); if (!create_rb_shell_proxies (bus, &shell_proxy, &player_proxy, &error)) { annoy (&error); exit (1); } g_clear_error (&error); /* 1. activate or quit */ if (quit) { if (shell_proxy) { rb_debug ("quitting existing instance"); dbus_g_proxy_call_no_reply (shell_proxy, "quit", G_TYPE_INVALID); } else { rb_debug ("no existing instance to quit"); } exit (0); } if (shell_proxy == NULL) { DBusGProxy *bus_proxy; guint start_service_reply; if (no_start) { rb_debug ("no existing instance, and can't start one"); exit (0); } rb_debug ("starting new instance"); bus_proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus"); if (!dbus_g_proxy_call (bus_proxy, "StartServiceByName", &error, G_TYPE_STRING, "org.gnome.Rhythmbox", G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_UINT, &start_service_reply, G_TYPE_INVALID)) { g_warning ("%s", error->message); exit (1); } /* hopefully we can get a proxy for the rb shell now.. */ if (!create_rb_shell_proxies (bus, &shell_proxy, &player_proxy, &error)) { annoy (&error); exit (1); } g_clear_error (&error); } /* don't present if we're doing something else */ if (next || previous || clear_queue || play_uri || other_stuff || play || pause || play_pause || stop || print_playing || print_playing_format || notify || (set_volume > -0.01) || volume_up || volume_down || print_volume || mute || unmute) no_present = TRUE; /* 2. present or hide */ if (hide || !no_present) { DBusGProxy *properties_proxy; GValue value = {0,}; rb_debug ("setting visibility property"); g_value_init (&value, G_TYPE_BOOLEAN); g_value_set_boolean (&value, !hide); properties_proxy = dbus_g_proxy_new_from_proxy (shell_proxy, "org.freedesktop.DBus.Properties", "/org/gnome/Rhythmbox/Shell"); dbus_g_proxy_call_no_reply (properties_proxy, "Set", G_TYPE_STRING, "org.gnome.Rhythmbox.Shell", G_TYPE_STRING, "visibility", G_TYPE_VALUE, &value, G_TYPE_INVALID); g_object_unref (G_OBJECT (properties_proxy)); } /* 3. skip to next or previous track */ if (next) { rb_debug ("next track"); org_gnome_Rhythmbox_Player_next (player_proxy, &error); annoy (&error); } else if (previous) { rb_debug ("previous track"); org_gnome_Rhythmbox_Player_previous (player_proxy, &error); annoy (&error); } /* 4. add/enqueue */ if (clear_queue) { org_gnome_Rhythmbox_Shell_clear_queue (shell_proxy, &error); annoy (&error); } if (other_stuff) { int i; for (i = 0; other_stuff[i] != NULL; i++) { GFile *file; char *fileuri; file = g_file_new_for_commandline_arg (other_stuff[i]); fileuri = g_file_get_uri (file); if (fileuri == NULL) { g_warning ("couldn't convert \"%s\" to a URI", other_stuff[i]); continue; } if (enqueue) { rb_debug ("enqueueing %s", fileuri); org_gnome_Rhythmbox_Shell_add_to_queue (shell_proxy, fileuri, &error); } else { rb_debug ("importing %s", fileuri); org_gnome_Rhythmbox_Shell_load_ur_i (shell_proxy, fileuri, FALSE, &error); } annoy (&error); g_free (fileuri); g_object_unref (file); } } /* play uri */ if (play_uri) { GFile *file; char *fileuri; file = g_file_new_for_commandline_arg (play_uri); fileuri = g_file_get_uri (file); if (fileuri == NULL) { g_warning ("couldn't convert \"%s\" to a URI", play_uri); } else { rb_debug ("loading and playing %s", fileuri); org_gnome_Rhythmbox_Shell_load_ur_i (shell_proxy, fileuri, TRUE, &error); annoy (&error); } g_free (fileuri); g_object_unref (file); } /* 5. play/pause/stop */ org_gnome_Rhythmbox_Player_get_playing (player_proxy, &is_playing, &error); if (!annoy (&error)) { rb_debug ("playback state: %d", is_playing); if (play || pause || play_pause) { if (is_playing != play || play_pause) { rb_debug ("calling playPause to change playback state"); org_gnome_Rhythmbox_Player_play_pause (player_proxy, FALSE, &error); annoy (&error); } else { rb_debug ("no need to change playback state"); } } else if (stop) { g_warning ("not implemented yet"); } } /* 6. get/set volume, mute/unmute */ if (set_volume > -0.01) { org_gnome_Rhythmbox_Player_set_volume (player_proxy, set_volume, &error); annoy (&error); } else if (volume_up || volume_down) { org_gnome_Rhythmbox_Player_set_volume_relative (player_proxy, volume_up ? 0.1 : -0.1, &error); annoy (&error); } else if (unmute || mute) { org_gnome_Rhythmbox_Player_set_mute (player_proxy, unmute ? FALSE : TRUE, &error); annoy (&error); } if (print_volume) { gboolean mute = FALSE; gdouble volume = 1.0; org_gnome_Rhythmbox_Player_get_mute (player_proxy, &mute, &error); annoy (&error); org_gnome_Rhythmbox_Player_get_volume (player_proxy, &volume, &error); annoy (&error); if (mute) g_print (_("Playback is muted.\n")); g_print (_("Playback volume is %f.\n"), volume); } /* 7. print playing song */ if (print_playing_format) { print_playing_song (shell_proxy, player_proxy, print_playing_format); } else if (print_playing) { print_playing_song_default (shell_proxy, player_proxy); } /* 8. display notification about playing song */ if (notify) { rb_debug ("show notification"); org_gnome_Rhythmbox_Shell_notify (shell_proxy, TRUE, &error); annoy (&error); } g_object_unref (shell_proxy); g_object_unref (player_proxy); g_option_context_free (context); return 0; }
int main (int argc, char *argv[]) { gboolean print_all = FALSE; gboolean do_print_blacklist = FALSE; gboolean plugin_name = FALSE; gboolean print_aii = FALSE; gboolean uri_handlers = FALSE; gboolean check_exists = FALSE; gchar *min_version = NULL; guint minver_maj = GST_VERSION_MAJOR; guint minver_min = GST_VERSION_MINOR; guint minver_micro = 0; #ifndef GST_DISABLE_OPTION_PARSING GOptionEntry options[] = { {"print-all", 'a', 0, G_OPTION_ARG_NONE, &print_all, N_("Print all elements"), NULL}, {"print-blacklist", 'b', 0, G_OPTION_ARG_NONE, &do_print_blacklist, N_("Print list of blacklisted files"), NULL}, {"print-plugin-auto-install-info", '\0', 0, G_OPTION_ARG_NONE, &print_aii, N_("Print a machine-parsable list of features the specified plugin " "or all plugins provide.\n " "Useful in connection with external automatic plugin " "installation mechanisms"), NULL}, {"plugin", '\0', 0, G_OPTION_ARG_NONE, &plugin_name, N_("List the plugin contents"), NULL}, {"exists", '\0', 0, G_OPTION_ARG_NONE, &check_exists, N_("Check if the specified element or plugin exists"), NULL}, {"atleast-version", '\0', 0, G_OPTION_ARG_STRING, &min_version, N_ ("When checking if an element or plugin exists, also check that its " "version is at least the version specified"), NULL}, {"uri-handlers", 'u', 0, G_OPTION_ARG_NONE, &uri_handlers, N_ ("Print supported URI schemes, with the elements that implement them"), NULL}, GST_TOOLS_GOPTION_VERSION, {NULL} }; GOptionContext *ctx; GError *err = NULL; #endif setlocale (LC_ALL, ""); #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif /* avoid glib warnings when inspecting deprecated properties */ g_setenv ("G_ENABLE_DIAGNOSTIC", "0", FALSE); g_set_prgname ("gst-inspect-" GST_API_VERSION); #ifndef GST_DISABLE_OPTION_PARSING ctx = g_option_context_new ("[ELEMENT-NAME | PLUGIN-NAME]"); g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE); g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { g_printerr ("Error initializing: %s\n", err->message); g_clear_error (&err); g_option_context_free (ctx); return -1; } g_option_context_free (ctx); #else gst_init (&argc, &argv); #endif gst_tools_print_version (); if (print_all && argc > 1) { g_printerr ("-a requires no extra arguments\n"); return -1; } if (uri_handlers && argc > 1) { g_printerr ("-u requires no extra arguments\n"); return -1; } /* --atleast-version implies --exists */ if (min_version != NULL) { if (sscanf (min_version, "%u.%u.%u", &minver_maj, &minver_min, &minver_micro) < 2) { g_printerr ("Can't parse version '%s' passed to --atleast-version\n", min_version); return -1; } check_exists = TRUE; } if (check_exists) { int exit_code; if (argc == 1) { g_printerr ("--exists requires an extra command line argument\n"); exit_code = -1; } else { if (!plugin_name) { GstPluginFeature *feature; feature = gst_registry_lookup_feature (gst_registry_get (), argv[1]); if (feature != NULL && gst_plugin_feature_check_version (feature, minver_maj, minver_min, minver_micro)) { exit_code = 0; } else { exit_code = 1; } } else { /* FIXME: support checking for plugins too */ g_printerr ("Checking for plugins is not supported yet\n"); exit_code = -1; } } return exit_code; } /* if no arguments, print out list of elements */ if (uri_handlers) { print_all_uri_handlers (); } else if (argc == 1 || print_all) { if (do_print_blacklist) print_blacklist (); else { if (print_aii) print_all_plugin_automatic_install_info (); else print_element_list (print_all); } } else { /* else we try to get a factory */ GstElementFactory *factory; GstPlugin *plugin; const char *arg = argv[argc - 1]; int retval; if (!plugin_name) { factory = gst_element_factory_find (arg); /* if there's a factory, print out the info */ if (factory) { retval = print_element_info (factory, print_all); gst_object_unref (factory); } else { retval = print_element_features (arg); } } else { retval = -1; } /* otherwise check if it's a plugin */ if (retval) { plugin = gst_registry_find_plugin (gst_registry_get (), arg); /* if there is such a plugin, print out info */ if (plugin) { if (print_aii) { print_plugin_automatic_install_info (plugin); } else { print_plugin_info (plugin); print_plugin_features (plugin); } } else { GError *error = NULL; if (g_file_test (arg, G_FILE_TEST_EXISTS)) { plugin = gst_plugin_load_file (arg, &error); if (plugin) { if (print_aii) { print_plugin_automatic_install_info (plugin); } else { print_plugin_info (plugin); print_plugin_features (plugin); } } else { g_printerr (_("Could not load plugin file: %s\n"), error->message); g_clear_error (&error); return -1; } } else { g_printerr (_("No such element or plugin '%s'\n"), arg); return -1; } } } } return 0; }
int main( int argc, char** argv ) { int status = EXIT_SUCCESS; GOptionContext *context; GError *error = NULL; NAObjectAction *action; GSList *msg = NULL; GSList *im; gchar *help; gint errors; #if !GLIB_CHECK_VERSION( 2,36, 0 ) g_type_init(); #endif setlocale( LC_ALL, "" ); console_init_log_handler(); context = init_options(); if( argc == 1 ){ g_set_prgname( argv[0] ); help = g_option_context_get_help( context, FALSE, NULL ); g_print( "\n%s", help ); g_free( help ); exit( status ); } if( !g_option_context_parse( context, &argc, &argv, &error )){ g_printerr( _( "Syntax error: %s\n" ), error->message ); g_error_free (error); exit_with_usage(); } if( version ){ na_core_utils_print_version(); exit( status ); } errors = 0; if( !label || !g_utf8_strlen( label, -1 )){ g_printerr( _( "Error: an action label is mandatory.\n" )); errors += 1; } if( enabled && disabled ){ g_printerr( CANNOT_BOTH, "--enabled", "--disabled" ); errors += 1; } else if( !disabled ){ enabled = TRUE; } if( target_selection && nocontext ){ g_printerr( CANNOT_BOTH, "--context", "--nocontext" ); errors += 1; } else if( !nocontext ){ target_selection = TRUE; } if( target_location && nolocation ){ g_printerr( CANNOT_BOTH, "--location", "--nolocation" ); errors += 1; } if( target_toolbar && notoolbar ){ g_printerr( CANNOT_BOTH, "--toolbar", "--notoolbar" ); errors += 1; } if( matchcase && nocase ){ g_printerr( CANNOT_BOTH, "--match-case", "--nocase" ); errors += 1; } else if( !nocase ){ matchcase = TRUE; } if( accept_multiple && strlen( selection_count )){ g_printerr( CANNOT_BOTH, "--accept-multiple", "--selection-count" ); errors += 1; } if( onlyshow_array && notshow_array ){ g_printerr( CANNOT_BOTH, "--only-show-in", "--not-show-in" ); errors += 1; } if( output_stdout && output_desktop ){ g_printerr( _( "Error: only one output option may be specified.\n" )); errors += 1; } if( errors ){ exit_with_usage(); } action = get_action_from_cmdline(); if( output_desktop ){ output_to_desktop( action, &msg ); } else { output_to_stdout( action, &msg ); } if( msg ){ for( im = msg ; im ; im = im->next ){ g_printerr( "%s\n", ( gchar * ) im->data ); } na_core_utils_slist_free( msg ); status = EXIT_FAILURE; } g_object_unref( action ); g_option_context_free( context ); exit( status ); }
static VALUE rg_s_set_application_name(VALUE self, VALUE application_name) { g_set_prgname(RVAL2CSTR_ACCEPT_NIL(application_name)); return self; }
static VALUE rg_s_set_prgname(VALUE self, VALUE prgname) { g_set_prgname(RVAL2CSTR_ACCEPT_NIL(prgname)); return self; }
int main (int argc, char **argv) { GstPlay *play; GPtrArray *playlist; gboolean print_version = FALSE; gboolean interactive = TRUE; gboolean gapless = FALSE; gboolean shuffle = FALSE; gdouble volume = -1; gchar **filenames = NULL; gchar *audio_sink = NULL; gchar *video_sink = NULL; gchar **uris; guint num, i; GError *err = NULL; GOptionContext *ctx; gchar *playlist_file = NULL; GOptionEntry options[] = { {"version", 0, 0, G_OPTION_ARG_NONE, &print_version, N_("Print version information and exit"), NULL}, {"videosink", 0, 0, G_OPTION_ARG_STRING, &video_sink, N_("Video sink to use (default is autovideosink)"), NULL}, {"audiosink", 0, 0, G_OPTION_ARG_STRING, &audio_sink, N_("Audio sink to use (default is autoaudiosink)"), NULL}, {"gapless", 0, 0, G_OPTION_ARG_NONE, &gapless, N_("Enable gapless playback"), NULL}, {"shuffle", 0, 0, G_OPTION_ARG_NONE, &shuffle, N_("Shuffle playlist"), NULL}, {"no-interactive", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &interactive, N_("Disable interactive control via the keyboard"), NULL}, {"volume", 0, 0, G_OPTION_ARG_DOUBLE, &volume, N_("Volume"), NULL}, {"playlist", 0, 0, G_OPTION_ARG_FILENAME, &playlist_file, N_("Playlist file containing input media files"), NULL}, {"quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, N_("Do not print any output (apart from errors)"), NULL}, {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL}, {NULL} }; setlocale (LC_ALL, ""); #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif g_set_prgname ("gst-play-" GST_API_VERSION); ctx = g_option_context_new ("FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ..."); g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE); g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { g_print ("Error initializing: %s\n", GST_STR_NULL (err->message)); return 1; } g_option_context_free (ctx); GST_DEBUG_CATEGORY_INIT (play_debug, "play", 0, "gst-play"); if (print_version) { gchar *version_str; version_str = gst_version_string (); g_print ("%s version %s\n", g_get_prgname (), PACKAGE_VERSION); g_print ("%s\n", version_str); g_print ("%s\n", GST_PACKAGE_ORIGIN); g_free (version_str); g_free (audio_sink); g_free (video_sink); g_free (playlist_file); return 0; } playlist = g_ptr_array_new (); if (playlist_file != NULL) { gchar *playlist_contents = NULL; gchar **lines = NULL; if (g_file_get_contents (playlist_file, &playlist_contents, NULL, &err)) { lines = g_strsplit (playlist_contents, "\n", 0); num = g_strv_length (lines); for (i = 0; i < num; i++) { if (lines[i][0] != '\0') { GST_LOG ("Playlist[%d]: %s", i + 1, lines[i]); add_to_playlist (playlist, lines[i]); } } g_strfreev (lines); g_free (playlist_contents); } else { g_printerr ("Could not read playlist: %s\n", err->message); g_clear_error (&err); } g_free (playlist_file); playlist_file = NULL; } if (playlist->len == 0 && (filenames == NULL || *filenames == NULL)) { g_printerr (_("Usage: %s FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ..."), "gst-play-" GST_API_VERSION); g_printerr ("\n\n"), g_printerr ("%s\n\n", _("You must provide at least one filename or URI to play.")); /* No input provided. Free array */ g_ptr_array_free (playlist, TRUE); g_free (audio_sink); g_free (video_sink); return 1; } /* fill playlist */ if (filenames != NULL && *filenames != NULL) { num = g_strv_length (filenames); for (i = 0; i < num; ++i) { GST_LOG ("command line argument: %s", filenames[i]); add_to_playlist (playlist, filenames[i]); } g_strfreev (filenames); } num = playlist->len; g_ptr_array_add (playlist, NULL); uris = (gchar **) g_ptr_array_free (playlist, FALSE); if (shuffle) shuffle_uris (uris, num); /* prepare */ play = play_new (uris, audio_sink, video_sink, gapless, volume); if (play == NULL) { g_printerr ("Failed to create 'playbin' element. Check your GStreamer installation.\n"); return EXIT_FAILURE; } if (interactive) { if (gst_play_kb_set_key_handler (keyboard_cb, play)) { g_print (_("Press 'k' to see a list of keyboard shortcuts.\n")); atexit (restore_terminal); } else { g_print ("Interactive keyboard handling in terminal not available.\n"); } } /* play */ do_play (play); /* clean up */ play_free (play); g_free (audio_sink); g_free (video_sink); g_print ("\n"); return 0; }
int main (int argc, char **argv) { GOptionContext *context; GError *error = NULL; EmpathyAuthFactory *factory; TpDebugSender *debug_sender; TpSimpleClientFactory *tp_factory; TpDBusDaemon *dbus; context = g_option_context_new (N_(" — Empathy authentication client")); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_set_translation_domain (context, GETTEXT_PACKAGE); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_print ("%s\nRun '%s --help' to see a full list of available command " "line options.\n", error->message, argv[0]); g_warning ("Error in empathy-auth-client init: %s", error->message); return EXIT_FAILURE; } g_option_context_free (context); empathy_gtk_init (); gnutls_global_init (); g_set_application_name (_("Empathy authentication client")); /* Make empathy and empathy-auth-client appear as the same app in * gnome-shell */ g_set_prgname ("empathy"); gtk_window_set_default_icon_name ("empathy"); textdomain (GETTEXT_PACKAGE); /* There is no 'main' UI window so just use the default GdkScreen */ empathy_set_css_provider (NULL); #ifdef ENABLE_DEBUG /* Set up debug sender */ debug_sender = tp_debug_sender_dup (); g_log_set_default_handler (tp_debug_sender_log_handler, G_LOG_DOMAIN); #endif dbus = tp_dbus_daemon_dup (NULL); tp_factory = tp_simple_client_factory_new (dbus); tp_simple_client_factory_add_account_features_varargs (tp_factory, TP_ACCOUNT_FEATURE_STORAGE, 0); factory = empathy_auth_factory_new (tp_factory); g_object_unref (tp_factory); g_object_unref (dbus); g_signal_connect (factory, "new-server-tls-handler", G_CALLBACK (auth_factory_new_tls_handler_cb), NULL); g_signal_connect (factory, "new-server-sasl-handler", G_CALLBACK (auth_factory_new_sasl_handler_cb), NULL); g_signal_connect (factory, "auth-password-failed", G_CALLBACK (auth_factory_auth_passsword_failed), NULL); if (!empathy_auth_factory_register (factory, &error)) { g_critical ("Failed to register the auth factory: %s\n", error->message); g_error_free (error); g_object_unref (factory); return EXIT_FAILURE; } DEBUG ("Empathy auth client started."); if (g_getenv ("EMPATHY_PERSIST") != NULL) { DEBUG ("Timed-exit disabled"); use_timer = FALSE; } /* Wait for the migration code to be done before starting the timer */ empathy_sanity_checking_run_async (sanity_cb, NULL); gtk_main (); g_object_unref (factory); g_object_unref (debug_sender); return EXIT_SUCCESS; }
int main(int argc, char * argv[], char * env[]) { setlocale(LC_ALL,""); gtk_set_locale(); textdomain(GETTEXT_PACKAGE); GError * err = NULL; gchar * domain_dir=NULL; GOptionEntry args[] = { {"locale",'\0',0,G_OPTION_ARG_STRING,&domain_dir,_("set domain dir root"),N_("dir")}, {0} }; g_set_prgname(PACKAGE_NAME); if(G_UNLIKELY(!gtk_init_with_args(&argc, &argv,PACKAGE_STRING,args,PACKAGE_NAME,&err))) { g_error("%s",err->message); } if(domain_dir) { bindtextdomain(GETTEXT_PACKAGE,domain_dir); g_free(domain_dir); } g_set_application_name(_("gl2tp - GUI frontend for l2tp connection")); UniqueApp * unique = unique_app_new("net.vpn." PACKAGE_NAME,NULL); if (unique_app_is_running(unique)) { g_message("already running!"); if(UNIQUE_RESPONSE_OK != unique_app_send_message(unique,UNIQUE_ACTIVATE,NULL)) { GtkWidget * dlg = gtk_message_dialog_new(NULL,GTK_DIALOG_MODAL,GTK_MESSAGE_INFO,GTK_BUTTONS_CLOSE, _("Another one is running")); gtk_dialog_run(GTK_DIALOG(dlg)); }else { g_message("active previous one"); } return 1; } Gl2tpClient * l2client = gl2tpclient_new(); if(!gl2tpclient_bind(l2client)) { GtkWidget * dlg = gtk_message_dialog_new(NULL,GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE, _("unable to bind to local port 1701? Another one running?")); gtk_dialog_run(GTK_DIALOG(dlg)); g_error(_("unable to bind to local port 1701? Another one running?")); } GdkPixbuf * pixbuf = gdk_pixbuf_new_from_inline(-1,gl2tp_icon,FALSE,NULL); GtkWidget * main = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(unique,"message-received",G_CALLBACK(active_instance),main); gtk_window_set_icon(GTK_WINDOW(main),pixbuf); GtkWidget * box = gtk_vbox_new(FALSE,TRUE); gtk_container_add(GTK_CONTAINER(main),box); g_signal_connect(G_OBJECT (main), "destroy", G_CALLBACK(gtk_main_quit), NULL); GtkWidget * gl2tp = gl2tp_new(); gtk_box_pack_start(GTK_BOX(box),gl2tp,TRUE,TRUE,FALSE); status = gtk_statusbar_new(); guint id = gtk_statusbar_get_context_id(GTK_STATUSBAR(status),"status"); gtk_box_pack_end(GTK_BOX(box),status,FALSE,TRUE,TRUE); gtk_statusbar_push(GTK_STATUSBAR(status),id,_("Ready")); g_signal_connect(gl2tp,"status-changed",G_CALLBACK(show_status),GUINT_TO_POINTER(id)); g_signal_connect(gl2tp,"status-restore",G_CALLBACK(pop_status),GUINT_TO_POINTER(id)); g_idle_add(gl2tp_load_config,gl2tp); gtk_widget_show_all(main); gtk_main(); return 0; }
int main (int argc, char **argv) { GSThemeEngine *engine; GtkWidget *window; GError *error; gboolean ret; char *location = NULL; char *background_color = NULL; gboolean sort_images = FALSE; gboolean no_stretch = FALSE; GOptionEntry entries [] = { { "location", 0, 0, G_OPTION_ARG_STRING, &location, N_("Location to get images from"), N_("PATH") }, { "background-color", 0, 0, G_OPTION_ARG_STRING, &background_color, N_("Color to use for images background"), N_("\"#rrggbb\"") }, { "sort-images", 0, 0, G_OPTION_ARG_NONE, &sort_images, N_("Do not randomize pictures from location"), NULL }, { "no-stretch", 0, 0, G_OPTION_ARG_NONE, &no_stretch, N_("Do not try to stretch images on screen"), NULL }, { NULL } }; bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); error = NULL; g_thread_init (NULL); ret = gtk_init_with_args (&argc, &argv, NULL, entries, NULL, &error); if (! ret) { g_message ("%s", error->message); g_error_free (error); exit (1); } g_chdir (g_get_home_dir ()); g_set_prgname ("slideshow"); window = gs_theme_window_new (); g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (gtk_main_quit), NULL); engine = g_object_new (GSTE_TYPE_SLIDESHOW, NULL); if (location == NULL) { location = xdg_user_dir_lookup ("PICTURES"); if (location == NULL || strcmp (location, "/tmp") == 0 || strcmp (location, g_get_home_dir ()) == 0) { free (location); location = g_build_filename (g_get_home_dir (), "Pictures", NULL); } } if (location != NULL) { g_object_set (engine, "images-location", location, NULL); } if (sort_images) { g_object_set (engine, "sort-images", sort_images, NULL); } if (background_color != NULL) { g_object_set (engine, "background-color", background_color, NULL); } if (no_stretch) { g_object_set (engine, "no-stretch", no_stretch, NULL); } gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (engine)); gtk_widget_show (GTK_WIDGET (engine)); gtk_window_set_default_size (GTK_WINDOW (window), 640, 480); gtk_widget_show (window); gtk_main (); return 0; }
int main (int argc, char **argv) { char *desktopfile; GOptionContext *context; GError *error; bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* We will register explicitly when we're ready -- see panel-session.c */ egg_sm_client_set_mode (EGG_SM_CLIENT_MODE_DISABLED); g_set_prgname ("mate-panel"); desktopfile = panel_g_lookup_in_applications_dirs ("mate-panel.desktop"); if (desktopfile) { egg_set_desktop_file (desktopfile); g_free (desktopfile); } context = g_option_context_new (""); g_option_context_add_group (context, egg_sm_client_get_option_group ()); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); gtk_init (&argc, &argv); error = NULL; if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("%s\n", error->message); g_error_free (error); g_option_context_free (context); return 1; } g_option_context_free (context); /* set the default layout */ if (layout != NULL && layout[0] != 0) { GSettings *settings; settings = g_settings_new (PANEL_SCHEMA); g_settings_set_string (settings, PANEL_DEFAULT_LAYOUT, layout); g_object_unref (settings); g_message ("Panel layout set to '%s'", layout); /* exit, except if reset argument is given */ if (!reset) return 0; } /* reset the configuration and exit. */ if (reset == TRUE) { panel_reset(); return 0; } /* open the run dialog and exit */ if (run_dialog == TRUE) { panel_multiscreen_init (); panel_global_config_load (); panel_lockdown_init (); panel_profile_settings_load (); panel_run_dialog_present (gdk_screen_get_default (), gtk_get_current_event_time ()); panel_run_dialog_quit_on_destroy (); gtk_main (); panel_lockdown_finalize (); panel_cleanup_do (); return 0; } if (!egg_get_desktop_file ()) { g_set_application_name (_("Panel")); gtk_window_set_default_icon_name (PANEL_ICON_PANEL); } if (!panel_shell_register (replace)) { panel_cleanup_do (); return -1; } panel_action_protocol_init (); panel_multiscreen_init (); panel_init_stock_icons_and_items (); panel_global_config_load (); panel_lockdown_init (); panel_profile_load (); /*add forbidden lists to ALL panels*/ g_slist_foreach (panels, (GFunc)panel_widget_add_forbidden, NULL); xstuff_init (); /* Flush to make sure our struts are seen by everyone starting * immediate after (eg, the caja desktop). */ gdk_flush (); /* Do this at the end, to be sure that we're really ready when * connecting to the session manager */ panel_session_init (); gtk_main (); panel_lockdown_finalize (); panel_cleanup_do (); return 0; }
int main (int argc, char **argv) { GCancellable *cancellable = g_cancellable_new (); RpmOstreeCommand *command; int exit_status = EXIT_SUCCESS; int in, out; const char *command_name = NULL; g_autofree char *prgname = NULL; GError *local_error = NULL; /* avoid gvfs (http://bugzilla.gnome.org/show_bug.cgi?id=526454) */ g_setenv ("GIO_USE_VFS", "local", TRUE); g_set_prgname (argv[0]); setlocale (LC_ALL, ""); /* * Parse the global options. We rearrange the options as * necessary, in order to pass relevant options through * to the commands, but also have them take effect globally. */ for (in = 1, out = 1; in < argc; in++, out++) { /* The non-option is the command, take it out of the arguments */ if (argv[in][0] != '-') { if (command_name == NULL) { command_name = argv[in]; out--; continue; } } else if (g_str_equal (argv[in], "--")) { break; } argv[out] = argv[in]; } argc = out; g_unix_signal_add (SIGINT, on_sigint, cancellable); g_unix_signal_add (SIGTERM, on_sigint, cancellable); g_unix_signal_add (SIGHUP, on_sigint, cancellable); /* Keep the "rpm" command working for backward-compatibility. */ if (g_strcmp0 (command_name, "rpm") == 0) command_name = "db"; command = lookup_command_of_type (supported_commands, command_name, NULL); if (!command) command = lookup_command_of_type (legacy_alias_commands, command_name, NULL); if (!command) command = lookup_command_of_type (preview_commands, command_name, "a preview"); if (!command) command = lookup_command_of_type (experimental_commands, command_name, "an experimental"); if (!command) { g_autoptr(GOptionContext) context = option_context_new_with_commands (); g_autofree char *help = NULL; /* This will not return for some options (e.g. --version). */ (void) rpmostree_option_context_parse (context, NULL, &argc, &argv, RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD, NULL, NULL, NULL); if (command_name == NULL) { local_error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, "No command specified"); } else { local_error = g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED, "Unknown command '%s'", command_name); } help = g_option_context_get_help (context, FALSE, NULL); g_printerr ("%s", help); exit_status = EXIT_FAILURE; goto out; } prgname = g_strdup_printf ("%s %s", g_get_prgname (), command_name); g_set_prgname (prgname); exit_status = command->fn (argc, argv, cancellable, &local_error); out: if (local_error != NULL) { int is_tty = isatty (1); const char *prefix = ""; const char *suffix = ""; if (is_tty) { prefix = "\x1b[31m\x1b[1m"; /* red, bold */ suffix = "\x1b[22m\x1b[0m"; /* bold off, color reset */ } g_dbus_error_strip_remote_error (local_error); g_printerr ("%serror: %s%s\n", prefix, suffix, local_error->message); g_error_free (local_error); /* Print a warning if the exit status indicates success when we * actually had an error, so it gets reported and fixed quickly. */ g_warn_if_fail (exit_status != EXIT_SUCCESS); } return exit_status; }
gboolean ostree_builtin_remote (int argc, char **argv, GCancellable *cancellable, GError **error) { OstreeRemoteCommand *subcommand; const char *subcommand_name = NULL; g_autofree char *prgname = NULL; gboolean ret = FALSE; int in, out; for (in = 1, out = 1; in < argc; in++, out++) { /* The non-option is the command, take it out of the arguments */ if (argv[in][0] != '-') { if (subcommand_name == NULL) { subcommand_name = argv[in]; out--; continue; } } else if (g_str_equal (argv[in], "--")) { break; } argv[out] = argv[in]; } argc = out; subcommand = remote_subcommands; while (subcommand->name) { if (g_strcmp0 (subcommand_name, subcommand->name) == 0) break; subcommand++; } if (!subcommand->name) { g_autoptr(GOptionContext) context = NULL; g_autofree char *help; context = remote_option_context_new_with_commands (); /* This will not return for some options (e.g. --version). */ if (ostree_option_context_parse (context, NULL, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, NULL, cancellable, error)) { if (subcommand_name == NULL) { g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "No \"remote\" subcommand specified"); } else { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unknown \"remote\" subcommand '%s'", subcommand_name); } } help = g_option_context_get_help (context, FALSE, NULL); g_printerr ("%s", help); goto out; } prgname = g_strdup_printf ("%s %s", g_get_prgname (), subcommand_name); g_set_prgname (prgname); if (!subcommand->fn (argc, argv, cancellable, error)) goto out; ret = TRUE; out: return ret; }
int main (int argc, char **argv) { GError *error = NULL; GCancellable *cancellable = g_cancellable_new (); RpmOstreeCommand *command; int in, out; const char *command_name = NULL; gs_free char *prgname = NULL; /* avoid gvfs (http://bugzilla.gnome.org/show_bug.cgi?id=526454) */ g_setenv ("GIO_USE_VFS", "local", TRUE); g_set_prgname (argv[0]); setlocale (LC_ALL, ""); /* * Parse the global options. We rearrange the options as * necessary, in order to pass relevant options through * to the commands, but also have them take effect globally. */ for (in = 1, out = 1; in < argc; in++, out++) { /* The non-option is the command, take it out of the arguments */ if (argv[in][0] != '-') { if (command_name == NULL) { command_name = argv[in]; out--; continue; } } else if (g_str_equal (argv[in], "--")) { break; } argv[out] = argv[in]; } argc = out; g_unix_signal_add (SIGINT, on_sigint, cancellable); g_unix_signal_add (SIGTERM, on_sigint, cancellable); g_unix_signal_add (SIGHUP, on_sigint, cancellable); /* Keep the "rpm" command working for backward-compatibility. */ if (g_strcmp0 (command_name, "rpm") == 0) command_name = "db"; command = commands; while (command->name) { if (g_strcmp0 (command_name, command->name) == 0) break; command++; } if (!command->fn) { GOptionContext *context; gs_free char *help; context = option_context_new_with_commands (); /* This will not return for some options (e.g. --version). */ if (rpmostree_option_context_parse (context, NULL, &argc, &argv, RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD, NULL, NULL, &error)) { if (command_name == NULL) { g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED, "No command specified"); } else { g_set_error (&error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unknown command '%s'", command_name); } } help = g_option_context_get_help (context, FALSE, NULL); g_printerr ("%s", help); g_option_context_free (context); goto out; } prgname = g_strdup_printf ("%s %s", g_get_prgname (), command_name); g_set_prgname (prgname); if (!command->fn (argc, argv, cancellable, &error)) goto out; out: if (error != NULL) { int is_tty = isatty (1); const char *prefix = ""; const char *suffix = ""; if (is_tty) { prefix = "\x1b[31m\x1b[1m"; /* red, bold */ suffix = "\x1b[22m\x1b[0m"; /* bold off, color reset */ } g_dbus_error_strip_remote_error (error); g_printerr ("%serror: %s%s\n", prefix, suffix, error->message); g_error_free (error); return 1; } return 0; }
int main (int argc, char **argv) { GtkWidget *window; GdkScreen *screen; int monitor; GdkRectangle rect; GError *error = NULL; char *font = NULL; char **remaining = NULL; GtkApplication *application; guint status; GOptionEntry goptions[] = { { "font", 0, 0, G_OPTION_ARG_STRING, &font, N_("Font to start with; ex: 'Serif 27'"), N_("FONT") }, { "version", 0, G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_version_cb, NULL, NULL }, { "print", 'p', 0, G_OPTION_ARG_CALLBACK, option_print_cb, "Print characters in string", "STRING" }, { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining, NULL, N_("[STRING…]") }, { NULL } }; bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* Not interested in silly debug spew polluting the journal, bug #749195 */ if (g_getenv ("G_ENABLE_DIAGNOSTIC") == NULL) g_setenv ("G_ENABLE_DIAGNOSTIC", "0", TRUE); /* Set programme name explicitly (see bug #653115) */ g_set_prgname("gucharmap"); if (!gtk_init_with_args (&argc, &argv, NULL, goptions, GETTEXT_PACKAGE, &error)) { g_printerr ("%s\n", error->message); g_error_free (error); exit (1); } g_set_application_name (_("Character Map")); gtk_window_set_default_icon_name (GUCHARMAP_ICON_NAME); application = gtk_application_new ("org.gnome.Charmap", G_APPLICATION_NON_UNIQUE); g_signal_connect (application, "startup", G_CALLBACK (startup_cb), NULL); g_signal_connect (application, "activate", G_CALLBACK (gucharmap_activate), NULL); g_application_register (G_APPLICATION (application), NULL, NULL); /* Gucharmap doesn't work right with the dark theme, see #741939. * Apparently this got fixed in gtk+ some time before 3.22, so * only work around this on older versions. */ if (gtk_check_version (3, 22, 0) != NULL /* < 3.22.0 */) g_object_set (gtk_settings_get_default (), "gtk-application-prefer-dark-theme", FALSE, NULL); window = gucharmap_window_new (application); screen = gtk_window_get_screen (GTK_WINDOW (window)); monitor = gdk_screen_get_monitor_at_point (screen, 0, 0); #if GTK_CHECK_VERSION (3, 3, 5) gdk_screen_get_monitor_workarea (screen, monitor, &rect); #else gdk_screen_get_monitor_geometry (screen, monitor, &rect); #endif gtk_window_set_default_size (GTK_WINDOW (window), rect.width * 9/16, rect.height * 9/16); if (font) { gucharmap_window_set_font (GUCHARMAP_WINDOW (window), font); g_free (font); } gtk_window_present (GTK_WINDOW (window)); if (remaining) { char *str = g_strjoinv (" ", remaining); gucharmap_window_search (GUCHARMAP_WINDOW (window), str); g_free (str); g_strfreev (remaining); } status = g_application_run (G_APPLICATION (application), argc, argv); g_object_unref (application); return status; }
int main (int argc, char **argv) { gchar exe_path[PATH_MAX+1]; ssize_t exe_path_len; gboolean replace; gboolean verbose; gboolean show_version; GBusNameOwnerFlags flags; GOptionContext *context; g_autoptr(GError) error = NULL; const GOptionEntry options[] = { { "replace", 'r', 0, G_OPTION_ARG_NONE, &replace, "Replace old daemon.", NULL }, { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Enable debug output.", NULL }, { "session", 0, 0, G_OPTION_ARG_NONE, &on_session_bus, "Run in session, not system scope (for tests).", NULL }, { "no-idle-exit", 0, 0, G_OPTION_ARG_NONE, &no_idle_exit, "Don't exit when idle.", NULL }, { "version", 0, 0, G_OPTION_ARG_NONE, &show_version, "Show program version.", NULL}, { NULL } }; setlocale (LC_ALL, ""); g_setenv ("GIO_USE_VFS", "local", TRUE); g_set_prgname (argv[0]); g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, message_handler, NULL); context = g_option_context_new (""); g_option_context_set_summary (context, "Flatpak system helper"); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); replace = FALSE; verbose = FALSE; show_version = FALSE; if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("%s: %s", g_get_application_name(), error->message); g_printerr ("\n"); g_printerr ("Try \"%s --help\" for more information.", g_get_prgname ()); g_printerr ("\n"); g_option_context_free (context); return 1; } if (show_version) { g_print (PACKAGE_STRING "\n"); return 0; } if (verbose) g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, message_handler, NULL); authority = polkit_authority_get_sync (NULL, &error); if (authority == NULL) { g_printerr ("Can't get polkit authority: %s\n", error->message); return 1; } exe_path_len = readlink ("/proc/self/exe", exe_path, sizeof (exe_path) - 1); if (exe_path_len > 0) { exe_path[exe_path_len] = 0; GFileMonitor *monitor; g_autoptr(GFile) exe = NULL; g_autoptr(GError) local_error = NULL; exe = g_file_new_for_path (exe_path); monitor = g_file_monitor_file (exe, G_FILE_MONITOR_NONE, NULL, &local_error); if (monitor == NULL) g_warning ("Failed to set watch on %s: %s", exe_path, error->message); else g_signal_connect (monitor, "changed", G_CALLBACK (binary_file_changed_cb), NULL); } flags = G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT; if (replace) flags |= G_BUS_NAME_OWNER_FLAGS_REPLACE; name_owner_id = g_bus_own_name (on_session_bus ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM, "org.freedesktop.Flatpak.SystemHelper", flags, on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL); /* Ensure we don't idle exit */ schedule_idle_callback (); main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); return 0; }
gint main (gint argc, gchar *argv[]) { G_PASTE_INIT_GETTEXT (); g_set_prgname (argv[0]); struct option long_options[] = { { "decoration", required_argument, NULL, 'd' }, { "help", no_argument, NULL, 'h' }, { "oneline", no_argument, NULL, 'o' }, { "raw" , no_argument, NULL, 'r' }, { "separator" , required_argument, NULL, 's' }, { "version", no_argument, NULL, 'v' }, { "zero", no_argument, NULL, 'z' }, { NULL, no_argument, NULL, '\0' } }; gboolean help = FALSE, version = FALSE; gboolean oneline = FALSE, raw = FALSE, zero = FALSE; const gchar *decoration = NULL, *separator = NULL; gint c; while ((c = getopt_long(argc, argv, "d:hors:vz", long_options, NULL)) != -1) { switch (c) { case 'd': decoration = optarg; break; case 'h': help = TRUE; break; case 'o': oneline = TRUE; break; case 'r': raw = TRUE; break; case 's': separator = optarg; break; case 'v': version = TRUE; break; case 'z': zero = TRUE; break; default: return EXIT_FAILURE; } } argv += optind; argc -= optind; if (help || (argc > 0 && !g_strcmp0 (argv[0], "help"))) { show_help (); return EXIT_SUCCESS; } else if (version || (argc > 0 && is_version (argv[0]))) { show_version (); return EXIT_SUCCESS; } int status = EXIT_SUCCESS; g_autoptr (GError) error = NULL; g_autoptr (GPasteClient) client = g_paste_client_new_sync (&error); if (!client) failure_exit (error); gboolean was_valid_pipe = FALSE; if (!isatty (fileno (stdin))) { /* We are being piped */ G_PASTE_CLEANUP_STRING_FREE GString *data = g_string_new (NULL); while ((c = fgetc (stdin)) != EOF) data = g_string_append_c (data, (guchar)c); data->str[data->len - 1] = '\0'; if (!argc) { g_paste_client_add_sync (client, data->str, &error); was_valid_pipe = TRUE; } else if (argc == 2) { const gchar *arg1 = argv[0]; const gchar *arg2 = argv[1]; if (!g_strcmp0 (arg1, "ap") || !g_strcmp0 (arg1, "add-password")) { g_paste_client_add_password_sync (client, arg2, data->str, &error); was_valid_pipe = TRUE; } } } if (was_valid_pipe) {} else if (argc > 0 && (!g_strcmp0 (argv[0], "merge") || !g_strcmp0 (argv[0], "m"))) { --argc; ++argv; guint32 *indexes = alloca (argc * sizeof (guint32)); for (gint i = 0; i < argc; ++i) indexes[i] = _strtoull (argv[i]); g_paste_client_merge_sync (client, decoration, separator, indexes, argc, &error); } else { const gchar *arg1, *arg2, *arg3; switch (argc) { case 0: show_history (client, oneline, raw, zero, &error); break; case 1: arg1 = argv[0]; if (!g_strcmp0 (arg1, "about")) g_paste_client_about_sync (client, &error); else if (!g_strcmp0 (arg1, "dr") || !g_strcmp0 (arg1, "daemon-reexec")) { g_paste_client_reexecute_sync (client, &error); if (error && error->code == G_DBUS_ERROR_NO_REPLY) { printf (_("Successfully reexecuted the daemon\n")); return EXIT_SUCCESS; } } else if (!g_strcmp0 (arg1, "dv") || !g_strcmp0 (arg1, "daemon-version")) { g_autofree gchar *v = g_paste_client_get_version (client); printf ("%s\n", v); } else if (!g_strcmp0 (arg1, "e") || !g_strcmp0 (arg1, "empty")) { g_paste_client_empty_sync (client, &error); } else if (!g_strcmp0 (arg1, "h") || !g_strcmp0 (arg1, "history")) { show_history (client, oneline, raw, zero, &error); } else if (!g_strcmp0 (arg1, "hs") || !g_strcmp0 (arg1, "history-size")) { guint32 size = g_paste_client_get_history_size_sync (client, &error); if (!error) printf ("%u\n", size); } else if (!g_strcmp0 (arg1, "lh") || !g_strcmp0 (arg1, "list-histories")) { g_auto (GStrv) histories = g_paste_client_list_histories_sync (client, &error); if (!error) { for (GStrv h = histories; *h; ++h) printf ("%s\n", *h); } } else if (!g_strcmp0 (arg1, "settings") || !g_strcmp0 (arg1, "p") || !g_strcmp0 (arg1, "preferences")) { if (!g_paste_util_activate_ui_sync ("prefs", NULL, &error)) { g_critical ("%s Ui: %s", _("Couldn't spawn"), error->message); return EXIT_FAILURE; } } else if (!g_strcmp0 (arg1, "show-history")) { g_paste_client_show_history_sync (client, &error); } else if (!g_strcmp0 (arg1, "start") || !g_strcmp0 (arg1, "d") || !g_strcmp0 (arg1, "daemon")) { g_paste_client_track_sync (client, TRUE, &error); } else if (!g_strcmp0 (arg1, "stop") || !g_strcmp0 (arg1, "q") || !g_strcmp0 (arg1, "quit")) { g_paste_client_track_sync (client, FALSE, &error); } else if (!g_strcmp0 (arg1, "ui")) { status = spawn ("Ui"); } else if (g_paste_util_has_applet () && !g_strcmp0 (arg1, "applet")) { status = spawn ("Applet"); } else if (g_paste_util_has_unity () && !g_strcmp0 (arg1, "app-indicator")) { status = spawn ("AppIndicator"); } else { show_help (); status = EXIT_FAILURE; } break; case 2: arg1 = argv[0]; arg2 = argv[1]; if (!g_strcmp0 (arg1, "a") || !g_strcmp0 (arg1, "add")) { g_paste_client_add_sync (client, arg2, &error); } else if (!g_strcmp0 (arg1, "bh") || !g_strcmp0 (arg1, "backup-history")) { g_paste_client_backup_history_sync (client, arg2, &error); } else if (!g_strcmp0 (arg1, "d") || !g_strcmp0 (arg1, "del") || !g_strcmp0 (arg1, "delete") || !g_strcmp0 (arg1, "rm") || !g_strcmp0 (arg1, "remove")) { g_paste_client_delete_sync (client, _strtoull (arg2), &error); } else if (!g_strcmp0 (arg1, "dp") || !g_strcmp0 (arg1, "delete-password")) { g_paste_client_delete_password_sync (client, arg2, &error); } else if (!g_strcmp0 (arg1, "dh") || !g_strcmp0 (arg1, "delete-history")) { g_paste_client_delete_history_sync (client, arg2, &error); } else if (!g_strcmp0 (arg1, "f") || !g_strcmp0 (arg1, "file")) { g_paste_client_add_file_sync (client, arg2, &error); } else if (!g_strcmp0 (arg1, "g") || !g_strcmp0 (arg1, "get")) { const gchar *value = (!raw) ? g_paste_client_get_element_sync (client, _strtoull (arg2), &error) : g_paste_client_get_raw_element_sync (client, _strtoull (arg2), &error); if (!error) printf ("%s", value); } else if (!g_strcmp0 (arg1, "search")) { gsize hits; g_autofree guint32 *results = g_paste_client_search_sync (client, arg2, &hits, &error); if (!error) { if (hits > 0) { for (gsize i = 0; i < hits; ++i) { guint32 index = results[i]; gchar *line = g_paste_client_get_element_sync (client, index, &error); if (error) break; print_history_line (line, index, oneline, raw, zero); } } } } else if (!g_strcmp0 (arg1, "s") || !g_strcmp0 (arg1, "set") || !g_strcmp0 (arg1, "select")) { g_paste_client_select_sync (client, _strtoull (arg2), &error); } else if (!g_strcmp0 (arg1, "sh") || !g_strcmp0 (arg1, "switch-history")) { g_paste_client_switch_history_sync (client, arg2, &error); } else if (!g_strcmp0 (arg1, "u") || !g_strcmp0 (arg1, "upload")) { g_paste_client_upload_sync (client, _strtoull (arg2), &error); } else { show_help (); status = EXIT_FAILURE; } break; case 3: arg1 = argv[0]; arg2 = argv[1]; arg3 = argv[2]; if (!g_strcmp0 (arg1, "ap") || !g_strcmp0 (arg1, "add-password")) { g_paste_client_add_password_sync (client, arg2, arg3, &error); } else if (!g_strcmp0 (arg1, "rp") || !g_strcmp0 (arg1, "rename-password")) { g_paste_client_rename_password_sync (client, arg2, arg3, &error); } else if (!g_strcmp0 (arg1, "sp") || !g_strcmp0 (arg1, "set-password")) { g_paste_client_set_password_sync (client, _strtoull (arg2), arg3, &error); } else { show_help (); status = EXIT_FAILURE; } break; default: show_help (); status = EXIT_FAILURE; break; } } if (error) failure_exit (error); return status; }
int handle_mount (int argc, char *argv[], gboolean do_help) { GOptionContext *context; gchar *param; GError *error = NULL; GFile *file; int i; g_set_prgname ("gio mount"); /* Translators: commandline placeholder */ param = g_strdup_printf ("[%s...]", _("LOCATION")); context = g_option_context_new (param); g_free (param); g_option_context_set_help_enabled (context, FALSE); g_option_context_set_summary (context, _("Mount or unmount the locations.")); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); if (do_help) { show_help (context, NULL); g_option_context_free (context); return 0; } if (!g_option_context_parse (context, &argc, &argv, &error)) { show_help (context, error->message); g_error_free (error); g_option_context_free (context); return 1; } g_option_context_free (context); main_loop = g_main_loop_new (NULL, FALSE); if (mount_list) list_monitor_items (); else if (mount_device_file != NULL) mount_with_device_file (mount_device_file); else if (unmount_scheme != NULL) unmount_all_with_scheme (unmount_scheme); else if (mount_monitor) monitor (); else if (argc > 1) { for (i = 1; i < argc; i++) { file = g_file_new_for_commandline_arg (argv[i]); if (mount_unmount) unmount (file); else if (mount_eject) eject (file); else mount (file); g_object_unref (file); } } if (outstanding_mounts > 0) g_main_loop_run (main_loop); return success ? 0 : 2; }
int main(int argc, char **argv) { GOptionContext *context; GError *error = NULL; ShellGlobal *global; GjsContext *js_context; char *script; const char *filename; char *title; gsize len; int code; gtk_init (&argc, &argv); clutter_x11_set_display (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())); clutter_x11_disable_event_retrieval (); if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; gdk_window_add_filter (NULL, event_filter, NULL); context = g_option_context_new (NULL); /* pass unknown through to the JS script */ g_option_context_set_ignore_unknown_options (context, TRUE); g_option_context_add_main_entries (context, entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) g_error ("option parsing failed: %s", error->message); setlocale (LC_ALL, ""); g_type_init (); _shell_global_init (NULL); global = shell_global_get (); js_context = _shell_global_get_gjs_context (global); /* prepare command line arguments */ if (!gjs_context_define_string_array (js_context, "ARGV", argc - 2, (const char**)argv + 2, &error)) { g_printerr ("Failed to defined ARGV: %s", error->message); exit (1); } if (command != NULL) { script = command; len = strlen (script); filename = "<command line>"; } else if (argc <= 1) { script = g_strdup ("const Console = imports.console; Console.interact();"); len = strlen (script); filename = "<stdin>"; } else /*if (argc >= 2)*/ { error = NULL; if (!g_file_get_contents (argv[1], &script, &len, &error)) { g_printerr ("%s\n", error->message); exit (1); } filename = argv[1]; } title = g_filename_display_basename (filename); g_set_prgname (title); g_free (title); #if HAVE_BLUETOOTH /* The module imports are all so intertwined that if the test * imports anything in js/ui, it will probably eventually end up * pulling in ui/status/bluetooth.js. So we need this. */ g_irepository_prepend_search_path (BLUETOOTH_DIR); #endif /* evaluate the script */ error = NULL; if (!gjs_context_eval (js_context, script, len, filename, &code, &error)) { g_free (script); g_printerr ("%s\n", error->message); exit (1); } g_free (script); exit (code); }
int main (int argc, char *argv[]) { gchar *prgname; GsmInhibitorFlag inhibit_flags = 0; gboolean show_help = FALSE; gboolean show_version = FALSE; gboolean no_launch = FALSE; gint i; const gchar *app_id = "unknown"; const gchar *reason = "not specified"; prgname = g_path_get_basename (argv[0]); g_set_prgname (prgname); g_free (prgname); setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); for (i = 1; i < argc; i++) { if (strcmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) show_help = TRUE; else if (strcmp (argv[i], "--version") == 0) show_version = TRUE; else if (strcmp (argv[i], "--inhibit-only") == 0) no_launch = TRUE; else if (strcmp (argv[i], "--app-id") == 0) { i++; if (i == argc) { g_print (_("%s requires an argument\n"), argv[i]); exit (1); } app_id = argv[i]; } else if (strcmp (argv[i], "--reason") == 0) { i++; if (i == argc) { g_print (_("%s requires an argument\n"), argv[i]); exit (1); } reason = argv[i]; } else if (strcmp (argv[i], "--inhibit") == 0) { i++; if (i == argc) { g_print (_("%s requires an argument\n"), argv[i]); exit (1); } inhibit_flags |= parse_flags (argv[i]); } else break; } if (show_version) { version (); return 0; } if (show_help || (i == argc && !no_launch)) { usage (); return 0; } if (inhibit_flags == 0) inhibit_flags = GSM_INHIBITOR_FLAG_IDLE; if (inhibit (app_id, reason, inhibit_flags) == FALSE) return 1; if (!no_launch) wait_for_child_app (argv + i); else wait_forever (); return 0; }
int main (int argc, char **argv) { GOptionContext* context; GError *error = NULL; GFile *infile; GFile *outfile; GInputStream *instream; GOutputStream *outstream; GMainLoop *loop; ByzanzEncoder *encoder; g_set_prgname (argv[0]); #ifdef GETTEXT_PACKAGE bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif context = g_option_context_new (_("process a Byzanz debug recording")); #ifdef GETTEXT_PACKAGE g_option_context_set_translation_domain(context, GETTEXT_PACKAGE); #endif g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_print (_("Wrong option: %s\n"), error->message); usage (); g_error_free (error); return 1; } if (argc != 3) { usage (); return 0; } infile = g_file_new_for_commandline_arg (argv[1]); outfile = g_file_new_for_commandline_arg (argv[2]); loop = g_main_loop_new (NULL, FALSE); instream = G_INPUT_STREAM (g_file_read (infile, NULL, &error)); if (instream == NULL) { g_print ("%s\n", error->message); g_error_free (error); return 1; } outstream = G_OUTPUT_STREAM (g_file_replace (outfile, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, NULL, &error)); if (outstream == NULL) { g_print ("%s\n", error->message); g_error_free (error); return 1; } encoder = byzanz_encoder_new (byzanz_encoder_get_type_from_file (outfile), instream, outstream, FALSE, NULL); g_signal_connect (encoder, "notify", G_CALLBACK (encoder_notify), loop); g_main_loop_run (loop); g_main_loop_unref (loop); g_object_unref (encoder); g_object_unref (instream); g_object_unref (outstream); g_object_unref (infile); g_object_unref (outfile); return 0; }
int main (int argc, char **argv) { char *desktopfile; GOptionContext *context; GError *error; bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* We will register explicitly when we're ready -- see panel-session.c */ egg_sm_client_set_mode (EGG_SM_CLIENT_MODE_DISABLED); g_set_prgname ("gnome-panel"); desktopfile = panel_g_lookup_in_applications_dirs ("gnome-panel.desktop"); if (desktopfile) { egg_set_desktop_file (desktopfile); g_free (desktopfile); } context = g_option_context_new (""); g_option_context_add_group (context, egg_sm_client_get_option_group ()); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); gtk_init (&argc, &argv); error = NULL; if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("%s\n", error->message); g_error_free (error); g_option_context_free (context); return 1; } g_option_context_free (context); if (!egg_get_desktop_file ()) { g_set_application_name (_("Panel")); gtk_window_set_default_icon_name (PANEL_ICON_PANEL); } if (!panel_shell_register (replace)) { panel_cleanup_do (); return 1; } panel_action_protocol_init (); panel_multiscreen_init (); panel_init_stock_icons_and_items (); if (!panel_layout_load ()) { panel_cleanup_do (); return 1; } xstuff_init (); /* Flush to make sure our struts are seen by everyone starting * immediate after (eg, the nautilus desktop). */ gdk_flush (); /* Do this at the end, to be sure that we're really ready when * connecting to the session manager */ panel_session_init (); gtk_main (); panel_cleanup_do (); return 0; }
int main(int argc, char *argv[]) #endif { gboolean opt_force_online = FALSE; gboolean opt_help = FALSE; gboolean opt_login = FALSE; gboolean opt_nologin = FALSE; gboolean opt_version = FALSE; gboolean opt_si = TRUE; /* Check for single instance? */ char *opt_config_dir_arg = NULL; char *opt_login_arg = NULL; char *opt_session_arg = NULL; char *search_path; GList *accounts; #ifdef HAVE_SIGNAL_H int sig_indx; /* for setting up signal catching */ sigset_t sigset; RETSIGTYPE (*prev_sig_disp)(int); char errmsg[BUFSIZ]; GIOChannel *signal_channel; GIOStatus signal_status; guint signal_channel_watcher; #ifndef DEBUG char *segfault_message_tmp; #endif GError *error; #endif int opt; gboolean gui_check; gboolean debug_enabled; gboolean migration_failed = FALSE; GList *active_accounts; struct stat st; struct option long_options[] = { {"config", required_argument, NULL, 'c'}, {"debug", no_argument, NULL, 'd'}, {"force-online", no_argument, NULL, 'f'}, {"help", no_argument, NULL, 'h'}, {"login", optional_argument, NULL, 'l'}, {"multiple", no_argument, NULL, 'm'}, {"nologin", no_argument, NULL, 'n'}, {"session", required_argument, NULL, 's'}, {"version", no_argument, NULL, 'v'}, {"display", required_argument, NULL, 'D'}, {"sync", no_argument, NULL, 'S'}, {0, 0, 0, 0} }; #ifdef DEBUG debug_enabled = TRUE; #else debug_enabled = FALSE; #endif /* Initialize GThread before calling any Glib or GTK+ functions. */ g_thread_init(NULL); g_set_prgname("Pidgin"); #ifdef ENABLE_NLS bindtextdomain(PACKAGE, LOCALEDIR); bind_textdomain_codeset(PACKAGE, "UTF-8"); textdomain(PACKAGE); #endif #ifdef HAVE_SETLOCALE /* Locale initialization is not complete here. See gtk_init_check() */ setlocale(LC_ALL, ""); #endif #ifdef HAVE_SIGNAL_H #ifndef DEBUG /* We translate this here in case the crash breaks gettext. */ segfault_message_tmp = g_strdup_printf(_( "%s %s has segfaulted and attempted to dump a core file.\n" "This is a bug in the software and has happened through\n" "no fault of your own.\n\n" "If you can reproduce the crash, please notify the developers\n" "by reporting a bug at:\n" "%ssimpleticket/\n\n" "Please make sure to specify what you were doing at the time\n" "and post the backtrace from the core file. If you do not know\n" "how to get the backtrace, please read the instructions at\n" "%swiki/GetABacktrace\n"), PIDGIN_NAME, DISPLAY_VERSION, PURPLE_DEVEL_WEBSITE, PURPLE_DEVEL_WEBSITE ); /* we have to convert the message (UTF-8 to console charset) early because after a segmentation fault it's not a good practice to allocate memory */ error = NULL; segfault_message = g_locale_from_utf8(segfault_message_tmp, -1, NULL, NULL, &error); if (segfault_message != NULL) { g_free(segfault_message_tmp); } else { /* use 'segfault_message_tmp' (UTF-8) as a fallback */ g_warning("%s\n", error->message); g_error_free(error); segfault_message = segfault_message_tmp; } #else /* Don't mark this for translation. */ segfault_message = g_strdup( "Hi, user. We need to talk.\n" "I think something's gone wrong here. It's probably my fault.\n" "No, really, it's not you... it's me... no no no, I think we get along well\n" "it's just that.... well, I want to see other people. I... what?!? NO! I \n" "haven't been cheating on you!! How many times do you want me to tell you?! And\n" "for the last time, it's just a rash!\n" ); #endif /* * Create a socket pair for receiving unix signals from a signal * handler. */ if (socketpair(AF_UNIX, SOCK_STREAM, 0, signal_sockets) < 0) { perror("Failed to create sockets for GLib signal handling"); exit(1); } signal_channel = g_io_channel_unix_new(signal_sockets[1]); /* * Set the channel encoding to raw binary instead of the default of * UTF-8, because we'll be sending integers across instead of strings. */ error = NULL; signal_status = g_io_channel_set_encoding(signal_channel, NULL, &error); if (signal_status != G_IO_STATUS_NORMAL) { fprintf(stderr, "Failed to set the signal channel to raw " "binary: %s", error->message); exit(1); } signal_channel_watcher = g_io_add_watch(signal_channel, G_IO_IN, mainloop_sighandler, NULL); g_io_channel_unref(signal_channel); /* Let's not violate any PLA's!!!! */ /* jseymour: whatever the fsck that means */ /* Robot101: for some reason things like gdm like to block * * useful signals like SIGCHLD, so we unblock all the ones we * * declare a handler for. thanks JSeymour and Vann. */ if (sigemptyset(&sigset)) { snprintf(errmsg, sizeof(errmsg), "Warning: couldn't initialise empty signal set"); perror(errmsg); } for(sig_indx = 0; catch_sig_list[sig_indx] != -1; ++sig_indx) { if((prev_sig_disp = signal(catch_sig_list[sig_indx], sighandler)) == SIG_ERR) { snprintf(errmsg, sizeof(errmsg), "Warning: couldn't set signal %d for catching", catch_sig_list[sig_indx]); perror(errmsg); } if(sigaddset(&sigset, catch_sig_list[sig_indx])) { snprintf(errmsg, sizeof(errmsg), "Warning: couldn't include signal %d for unblocking", catch_sig_list[sig_indx]); perror(errmsg); } } for(sig_indx = 0; ignore_sig_list[sig_indx] != -1; ++sig_indx) { if((prev_sig_disp = signal(ignore_sig_list[sig_indx], SIG_IGN)) == SIG_ERR) { snprintf(errmsg, sizeof(errmsg), "Warning: couldn't set signal %d to ignore", ignore_sig_list[sig_indx]); perror(errmsg); } } if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) { snprintf(errmsg, sizeof(errmsg), "Warning: couldn't unblock signals"); perror(errmsg); } #endif /* scan command-line options */ opterr = 1; while ((opt = getopt_long(argc, argv, #ifndef _WIN32 "c:dfhmnl::s:v", #else "c:dfhmnl::v", #endif long_options, NULL)) != -1) { switch (opt) { case 'c': /* config dir */ g_free(opt_config_dir_arg); opt_config_dir_arg = g_strdup(optarg); break; case 'd': /* debug */ debug_enabled = TRUE; break; case 'f': /* force-online */ opt_force_online = TRUE; break; case 'h': /* help */ opt_help = TRUE; break; case 'n': /* no autologin */ opt_nologin = TRUE; break; case 'l': /* login, option username */ opt_login = TRUE; g_free(opt_login_arg); if (optarg != NULL) opt_login_arg = g_strdup(optarg); break; case 's': /* use existing session ID */ g_free(opt_session_arg); opt_session_arg = g_strdup(optarg); break; case 'v': /* version */ opt_version = TRUE; break; case 'm': /* do not ensure single instance. */ opt_si = FALSE; break; case 'D': /* --display */ case 'S': /* --sync */ /* handled by gtk_init_check below */ break; case '?': /* show terse help */ default: show_usage(argv[0], TRUE); #ifdef HAVE_SIGNAL_H g_free(segfault_message); #endif return 0; break; } } /* show help message */ if (opt_help) { show_usage(argv[0], FALSE); #ifdef HAVE_SIGNAL_H g_free(segfault_message); #endif return 0; } /* show version message */ if (opt_version) { printf("%s %s (libpurple %s)\n", PIDGIN_NAME, DISPLAY_VERSION, purple_core_get_version()); #ifdef HAVE_SIGNAL_H g_free(segfault_message); #endif return 0; } /* set a user-specified config directory */ if (opt_config_dir_arg != NULL) { purple_util_set_user_dir(opt_config_dir_arg); } /* * We're done piddling around with command line arguments. * Fire up this baby. */ purple_debug_set_enabled(debug_enabled); /* If we're using a custom configuration directory, we * do NOT want to migrate, or weird things will happen. */ if (opt_config_dir_arg == NULL) { if (!purple_core_migrate()) { migration_failed = TRUE; } } search_path = g_build_filename(purple_user_dir(), "gtkrc-2.0", NULL); gtk_rc_add_default_file(search_path); g_free(search_path); gui_check = gtk_init_check(&argc, &argv); if (!gui_check) { char *display = gdk_get_display(); printf("%s %s\n", PIDGIN_NAME, DISPLAY_VERSION); g_warning("cannot open display: %s", display ? display : "unset"); g_free(display); #ifdef HAVE_SIGNAL_H g_free(segfault_message); #endif return 1; } g_set_application_name(PIDGIN_NAME); #ifdef _WIN32 winpidgin_init(hint); #endif if (migration_failed) { char *old = g_strconcat(purple_home_dir(), G_DIR_SEPARATOR_S ".gaim", NULL); const char *text = _( "%s encountered errors migrating your settings " "from %s to %s. Please investigate and complete the " "migration by hand. Please report this error at http://developer.pidgin.im"); GtkWidget *dialog; dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, text, PIDGIN_NAME, old, purple_user_dir()); g_free(old); g_signal_connect_swapped(dialog, "response", G_CALLBACK(gtk_main_quit), NULL); gtk_widget_show_all(dialog); gtk_main(); #ifdef HAVE_SIGNAL_H g_free(segfault_message); #endif return 0; } purple_core_set_ui_ops(pidgin_core_get_ui_ops()); purple_eventloop_set_ui_ops(pidgin_eventloop_get_ui_ops()); /* * Set plugin search directories. Give priority to the plugins * in user's home directory. */ search_path = g_build_filename(purple_user_dir(), "plugins", NULL); if (!g_stat(search_path, &st)) g_mkdir(search_path, S_IRUSR | S_IWUSR | S_IXUSR); purple_plugins_add_search_path(search_path); g_free(search_path); purple_plugins_add_search_path(LIBDIR); if (!purple_core_init(PIDGIN_UI)) { fprintf(stderr, "Initialization of the libpurple core failed. Dumping core.\n" "Please report this!\n"); #ifdef HAVE_SIGNAL_H g_free(segfault_message); #endif abort(); } if (opt_si && !purple_core_ensure_single_instance()) { #ifdef HAVE_DBUS DBusConnection *conn = purple_dbus_get_connection(); DBusMessage *message = dbus_message_new_method_call(DBUS_SERVICE_PURPLE, DBUS_PATH_PURPLE, DBUS_INTERFACE_PURPLE, "PurpleBlistSetVisible"); gboolean tr = TRUE; dbus_message_append_args(message, DBUS_TYPE_INT32, &tr, DBUS_TYPE_INVALID); dbus_connection_send_with_reply_and_block(conn, message, -1, NULL); dbus_message_unref(message); #endif gdk_notify_startup_complete(); purple_core_quit(); g_printerr(_("Exiting because another libpurple client is already running.\n")); #ifdef HAVE_SIGNAL_H g_free(segfault_message); #endif return 0; } /* TODO: Move blist loading into purple_blist_init() */ purple_set_blist(purple_blist_new()); purple_blist_load(); /* load plugins we had when we quit */ purple_plugins_load_saved(PIDGIN_PREFS_ROOT "/plugins/loaded"); /* TODO: Move pounces loading into purple_pounces_init() */ purple_pounces_load(); ui_main(); #ifdef USE_SM pidgin_session_init(argv[0], opt_session_arg, opt_config_dir_arg); #endif if (opt_session_arg != NULL) { g_free(opt_session_arg); opt_session_arg = NULL; } if (opt_config_dir_arg != NULL) { g_free(opt_config_dir_arg); opt_config_dir_arg = NULL; } /* This needs to be before purple_blist_show() so the * statusbox gets the forced online status. */ if (opt_force_online) purple_network_force_online(); /* * We want to show the blist early in the init process so the * user feels warm and fuzzy (not cold and prickley). */ purple_blist_show(); if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/enabled")) pidgin_debug_window_show(); if (opt_login) { /* disable all accounts */ for (accounts = purple_accounts_get_all(); accounts != NULL; accounts = accounts->next) { PurpleAccount *account = accounts->data; purple_account_set_enabled(account, PIDGIN_UI, FALSE); } /* honor the startup status preference */ if (!purple_prefs_get_bool("/purple/savedstatus/startup_current_status")) purple_savedstatus_activate(purple_savedstatus_get_startup()); /* now enable the requested ones */ dologin_named(opt_login_arg); if (opt_login_arg != NULL) { g_free(opt_login_arg); opt_login_arg = NULL; } } else if (opt_nologin) { /* Set all accounts to "offline" */ PurpleSavedStatus *saved_status; /* If we've used this type+message before, lookup the transient status */ saved_status = purple_savedstatus_find_transient_by_type_and_message( PURPLE_STATUS_OFFLINE, NULL); /* If this type+message is unique then create a new transient saved status */ if (saved_status == NULL) saved_status = purple_savedstatus_new(NULL, PURPLE_STATUS_OFFLINE); /* Set the status for each account */ purple_savedstatus_activate(saved_status); } else { /* Everything is good to go--sign on already */ if (!purple_prefs_get_bool("/purple/savedstatus/startup_current_status")) purple_savedstatus_activate(purple_savedstatus_get_startup()); purple_accounts_restore_current_statuses(); } if ((active_accounts = purple_accounts_get_all_active()) == NULL) { pidgin_accounts_window_show(); } else { g_list_free(active_accounts); } /* GTK clears the notification for us when opening the first window, * but we may have launched with only a status icon, so clear the it * just in case. */ gdk_notify_startup_complete(); #ifdef _WIN32 winpidgin_post_init(); #endif gtk_main(); #ifdef HAVE_SIGNAL_H g_free(segfault_message); g_source_remove(signal_channel_watcher); close(signal_sockets[0]); close(signal_sockets[1]); #endif #ifdef _WIN32 winpidgin_cleanup(); #endif return 0; }
int rpmostree_builtin_internals (int argc, char **argv, GCancellable *cancellable, GError **error) { RpmOstreeInternalsCommand *subcommand; const char *subcommand_name = NULL; gs_free char *prgname = NULL; int exit_status = EXIT_SUCCESS; int in, out; for (in = 1, out = 1; in < argc; in++, out++) { /* The non-option is the command, take it out of the arguments */ if (argv[in][0] != '-') { if (subcommand_name == NULL) { subcommand_name = argv[in]; out--; continue; } } else if (g_str_equal (argv[in], "--")) { break; } argv[out] = argv[in]; } argc = out; subcommand = internals_subcommands; while (subcommand->name) { if (g_strcmp0 (subcommand_name, subcommand->name) == 0) break; subcommand++; } if (!subcommand->name) { GOptionContext *context; gs_free char *help = NULL; context = internals_option_context_new_with_commands (); /* This will not return for some options (e.g. --version). */ if (rpmostree_option_context_parse (context, NULL, &argc, &argv, RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD, cancellable, NULL, error)) { if (subcommand_name == NULL) { g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "No \"internals\" subcommand specified"); } else { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unknown \"internals\" subcommand '%s'", subcommand_name); } exit_status = EXIT_FAILURE; } help = g_option_context_get_help (context, FALSE, NULL); g_printerr ("%s", help); g_option_context_free (context); goto out; } prgname = g_strdup_printf ("%s %s", g_get_prgname (), subcommand_name); g_set_prgname (prgname); exit_status = subcommand->fn (argc, argv, cancellable, error); out: return exit_status; }
/** * vips_init: * @argv0: name of application * * vips_init() starts up the world of VIPS. You should call this on * program startup before using any other VIPS operations. If you do not call * vips_init(), VIPS will call it for you when you use your first VIPS * operation, but * it may not be able to get hold of @argv0 and VIPS may therefore be unable * to find its data files. It is much better to call this function yourself. * * vips_init() does approximately the following: * * <itemizedlist> * <listitem> * <para>initialises any libraries that VIPS is using, including GObject * and the threading system, if neccessary</para> * </listitem> * <listitem> * <para>guesses where the VIPS data files are and sets up * internationalisation --- see vips_guess_prefix() * </para> * </listitem> * <listitem> * <para>creates the main vips types, including VipsImage and friends * </para> * </listitem> * <listitem> * <para>loads any plugins from $libdir/vips-x.y, where x and y are the * major and minor version numbers for this VIPS. * </para> * </listitem> * </itemizedlist> * * Example: * * |[ * int main( int argc, char **argv ) * { * if( vips_init( argv[0] ) ) * vips_error_exit( "unable to start VIPS" ); * * vips_shutdown(); * * return( 0 ); * } * ]| * * See also: vips_shutdown(), vips_get_option_group(), vips_version(), * vips_guess_prefix(), vips_guess_libdir(). * * Returns: 0 on success, -1 otherwise */ int vips_init( const char *argv0 ) { extern GType vips_system_get_type( void ); static gboolean started = FALSE; static gboolean done = FALSE; char *prgname; const char *prefix; const char *libdir; char name[256]; /* Two stage done handling: 'done' means we've completed, 'started' * means we're currently initialising. Use this to prevent recursive * invocation. */ if( done ) /* Called more than once, we succeeded, just return OK. */ return( 0 ); if( started ) /* Recursive invocation, something has broken horribly. * Hopefully the first init will handle it. */ return( 0 ); started = TRUE; #ifdef NEED_TYPE_INIT /* Before glib 2.36 you have to call this on startup. */ g_type_init(); #endif /*NEED_TYPE_INIT*/ /* Older glibs need this. */ #ifndef HAVE_THREAD_NEW if( !g_thread_supported() ) g_thread_init( NULL ); #endif if( !vips__global_lock ) vips__global_lock = vips_g_mutex_new(); VIPS_SETSTR( vips__argv0, argv0 ); prgname = g_path_get_basename( argv0 ); g_set_prgname( prgname ); g_free( prgname ); /* Try to discover our prefix. */ if( !(prefix = vips_guess_prefix( argv0, "VIPSHOME" )) || !(libdir = vips_guess_libdir( argv0, "VIPSHOME" )) ) return( -1 ); /* Get i18n .mo files from $VIPSHOME/share/locale/. */ vips_snprintf( name, 256, "%s" G_DIR_SEPARATOR_S "share" G_DIR_SEPARATOR_S "locale", prefix ); bindtextdomain( GETTEXT_PACKAGE, name ); bind_textdomain_codeset( GETTEXT_PACKAGE, "UTF-8" ); /* Default info setting from env. */ if( g_getenv( "IM_INFO" ) ) vips__info = 1; /* Register base vips types. */ (void) vips_image_get_type(); (void) vips_region_get_type(); vips__meta_init_types(); vips__interpolate_init(); im__format_init(); /* Start up operator cache. */ vips__cache_init(); /* Start up packages. */ (void) vips_system_get_type(); vips_arithmetic_operation_init(); vips_conversion_operation_init(); vips_create_operation_init(); vips_foreign_operation_init(); vips_resample_operation_init(); vips_colour_operation_init(); vips_histogram_operation_init(); vips_convolution_operation_init(); /* Load up any plugins in the vips libdir. We don't error on failure, * it's too annoying to have VIPS refuse to start because of a broken * plugin. */ if( im_load_plugins( "%s/vips-%d.%d", libdir, VIPS_MAJOR_VERSION, VIPS_MINOR_VERSION ) ) { vips_warn( "vips_init", "%s", vips_error_buffer() ); vips_error_clear(); } /* Also load from libdir. This is old and slightly broken behaviour * :-( kept for back compat convenience. */ if( im_load_plugins( "%s", libdir ) ) { vips_warn( "vips_init", "%s", vips_error_buffer() ); vips_error_clear(); } /* Build classes which wrap old vips7 operations. */ vips__init_wrap7_classes(); /* Start up the buffer cache. */ vips__buffer_init(); /* Get the run-time compiler going. */ vips_vector_init(); /* Register vips_shutdown(). This may well not get called and many * platforms don't support it anyway. */ #ifdef HAVE_ATEXIT atexit( vips_shutdown ); #endif /*HAVE_ATEXIT*/ done = TRUE; return( 0 ); }