int main (int argc, char *argv[]) { TrackerMiner *miner; GMainLoop *loop; GError *error = NULL; setlocale (LC_ALL, ""); miner = tmc_miner_new (&error); if (error) { g_critical ("Miner could not be initialized: %s", error->message); g_error_free (error); return -1; } loop = g_main_loop_new (NULL, FALSE); initialize_signal_handler (loop); g_main_loop_run (loop); g_object_unref (tmc_entity_pool_contacts_get ()); g_object_unref (tmc_entity_pool_channels_get ()); return 0; }
int main(int argc, char *argv[]) { if (argc < 2) { fprintf(stderr, "Usage: %s <interface> [whitelist]\n", argv[0]); return 1; } struct timeval start_timeval; gettimeofday(&start_timeval, NULL); start_timestamp_microseconds = start_timeval.tv_sec * NUM_MICROS_PER_SECOND + start_timeval.tv_usec; initialize_bismark_id(); if (argc < 3 || initialize_domain_whitelist(argv[2])) { fprintf(stderr, "Error loading domain whitelist; whitelisting disabled.\n"); } #ifndef DISABLE_ANONYMIZATION if (anonymization_init()) { fprintf(stderr, "Error initializing anonymizer\n"); return 1; } #endif #ifdef ENABLE_FREQUENT_UPDATES if (anonymize_mac(bismark_mac, bismark_mac)) { fprintf(stderr, "Error anonymizing router MAC address\n"); } #endif packet_series_init(&packet_data); flow_table_init(&flow_table); dns_table_init(&dns_table, &domain_whitelist); #ifdef ENABLE_HTTP_URL http_table_init(&http_table); #endif address_table_init(&address_table); drop_statistics_init(&drop_statistics); #ifdef ENABLE_FREQUENT_UPDATES device_throughput_table_init(&device_throughput_table); #endif upload_failures_init(&upload_failures, UPLOAD_FAILURES_FILENAME); initialize_signal_handler(); set_next_alarm(); /* By default, pcap uses an internal buffer of 500 KB. Any packets that * overflow this buffer will be dropped. pcap_stats tells the number of * dropped packets. * * Because pcap does its own buffering, we don't need to run packet * processing in a separate thread. (It would be easier to just increase * the buffer size if we experience performance problems.) */ pcap_handle = initialize_pcap(argv[1]); if (!pcap_handle) { return 1; } return pcap_loop(pcap_handle, -1, process_packet, NULL); }
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; }
int main (gint argc, gchar *argv[]) { TrackerConfig *config; TrackerMiner *miner_files; TrackerMinerFilesIndex *miner_files_index; GOptionContext *context; GError *error = NULL; gchar *log_filename = NULL; gboolean do_mtime_checking; gboolean do_crawling; gboolean force_mtime_checking = FALSE; gboolean store_available; g_type_init(); main_loop = NULL; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* Set timezone info */ tzset (); /* Translators: this messagge will apper immediately after the * usage string - Usage: COMMAND <THIS_MESSAGE> */ context = g_option_context_new (_("- start the tracker indexer")); disable_options = g_array_new (FALSE, FALSE, sizeof (gint)); g_option_context_add_main_entries (context, entries, NULL); g_option_context_parse (context, &argc, &argv, &error); g_option_context_free (context); if (error) { g_printerr ("%s\n", error->message); g_error_free (error); g_array_free (disable_options, TRUE); return EXIT_FAILURE; } if (version) { g_print ("\n" ABOUT "\n" LICENSE "\n"); g_array_free (disable_options, TRUE); return EXIT_SUCCESS; } if (eligible) { check_eligible (); g_array_free (disable_options, TRUE); return EXIT_SUCCESS; } initialize_signal_handler (); /* Initialize logging */ config = tracker_config_new (); if (verbosity > -1) { tracker_config_set_verbosity (config, verbosity); } if (initial_sleep > -1) { tracker_config_set_initial_sleep (config, initial_sleep); } tracker_log_init (tracker_config_get_verbosity (config), &log_filename); if (log_filename) { 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); main_loop = g_main_loop_new (NULL, FALSE); g_message ("Checking if we're running as a daemon:"); g_message (" %s %s", no_daemon ? "No" : "Yes", no_daemon ? "(forced by command line)" : ""); /* Create new TrackerMinerFiles object */ miner_files = tracker_miner_files_new (config, &error); if (!miner_files) { g_critical ("Couldn't create new Files miner: '%s'", error ? error->message : "unknown error"); g_object_unref (config); tracker_log_shutdown (); g_array_free (disable_options, TRUE); return EXIT_FAILURE; } tracker_writeback_init (TRACKER_MINER_FILES (miner_files), config, &error); if (error) { g_critical ("Couldn't create writeback handling: '%s'", error ? error->message : "unknown error"); g_object_unref (config); g_object_unref (miner_files); tracker_log_shutdown (); g_array_free (disable_options, TRUE); return EXIT_FAILURE; } /* Create new TrackerMinerFilesIndex object */ miner_files_index = tracker_miner_files_index_new (TRACKER_MINER_FILES (miner_files)); if (!miner_files_index) { g_object_unref (miner_files); tracker_writeback_shutdown (); g_object_unref (config); tracker_log_shutdown (); g_array_free (disable_options, TRUE); return EXIT_FAILURE; } /* Check if we should crawl and if we should force mtime * checking based on the config. */ do_crawling = should_crawl (config, &force_mtime_checking); /* Get the last shutdown state to see if we need to perform a * full mtime check against the db or not. * * Set to TRUE here in case we crash and miss file system * events. */ g_message ("Checking whether to force mtime checking during crawling (based on last clean shutdown):"); /* Override the shutdown state decision based on the config */ if (force_mtime_checking) { do_mtime_checking = TRUE; } else { do_mtime_checking = tracker_db_manager_get_need_mtime_check (); } g_message (" %s %s", do_mtime_checking ? "Yes" : "No", force_mtime_checking ? "(forced from config)" : ""); /* Set the need for an mtime check to TRUE so we check in the * event of a crash, this is changed back on shutdown if * everything appears to be fine. */ tracker_db_manager_set_need_mtime_check (TRUE); /* Configure files miner */ tracker_miner_fs_set_initial_crawling (TRACKER_MINER_FS (miner_files), do_crawling); tracker_miner_fs_set_mtime_checking (TRACKER_MINER_FS (miner_files), do_mtime_checking); g_signal_connect (miner_files, "finished", G_CALLBACK (miner_finished_cb), NULL); miners = g_slist_prepend (miners, miner_files); tracker_thumbnailer_init (); miner_handle_first (config, do_mtime_checking); /* Go, go, go! */ g_main_loop_run (main_loop); g_message ("Shutdown started"); store_available = store_is_available (); if (miners_timeout_id == 0 && !miner_needs_check (miner_files, store_available)) { tracker_db_manager_set_need_mtime_check (FALSE); } g_main_loop_unref (main_loop); g_object_unref (config); g_object_unref (miner_files_index); tracker_thumbnailer_shutdown (); g_slist_foreach (miners, (GFunc) finalize_miner, NULL); g_slist_free (miners); tracker_writeback_shutdown (); tracker_log_shutdown (); g_array_free (disable_options, TRUE); g_print ("\nOK\n\n"); return EXIT_SUCCESS; }
int main (gint argc, gchar *argv[]) { TrackerMiner *miner_applications; GOptionContext *context; GError *error = NULL; gchar *log_filename = NULL; main_loop = NULL; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* Set timezone info */ tzset (); /* Translators: this messagge will apper immediately after the * usage string - Usage: COMMAND <THIS_MESSAGE> */ context = g_option_context_new (_("— start the application data miner")); g_option_context_add_main_entries (context, entries, NULL); g_option_context_parse (context, &argc, &argv, &error); g_option_context_free (context); if (error) { g_printerr ("%s\n", error->message); g_error_free (error); return EXIT_FAILURE; } if (version) { g_print ("\n" ABOUT "\n" LICENSE "\n"); return EXIT_SUCCESS; } tracker_log_init (verbosity, &log_filename); if (log_filename) { g_message ("Using log file:'%s'", log_filename); g_free (log_filename); } /* This makes sure we don't steal all the system's resources */ initialize_priority_and_scheduling (TRACKER_SCHED_IDLE_ALWAYS, FALSE); main_loop = g_main_loop_new (NULL, FALSE); g_message ("Checking if we're running as a daemon:"); g_message (" %s %s", no_daemon ? "No" : "Yes", no_daemon ? "(forced by command line)" : ""); /* Create miner for applications */ miner_applications = tracker_miner_applications_new (&error); if (!miner_applications) { g_critical ("Couldn't create new applications miner, '%s'", error ? error->message : "unknown error"); tracker_log_shutdown (); return EXIT_FAILURE; } g_signal_connect (miner_applications, "finished", G_CALLBACK (miner_finished_cb), NULL); initialize_signal_handler (); /* Go, go, go! */ tracker_miner_start (miner_applications); g_main_loop_run (main_loop); g_message ("Shutdown started"); g_main_loop_unref (main_loop); g_object_unref (G_OBJECT (miner_applications)); tracker_log_shutdown (); g_print ("\nOK\n\n"); return EXIT_SUCCESS; }
gint tracker_control_status_run (void) { TrackerMinerManager *manager; /* --follow implies --status */ if (follow) { status = TRUE; } if (list_common_statuses) { gint i; g_print ("%s:\n", _("Common statuses include")); for (i = 0; i < G_N_ELEMENTS (statuses); i++) { g_print (" %s\n", _(statuses[i])); } return EXIT_SUCCESS; } if (status) { GError *error = NULL; GSList *miners_available; GSList *miners_running; GSList *l; /* Don't auto-start the miners here */ manager = tracker_miner_manager_new_full (FALSE, &error); if (!manager) { g_printerr (_("Could not get status, manager could not be created, %s"), error ? error->message : "unknown error"); g_printerr ("\n"); g_clear_error (&error); return EXIT_FAILURE; } miners_available = tracker_miner_manager_get_available (manager); miners_running = tracker_miner_manager_get_running (manager); /* Work out lengths for output spacing */ paused_length = strlen (_("PAUSED")); for (l = miners_available; l; l = l->next) { const gchar *name; name = tracker_miner_manager_get_display_name (manager, l->data); longest_miner_name_length = MAX (longest_miner_name_length, strlen (name)); } /* Display states */ g_print ("%s:\n", _("Store")); store_init (); store_get_and_print_state (); g_print ("\n"); g_print ("%s:\n", _("Miners")); for (l = miners_available; l; l = l->next) { const gchar *name; gboolean is_running; name = tracker_miner_manager_get_display_name (manager, l->data); if (!name) { g_critical ("Could not get name for '%s'", (gchar *) l->data); continue; } is_running = tracker_string_in_gslist (l->data, miners_running); if (is_running) { GStrv pause_applications, pause_reasons; gchar *status = NULL; gdouble progress; gint remaining_time; gboolean is_paused; if (!miner_get_details (manager, l->data, &status, &progress, &remaining_time, &pause_applications, &pause_reasons)) { continue; } is_paused = *pause_applications || *pause_reasons; miner_print_state (manager, l->data, status, progress, remaining_time, TRUE, is_paused); g_strfreev (pause_applications); g_strfreev (pause_reasons); g_free (status); } else { miner_print_state (manager, l->data, NULL, 0.0, -1, FALSE, FALSE); } } g_slist_foreach (miners_available, (GFunc) g_free, NULL); g_slist_free (miners_available); g_slist_foreach (miners_running, (GFunc) g_free, NULL); g_slist_free (miners_running); if (!follow) { /* Do nothing further */ if (proxy) { g_object_unref (proxy); } g_print ("\n"); return EXIT_SUCCESS; } g_print ("Press Ctrl+C to end follow of Tracker state\n"); g_signal_connect (manager, "miner-progress", G_CALLBACK (manager_miner_progress_cb), NULL); g_signal_connect (manager, "miner-paused", G_CALLBACK (manager_miner_paused_cb), NULL); g_signal_connect (manager, "miner-resumed", G_CALLBACK (manager_miner_resumed_cb), NULL); initialize_signal_handler (); miners_progress = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) miners_progress_destroy_notify); miners_status = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) g_free); main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); g_main_loop_unref (main_loop); g_hash_table_unref (miners_progress); g_hash_table_unref (miners_status); if (proxy) { g_object_unref (proxy); } if (manager) { g_object_unref (manager); } return EXIT_SUCCESS; } /* All known options have their own exit points */ g_warn_if_reached (); return EXIT_FAILURE; }