GNUnet 0.22.2
getopt_helpers.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet
3 Copyright (C) 2006, 2011, 2020 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 */
20
27#include "platform.h"
28#include "gnunet_util_lib.h"
29
30#define LOG(kind, ...) GNUNET_log_from (kind, "util-getopt", __VA_ARGS__)
31
32
44 void *scls,
45 const char *option,
46 const char *value)
47{
48 const char *version = scls;
49
50 (void) option;
51 (void) value;
52 printf ("%s v%s\n",
53 ctx->binaryName,
54 version);
55 return GNUNET_NO;
56}
57
58
60GNUNET_GETOPT_option_version (const char *version)
61{
63 .shortName = 'v',
64 .name = "version",
65 .description = gettext_noop (
66 "print the version number"),
67 .option_exclusive = 1,
68 .processor = &print_version,
69 .scls = (void *) version
70 };
71
72 return clo;
73}
74
75
79#define BORDER 29
80
92 void *scls,
93 const char *option,
94 const char *value)
95{
96 const struct GNUNET_OS_ProjectData *pd = scls;
97 const char *about = NULL;
98 size_t slen;
99 unsigned int i;
100 int j;
101 size_t ml;
102 size_t p;
103 char *scp;
104 const char *trans;
105 const struct GNUNET_GETOPT_CommandLineOption *opt;
106
107 (void) option;
108 (void) value;
109 opt = ctx->allOptions;
110 for (i=0; NULL != opt[i].description; i++)
111 {
112 /* we hacked the about argument into our own argumentHelp! */
113 if ('h' == opt[i].shortName)
114 about = opt[i].argumentHelp;
115 }
116 if (NULL != about)
117 {
118 printf ("%s\n%s\n",
119 ctx->binaryOptions,
120 gettext (about));
121 printf (_ (
122 "Arguments mandatory for long options are also mandatory for short options.\n"));
123 }
124 for (i=0; NULL != opt[i].description; i++)
125 {
126 if (opt[i].shortName == '\0')
127 printf (" ");
128 else
129 printf (" -%c, ", opt[i].shortName);
130 printf ("--%s", opt[i].name);
131 slen = 8 + strlen (opt[i].name);
132 if ( (NULL != opt[i].argumentHelp) &&
133 ('h' != opt[i].shortName) )
134 {
135 printf ("=%s", opt[i].argumentHelp);
136 slen += 1 + strlen (opt[i].argumentHelp);
137 }
138 if (slen > BORDER)
139 {
140 printf ("\n%*s", BORDER, "");
141 slen = BORDER;
142 }
143 if (slen < BORDER)
144 {
145 printf ("%*s", (int) (BORDER - slen), "");
146 slen = BORDER;
147 }
148 if (0 < strlen (opt[i].description))
149 trans = gettext (opt[i].description);
150 else
151 trans = "";
152 ml = strlen (trans);
153 p = 0;
154OUTER:
155 while (ml - p > 78 - slen)
156 {
157 for (j = p + 78 - slen; j > (int) p; j--)
158 {
159 if (isspace ((unsigned char) trans[j]))
160 {
161 scp = GNUNET_malloc (j - p + 1);
162 GNUNET_memcpy (scp, &trans[p], j - p);
163 scp[j - p] = '\0';
164 printf ("%s\n%*s", scp, BORDER + 2, "");
165 GNUNET_free (scp);
166 p = j + 1;
167 slen = BORDER + 2;
168 goto OUTER;
169 }
170 }
171 /* could not find space to break line */
172 scp = GNUNET_malloc (78 - slen + 1);
173 GNUNET_memcpy (scp, &trans[p], 78 - slen);
174 scp[78 - slen] = '\0';
175 printf ("%s\n%*s", scp, BORDER + 2, "");
176 GNUNET_free (scp);
177 slen = BORDER + 2;
178 p = p + 78 - slen;
179 }
180 /* print rest */
181 if (p < ml)
182 printf ("%s\n", &trans[p]);
183 if (strlen (trans) == 0)
184 printf ("\n");
185 }
186 printf ("\n"
187 "Report bugs to %s.\n"
188 "Home page: %s\n",
189 pd->bug_email,
190 pd->homepage);
191
192 if (0 != pd->is_gnu)
193 printf ("General help using GNU software: http://www.gnu.org/gethelp/\n");
194
195 return GNUNET_NO;
196}
197
198
201 const char *about)
202{
204 .shortName = 'h',
205 .name = "help",
206 .argumentHelp = about,
207 .description = gettext_noop (
208 "print this help"),
209 .option_exclusive = 1,
210 .processor = &format_help,
211 .scls = (void *) pd,
212 };
213
214 return clo;
215}
216
217
234 void *scls,
235 const char *option,
236 const char *value)
237{
238 unsigned int *val = scls;
239
240 (void) ctx;
241 (void) option;
242 (void) value;
243 (*val)++;
244 return GNUNET_OK;
245}
246
247
250 const char *name,
251 const char *description,
252 unsigned int *val)
253{
256 .name = name,
257 .description = description,
258 .processor = &increment_value,
259 .scls = (void *) val
260 };
261
262 return clo;
263}
264
265
268{
270 .shortName = 'V',
271 .name = "verbose",
272 .description =
273 gettext_noop ("be verbose"),
274 .processor = &increment_value,
275 .scls = (void *) level
276 };
277
278 return clo;
279}
280
281
298 void *scls,
299 const char *option,
300 const char *value)
301{
302 int *val = scls;
303
304 (void) ctx;
305 (void) option;
306 (void) value;
307 *val = 1;
308 return GNUNET_OK;
309}
310
311
314 const char *name,
315 const char *description,
316 int *val)
317{
320 .name = name,
321 .description = description,
322 .processor = &set_one,
323 .scls = (void *) val
324 };
325
326 return clo;
327}
328
329
346 void *scls,
347 const char *option,
348 const char *value)
349{
350 char **val = scls;
351
352 (void) ctx;
353 (void) option;
354 GNUNET_assert (NULL != value);
355 GNUNET_free (*val);
356 *val = GNUNET_strdup (value);
357 return GNUNET_OK;
358}
359
360
363 const char *name,
364 const char *argumentHelp,
365 const char *description,
366 char **str)
367{
370 .name = name,
371 .argumentHelp = argumentHelp,
372 .description = description,
373 .require_argument = 1,
374 .processor = &set_string,
375 .scls = (void *) str
376 };
377
378 return clo;
379}
380
381
384{
386 .shortName = 'L',
387 .name = "log",
388 .argumentHelp = "LOGLEVEL",
389 .description = gettext_noop ("configure logging to use LOGLEVEL"),
390 .require_argument = 1,
391 .processor = &set_string,
392 .scls = (void *) level
393 };
394
395 return clo;
396}
397
398
412 void *scls,
413 const char *option,
414 const char *value)
415{
416 char **val = scls;
417
418 (void) ctx;
419 (void) option;
420 GNUNET_assert (NULL != value);
421 GNUNET_free (*val);
423 return GNUNET_OK;
424}
425
426
429 const char *name,
430 const char *argumentHelp,
431 const char *description,
432 char **str)
433{
436 .name = name,
437 .argumentHelp = argumentHelp,
438 .description = description,
439 .require_argument = 1,
440 .processor = &set_filename,
441 .scls = (void *) str
442 };
443
444 return clo;
445}
446
447
450{
452 .shortName = 'l',
453 .name = "logfile",
454 .argumentHelp = "FILENAME",
455 .description =
456 gettext_noop ("configure logging to write logs to FILENAME"),
457 .require_argument = 1,
458 .processor = &set_filename,
459 .scls = (void *) logfn
460 };
461
462 return clo;
463}
464
465
468{
470 .shortName = 'c',
471 .name = "config",
472 .argumentHelp = "FILENAME",
473 .description = gettext_noop ("use configuration file FILENAME"),
474 .require_argument = 1,
475 .processor = &set_filename,
476 .scls = (void *) fn
477 };
478
479 return clo;
480}
481
482
498 void *scls,
499 const char *option,
500 const char *value)
501{
502 unsigned long long *val = scls;
503 char dummy[2];
504
505 (void) ctx;
506 if (1 != sscanf (value, "%llu%1s", val, dummy))
507 {
508 fprintf (stderr,
509 _ ("You must pass a number to the `%s' option.\n"),
510 option);
511 return GNUNET_SYSERR;
512 }
513 return GNUNET_OK;
514}
515
516
519 const char *name,
520 const char *argumentHelp,
521 const char *description,
522 unsigned long long *val)
523{
526 .name = name,
527 .argumentHelp = argumentHelp,
528 .description = description,
529 .require_argument = 1,
530 .processor = &set_ulong,
531 .scls = (void *) val
532 };
533
534 return clo;
535}
536
537
553 void *scls,
554 const char *option,
555 const char *value)
556{
557 long long delta;
558 long long minus;
559 struct GNUNET_TIME_Relative rt;
560
561 (void) scls;
562 (void) ctx;
563 while (isspace (value[0]))
564 value++;
565 minus = 1;
566 if (value[0] == '-')
567 {
568 minus = -1;
569 value++;
570 }
571 else if (value[0] == '+')
572 {
573 value++;
574 }
575 if (GNUNET_OK !=
577 &rt))
578 {
579 fprintf (stderr,
580 _ (
581 "You must pass a relative time (optionally with sign) to the `%s' option.\n"),
582 option);
583 return GNUNET_SYSERR;
584 }
585 if (rt.rel_value_us > LLONG_MAX)
586 {
587 fprintf (stderr,
588 _ ("Value given for time travel `%s' option is too big.\n"),
589 option);
590 return GNUNET_SYSERR;
591 }
592 delta = (long long) rt.rel_value_us;
593 delta *= minus;
595 return GNUNET_OK;
596}
597
598
601 const char *name)
602{
605 .name = name,
606 .argumentHelp = _ ("[+/-]MICROSECONDS"),
607 .description = _ (
608 "modify system time by given offset (for debugging/testing only)"),
609 .require_argument = 1,
610 .processor = &set_timetravel_time
611 };
612
613 return clo;
614}
615
616
632 void *scls,
633 const char *option,
634 const char *value)
635{
636 struct GNUNET_TIME_Relative *val = scls;
637
638 (void) ctx;
640 {
641 fprintf (stderr,
642 _ ("You must pass relative time to the `%s' option.\n"),
643 option);
644 return GNUNET_SYSERR;
645 }
646 return GNUNET_OK;
647}
648
649
652 const char *name,
653 const char *argumentHelp,
654 const char *description,
655 struct GNUNET_TIME_Relative *val)
656{
659 .name = name,
660 .argumentHelp = argumentHelp,
661 .description = description,
662 .require_argument = 1,
663 .processor = &set_relative_time,
664 .scls = (void *) val
665 };
666
667 return clo;
668}
669
670
686 void *scls,
687 const char *option,
688 const char *value)
689{
690 struct GNUNET_TIME_Absolute *val = scls;
691
692 (void) ctx;
694 {
695 fprintf (stderr,
696 _ ("You must pass absolute time to the `%s' option.\n"),
697 option);
698 return GNUNET_SYSERR;
699 }
700 return GNUNET_OK;
701}
702
703
706 const char *name,
707 const char *argumentHelp,
708 const char *description,
709 struct GNUNET_TIME_Absolute *val)
710{
713 .name = name,
714 .argumentHelp = argumentHelp,
715 .description = description,
716 .require_argument = 1,
717 .processor = &set_absolute_time,
718 .scls = (void *) val
719 };
720
721 return clo;
722}
723
724
740 void *scls,
741 const char *option,
742 const char *value)
743{
744 struct GNUNET_TIME_Timestamp *t = scls;
745 struct GNUNET_TIME_Absolute abs;
746
747 (void) ctx;
748 if (GNUNET_OK !=
750 &abs))
751 {
752 fprintf (stderr,
753 _ ("You must pass a timestamp to the `%s' option.\n"),
754 option);
755 return GNUNET_SYSERR;
756 }
757 if (0 != abs.abs_value_us % GNUNET_TIME_UNIT_SECONDS.rel_value_us)
758 {
759 fprintf (stderr,
760 _ ("The maximum precision allowed for timestamps is seconds.\n"));
761 return GNUNET_SYSERR;
762 }
763 t->abs_time = abs;
764 return GNUNET_OK;
765}
766
767
770 const char *name,
771 const char *argumentHelp,
772 const char *description,
773 struct GNUNET_TIME_Timestamp *val)
774{
777 .name = name,
778 .argumentHelp = argumentHelp,
779 .description = description,
780 .require_argument = 1,
781 .processor = &set_timestamp,
782 .scls = (void *) val
783 };
784
785 return clo;
786}
787
788
804 void *scls,
805 const char *option,
806 const char *value)
807{
808 unsigned int *val = scls;
809 char dummy[2];
810
811 (void) ctx;
812 if ('-' == *value)
813 {
814 fprintf (stderr,
815 _ (
816 "Your input for the '%s' option has to be a non negative number\n"),
817 option);
818 return GNUNET_SYSERR;
819 }
820 if (1 != sscanf (value, "%u%1s", val, dummy))
821 {
822 fprintf (stderr,
823 _ ("You must pass a number to the `%s' option.\n"),
824 option);
825 return GNUNET_SYSERR;
826 }
827 return GNUNET_OK;
828}
829
830
833 const char *name,
834 const char *argumentHelp,
835 const char *description,
836 unsigned int *val)
837{
840 .name = name,
841 .argumentHelp = argumentHelp,
842 .description = description,
843 .require_argument = 1,
844 .processor = &set_uint,
845 .scls = (void *) val
846 };
847
848 return clo;
849}
850
851
867 void *scls,
868 const char *option,
869 const char *value)
870{
871 uint16_t *val = scls;
872 unsigned int v;
873 char dummy[2];
874
875 (void) ctx;
876 if (1 != sscanf (value, "%u%1s", &v, dummy))
877 {
878 fprintf (stderr,
879 _ ("You must pass a number to the `%s' option.\n"),
880 option);
881 return GNUNET_SYSERR;
882 }
883 if (v > UINT16_MAX)
884 {
885 fprintf (stderr,
886 _ ("You must pass a number below %u to the `%s' option.\n"),
887 (unsigned int) UINT16_MAX,
888 option);
889 return GNUNET_SYSERR;
890 }
891 *val = (uint16_t) v;
892 return GNUNET_OK;
893}
894
895
898 const char *name,
899 const char *argumentHelp,
900 const char *description,
901 uint16_t *val)
902{
905 .name = name,
906 .argumentHelp = argumentHelp,
907 .description = description,
908 .require_argument = 1,
909 .processor = &set_uint16,
910 .scls = (void *) val
911 };
912
913 return clo;
914}
915
916
921{
925 void *val;
926
930 size_t val_size;
931};
932
933
949 void *scls,
950 const char *option,
951 const char *value)
952{
953 struct Base32Context *bc = scls;
954
955 (void) ctx;
957 strlen (value),
958 bc->val,
959 bc->val_size))
960 {
961 fprintf (
962 stderr,
963 _ (
964 "Argument `%s' malformed. Expected base32 (Crockford) encoded value.\n")
965 ,
966 option);
967 return GNUNET_SYSERR;
968 }
969 return GNUNET_OK;
970}
971
972
979static void
980free_bc (void *cls)
981{
982 GNUNET_free (cls);
983}
984
985
988 const char *name,
989 const char *argumentHelp,
990 const char *description,
991 void *val,
992 size_t val_size)
993{
994 struct Base32Context *bc = GNUNET_new (struct Base32Context);
997 .name = name,
998 .argumentHelp = argumentHelp,
999 .description = description,
1000 .require_argument = 1,
1001 .processor = &set_base32,
1002 .cleaner = &free_bc,
1003 .scls = (void *) bc
1004 };
1005
1006 bc->val = val;
1007 bc->val_size = val_size;
1008 return clo;
1009}
1010
1011
1014{
1015 opt.option_mandatory = 1;
1016 return opt;
1017}
1018
1019
1022{
1023 opt.option_exclusive = 1;
1024 return opt;
1025}
1026
1027
1028/* end of getopt_helpers.c */
static enum GNUNET_GenericReturnValue set_absolute_time(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Set an option of type 'struct GNUNET_TIME_Absolute' from the command line.
static enum GNUNET_GenericReturnValue set_uint16(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Set an option of type 'uint16_t' from the command line.
static enum GNUNET_GenericReturnValue set_ulong(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Set an option of type 'unsigned long long' from the command line.
static enum GNUNET_GenericReturnValue set_one(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Set an option of type 'int' from the command line to 1 if the given option is present.
static enum GNUNET_GenericReturnValue set_filename(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Set an option of type 'char *' from the command line with filename expansion a la GNUNET_STRINGS_file...
static enum GNUNET_GenericReturnValue set_timestamp(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Set an option of type 'struct GNUNET_TIME_Timestamp' from the command line.
static enum GNUNET_GenericReturnValue set_uint(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Set an option of type 'unsigned int' from the command line.
#define BORDER
At what offset does the help text start?
static enum GNUNET_GenericReturnValue set_relative_time(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Set an option of type 'struct GNUNET_TIME_Relative' from the command line.
static enum GNUNET_GenericReturnValue format_help(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Print out details on command line options (implements –help).
static enum GNUNET_GenericReturnValue set_base32(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Set an option of type 'unsigned int' from the command line.
static enum GNUNET_GenericReturnValue print_version(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Print out program version (implements –version).
static enum GNUNET_GenericReturnValue set_string(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Set an option of type 'char *' from the command line.
static enum GNUNET_GenericReturnValue increment_value(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Set an option of type 'unsigned int' from the command line.
static void free_bc(void *cls)
Helper function to clean up after GNUNET_GETOPT_option_base32_fixed_size.
static enum GNUNET_GenericReturnValue set_timetravel_time(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Set an option of type 'struct GNUNET_TIME_Relative' from the command line.
#define gettext_noop(String)
Definition: gettext.h:74
#define gettext(Msgid)
Definition: gettext.h:50
static struct GNUNET_FS_Handle * ctx
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
static char * name
Name (label) of the records to list.
static char * value
Value of the record to add/remove.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:38
static struct GNUNET_SCHEDULER_Task * t
Main task.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_timestamp(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Timestamp *val)
Allow user to specify a struct GNUNET_TIME_Timestamp (using human-readable "fancy" time).
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_cfgfile(char **fn)
Allow user to specify configuration file name (-c option)
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_logfile(char **logfn)
Allow user to specify log file name (-l option)
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_filename(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a filename (automatically path expanded).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_exclusive(struct GNUNET_GETOPT_CommandLineOption opt)
Make the given option mutually exclusive with other options.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_mandatory(struct GNUNET_GETOPT_CommandLineOption opt)
Make the given option mandatory.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_timetravel(char shortName, const char *name)
Allow user to specify a long long with an offset to add to the current system time to construct the t...
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_base32_fixed_size(char shortName, const char *name, const char *argumentHelp, const char *description, void *val, size_t val_size)
Allow user to specify a binary value using Crockford Base32 encoding.
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_help(const struct GNUNET_OS_ProjectData *pd, const char *about)
Defining the option to print the command line help text (-h option).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_absolute_time(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Absolute *val)
Allow user to specify a struct GNUNET_TIME_Absolute (using human-readable "fancy" time).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_loglevel(char **level)
Define the '-L' log level option.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_ulong(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned long long *val)
Allow user to specify an unsigned long long.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the '-V' verbosity option.
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.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint16(char shortName, const char *name, const char *argumentHelp, const char *description, uint16_t *val)
Allow user to specify an uint16_t.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_version(const char *version)
Define the option to print the version of the application (-v option)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_OK
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Definition: strings.c:504
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:812
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_relative(const char *fancy_time, struct GNUNET_TIME_Relative *rtime)
Convert a given fancy human-readable time to our internal representation.
Definition: strings.c:259
#define GNUNET_TIME_UNIT_SECONDS
One second.
void GNUNET_TIME_set_offset(long long offset)
Set the timestamp offset for this instance.
Definition: time.c:49
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_absolute(const char *fancy_time, struct GNUNET_TIME_Absolute *atime)
Convert a given fancy human-readable time to our internal representation.
Definition: strings.c:301
#define _(String)
GNU gettext support macro.
Definition: platform.h:179
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:36
Closure for set_base32().
void * val
Value to initialize (already allocated)
size_t val_size
Number of bytes expected for val.
Definition of a command line option.
const char * description
Help text for the option (description)
const char * argumentHelp
Name of the argument for the user in help text.
int option_exclusive
Is the option exclusive?
int option_mandatory
Is the presence of this option mandatory?
void * scls
Specific closure to pass to the processor.
const char shortName
Short name of the option.
General context for command line processors.
Project-specific data used to help the OS subsystem find installation paths.
const char * bug_email
E-mail address for reporting bugs.
int is_gnu
Non-zero means this project is part of GNU.
const char * homepage
Project homepage.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Time for timestamps used by GNUnet, in microseconds rounded to seconds.