searching for files on GNUnet More...
#include "platform.h"
#include <ctype.h>
#include <inttypes.h>
#include <limits.h>
#include "gnunet_fs_service.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_SEARCH_MetadataPrinterInfo |
Macros | |
#define | GNUNET_SEARCH_log(kind, ...) GNUNET_log_from (kind, "gnunet-search", __VA_ARGS__) |
#define | DEFAULT_DIR_FORMAT "#%n:\ngnunet-download -o \"%f\" -R %u\n\n" |
#define | HELP_DEFAULT_DIR_FORMAT "#%n:\\ngnunet-download -o \"%f\" -R %u\\n\\n" |
#define | DEFAULT_FILE_FORMAT "#%n:\ngnunet-download -o \"%f\" %u\n\n" |
#define | HELP_DEFAULT_FILE_FORMAT "#%n:\\ngnunet-download -o \"%f\" %u\\n\\n" |
#define | VERB_DEFAULT_DIR_FORMAT DEFAULT_DIR_FORMAT "%a\n" |
#define | VERB_DEFAULT_FILE_FORMAT DEFAULT_FILE_FORMAT "%a\n" |
#define | DEFAULT_META_FORMAT " MetaType #%i: %p\n" |
#define | HELP_DEFAULT_META_FORMAT " MetaType #%i: %p\\n" |
#define | HELP_EXTRACTOR_TEXTADD "" |
#define | GENERIC_DIRECTORY_NAME "collection" |
#define | GENERIC_FILE_NAME "no-name" |
#define | GENERIC_FILE_MIMETYPE "application/octet-stream" |
#define | info ((struct GNUNET_SEARCH_MetadataPrinterInfo *) cls) |
Enumerations | |
enum | GNUNET_SEARCH_MetadataPrinterFlags { METADATA_PRINTER_FLAG_NONE = 0 , METADATA_PRINTER_FLAG_ONE_RUN = 1 , METADATA_PRINTER_FLAG_HAVE_TYPE = 2 } |
Functions | |
static const char * | print_escape_sequence (const char *const esc) |
Print the escape sequence at the beginning of a string. More... | |
static int | item_printer (void *const cls, const char *const plugin_name, const enum EXTRACTOR_MetaType type, const enum EXTRACTOR_MetaFormat format, const char *const data_mime_type, const char *const data, const size_t data_size) |
Type of a function that libextractor calls for each meta data item found. More... | |
static void | print_search_result (const char *const filename, const struct GNUNET_FS_Uri *const uri, const struct GNUNET_FS_MetaData *const metadata, const unsigned int resultnum, const int is_directory) |
Print a search result according to the current formats. More... | |
static void | clean_task (void *const cls) |
static void * | progress_cb (void *const cls, const struct GNUNET_FS_ProgressInfo *const info) |
Called by FS client to give information about the progress of an operation. More... | |
static void | shutdown_task (void *const cls) |
static void | timeout_task (void *const cls) |
static void | run (void *const cls, char *const *const args, const char *const cfgfile, const struct GNUNET_CONFIGURATION_Handle *const cfgarg) |
Main function that will be run by the scheduler. More... | |
int | main (int argc, char *const *argv) |
The main function to search GNUnet. More... | |
Variables | |
static int | ret |
static const struct GNUNET_CONFIGURATION_Handle * | cfg |
static struct GNUNET_FS_Handle * | ctx |
static struct GNUNET_FS_SearchContext * | sc |
static char * | output_filename |
static char * | format_string_opt |
static char * | dir_format_string_opt |
static char * | meta_format_string_opt |
static const char * | format_string |
static const char * | dir_format_string |
static const char * | meta_format_string |
static struct GNUNET_FS_DirectoryBuilder * | db |
static unsigned int | anonymity = 1 |
static struct GNUNET_TIME_Relative | timeout |
Timeout for the search, 0 means to wait for CTRL-C. More... | |
static unsigned int | results_limit |
static unsigned int | results |
static unsigned int | verbose |
static int | bookmark_only |
static int | local_only |
static int | silent_mode |
static struct GNUNET_SCHEDULER_Task * | tt |
static int | stop_searching |
searching for files on GNUnet
Definition in file gnunet-search.c.
#define GNUNET_SEARCH_log | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "gnunet-search", __VA_ARGS__) |
Definition at line 37 of file gnunet-search.c.
#define DEFAULT_DIR_FORMAT "#%n:\ngnunet-download -o \"%f\" -R %u\n\n" |
Definition at line 43 of file gnunet-search.c.
#define HELP_DEFAULT_DIR_FORMAT "#%n:\\ngnunet-download -o \"%f\" -R %u\\n\\n" |
Definition at line 44 of file gnunet-search.c.
#define DEFAULT_FILE_FORMAT "#%n:\ngnunet-download -o \"%f\" %u\n\n" |
Definition at line 45 of file gnunet-search.c.
#define HELP_DEFAULT_FILE_FORMAT "#%n:\\ngnunet-download -o \"%f\" %u\\n\\n" |
Definition at line 46 of file gnunet-search.c.
#define VERB_DEFAULT_DIR_FORMAT DEFAULT_DIR_FORMAT "%a\n" |
Definition at line 47 of file gnunet-search.c.
#define VERB_DEFAULT_FILE_FORMAT DEFAULT_FILE_FORMAT "%a\n" |
Definition at line 48 of file gnunet-search.c.
#define DEFAULT_META_FORMAT " MetaType #%i: %p\n" |
Definition at line 55 of file gnunet-search.c.
#define HELP_DEFAULT_META_FORMAT " MetaType #%i: %p\\n" |
Definition at line 56 of file gnunet-search.c.
#define HELP_EXTRACTOR_TEXTADD "" |
Definition at line 57 of file gnunet-search.c.
#define GENERIC_DIRECTORY_NAME "collection" |
Definition at line 60 of file gnunet-search.c.
#define GENERIC_FILE_NAME "no-name" |
Definition at line 61 of file gnunet-search.c.
#define GENERIC_FILE_MIMETYPE "application/octet-stream" |
Definition at line 62 of file gnunet-search.c.
#define info ((struct GNUNET_SEARCH_MetadataPrinterInfo *) cls) |
Enumerator | |
---|---|
METADATA_PRINTER_FLAG_NONE | |
METADATA_PRINTER_FLAG_ONE_RUN | |
METADATA_PRINTER_FLAG_HAVE_TYPE |
Definition at line 65 of file gnunet-search.c.
|
static |
Print the escape sequence at the beginning of a string.
esc | a string that must begin with a backslash (the function only assumes that it does, but does not check) |
If "\\nfoo"
is passed as argument, this function prints a new line and returns "foo"
Definition at line 141 of file gnunet-search.c.
Referenced by item_printer(), and print_search_result().
|
static |
Type of a function that libextractor calls for each meta data item found.
cls | closure (user-defined, used for the iteration info) |
plugin_name | name of the plugin that produced this value; special values can be used (e.g. '<zlib>' for zlib being used in the main libextractor library and yielding meta data). |
type | libextractor-type describing the meta data |
format | basic format information about data |
data_mime_type | mime-type of data (not of the original file); can be NULL (if mime-type is not known) |
data | actual meta-data found |
data_size | number of bytes in data |
Definition at line 206 of file gnunet-search.c.
References data, data_size, dgettext, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, info, LIBEXTRACTOR_GETTEXT_DOMAIN, meta_format_string, METADATA_PRINTER_FLAG_HAVE_TYPE, METADATA_PRINTER_FLAG_ONE_RUN, plugin_name, print_escape_sequence(), and type.
Referenced by print_search_result().
|
static |
Print a search result according to the current formats.
filename | the filename for this result |
uri | the struct GNUNET_FS_Uri this result refers to |
metadata | the struct GNUNET_FS_MetaData associated with this result |
resultnum | the result number |
is_directory | GNUNET_YES if this is a directory, otherwise GNUNET_NO |
Definition at line 292 of file gnunet-search.c.
References dir_format_string, filename, format_string, GENERIC_FILE_MIMETYPE, GNUNET_free, GNUNET_FS_DIRECTORY_EXT, GNUNET_FS_DIRECTORY_MIME, GNUNET_FS_meta_data_get_by_type(), GNUNET_FS_meta_data_iterate(), GNUNET_FS_uri_chk_get_file_size(), GNUNET_FS_uri_to_string(), GNUNET_YES, info, INT_MAX, item_printer(), METADATA_PRINTER_FLAG_HAVE_TYPE, METADATA_PRINTER_FLAG_NONE, METADATA_PRINTER_FLAG_ONE_RUN, print_escape_sequence(), and uri.
Referenced by progress_cb().
|
static |
Definition at line 430 of file gnunet-search.c.
References _, ctx, db, GNUNET_break, GNUNET_DISK_directory_remove(), GNUNET_DISK_fn_write(), GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_FS_directory_builder_finish(), GNUNET_FS_stop(), GNUNET_OK, GNUNET_SEARCH_log, and output_filename.
Referenced by progress_cb().
|
static |
Called by FS client to give information about the progress of an operation.
cls | closure |
info | details about the event, specifying the event type and various bits about the event |
Definition at line 478 of file gnunet-search.c.
References _, clean_task(), db, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, filename, GENERIC_DIRECTORY_NAME, GENERIC_FILE_NAME, GNUNET_DISK_filename_canonicalize(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_FS_directory_builder_add(), GNUNET_FS_meta_data_get_by_type(), GNUNET_FS_meta_data_test_for_directory(), GNUNET_FS_STATUS_SEARCH_ERROR, GNUNET_FS_STATUS_SEARCH_RESULT, GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED, GNUNET_FS_STATUS_SEARCH_START, GNUNET_FS_STATUS_SEARCH_STOPPED, GNUNET_FS_STATUS_SEARCH_UPDATE, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_shutdown(), GNUNET_SEARCH_log, GNUNET_YES, info, print_search_result(), results, results_limit, silent_mode, and stop_searching.
Referenced by run().
|
static |
Definition at line 564 of file gnunet-search.c.
References dir_format_string_opt, format_string_opt, GNUNET_free, GNUNET_FS_search_stop(), meta_format_string_opt, and sc.
Referenced by run().
|
static |
Definition at line 578 of file gnunet-search.c.
References GNUNET_SCHEDULER_shutdown(), GNUNET_YES, stop_searching, and tt.
Referenced by run().
|
static |
Main function that will be run by the scheduler.
cls | closure |
args | remaining command-line arguments |
cfgfile | name of the configuration file used (for saving, can be NULL!) |
cfgarg | configuration |
Definition at line 595 of file gnunet-search.c.
References _, anonymity, consensus-simulation::args, bookmark_only, cfg, ctx, db, DEFAULT_DIR_FORMAT, DEFAULT_FILE_FORMAT, DEFAULT_META_FORMAT, dir_format_string, dir_format_string_opt, format_string, format_string_opt, GNUNET_free, GNUNET_FS_directory_builder_create(), GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END, GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY, GNUNET_FS_SEARCH_OPTION_NONE, GNUNET_FS_search_start(), GNUNET_FS_start(), GNUNET_FS_stop(), GNUNET_FS_uri_destroy(), GNUNET_FS_uri_ksk_create_from_args(), GNUNET_FS_uri_test_ksk(), GNUNET_FS_uri_test_sks(), GNUNET_FS_uri_to_string(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_shutdown(), local_only, meta_format_string, meta_format_string_opt, options, output_filename, progress_cb(), GNUNET_TIME_Relative::rel_value_us, ret, sc, shutdown_task(), silent_mode, timeout, timeout_task(), tt, uri, VERB_DEFAULT_DIR_FORMAT, VERB_DEFAULT_FILE_FORMAT, and verbose.
Referenced by main().
int main | ( | int | argc, |
char *const * | argv | ||
) |
The main function to search GNUnet.
argc | number of arguments from the command line |
argv | command line arguments |
Definition at line 713 of file gnunet-search.c.
References anonymity, bookmark_only, dir_format_string_opt, format_string_opt, gettext_noop, GNUNET_FS_DIRECTORY_EXT, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_increment_uint(), GNUNET_GETOPT_option_relative_time(), GNUNET_GETOPT_option_string(), GNUNET_GETOPT_option_uint(), GNUNET_OS_project_data_gnunet(), GNUNET_PROGRAM_run(), GNUNET_SYSERR, HELP_DEFAULT_DIR_FORMAT, HELP_DEFAULT_FILE_FORMAT, HELP_DEFAULT_META_FORMAT, HELP_EXTRACTOR_TEXTADD, local_only, meta_format_string_opt, options, output_filename, results_limit, ret, run(), silent_mode, timeout, and verbose.
|
static |
Definition at line 81 of file gnunet-search.c.
|
static |
Definition at line 83 of file gnunet-search.c.
Referenced by run().
|
static |
Definition at line 85 of file gnunet-search.c.
Referenced by clean_task(), and run().
|
static |
Definition at line 87 of file gnunet-search.c.
Referenced by connect_cb(), continue_writing(), decrypt_block_with_keyword(), deserialize_search(), deserialize_search_file(), deserialize_search_result(), destroy_storecontext(), disconnect_cb(), do_reconnect(), extract_box_cb(), free_search_context(), GNUNET_FS_search_continue(), GNUNET_FS_search_make_status_(), GNUNET_FS_search_pause(), GNUNET_FS_search_signal_suspend_(), GNUNET_FS_search_start_searching_(), GNUNET_FS_search_stop(), GNUNET_FS_search_sync_(), GNUNET_PEERSTORE_store(), GNUNET_PEERSTORE_store_cancel(), GNUNET_TRANSPORT_TESTING_large_send(), GNUNET_TRANSPORT_TESTING_simple_send(), handle_client_start_search(), handle_datastore_reply(), handle_request(), handle_result(), handle_store_result(), notify_client_chk_result(), notify_client_chk_update(), process_kblock(), process_ksk_result(), process_sblock(), process_sks_result(), reconnect(), refresh_timeout_task(), run(), schedule_transmit_search_request(), search_mq_error_handler(), search_result_stop(), search_result_suspend(), search_start(), select_best_pending_from_link(), shutdown_task(), signal_result_resume(), signal_search_resume(), signal_socks_failure(), timeout_cadet_task(), transmit_on_queue(), try_reconnect(), and update_sre_result_maps().
|
static |
Definition at line 89 of file gnunet-search.c.
Referenced by clean_task(), main(), and run().
|
static |
Definition at line 91 of file gnunet-search.c.
Referenced by main(), run(), and shutdown_task().
|
static |
Definition at line 93 of file gnunet-search.c.
Referenced by main(), run(), and shutdown_task().
|
static |
Definition at line 95 of file gnunet-search.c.
Referenced by main(), run(), and shutdown_task().
|
static |
Definition at line 97 of file gnunet-search.c.
Referenced by print_search_result(), and run().
|
static |
Definition at line 99 of file gnunet-search.c.
Referenced by print_search_result(), and run().
|
static |
Definition at line 101 of file gnunet-search.c.
Referenced by item_printer(), and run().
|
static |
Definition at line 103 of file gnunet-search.c.
Referenced by check_patch_applied(), clean_task(), do_scheduler_notify(), download_cb(), GNUNET_CURL_download_get_result_(), GNUNET_PQ_connect2(), GNUNET_PQ_connect_with_cfg2(), GNUNET_PQ_disconnect(), GNUNET_PQ_eval_prepared_multi_select(), GNUNET_PQ_eval_prepared_non_select(), GNUNET_PQ_eval_prepared_singleton_select(), GNUNET_PQ_eval_result(), GNUNET_PQ_event_do_poll(), GNUNET_PQ_event_listen(), GNUNET_PQ_event_listen_cancel(), GNUNET_PQ_event_notify(), GNUNET_PQ_event_reconnect_(), GNUNET_PQ_exec_prepared(), GNUNET_PQ_exec_sql(), GNUNET_PQ_exec_statements(), GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_prepare_once(), GNUNET_PQ_prepare_statements(), GNUNET_PQ_query_param_array_abs_time(), GNUNET_PQ_query_param_array_bool(), GNUNET_PQ_query_param_array_bytes(), GNUNET_PQ_query_param_array_bytes_same_size(), GNUNET_PQ_query_param_array_ptrs_abs_time(), GNUNET_PQ_query_param_array_ptrs_bytes(), GNUNET_PQ_query_param_array_ptrs_bytes_same_size(), GNUNET_PQ_query_param_array_ptrs_rel_time(), GNUNET_PQ_query_param_array_ptrs_string(), GNUNET_PQ_query_param_array_ptrs_timestamp(), GNUNET_PQ_query_param_array_rel_time(), GNUNET_PQ_query_param_array_string(), GNUNET_PQ_query_param_array_timestamp(), GNUNET_PQ_query_param_array_uint16(), GNUNET_PQ_query_param_array_uint32(), GNUNET_PQ_query_param_array_uint64(), GNUNET_PQ_reconnect(), GNUNET_PQ_reconnect_if_down(), GNUNET_PQ_result_spec_array_abs_time(), GNUNET_PQ_result_spec_array_bool(), GNUNET_PQ_result_spec_array_fixed_size(), GNUNET_PQ_result_spec_array_rel_time(), GNUNET_PQ_result_spec_array_string(), GNUNET_PQ_result_spec_array_timestamp(), GNUNET_PQ_result_spec_array_uint16(), GNUNET_PQ_result_spec_array_uint32(), GNUNET_PQ_result_spec_array_uint64(), GNUNET_PQ_result_spec_array_variable_size(), GNUNET_PQ_run_sql(), load_initial_oids(), manage_subscribe(), prepare_check_patch(), prepare_get_oid_by_name(), progress_cb(), publish_content(), register_notify(), reset_connection(), run(), and scheduler_fd_cb().
|
static |
Definition at line 105 of file gnunet-search.c.
|
static |
Timeout for the search, 0 means to wait for CTRL-C.
Definition at line 110 of file gnunet-search.c.
|
static |
Definition at line 112 of file gnunet-search.c.
Referenced by main(), and progress_cb().
|
static |
Definition at line 114 of file gnunet-search.c.
Referenced by GNUNET_DHT_get_filter_known_results(), progress_cb(), and sqlite_plugin_get_keys().
|
static |
Definition at line 116 of file gnunet-search.c.
|
static |
Definition at line 118 of file gnunet-search.c.
|
static |
Definition at line 120 of file gnunet-search.c.
|
static |
Definition at line 122 of file gnunet-search.c.
Referenced by main(), progress_cb(), and run().
|
static |
Definition at line 124 of file gnunet-search.c.
Referenced by run(), and timeout_task().
|
static |
Definition at line 126 of file gnunet-search.c.
Referenced by progress_cb(), and timeout_task().