int main (int argc, char *argv[]) { GOptionContext *context; GError *error; GFile *file; setlocale (LC_ALL, ""); g_type_init (); error = NULL; context = g_option_context_new (_("- mount <location>")); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_parse (context, &argc, &argv, &error); 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) { int i; 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 0; }
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; GFile *file; gchar *param; gchar *summary; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); error = NULL; param = g_strdup_printf ("[%s...]", _("LOCATION")); summary = _("Mount the locations."); context = g_option_context_new (param); g_option_context_set_summary (context, summary); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_parse (context, &argc, &argv, &error); g_option_context_free (context); g_free (param); if (error != NULL) { g_printerr (_("Error parsing commandline options: %s\n"), error->message); g_printerr ("\n"); g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ()); g_printerr ("\n"); g_error_free (error); return 1; } if (show_version) { g_print (PACKAGE_STRING "\n"); return 0; } 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) { int i; 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; }