83 const char *data_mime_type,
93 printf (
"\t%20s: %s\n",
95 EXTRACTOR_metatype_to_string (type)),
98 printf (
"\t%20d: %s\n", type, data);
130 _ (
"Failed to write directory with search results to `%s'\n"),
154 static unsigned int cnt;
171 printf (
"#%u:\n", ++cnt);
177 if (NULL != filename)
179 while ((filename[0] !=
'\0') && (
'/' == filename[strlen (filename) - 1]))
180 filename[strlen (filename) - 1] =
'\0';
183 printf (
"gnunet-download -o \"%s%s\" -R %s\n",
188 printf (
"gnunet-download -o \"%s\" %s\n", filename, uri);
191 printf (
"gnunet-download -o \"collection%s\" -R %s\n",
195 printf (
"gnunet-download %s\n", uri);
219 _ (
"Error searching: %s.\n"),
229 fprintf (stderr,
_ (
"Unexpected status: %d\n"), info->
status);
274 while (NULL != args[argc])
281 _ (
"Could not create keyword URI from arguments.\n"));
294 fprintf (stderr,
_ (
"Could not initialize `%s' subsystem.\n"),
"FS");
308 fprintf (stderr,
"%s",
_ (
"Could not start searching.\n"));
327 main (
int argc,
char *
const *argv)
334 "set the desired LEVEL of receiver-anonymity"),
339 gettext_noop (
"only search the local peer (no P2P network search)"),
345 gettext_noop (
"write search results to file starting with PREFIX"),
351 gettext_noop (
"automatically terminate search after DELAY"),
358 "after VALUE results are found"),
369 "gnunet-search [OPTIONS] KEYWORD",
371 "Search GNUnet for files that were published on GNUnet"),
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_relative_time(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Relative *val)
Allow user to specify a struct GNUNET_TIME_Relative (using human-readable "fancy" time)...
int GNUNET_FS_directory_builder_finish(struct GNUNET_FS_DirectoryBuilder *bld, size_t *rsize, void **rdata)
Finish building the directory.
No options (use defaults for everything).
EXTRACTOR_MetaFormat
Format in which the extracted meta data is presented.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
uint64_t rel_value_us
The actual value.
This search has yielded a result.
Last message from a search; this signals that there will be no further events associated with this se...
struct GNUNET_FS_Uri * GNUNET_FS_uri_ksk_create_from_args(unsigned int argc, const char **argv)
Create an FS URI from a user-supplied command line of keywords.
struct GNUNET_GETOPT_CommandLineOption options[]
static void clean_task(void *cls)
Event generated for each search result when the respective search is stopped.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Master context for most FS operations.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the '-V' verbosity option.
static void shutdown_task(void *cls)
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
static size_t data_size
Number of bytes in data.
GNUNET_FS_SearchOptions
Options for searching.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run by the scheduler.
Last option in the VARARG list.
static struct GNUNET_SCHEDULER_Task * tt
First event generated when a client requests a search to begin or when a namespace result automatical...
Internal state of a directory builder.
0-terminated, UTF-8 encoded string.
Definition of a command line option.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
EXTRACTOR_MetaType
Enumeration defining various sources of keywords.
void GNUNET_FS_stop(struct GNUNET_FS_Handle *h)
Close our connection with the file-sharing service.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static unsigned int verbose
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_FS_Handle * GNUNET_FS_start(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *client_name, GNUNET_FS_ProgressCallback upcb, void *upcb_cls, enum GNUNET_FS_Flags flags,...)
Setup a connection to the file-sharing service.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
void GNUNET_FS_directory_builder_add(struct GNUNET_FS_DirectoryBuilder *bld, const struct GNUNET_FS_Uri *uri, const struct GNUNET_CONTAINER_MetaData *md, const void *data)
Add an entry to a directory.
union GNUNET_FS_ProgressInfo::@25 value
Values that depend on the event type.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
static void * progress_cb(void *cls, const struct GNUNET_FS_ProgressInfo *info)
Called by FS client to give information about the progress of an operation.
static const struct GNUNET_CONFIGURATION_Handle * cfg
#define GNUNET_FS_DIRECTORY_EXT
#define dgettext(Domainname, Msgid)
static int item_printer(void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format, const char *data_mime_type, const char *data, size_t data_size)
Type of a function that libextractor calls for each meta data item found.
struct GNUNET_FS_ProgressInfo::@25::@28 search
Values for all "GNUNET_FS_STATUS_SEARCH_*" events.
int main(int argc, char *const *argv)
The main function to search GNUnet.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
enum GNUNET_FS_Status status
Specific status code (determines the event type).
struct GNUNET_FS_SearchContext * GNUNET_FS_search_start(struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, uint32_t anonymity, enum GNUNET_FS_SearchOptions options, void *cctx)
Start search for content.
static struct GNUNET_TIME_Relative timeout
Timeout for the search, 0 means to wait for CTRL-C.
static char * output_filename
static unsigned int anonymity
static void timeout_task(void *cls)
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
#define GNUNET_free_nz(ptr)
Wrapper around free.
static struct GNUNET_FS_SearchContext * sc
int GNUNET_FS_meta_data_test_for_directory(const struct GNUNET_CONTAINER_MetaData *md)
Does the meta-data claim that this is a directory? Checks if the mime-type is that of a GNUnet direct...
enum GNUNET_GenericReturnValue GNUNET_DISK_fn_write(const char *fn, const void *buf, size_t buf_size, enum GNUNET_DISK_AccessPermissions mode)
Write a buffer to a file atomically.
static struct GNUNET_FS_DirectoryBuilder * db
static struct GNUNET_FS_Handle * ctx
A Universal Resource Identifier (URI), opaque.
Handle for controlling a search.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
static unsigned int results
Entry in list of pending tasks.
Only search the local host, do not search remote systems (no P2P)
Signals a problem with this search.
We have additional data about the quality or availability of a search result.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
static unsigned int results_limit
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
uint32_t data
The data value.
struct GNUNET_FS_DirectoryBuilder * GNUNET_FS_directory_builder_create(const struct GNUNET_CONTAINER_MetaData *mdir)
Create a directory builder.
static char * plugin_name
Name of our plugin.
void GNUNET_FS_search_stop(struct GNUNET_FS_SearchContext *sc)
Stop search for content.
void GNUNET_DISK_filename_canonicalize(char *fn)
Removes special characters as ':' from a filename.
#define GNUNET_free(ptr)
Wrapper around free.
Argument given to the progress callback with information about what is going on.
Time for relative time used by GNUnet, in microseconds.
#define gettext_noop(String)