aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_getopt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/fs_getopt.c')
-rw-r--r--src/fs/fs_getopt.c79
1 files changed, 70 insertions, 9 deletions
diff --git a/src/fs/fs_getopt.c b/src/fs/fs_getopt.c
index f78e311d3..bfe45957e 100644
--- a/src/fs/fs_getopt.c
+++ b/src/fs/fs_getopt.c
@@ -25,6 +25,7 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_fs_service.h" 27#include "gnunet_fs_service.h"
28#include "gnunet_getopt_lib.h"
28#include "fs_api.h" 29#include "fs_api.h"
29 30
30/* ******************** command-line option parsing API ******************** */ 31/* ******************** command-line option parsing API ******************** */
@@ -41,10 +42,10 @@
41 * @param value command line argument given 42 * @param value command line argument given
42 * @return GNUNET_OK on success 43 * @return GNUNET_OK on success
43 */ 44 */
44int 45static int
45GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext 46getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext
46 *ctx, void *scls, const char *option, 47 *ctx, void *scls, const char *option,
47 const char *value) 48 const char *value)
48{ 49{
49 struct GNUNET_FS_Uri **uri = scls; 50 struct GNUNET_FS_Uri **uri = scls;
50 struct GNUNET_FS_Uri *u = *uri; 51 struct GNUNET_FS_Uri *u = *uri;
@@ -107,6 +108,34 @@ GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext
107 return GNUNET_OK; 108 return GNUNET_OK;
108} 109}
109 110
111/**
112 * Allow user to specify keywords.
113 *
114 * @param shortName short name of the option
115 * @param name long name of the option
116 * @param argumentHelp help text for the option argument
117 * @param description long help text for the option
118 * @param[out] topKeywords set to the desired value
119 */
120struct GNUNET_GETOPT_CommandLineOption
121GNUNET_FS_GETOPT_KEYWORDS (char shortName,
122 const char *name,
123 const char *argumentHelp,
124 const char *description,
125 struct GNUNET_FS_Uri **topKeywords)
126{
127 struct GNUNET_GETOPT_CommandLineOption clo = {
128 .shortName = shortName,
129 .name = name,
130 .argumentHelp = argumentHelp,
131 .description = description,
132 .require_argument = 1,
133 .processor = &getopt_set_keywords,
134 .scls = (void *) topKeywords
135 };
136
137 return clo;
138}
110 139
111/** 140/**
112 * Command-line option parser function that allows the user to specify 141 * Command-line option parser function that allows the user to specify
@@ -120,11 +149,11 @@ GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext
120 * @param value command line argument given 149 * @param value command line argument given
121 * @return #GNUNET_OK on success 150 * @return #GNUNET_OK on success
122 */ 151 */
123int 152static int
124GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, 153getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
125 void *scls, 154 void *scls,
126 const char *option, 155 const char *option,
127 const char *value) 156 const char *value)
128{ 157{
129 struct GNUNET_CONTAINER_MetaData **mm = scls; 158 struct GNUNET_CONTAINER_MetaData **mm = scls;
130#if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR 159#if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR
@@ -200,4 +229,36 @@ GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext
200 return GNUNET_OK; 229 return GNUNET_OK;
201} 230}
202 231
232/**
233 * Allow user to specify metadata.
234 *
235 * @param shortName short name of the option
236 * @param name long name of the option
237 * @param argumentHelp help text for the option argument
238 * @param description long help text for the option
239 * @param[out] metadata set to the desired value
240 */
241struct GNUNET_GETOPT_CommandLineOption
242GNUNET_FS_GETOPT_METADATA (char shortName,
243 const char *name,
244 const char *argumentHelp,
245 const char *description,
246 struct GNUNET_CONTAINER_MetaData **meta)
247{
248 struct GNUNET_GETOPT_CommandLineOption clo = {
249 .shortName = shortName,
250 .name = name,
251 .argumentHelp = argumentHelp,
252 .description = description,
253 .require_argument = 1,
254 .processor = &getopt_set_metadata,
255 .scls = (void *) meta
256 };
257
258 return clo;
259}
260
261
262
263
203/* end of fs_getopt.c */ 264/* end of fs_getopt.c */