aboutsummaryrefslogtreecommitdiff
path: root/src/util/getopt_helpers.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-01-24 13:22:43 +0000
committerChristian Grothoff <christian@grothoff.org>2011-01-24 13:22:43 +0000
commitd9408bf11420e74e8defd6e26d4aa178632eefe9 (patch)
treeda38a61a9b73ea3869f36812608e465ff901403e /src/util/getopt_helpers.c
parentc45ae3089f9c7dfd619cf978726a6be5c317c47d (diff)
downloadgnunet-d9408bf11420e74e8defd6e26d4aa178632eefe9.tar.gz
gnunet-d9408bf11420e74e8defd6e26d4aa178632eefe9.zip
docu
Diffstat (limited to 'src/util/getopt_helpers.c')
-rw-r--r--src/util/getopt_helpers.c91
1 files changed, 90 insertions, 1 deletions
diff --git a/src/util/getopt_helpers.c b/src/util/getopt_helpers.c
index 5c4486b41..d74f6ec9f 100644
--- a/src/util/getopt_helpers.c
+++ b/src/util/getopt_helpers.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 (C) 2006 Christian Grothoff (and other contributing authors) 3 (C) 2006, 2011 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -29,6 +29,15 @@
29#include "gnunet_getopt_lib.h" 29#include "gnunet_getopt_lib.h"
30 30
31 31
32/**
33 * Print out program version (implements --version).
34 *
35 * @param ctx command line processing context
36 * @param scls additional closure (points to version string)
37 * @param option name of the option
38 * @param value not used (NULL)
39 * @return GNUNET_SYSERR (do not continue)
40 */
32int 41int
33GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorContext 42GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorContext
34 *ctx, void *scls, const char *option, 43 *ctx, void *scls, const char *option,
@@ -44,6 +53,15 @@ GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorContext
44 53
45#define BORDER 29 54#define BORDER 29
46 55
56/**
57 * Print out details on command line options (implements --help).
58 *
59 * @param ctx command line processing context
60 * @param scls additional closure (points to about text)
61 * @param option name of the option
62 * @param value not used (NULL)
63 * @return GNUNET_SYSERR (do not continue)
64 */
47int 65int
48GNUNET_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContext 66GNUNET_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContext
49 *ctx, void *scls, const char *option, 67 *ctx, void *scls, const char *option,
@@ -133,6 +151,20 @@ GNUNET_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContext
133} 151}
134 152
135 153
154/**
155 * Set an option of type 'unsigned int' from the command line. Each
156 * time the option flag is given, the value is incremented by one.
157 * A pointer to this function should be passed as part of the
158 * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
159 * of this type. It should be followed by a pointer to a value of
160 * type 'int'.
161 *
162 * @param ctx command line processing context
163 * @param scls additional closure (will point to the 'int')
164 * @param option name of the option
165 * @param value not used (NULL)
166 * @return GNUNET_OK
167 */
136int 168int
137GNUNET_GETOPT_increment_value (struct 169GNUNET_GETOPT_increment_value (struct
138 GNUNET_GETOPT_CommandLineProcessorContext *ctx, 170 GNUNET_GETOPT_CommandLineProcessorContext *ctx,
@@ -144,6 +176,21 @@ GNUNET_GETOPT_increment_value (struct
144 return GNUNET_OK; 176 return GNUNET_OK;
145} 177}
146 178
179
180/**
181 * Set an option of type 'int' from the command line to 1 if the
182 * given option is present.
183 * A pointer to this function should be passed as part of the
184 * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
185 * of this type. It should be followed by a pointer to a value of
186 * type 'int'.
187 *
188 * @param ctx command line processing context
189 * @param scls additional closure (will point to the 'int')
190 * @param option name of the option
191 * @param value not used (NULL)
192 * @return GNUNET_OK
193 */
147int 194int
148GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 195GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
149 void *scls, const char *option, const char *value) 196 void *scls, const char *option, const char *value)
@@ -153,6 +200,21 @@ GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
153 return GNUNET_OK; 200 return GNUNET_OK;
154} 201}
155 202
203
204/**
205 * Set an option of type 'char *' from the command line.
206 * A pointer to this function should be passed as part of the
207 * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
208 * of this type. It should be followed by a pointer to a value of
209 * type 'char *'.
210 *
211 * @param ctx command line processing context
212 * @param scls additional closure (will point to the 'char *',
213 * which will be allocated)
214 * @param option name of the option
215 * @param value actual value of the option (a string)
216 * @return GNUNET_OK
217 */
156int 218int
157GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext 219GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext
158 *ctx, void *scls, const char *option, 220 *ctx, void *scls, const char *option,
@@ -167,6 +229,20 @@ GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext
167 return GNUNET_OK; 229 return GNUNET_OK;
168} 230}
169 231
232
233/**
234 * Set an option of type 'unsigned long long' from the command line.
235 * A pointer to this function should be passed as part of the
236 * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
237 * of this type. It should be followed by a pointer to a value of
238 * type 'unsigned long long'.
239 *
240 * @param ctx command line processing context
241 * @param scls additional closure (will point to the 'unsigned long long')
242 * @param option name of the option
243 * @param value actual value of the option as a string.
244 * @return GNUNET_OK if parsing the value worked
245 */
170int 246int
171GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext 247GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext
172 *ctx, void *scls, const char *option, 248 *ctx, void *scls, const char *option,
@@ -183,6 +259,19 @@ GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext
183} 259}
184 260
185 261
262/**
263 * Set an option of type 'unsigned long long' from the command line.
264 * A pointer to this function should be passed as part of the
265 * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
266 * of this type. It should be followed by a pointer to a value of
267 * type 'unsigned int'.
268 *
269 * @param ctx command line processing context
270 * @param scls additional closure (will point to the 'unsigned int')
271 * @param option name of the option
272 * @param value actual value of the option as a string.
273 * @return GNUNET_OK if parsing the value worked
274 */
186int 275int
187GNUNET_GETOPT_set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 276GNUNET_GETOPT_set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
188 void *scls, const char *option, const char *value) 277 void *scls, const char *option, const char *value)