int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { Activator_Options opts; int result = opts.init (argc, argv); if (result < 0) return 1; // Error else if (result > 0) return 0; // No error, but we should exit anyway. result = run_service_command (opts); if (result < 0) return 1; // Error else if (result > 0) return 0; // No error, but we should exit anyway. if (opts.service ()) return run_service (); return run_standalone (opts); }
int main (int argc, char *argv[]) { GOptionContext *context; GError *error = NULL; TrackerExtract *extract; TrackerDecorator *decorator; TrackerExtractController *controller; gchar *log_filename = NULL; GMainLoop *my_main_loop; bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* Translators: this message will appear immediately after the */ /* usage string - Usage: COMMAND [OPTION]... <THIS_MESSAGE> */ context = g_option_context_new (_("- Extract file meta data")); g_option_context_add_main_entries (context, entries, NULL); g_option_context_parse (context, &argc, &argv, &error); if (!filename && mime_type) { gchar *help; g_printerr ("%s\n\n", _("Filename and mime type must be provided together")); help = g_option_context_get_help (context, TRUE, NULL); g_option_context_free (context); g_printerr ("%s", help); g_free (help); return EXIT_FAILURE; } g_option_context_free (context); if (version) { g_print ("\n" ABOUT "\n" LICENSE "\n"); return EXIT_SUCCESS; } g_set_application_name ("tracker-extract"); setlocale (LC_ALL, ""); config = tracker_config_new (); /* Set conditions when we use stand alone settings */ if (filename) { return run_standalone (config); } /* Initialize subsystems */ initialize_directories (); /* Extractor command line arguments */ if (verbosity > -1) { tracker_config_set_verbosity (config, verbosity); } tracker_log_init (tracker_config_get_verbosity (config), &log_filename); if (log_filename != NULL) { g_message ("Using log file:'%s'", log_filename); g_free (log_filename); } sanity_check_option_values (config); /* This makes sure we don't steal all the system's resources */ initialize_priority_and_scheduling (tracker_config_get_sched_idle (config), tracker_db_manager_get_first_index_done () == FALSE); extract = tracker_extract_new (TRUE, force_module); if (!extract) { g_object_unref (config); tracker_log_shutdown (); return EXIT_FAILURE; } decorator = tracker_extract_decorator_new (extract, NULL, &error); if (error) { g_critical ("Could not start decorator: %s\n", error->message); g_object_unref (config); tracker_log_shutdown (); return EXIT_FAILURE; } #ifdef THREAD_ENABLE_TRACE g_debug ("Thread:%p (Main) --- Waiting for extract requests...", g_thread_self ()); #endif /* THREAD_ENABLE_TRACE */ tracker_locale_init (); controller = tracker_extract_controller_new (decorator); tracker_miner_start (TRACKER_MINER (decorator)); /* Main loop */ main_loop = g_main_loop_new (NULL, FALSE); initialize_signal_handler (); g_main_loop_run (main_loop); my_main_loop = main_loop; main_loop = NULL; g_main_loop_unref (my_main_loop); tracker_miner_stop (TRACKER_MINER (decorator)); /* Shutdown subsystems */ tracker_locale_shutdown (); g_object_unref (extract); g_object_unref (decorator); g_object_unref (controller); tracker_log_shutdown (); g_object_unref (config); return EXIT_SUCCESS; }