int main (int argc, char const **argv) { GOErrorInfo *plugin_errs; GOCmdContext *cc; GOptionContext *ocontext; GError *error = NULL; const char *testname; /* No code before here, we need to init threads */ argv = gnm_pre_parse_init (argc, argv); ocontext = g_option_context_new (_("[testname]")); g_option_context_add_main_entries (ocontext, sstest_options, GETTEXT_PACKAGE); g_option_context_add_group (ocontext, gnm_get_option_group ()); g_option_context_parse (ocontext, &argc, (gchar ***)&argv, &error); g_option_context_free (ocontext); if (error) { g_printerr (_("%s\nRun '%s --help' to see a full list of available command line options.\n"), error->message, g_get_prgname ()); g_error_free (error); return 1; } if (sstest_show_version) { g_printerr (_("version '%s'\ndatadir := '%s'\nlibdir := '%s'\n"), GNM_VERSION_FULL, gnm_sys_data_dir (), gnm_sys_lib_dir ()); return 0; } gnm_init (); cc = cmd_context_stderr_new (); gnm_plugins_init (GO_CMD_CONTEXT (cc)); go_plugin_db_activate_plugin_list ( go_plugins_get_available_plugins (), &plugin_errs); if (plugin_errs) { /* FIXME: What do we want to do here? */ go_error_info_free (plugin_errs); } testname = argv[1]; if (!testname) testname = "all"; /* ---------------------------------------- */ MAYBE_DO ("test_insdel_rowcol_names") test_insdel_rowcol_names (); MAYBE_DO ("test_func_help") test_func_help (); MAYBE_DO ("test_go_data_cache_build_cache") test_go_data_cache_build_cache(); MAYBE_DO ("test_go_data_slicer_tuple_compare_to") test_go_data_slicer_tuple_compare_to (); /* ---------------------------------------- */ g_object_unref (cc); gnm_shutdown (); gnm_pre_parse_shutdown (); return 0; }
static void gnumeric_arg_parse (int argc, char **argv) { GOptionContext *ocontext; int i; gboolean funcdump = FALSE; GError *error = NULL; /* no need to init gtk when dumping function info */ for (i = 0 ; argv[i] ; i++) if (0 == strncmp ("--dump-func", argv[i], 11)) { funcdump = TRUE; break; } ocontext = g_option_context_new (_("[FILE ...]")); g_option_context_add_main_entries (ocontext, gnumeric_options, GETTEXT_PACKAGE); g_option_context_add_group (ocontext, gnm_get_option_group ()); #if defined(G_OS_WIN32) /* we have already translated to utf8, do not do it again. * http://bugzilla.gnome.org/show_bug.cgi?id=361321 */ g_option_context_set_delocalize (ocontext, FALSE); #endif if (!funcdump) g_option_context_add_group (ocontext, gtk_get_option_group (TRUE)); g_option_context_parse (ocontext, &argc, &argv, &error); if (ocontext) g_option_context_free (ocontext); if (error) { g_printerr (_("%s\nRun '%s --help' to see a full list of available command line options.\n"), error->message, argv[0]); g_error_free (error); exit (1); } if (!funcdump) { gtk_init (&argc, &argv); } }
int main (int argc, char const **argv) { GOErrorInfo *plugin_errs; int res = 0; GOCmdContext *cc; GOptionContext *ocontext; GError *error = NULL; /* No code before here, we need to init threads */ argv = gnm_pre_parse_init (argc, argv); ocontext = g_option_context_new (_("INFILE...")); g_option_context_add_main_entries (ocontext, ssindex_options, GETTEXT_PACKAGE); g_option_context_add_group (ocontext, gnm_get_option_group ()); g_option_context_parse (ocontext, &argc, (gchar ***)&argv, &error); g_option_context_free (ocontext); if (error) { g_printerr (_("%s\nRun '%s --help' to see a full list of available command line options.\n"), error->message, argv[0]); g_error_free (error); return 1; } if (ssindex_show_version) { g_printerr (_("ssindex version '%s'\ndatadir := '%s'\nlibdir := '%s'\n"), GNM_VERSION_FULL, gnm_sys_data_dir (), gnm_sys_lib_dir ()); return 0; } else if (!ssindex_run_indexer && !ssindex_list_mime_types) { g_printerr (_("Usage: %s [OPTION...] %s\n"), g_get_prgname (), _("INFILE...")); return 1; } gnm_init (); cc = gnm_cmd_context_stderr_new (); gnm_plugins_init (GO_CMD_CONTEXT (cc)); go_plugin_db_activate_plugin_list ( go_plugins_get_available_plugins (), &plugin_errs); if (plugin_errs) { /* FIXME: What do we want to do here? */ go_error_info_free (plugin_errs); } go_component_set_default_command_context (cc); if (ssindex_run_indexer) { GOIOContext *ioc = go_io_context_new (cc); int i; go_io_context_set_num_files (ioc, argc - 1); for (i = 1; i < argc; i++) { char const *file = argv[i]; go_io_context_processing_file (ioc, file); res |= ssindex (file, ioc); } g_object_unref (ioc); } else if (ssindex_list_mime_types) { GList *o; for (o = go_get_file_openers (); o != NULL ; o = o->next) { GSList const *mime = go_file_opener_get_mimes (o->data); for (; mime != NULL ; mime = mime->next) g_print ("%s\n", (char const *)mime->data); } } go_component_set_default_command_context (NULL); g_object_unref (cc); gnm_shutdown (); gnm_pre_parse_shutdown (); return res; }