aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_getopt_lib.h19
-rw-r--r--src/util/getopt_helpers.c12
2 files changed, 31 insertions, 0 deletions
diff --git a/src/include/gnunet_getopt_lib.h b/src/include/gnunet_getopt_lib.h
index a22b3f3d3..ce54674d8 100644
--- a/src/include/gnunet_getopt_lib.h
+++ b/src/include/gnunet_getopt_lib.h
@@ -304,6 +304,25 @@ int
304GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 304GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
305 void *scls, const char *option, const char *value); 305 void *scls, const char *option, const char *value);
306 306
307
308/**
309 * Set an option of type 'char *' from the command line doing fs expansion.
310 * A pointer to this function should be passed as part of the
311 * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
312 * of this type. It should be followed by a pointer to a value of
313 * type 'char *', which will be allocated with the requested string.
314 *
315 * @param ctx command line processing context
316 * @param scls additional closure (will point to the 'char *',
317 * which will be allocated)
318 * @param option name of the option
319 * @param value actual value of the option (a string)
320 * @return GNUNET_OK
321 */
322int
323GNUNET_GETOPT_set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
324 void *scls, const char *option, const char *value);
325
307/** 326/**
308 * Set an option of type 'unsigned int' from the command line. Each 327 * Set an option of type 'unsigned int' from the command line. Each
309 * time the option flag is given, the value is incremented by one. 328 * time the option flag is given, the value is incremented by one.
diff --git a/src/util/getopt_helpers.c b/src/util/getopt_helpers.c
index 5940c3ff9..f0f96d0d9 100644
--- a/src/util/getopt_helpers.c
+++ b/src/util/getopt_helpers.c
@@ -234,6 +234,18 @@ GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
234} 234}
235 235
236 236
237int
238GNUNET_GETOPT_set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
239 void *scls, const char *option, const char *value)
240{
241 char **val = scls;
242
243 GNUNET_assert (value != NULL);
244 GNUNET_free_non_null (*val);
245 *val = GNUNET_STRINGS_filename_expand (value);
246 return GNUNET_OK;
247}
248
237/** 249/**
238 * Set an option of type 'unsigned long long' from the command line. 250 * Set an option of type 'unsigned long long' from the command line.
239 * A pointer to this function should be passed as part of the 251 * A pointer to this function should be passed as part of the