diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-04-18 14:48:42 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-04-18 14:48:42 +0000 |
commit | e41a408e2bdf2f7f1a3b91769ba6c47e48bb5595 (patch) | |
tree | 8ba97dd04f2ad6ac18c570b839168fae20641620 /src | |
parent | 73703cf9e81d7a705aace4d030bab0befe0c0811 (diff) | |
download | gnunet-e41a408e2bdf2f7f1a3b91769ba6c47e48bb5595.tar.gz gnunet-e41a408e2bdf2f7f1a3b91769ba6c47e48bb5595.zip |
Add filename getopt operator
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_getopt_lib.h | 19 | ||||
-rw-r--r-- | src/util/getopt_helpers.c | 12 |
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 | |||
304 | GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 304 | GNUNET_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 | */ | ||
322 | int | ||
323 | GNUNET_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 | ||
237 | int | ||
238 | GNUNET_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 |