GNUnet  0.16.x
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 
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 
29 #define LOG(kind, ...) GNUNET_log_from (kind, "util-getopt", __VA_ARGS__)
30 
31 
41 static enum GNUNET_GenericReturnValue
43  void *scls,
44  const char *option,
45  const char *value)
46 {
47  const char *version = scls;
48 
49  (void) option;
50  (void) value;
51  printf ("%s v%s\n", ctx->binaryName, version);
52  return GNUNET_NO;
53 }
54 
55 
57 GNUNET_GETOPT_option_version (const char *version)
58 {
59  struct GNUNET_GETOPT_CommandLineOption clo = {
60  .shortName = 'v',
61  .name = "version",
62  .description = gettext_noop (
63  "print the version number"),
64  .option_exclusive = 1,
65  .processor = &print_version,
66  .scls = (void *) version
67  };
68 
69  return clo;
70 }
71 
72 
76 #define BORDER 29
77 
87 static enum GNUNET_GenericReturnValue
89  void *scls,
90  const char *option,
91  const char *value)
92 {
93  const char *about = scls;
94  size_t slen;
95  unsigned int i;
96  int j;
97  size_t ml;
98  size_t p;
99  char *scp;
100  const char *trans;
101  const struct GNUNET_GETOPT_CommandLineOption *opt;
102  const struct GNUNET_OS_ProjectData *pd;
103 
104  (void) option;
105  (void) value;
106  if (NULL != about)
107  {
108  printf ("%s\n%s\n", ctx->binaryOptions, gettext (about));
109  printf (_ (
110  "Arguments mandatory for long options are also mandatory for short options.\n"));
111  }
112  i = 0;
113  opt = ctx->allOptions;
114  while (NULL != opt[i].description)
115  {
116  if (opt[i].shortName == '\0')
117  printf (" ");
118  else
119  printf (" -%c, ", opt[i].shortName);
120  printf ("--%s", opt[i].name);
121  slen = 8 + strlen (opt[i].name);
122  if (NULL != opt[i].argumentHelp)
123  {
124  printf ("=%s", opt[i].argumentHelp);
125  slen += 1 + strlen (opt[i].argumentHelp);
126  }
127  if (slen > BORDER)
128  {
129  printf ("\n%*s", BORDER, "");
130  slen = BORDER;
131  }
132  if (slen < BORDER)
133  {
134  printf ("%*s", (int) (BORDER - slen), "");
135  slen = BORDER;
136  }
137  if (0 < strlen (opt[i].description))
138  trans = gettext (opt[i].description);
139  else
140  trans = "";
141  ml = strlen (trans);
142  p = 0;
143 OUTER:
144  while (ml - p > 78 - slen)
145  {
146  for (j = p + 78 - slen; j > (int) p; j--)
147  {
148  if (isspace ((unsigned char) trans[j]))
149  {
150  scp = GNUNET_malloc (j - p + 1);
151  GNUNET_memcpy (scp, &trans[p], j - p);
152  scp[j - p] = '\0';
153  printf ("%s\n%*s", scp, BORDER + 2, "");
154  GNUNET_free (scp);
155  p = j + 1;
156  slen = BORDER + 2;
157  goto OUTER;
158  }
159  }
160  /* could not find space to break line */
161  scp = GNUNET_malloc (78 - slen + 1);
162  GNUNET_memcpy (scp, &trans[p], 78 - slen);
163  scp[78 - slen] = '\0';
164  printf ("%s\n%*s", scp, BORDER + 2, "");
165  GNUNET_free (scp);
166  slen = BORDER + 2;
167  p = p + 78 - slen;
168  }
169  /* print rest */
170  if (p < ml)
171  printf ("%s\n", &trans[p]);
172  if (strlen (trans) == 0)
173  printf ("\n");
174  i++;
175  }
177  printf ("\n"
178  "Report bugs to %s.\n"
179  "Home page: %s\n",
180  pd->bug_email,
181  pd->homepage);
182 
183  if (0 != pd->is_gnu)
184  printf ("General help using GNU software: http://www.gnu.org/gethelp/\n");
185 
186  return GNUNET_NO;
187 }
188 
189 
191 GNUNET_GETOPT_option_help (const char *about)
192 {
193  struct GNUNET_GETOPT_CommandLineOption clo = {
194  .shortName = 'h',
195  .name = "help",
196  .description = gettext_noop (
197  "print this help"),
198  .option_exclusive = 1,
199  .processor = format_help,
200  .scls = (void *) about
201  };
202 
203  return clo;
204 }
205 
206 
221 static enum GNUNET_GenericReturnValue
223  void *scls,
224  const char *option,
225  const char *value)
226 {
227  unsigned int *val = scls;
228 
229  (void) ctx;
230  (void) option;
231  (void) value;
232  (*val)++;
233  return GNUNET_OK;
234 }
235 
236 
239  const char *name,
240  const char *description,
241  unsigned int *val)
242 {
243  struct GNUNET_GETOPT_CommandLineOption clo = {
244  .shortName = shortName,
245  .name = name,
246  .description = description,
247  .processor = &increment_value,
248  .scls = (void *) val
249  };
250 
251  return clo;
252 }
253 
254 
256 GNUNET_GETOPT_option_verbose (unsigned int *level)
257 {
258  struct GNUNET_GETOPT_CommandLineOption clo = {
259  .shortName = 'V',
260  .name = "verbose",
261  .description =
262  gettext_noop ("be verbose"),
263  .processor = &increment_value,
264  .scls = (void *) level
265  };
266 
267  return clo;
268 }
269 
270 
285 static enum GNUNET_GenericReturnValue
287  void *scls,
288  const char *option,
289  const char *value)
290 {
291  int *val = scls;
292 
293  (void) ctx;
294  (void) option;
295  (void) value;
296  *val = 1;
297  return GNUNET_OK;
298 }
299 
300 
303  const char *name,
304  const char *description,
305  int *val)
306 {
307  struct GNUNET_GETOPT_CommandLineOption clo = {
308  .shortName = shortName,
309  .name = name,
310  .description = description,
311  .processor = &set_one,
312  .scls = (void *) val
313  };
314 
315  return clo;
316 }
317 
318 
333 static enum GNUNET_GenericReturnValue
335  void *scls,
336  const char *option,
337  const char *value)
338 {
339  char **val = scls;
340 
341  (void) ctx;
342  (void) option;
343  GNUNET_assert (NULL != value);
344  GNUNET_free (*val);
345  *val = GNUNET_strdup (value);
346  return GNUNET_OK;
347 }
348 
349 
352  const char *name,
353  const char *argumentHelp,
354  const char *description,
355  char **str)
356 {
357  struct GNUNET_GETOPT_CommandLineOption clo = {
358  .shortName = shortName,
359  .name = name,
360  .argumentHelp = argumentHelp,
361  .description = description,
362  .require_argument = 1,
363  .processor = &set_string,
364  .scls = (void *) str
365  };
366 
367  return clo;
368 }
369 
370 
372 GNUNET_GETOPT_option_loglevel (char **level)
373 {
374  struct GNUNET_GETOPT_CommandLineOption clo = {
375  .shortName = 'L',
376  .name = "log",
377  .argumentHelp = "LOGLEVEL",
378  .description = gettext_noop ("configure logging to use LOGLEVEL"),
379  .require_argument = 1,
380  .processor = &set_string,
381  .scls = (void *) level
382  };
383 
384  return clo;
385 }
386 
387 
399 static enum GNUNET_GenericReturnValue
401  void *scls,
402  const char *option,
403  const char *value)
404 {
405  char **val = scls;
406 
407  (void) ctx;
408  (void) option;
409  GNUNET_assert (NULL != value);
410  GNUNET_free (*val);
412  return GNUNET_OK;
413 }
414 
415 
418  const char *name,
419  const char *argumentHelp,
420  const char *description,
421  char **str)
422 {
423  struct GNUNET_GETOPT_CommandLineOption clo = {
424  .shortName = shortName,
425  .name = name,
426  .argumentHelp = argumentHelp,
427  .description = description,
428  .require_argument = 1,
429  .processor = &set_filename,
430  .scls = (void *) str
431  };
432 
433  return clo;
434 }
435 
436 
438 GNUNET_GETOPT_option_logfile (char **logfn)
439 {
440  struct GNUNET_GETOPT_CommandLineOption clo = {
441  .shortName = 'l',
442  .name = "logfile",
443  .argumentHelp = "FILENAME",
444  .description =
445  gettext_noop ("configure logging to write logs to FILENAME"),
446  .require_argument = 1,
447  .processor = &set_filename,
448  .scls = (void *) logfn
449  };
450 
451  return clo;
452 }
453 
454 
457 {
458  struct GNUNET_GETOPT_CommandLineOption clo = {
459  .shortName = 'c',
460  .name = "config",
461  .argumentHelp = "FILENAME",
462  .description = gettext_noop ("use configuration file FILENAME"),
463  .require_argument = 1,
464  .processor = &set_filename,
465  .scls = (void *) fn
466  };
467 
468  return clo;
469 }
470 
471 
485 static enum GNUNET_GenericReturnValue
487  void *scls,
488  const char *option,
489  const char *value)
490 {
491  unsigned long long *val = scls;
492  char dummy[2];
493 
494  (void) ctx;
495  if (1 != sscanf (value, "%llu%1s", val, dummy))
496  {
497  fprintf (stderr,
498  _ ("You must pass a number to the `%s' option.\n"),
499  option);
500  return GNUNET_SYSERR;
501  }
502  return GNUNET_OK;
503 }
504 
505 
508  const char *name,
509  const char *argumentHelp,
510  const char *description,
511  unsigned long long *val)
512 {
513  struct GNUNET_GETOPT_CommandLineOption clo = {
514  .shortName = shortName,
515  .name = name,
516  .argumentHelp = argumentHelp,
517  .description = description,
518  .require_argument = 1,
519  .processor = &set_ulong,
520  .scls = (void *) val
521  };
522 
523  return clo;
524 }
525 
526 
540 static enum GNUNET_GenericReturnValue
542  void *scls,
543  const char *option,
544  const char *value)
545 {
546  long long delta;
547  long long minus;
548  struct GNUNET_TIME_Relative rt;
549 
550  (void) scls;
551  (void) ctx;
552  while (isspace (value[0]))
553  value++;
554  minus = 1;
555  if (value[0] == '-')
556  {
557  minus = -1;
558  value++;
559  }
560  else if (value[0] == '+')
561  {
562  value++;
563  }
564  if (GNUNET_OK !=
566  &rt))
567  {
568  fprintf (stderr,
569  _ (
570  "You must pass a relative time (optionally with sign) to the `%s' option.\n"),
571  option);
572  return GNUNET_SYSERR;
573  }
574  if (rt.rel_value_us > LLONG_MAX)
575  {
576  fprintf (stderr,
577  _ ("Value given for time travel `%s' option is too big.\n"),
578  option);
579  return GNUNET_SYSERR;
580  }
581  delta = (long long) rt.rel_value_us;
582  delta *= minus;
584  return GNUNET_OK;
585 }
586 
587 
590  const char *name)
591 {
592  struct GNUNET_GETOPT_CommandLineOption clo = {
593  .shortName = shortName,
594  .name = name,
595  .argumentHelp = _ ("[+/-]MICROSECONDS"),
596  .description = _ (
597  "modify system time by given offset (for debugging/testing only)"),
598  .require_argument = 1,
599  .processor = &set_timetravel_time
600  };
601 
602  return clo;
603 }
604 
605 
619 static enum GNUNET_GenericReturnValue
621  void *scls,
622  const char *option,
623  const char *value)
624 {
625  struct GNUNET_TIME_Relative *val = scls;
626 
627  (void) ctx;
629  {
630  fprintf (stderr,
631  _ ("You must pass relative time to the `%s' option.\n"),
632  option);
633  return GNUNET_SYSERR;
634  }
635  return GNUNET_OK;
636 }
637 
638 
641  const char *name,
642  const char *argumentHelp,
643  const char *description,
644  struct GNUNET_TIME_Relative *val)
645 {
646  struct GNUNET_GETOPT_CommandLineOption clo = {
647  .shortName = shortName,
648  .name = name,
649  .argumentHelp = argumentHelp,
650  .description = description,
651  .require_argument = 1,
652  .processor = &set_relative_time,
653  .scls = (void *) val
654  };
655 
656  return clo;
657 }
658 
659 
673 static enum GNUNET_GenericReturnValue
675  void *scls,
676  const char *option,
677  const char *value)
678 {
679  struct GNUNET_TIME_Absolute *val = scls;
680 
681  (void) ctx;
683  {
684  fprintf (stderr,
685  _ ("You must pass absolute time to the `%s' option.\n"),
686  option);
687  return GNUNET_SYSERR;
688  }
689  return GNUNET_OK;
690 }
691 
692 
695  const char *name,
696  const char *argumentHelp,
697  const char *description,
698  struct GNUNET_TIME_Absolute *val)
699 {
700  struct GNUNET_GETOPT_CommandLineOption clo = {
701  .shortName = shortName,
702  .name = name,
703  .argumentHelp = argumentHelp,
704  .description = description,
705  .require_argument = 1,
706  .processor = &set_absolute_time,
707  .scls = (void *) val
708  };
709 
710  return clo;
711 }
712 
713 
727 static enum GNUNET_GenericReturnValue
729  void *scls,
730  const char *option,
731  const char *value)
732 {
733  struct GNUNET_TIME_Timestamp *t = scls;
734  struct GNUNET_TIME_Absolute abs;
735 
736  (void) ctx;
737  if (GNUNET_OK !=
739  &abs))
740  {
741  fprintf (stderr,
742  _ ("You must pass a timestamp to the `%s' option.\n"),
743  option);
744  return GNUNET_SYSERR;
745  }
746  if (0 != abs.abs_value_us % GNUNET_TIME_UNIT_SECONDS.rel_value_us)
747  {
748  fprintf (stderr,
749  _ ("The maximum precision allowed for timestamps is seconds.\n"));
750  return GNUNET_SYSERR;
751  }
752  t->abs_time = abs;
753  return GNUNET_OK;
754 }
755 
756 
759  const char *name,
760  const char *argumentHelp,
761  const char *description,
762  struct GNUNET_TIME_Timestamp *val)
763 {
764  struct GNUNET_GETOPT_CommandLineOption clo = {
765  .shortName = shortName,
766  .name = name,
767  .argumentHelp = argumentHelp,
768  .description = description,
769  .require_argument = 1,
770  .processor = &set_timestamp,
771  .scls = (void *) val
772  };
773 
774  return clo;
775 }
776 
777 
791 static enum GNUNET_GenericReturnValue
793  void *scls,
794  const char *option,
795  const char *value)
796 {
797  unsigned int *val = scls;
798  char dummy[2];
799 
800  (void) ctx;
801  if ('-' == *value)
802  {
803  fprintf (stderr,
804  _ (
805  "Your input for the '%s' option has to be a non negative number\n"),
806  option);
807  return GNUNET_SYSERR;
808  }
809  if (1 != sscanf (value, "%u%1s", val, dummy))
810  {
811  fprintf (stderr,
812  _ ("You must pass a number to the `%s' option.\n"),
813  option);
814  return GNUNET_SYSERR;
815  }
816  return GNUNET_OK;
817 }
818 
819 
822  const char *name,
823  const char *argumentHelp,
824  const char *description,
825  unsigned int *val)
826 {
827  struct GNUNET_GETOPT_CommandLineOption clo = {
828  .shortName = shortName,
829  .name = name,
830  .argumentHelp = argumentHelp,
831  .description = description,
832  .require_argument = 1,
833  .processor = &set_uint,
834  .scls = (void *) val
835  };
836 
837  return clo;
838 }
839 
840 
854 static enum GNUNET_GenericReturnValue
856  void *scls,
857  const char *option,
858  const char *value)
859 {
860  uint16_t *val = scls;
861  unsigned int v;
862  char dummy[2];
863 
864  (void) ctx;
865  if (1 != sscanf (value, "%u%1s", &v, dummy))
866  {
867  fprintf (stderr,
868  _ ("You must pass a number to the `%s' option.\n"),
869  option);
870  return GNUNET_SYSERR;
871  }
872  if (v > UINT16_MAX)
873  {
874  fprintf (stderr,
875  _ ("You must pass a number below %u to the `%s' option.\n"),
876  (unsigned int) UINT16_MAX,
877  option);
878  return GNUNET_SYSERR;
879  }
880  *val = (uint16_t) v;
881  return GNUNET_OK;
882 }
883 
884 
887  const char *name,
888  const char *argumentHelp,
889  const char *description,
890  uint16_t *val)
891 {
892  struct GNUNET_GETOPT_CommandLineOption clo = {
893  .shortName = shortName,
894  .name = name,
895  .argumentHelp = argumentHelp,
896  .description = description,
897  .require_argument = 1,
898  .processor = &set_uint16,
899  .scls = (void *) val
900  };
901 
902  return clo;
903 }
904 
905 
910 {
914  void *val;
915 
919  size_t val_size;
920 };
921 
922 
936 static enum GNUNET_GenericReturnValue
938  void *scls,
939  const char *option,
940  const char *value)
941 {
942  struct Base32Context *bc = scls;
943 
944  (void) ctx;
946  strlen (value),
947  bc->val,
948  bc->val_size))
949  {
950  fprintf (
951  stderr,
952  _ (
953  "Argument `%s' malformed. Expected base32 (Crockford) encoded value.\n"),
954  option);
955  return GNUNET_SYSERR;
956  }
957  return GNUNET_OK;
958 }
959 
960 
967 static void
968 free_bc (void *cls)
969 {
970  GNUNET_free (cls);
971 }
972 
973 
976  const char *name,
977  const char *argumentHelp,
978  const char *description,
979  void *val,
980  size_t val_size)
981 {
982  struct Base32Context *bc = GNUNET_new (struct Base32Context);
983  struct GNUNET_GETOPT_CommandLineOption clo = {
984  .shortName = shortName,
985  .name = name,
986  .argumentHelp = argumentHelp,
987  .description = description,
988  .require_argument = 1,
989  .processor = &set_base32,
990  .cleaner = &free_bc,
991  .scls = (void *) bc
992  };
993 
994  bc->val = val;
995  bc->val_size = val_size;
996  return clo;
997 }
998 
999 
1002 {
1003  opt.option_mandatory = 1;
1004  return opt;
1005 }
1006 
1007 
1010 {
1011  opt.option_exclusive = 1;
1012  return opt;
1013 }
1014 
1015 
1016 /* 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:69
#define gettext(Msgid)
Definition: gettext.h:45
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
static char * value
Value of the record to add/remove.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:37
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
static struct GNUNET_SCHEDULER_Task * t
Main task.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:92
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_NO
Definition: gnunet_common.h:94
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
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_help(const char *about)
Defining the option to print the command line help text (-h option).
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_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_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.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_get(void)
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Definition: strings.c:495
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:789
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:261
#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:48
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:303
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
const char * name
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
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.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Rounded time for timestamps used by GNUnet, in seconds.