GNUnet 0.22.2
gnunet-search.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009, 2022 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
29#include "platform.h"
30#include <ctype.h>
31#include <inttypes.h>
32#include <limits.h>
33
34#include "gnunet_fs_service.h"
35
36
37#define GNUNET_SEARCH_log(kind, ...) \
38 GNUNET_log_from (kind, "gnunet-search", __VA_ARGS__)
39
40
41/* The default settings that we use for the printed output */
42
43#define DEFAULT_DIR_FORMAT "#%n:\ngnunet-download -o \"%f\" -R %u\n\n"
44#define HELP_DEFAULT_DIR_FORMAT "#%n:\\ngnunet-download -o \"%f\" -R %u\\n\\n"
45#define DEFAULT_FILE_FORMAT "#%n:\ngnunet-download -o \"%f\" %u\n\n"
46#define HELP_DEFAULT_FILE_FORMAT "#%n:\\ngnunet-download -o \"%f\" %u\\n\\n"
47#define VERB_DEFAULT_DIR_FORMAT DEFAULT_DIR_FORMAT "%a\n"
48#define VERB_DEFAULT_FILE_FORMAT DEFAULT_FILE_FORMAT "%a\n"
49
50#if HAVE_LIBEXTRACTOR
51#define DEFAULT_META_FORMAT " %t: %p\n"
52#define HELP_DEFAULT_META_FORMAT " %t: %p\\n"
53#define HELP_EXTRACTOR_TEXTADD ", %t"
54#else
55#define DEFAULT_META_FORMAT " MetaType #%i: %p\n"
56#define HELP_DEFAULT_META_FORMAT " MetaType #%i: %p\\n"
57#define HELP_EXTRACTOR_TEXTADD ""
58#endif
59
60#define GENERIC_DIRECTORY_NAME "collection"
61#define GENERIC_FILE_NAME "no-name"
62#define GENERIC_FILE_MIMETYPE "application/octet-stream"
63
64
66{
70};
71
72
74{
75 unsigned int counter;
76 unsigned int flags;
77 int type;
78};
79
80
81static int ret;
82
83static const struct GNUNET_CONFIGURATION_Handle *cfg;
84
85static struct GNUNET_FS_Handle *ctx;
86
88
89static char *output_filename;
90
91static char *format_string_opt;
92
94
96
97static const char *format_string;
98
99static const char *dir_format_string;
100
101static const char *meta_format_string;
102
104
105static unsigned int anonymity = 1;
106
111
112static unsigned int results_limit;
113
114static unsigned int results;
115
116static unsigned int verbose;
117
118static int bookmark_only;
119
120static int local_only;
121
122static int silent_mode;
123
125
126static int stop_searching;
127
128
140static const char *
141print_escape_sequence (const char *const esc)
142{
143 unsigned int probe;
144 const char *cursor = esc + 1;
145 char tmp;
146 switch (*cursor)
147 {
148 /* Trivia */
149 case '\\': putchar ('\\'); return cursor + 1;
150 case 'a': putchar ('\a'); return cursor + 1;
151 case 'b': putchar ('\b'); return cursor + 1;
152 case 'e': putchar ('\x1B'); return cursor + 1;
153 case 'f': putchar ('\f'); return cursor + 1;
154 case 'n': putchar ('\n'); return cursor + 1;
155 case 'r': putchar ('\r'); return cursor + 1;
156 case 't': putchar ('\t'); return cursor + 1;
157 case 'v': putchar ('\v'); return cursor + 1;
158
159 /* Possibly hexadecimal code point */
160 case 'x':
161 probe = 0;
162 while (probe < 256 && isxdigit ((tmp = *++cursor)))
163 probe = (probe << 4) + tmp - (tmp > 96 ? 87 : tmp > 64 ? 55 : 48);
164 goto maybe_codepoint;
165
166 /* Possibly octal code point */
167 case '0': case '1': case '2': case '3':
168 case '4': case '5': case '6': case '7':
169 probe = *cursor++ - 48;
170 do probe = (probe << 3) + *cursor++ - 48;
171 while (probe < 256 && cursor < esc + 4 && *cursor > 47 && *cursor < 56);
172 goto maybe_codepoint;
173
174 /* Boredom */
175 case '\0': putchar ('\\'); return cursor;
176 default: printf ("\\%c", *cursor); return cursor + 1;
177 }
178
179maybe_codepoint:
180 if (probe < 256)
181 putchar (probe);
182 else
183 fwrite (esc, 1, cursor - esc, stdout);
184 return cursor;
185}
186
187
205static int
206item_printer (void *const cls,
207 const char *const plugin_name,
208 const enum EXTRACTOR_MetaType type,
209 const enum EXTRACTOR_MetaFormat format,
210 const char *const data_mime_type,
211 const char *const data,
212 const size_t data_size)
213{
214 const char *cursor;
215 const char *next_spec;
216 const char *next_esc;
217#define info ((struct GNUNET_SEARCH_MetadataPrinterInfo *) cls)
218 if ((format != EXTRACTOR_METAFORMAT_UTF8 &&
219 format != EXTRACTOR_METAFORMAT_C_STRING) ||
221 return 0;
222 info->counter++;
223 if ((info->flags & METADATA_PRINTER_FLAG_HAVE_TYPE) && type != info->type)
224 return 0;
225
226 cursor = meta_format_string;
227 next_spec = strchr (cursor, '%');
228 next_esc = strchr (cursor, '\\');
229
230parse_format:
231
232 /* If an escape sequence exists before the next format specifier... */
233 if (next_esc && (! next_spec || next_esc < next_spec))
234 {
235 if (next_esc > cursor)
236 fwrite (cursor, 1, next_esc - cursor, stdout);
237
238 cursor = print_escape_sequence (next_esc);
239 next_esc = strchr (cursor, '\\');
240 goto parse_format;
241 }
242
243 /* If a format specifier exists before the next escape sequence... */
244 if (next_spec && (! next_esc || next_spec < next_esc))
245 {
246 if (next_spec > cursor)
247 fwrite (cursor, 1, next_spec - cursor, stdout);
248
249 switch (*++next_spec)
250 {
251 case '%': putchar ('%'); break;
252 case 'i': printf ("%d", type); break;
253 case 'l': printf ("%lu", (long unsigned int) data_size); break;
254 case 'n': printf ("%u", info->counter); break;
255 case 'p': printf ("%s", data); break;
256#if HAVE_LIBEXTRACTOR
257 case 't':
258 printf ("%s",
260 EXTRACTOR_metatype_to_string (type)));
261 break;
262#endif
263 case 'w': printf ("%s", plugin_name); break;
264 case '\0': putchar ('%'); return 0;
265 default: printf ("%%%c", *next_spec); break;
266 }
267 cursor = next_spec + 1;
268 next_spec = strchr (cursor, '%');
269 goto parse_format;
270 }
271
272 if (*cursor)
273 printf ("%s", cursor);
274
275 return info->flags & METADATA_PRINTER_FLAG_ONE_RUN;
276#undef info
277}
278
279
291static void
292print_search_result (const char *const filename,
293 const struct GNUNET_FS_Uri *const uri,
294 const struct GNUNET_FS_MetaData *const metadata,
295 const unsigned int resultnum,
296 const int is_directory)
297{
298
299 const char *cursor = GNUNET_YES == is_directory ?
302
303 const char *next_spec = strchr (cursor, '%');
304 const char *next_esc = strchr (cursor, '\\');
305 char *placeholder;
307
308parse_format:
309 /* If an escape sequence exists before the next format specifier... */
310 if (next_esc && (! next_spec || next_esc < next_spec))
311 {
312 if (next_esc > cursor)
313 fwrite (cursor, 1, next_esc - cursor, stdout);
314
315 cursor = print_escape_sequence (next_esc);
316 next_esc = strchr (cursor, '\\');
317 goto parse_format;
318 }
319
320 /* If a format specifier exists before the next escape sequence... */
321 if (next_spec && (! next_esc || next_spec < next_esc))
322 {
323 if (next_spec > cursor)
324 fwrite (cursor, 1, next_spec - cursor, stdout);
325
326 switch (*++next_spec)
327 {
328 /* All metadata fields */
329 case 'a':
331
332iterate_meta:
333 info.counter = 0;
335 break;
336 /* File's name */
337 case 'f':
338 if (GNUNET_YES == is_directory)
339 {
340 printf ("%s%s", filename, GNUNET_FS_DIRECTORY_EXT);
341 break;
342 }
343 printf ("%s", filename);
344 break;
345 /* Only the first metadata field */
346 case 'j':
348 goto iterate_meta;
349 /* File name's length */
350 case 'l':
351 printf ("%lu",
352 (long unsigned int) (GNUNET_YES == is_directory ?
353 strlen (filename)
354 + (sizeof(GNUNET_FS_DIRECTORY_EXT) - 1)
355 :
356 strlen (filename)));
357 break;
358 /* File's mime type */
359 case 'm':
360 if (GNUNET_YES == is_directory)
361 {
362 printf ("%s", GNUNET_FS_DIRECTORY_MIME);
363 break;
364 }
365 placeholder = GNUNET_FS_meta_data_get_by_type (
366 metadata,
367 EXTRACTOR_METATYPE_MIMETYPE);
368 printf ("%s", placeholder ? placeholder : GENERIC_FILE_MIMETYPE);
369 GNUNET_free (placeholder);
370 break;
371 /* Result number */
372 case 'n': printf ("%u", resultnum); break;
373 /* File's size */
374 case 's':
375 printf ("%" PRIu64, GNUNET_FS_uri_chk_get_file_size (uri));
376 break;
377 /* File's URI */
378 case 'u':
379 placeholder = GNUNET_FS_uri_to_string (uri);
380 printf ("%s", placeholder);
381 GNUNET_free (placeholder);
382 break;
383
384 /* We can add as many cases as we want here... */
385
386 /* Handle `%123#a` and `%123#j` (e.g. `%5#j` is a book title) */
387 case '0': case '1': case '2': case '3': case '4':
388 case '5': case '6': case '7': case '8': case '9':
389 cursor = next_spec;
390 info.type = *cursor - 48;
391 while (isdigit (*++cursor) && info.type < (INT_MAX - *cursor + 48) / 10)
392 info.type = info.type * 10 + *cursor - 48;
393 if (info.type == 0 || *cursor != '#')
394 goto not_a_specifier;
395 switch (*++cursor)
396 {
397 /* All metadata fields of type `info.type` */
398 case 'a':
399 next_spec = cursor;
401 goto iterate_meta;
402
403 /* Only the first metadata field of type `info.type` */
404 case 'j':
405 next_spec = cursor;
408 goto iterate_meta;
409 }
410 goto not_a_specifier;
411
412 /* All other cases */
413 case '%': putchar ('%'); break;
414 case '\0': putchar ('%'); return;
415
416not_a_specifier:
417 default: printf ("%%%c", *next_spec); break;
418 }
419 cursor = next_spec + 1;
420 next_spec = strchr (cursor, '%');
421 goto parse_format;
422 }
423
424 if (*cursor)
425 printf ("%s", cursor);
426}
427
428
429static void
430clean_task (void *const cls)
431{
432 size_t dsize;
433 void *ddata;
434
436 ctx = NULL;
437 if (output_filename == NULL)
438 return;
439 if (GNUNET_OK !=
440 GNUNET_FS_directory_builder_finish (db, &dsize, &ddata))
441 {
442 GNUNET_break (0);
444 return;
445 }
447 if (GNUNET_OK !=
449 ddata,
450 dsize,
453 {
455 _ ("Failed to write directory with search results to "
456 "`%s'\n"),
458 }
459 GNUNET_free (ddata);
461}
462
463
477static void *
478progress_cb (void *const cls,
479 const struct GNUNET_FS_ProgressInfo *const info)
480{
481 static unsigned int cnt;
482 int is_directory;
483 char *filename;
484
485 switch (info->status)
486 {
488 break;
489
491 if (stop_searching)
492 break;
493
494 if (db != NULL)
496 db,
497 info->value.search.specifics.result.uri,
498 info->value.search.specifics.result.meta,
499 NULL);
500
501 if (silent_mode)
502 break;
503
504 cnt++;
506 info->value.search.specifics.result.meta,
509 info->value.search.specifics.result.meta);
510 if (NULL != filename)
511 {
512 while ((filename[0] != '\0') && ('/' == filename[strlen (filename) - 1]))
513 filename[strlen (filename) - 1] = '\0';
515 }
518 : is_directory ?
520 :
522 info->value.search.specifics.result.uri,
523 info->value.search.specifics.result.meta,
524 cnt,
525 is_directory);
526 fflush (stdout);
528 results++;
529 if ((results_limit > 0) && (results >= results_limit))
530 {
532 /* otherwise the function might keep printing results for a while... */
534 }
535 break;
536
539 /* ignore */
540 break;
541
544 _ ("Error searching: %s.\n"),
545 info->value.search.specifics.error.message);
547 break;
548
551 break;
552
553 default:
555 _ ("Unexpected status: %d\n"),
556 info->status);
557 break;
558 }
559 return NULL;
560}
561
562
563static void
564shutdown_task (void *const cls)
565{
566 if (sc != NULL)
567 {
569 sc = NULL;
570 }
574}
575
576
577static void
578timeout_task (void *const cls)
579{
580 tt = NULL;
583}
584
585
594static void
595run (void *const cls,
596 char *const *const args,
597 const char *const cfgfile,
598 const struct GNUNET_CONFIGURATION_Handle *const cfgarg)
599{
600 struct GNUNET_FS_Uri *uri;
601 unsigned int argc;
603
605 {
606 fprintf (stderr,
607 _ ("Conflicting options --bookmark-only and --silent.\n"));
608 ret = 1;
609 return;
610 }
612 {
613 fprintf (stderr,
614 _ ("Conflicting options --bookmark-only and --output.\n"));
615 ret = 1;
616 return;
617 }
619 {
620 fprintf (stderr, _ ("An output file is mandatory for silent mode.\n"));
621 ret = 1;
622 return;
623 }
624 if (NULL == dir_format_string_opt)
628 else
630 if (NULL == format_string_opt)
633 else
635 if (NULL == meta_format_string_opt)
637 else
639 argc = 0;
640 while (NULL != args[argc])
641 argc++;
642 uri = GNUNET_FS_uri_ksk_create_from_args (argc, (const char **) args);
643 if (NULL == uri)
644 {
645 fprintf (stderr,
646 "%s",
647 _ ("Could not create keyword URI from arguments.\n"));
648 ret = 1;
649 return;
650 }
652 {
653 fprintf (stderr,
654 "%s",
655 _ ("Invalid URI. Valid URIs for searching are keyword query "
656 "URIs\n(\"gnunet://fs/ksk/...\") and namespace content URIs "
657 "(\"gnunet://fs/sks/...\").\n"));
659 ret = 1;
660 return;
661 }
662 if (bookmark_only)
663 {
664 char *bmstr = GNUNET_FS_uri_to_string (uri);
665 printf ("%s\n", bmstr);
666 GNUNET_free (bmstr);
668 ret = 0;
669 return;
670 }
671 cfg = cfgarg;
673 "gnunet-search",
675 NULL,
678 if (NULL == ctx)
679 {
680 fprintf (stderr, _ ("Could not initialize the `%s` subsystem.\n"), "FS");
682 ret = 1;
683 return;
684 }
685 if (output_filename != NULL)
688 if (local_only)
692 if (NULL == sc)
693 {
694 fprintf (stderr, "%s", _ ("Could not start searching.\n"));
696 ret = 1;
697 return;
698 }
699 if (0 != timeout.rel_value_us)
702}
703
704
712int
713main (int argc, char *const *argv)
714{
717 'a',
718 "anonymity",
719 "LEVEL",
720 gettext_noop ("set the desired LEVEL of receiver-anonymity (default: "
721 "1)"),
722 &anonymity),
724 'b',
725 "bookmark-only",
726 gettext_noop ("do not search, print only the URI that points to this "
727 "search"),
730 'F',
731 "dir-printf",
732 "FORMAT",
733 gettext_noop ("write search results for directories according to "
734 "FORMAT; accepted placeholders are: %a, %f, %j, %l, %m, "
735 "%n, %s; defaults to the value of --printf when omitted "
736 "or to `" HELP_DEFAULT_DIR_FORMAT "` if --printf is "
737 "omitted too"),
740 'f',
741 "printf",
742 "FORMAT",
743 gettext_noop ("write search results according to FORMAT; accepted "
744 "placeholders are: %a, %f, %j, %l, %m, %n, %s; defaults "
745 "to `" HELP_DEFAULT_FILE_FORMAT "` when omitted"),
748 'i',
749 "iter-printf",
750 "FORMAT",
751 gettext_noop ("when the %a or %j placeholders appear in --printf or "
752 "--dir-printf, list each metadata property according to "
753 "FORMAT; accepted placeholders are: %i, %l, %n, %p"
754 HELP_EXTRACTOR_TEXTADD ", %w; defaults to `"
755 HELP_DEFAULT_META_FORMAT "` when omitted"),
758 "results",
759 "VALUE",
760 gettext_noop ("automatically terminate search "
761 "after VALUE results are found"),
764 'n',
765 "no-network",
766 gettext_noop ("only search the local peer (no P2P network search)"),
767 &local_only),
769 'o',
770 "output",
771 "FILENAME",
772 gettext_noop ("create a GNUnet directory with search results at "
773 "FILENAME (e.g. `gnunet-search --output=commons"
774 GNUNET_FS_DIRECTORY_EXT " commons`)"),
777 's',
778 "silent",
779 gettext_noop ("silent mode (requires the --output argument)"),
780 &silent_mode),
782 't',
783 "timeout",
784 "DELAY",
785 gettext_noop ("automatically terminate search after DELAY; the value "
786 "given must be a number followed by a space and a time "
787 "unit, for example \"500 ms\"; without a unit it defaults "
788 "to microseconds - 1000000 = 1 second; if 0 or omitted "
789 "it means to wait for CTRL-C"),
790 &timeout),
792 'V',
793 "verbose",
794 gettext_noop ("be verbose (append \"%a\\n\" to the default --printf and "
795 "--dir-printf arguments - ignored when these are provided "
796 "by the user)"),
797 &verbose),
799
800 if (GNUNET_SYSERR ==
802 argc,
803 argv,
804 "gnunet-search [OPTIONS] KEYWORD1 KEYWORD2 ...",
805 gettext_noop ("Search for files that have been "
806 "published on GNUnet\n"),
807 options,
808 &run,
809 NULL))
810 ret = 1;
811
812 return ret;
813}
814
815
816/* end of gnunet-search.c */
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define INT_MAX
#define gettext_noop(String)
Definition: gettext.h:74
#define dgettext(Domainname, Msgid)
Definition: gettext.h:51
static char * plugin_name
Name of our plugin.
static char * data
The data to insert into the dht.
static char * filename
static uint32_t type
Type string converted to DNS type value.
static size_t data_size
Number of bytes in data.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
#define VERB_DEFAULT_DIR_FORMAT
Definition: gnunet-search.c:47
static const char * meta_format_string
#define info
static const char * dir_format_string
Definition: gnunet-search.c:99
static char * output_filename
Definition: gnunet-search.c:89
#define DEFAULT_META_FORMAT
Definition: gnunet-search.c:55
static unsigned int verbose
#define HELP_DEFAULT_FILE_FORMAT
Definition: gnunet-search.c:46
#define DEFAULT_DIR_FORMAT
Definition: gnunet-search.c:43
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:87
#define HELP_DEFAULT_DIR_FORMAT
Definition: gnunet-search.c:44
static void timeout_task(void *const cls)
#define HELP_DEFAULT_META_FORMAT
Definition: gnunet-search.c:56
static void shutdown_task(void *const cls)
static unsigned int anonymity
#define GENERIC_FILE_NAME
Definition: gnunet-search.c:61
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.
static void clean_task(void *const cls)
static int silent_mode
#define GNUNET_SEARCH_log(kind,...)
Definition: gnunet-search.c:37
static const char * format_string
Definition: gnunet-search.c:97
static const struct GNUNET_CONFIGURATION_Handle * cfg
Definition: gnunet-search.c:83
static int bookmark_only
static int ret
Definition: gnunet-search.c:81
static char * format_string_opt
Definition: gnunet-search.c:91
static char * dir_format_string_opt
Definition: gnunet-search.c:93
static struct GNUNET_SCHEDULER_Task * tt
static unsigned int results
static struct GNUNET_FS_Handle * ctx
Definition: gnunet-search.c:85
GNUNET_SEARCH_MetadataPrinterFlags
Definition: gnunet-search.c:66
@ METADATA_PRINTER_FLAG_HAVE_TYPE
Definition: gnunet-search.c:69
@ METADATA_PRINTER_FLAG_NONE
Definition: gnunet-search.c:67
@ METADATA_PRINTER_FLAG_ONE_RUN
Definition: gnunet-search.c:68
#define GENERIC_FILE_MIMETYPE
Definition: gnunet-search.c:62
static const char * print_escape_sequence(const char *const esc)
Print the escape sequence at the beginning of a string.
static struct GNUNET_TIME_Relative timeout
Timeout for the search, 0 means to wait for CTRL-C.
static int stop_searching
#define DEFAULT_FILE_FORMAT
Definition: gnunet-search.c:45
#define HELP_EXTRACTOR_TEXTADD
Definition: gnunet-search.c:57
static int local_only
static unsigned int results_limit
int main(int argc, char *const *argv)
The main function to search GNUnet.
#define GENERIC_DIRECTORY_NAME
Definition: gnunet-search.c:60
static char * meta_format_string_opt
Definition: gnunet-search.c:95
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.
#define VERB_DEFAULT_FILE_FORMAT
Definition: gnunet-search.c:48
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.
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.
static struct GNUNET_FS_DirectoryBuilder * db
API for file sharing via GNUnet.
void GNUNET_DISK_filename_canonicalize(char *fn)
Removes special characters as ':' from a filename.
Definition: disk.c:1169
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.
Definition: disk.c:722
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
Definition: disk.c:1065
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
GNUNET_FS_SearchOptions
Options for searching.
int GNUNET_FS_directory_builder_finish(struct GNUNET_FS_DirectoryBuilder *bld, size_t *rsize, void **rdata)
Finish building the directory.
Definition: fs_directory.c:578
uint64_t GNUNET_FS_uri_chk_get_file_size(const struct GNUNET_FS_Uri *uri)
What is the size of the file that this URI refers to?
Definition: fs_uri.c:1360
int GNUNET_FS_uri_test_ksk(const struct GNUNET_FS_Uri *uri)
Is this a keyword URI?
Definition: fs_uri.c:1324
#define GNUNET_FS_DIRECTORY_MIME
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:2034
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.
Definition: fs_api.c:3264
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.
Definition: fs_uri.c:1144
void GNUNET_FS_search_stop(struct GNUNET_FS_SearchContext *sc)
Stop search for content.
Definition: fs_search.c:1766
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:677
int GNUNET_FS_uri_test_sks(const struct GNUNET_FS_Uri *uri)
Is this a namespace URI?
Definition: fs_uri.c:1271
struct GNUNET_FS_DirectoryBuilder * GNUNET_FS_directory_builder_create(const struct GNUNET_FS_MetaData *mdir)
Create a directory builder.
Definition: fs_directory.c:366
int GNUNET_FS_meta_data_test_for_directory(const struct GNUNET_FS_MetaData *md)
Does the meta-data claim that this is a directory? Checks if the mime-type is that of a GNUnet direct...
Definition: fs_directory.c:55
#define GNUNET_FS_DIRECTORY_EXT
void GNUNET_FS_stop(struct GNUNET_FS_Handle *h)
Close our connection with the file-sharing service.
Definition: fs_api.c:3330
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.
Definition: fs_search.c:1607
void GNUNET_FS_directory_builder_add(struct GNUNET_FS_DirectoryBuilder *bld, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_MetaData *md, const void *data)
Add an entry to a directory.
Definition: fs_directory.c:392
@ GNUNET_FS_FLAGS_NONE
No special flags set.
@ GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY
Only search the local host, do not search remote systems (no P2P)
@ GNUNET_FS_SEARCH_OPTION_NONE
No options (use defaults for everything).
@ GNUNET_FS_OPTIONS_END
Last option in the VARARG list.
@ GNUNET_FS_STATUS_SEARCH_UPDATE
We have additional data about the quality or availability of a search result.
@ GNUNET_FS_STATUS_SEARCH_ERROR
Signals a problem with this search.
@ GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED
Event generated for each search result when the respective search is stopped.
@ GNUNET_FS_STATUS_SEARCH_RESULT
This search has yielded a result.
@ GNUNET_FS_STATUS_SEARCH_START
First event generated when a client requests a search to begin or when a namespace result automatical...
@ GNUNET_FS_STATUS_SEARCH_STOPPED
Last message from a search; this signals that there will be no further events associated with this se...
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_increment_uint(char shortName, const char *name, const char *description, unsigned int *val)
Increment val each time the option flag is given by one.
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.
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).
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.
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.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_SYSERR
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_free(ptr)
Wrapper around free.
int GNUNET_FS_meta_data_iterate(const struct GNUNET_FS_MetaData *md, EXTRACTOR_MetaDataProcessor iter, void *iter_cls)
Iterate over MD entries.
Definition: meta_data.c:418
char * GNUNET_FS_meta_data_get_by_type(const struct GNUNET_FS_MetaData *md, enum EXTRACTOR_MetaType type)
Get the first MD entry of the given type.
Definition: meta_data.c:438
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, 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,...
Definition: program.c:407
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
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,...
Definition: scheduler.c:1339
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.
Definition: scheduler.c:1304
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.
Definition: scheduler.c:1277
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
#define LIBEXTRACTOR_GETTEXT_DOMAIN
Definition: platform.h:179
Internal state of a directory builder.
Definition: fs_directory.c:342
Master context for most FS operations.
Definition: fs_api.h:1070
Meta data to associate with a file, directory or namespace.
Definition: meta_data.c:92
Argument given to the progress callback with information about what is going on.
Handle for controlling a search.
Definition: fs_api.h:1511
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:167
Definition of a command line option.
Entry in list of pending tasks.
Definition: scheduler.c:136
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.