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.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/fs/fs_getopt.c b/src/fs/fs_getopt.c
index 7b5c2991d..cbd9339c9 100644
--- a/src/fs/fs_getopt.c
+++ b/src/fs/fs_getopt.c
@@ -38,19 +38,20 @@
38 * @param scls must be of type "struct GNUNET_FS_Uri **" 38 * @param scls must be of type "struct GNUNET_FS_Uri **"
39 * @param option name of the option (typically 'k') 39 * @param option name of the option (typically 'k')
40 * @param value command line argument given 40 * @param value command line argument given
41 * @return GNUNET_OK on success 41 * @return #GNUNET_OK on success
42 */ 42 */
43static int 43static int
44getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext 44getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
45 *ctx, void *scls, const char *option, 45 void *scls,
46 const char *value) 46 const char *option,
47 const char *value)
47{ 48{
48 struct GNUNET_FS_Uri **uri = scls; 49 struct GNUNET_FS_Uri **uri = scls;
49 struct GNUNET_FS_Uri *u = *uri; 50 struct GNUNET_FS_Uri *u = *uri;
50 char *val; 51 char *val;
51 size_t slen; 52 size_t slen;
52 53
53 if (u == NULL) 54 if (NULL == u)
54 { 55 {
55 u = GNUNET_new (struct GNUNET_FS_Uri); 56 u = GNUNET_new (struct GNUNET_FS_Uri);
56 *uri = u; 57 *uri = u;
@@ -60,10 +61,10 @@ getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext
60 } 61 }
61 else 62 else
62 { 63 {
63 GNUNET_assert (u->type == GNUNET_FS_URI_KSK); 64 GNUNET_assert (GNUNET_FS_URI_KSK == u->type);
64 } 65 }
65 slen = strlen (value); 66 slen = strlen (value);
66 if (slen == 0) 67 if (0 == slen)
67 return GNUNET_SYSERR; /* cannot be empty */ 68 return GNUNET_SYSERR; /* cannot be empty */
68 if (value[0] == '+') 69 if (value[0] == '+')
69 { 70 {
@@ -75,7 +76,9 @@ getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext
75 /* remove the quotes, keep the '+' */ 76 /* remove the quotes, keep the '+' */
76 val = GNUNET_malloc (slen - 1); 77 val = GNUNET_malloc (slen - 1);
77 val[0] = '+'; 78 val[0] = '+';
78 GNUNET_memcpy (&val[1], &value[2], slen - 3); 79 GNUNET_memcpy (&val[1],
80 &value[2],
81 slen - 3);
79 val[slen - 2] = '\0'; 82 val[slen - 2] = '\0';
80 } 83 }
81 else 84 else
@@ -91,7 +94,9 @@ getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext
91 /* remove the quotes, add a space */ 94 /* remove the quotes, add a space */
92 val = GNUNET_malloc (slen); 95 val = GNUNET_malloc (slen);
93 val[0] = ' '; 96 val[0] = ' ';
94 GNUNET_memcpy (&val[1], &value[1], slen - 2); 97 GNUNET_memcpy (&val[1],
98 &value[1],
99 slen - 2);
95 val[slen - 1] = '\0'; 100 val[slen - 1] = '\0';
96 } 101 }
97 else 102 else
@@ -102,10 +107,13 @@ getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext
102 strcat (val, value); 107 strcat (val, value);
103 } 108 }
104 } 109 }
105 GNUNET_array_append (u->data.ksk.keywords, u->data.ksk.keywordCount, val); 110 GNUNET_array_append (u->data.ksk.keywords,
111 u->data.ksk.keywordCount,
112 val);
106 return GNUNET_OK; 113 return GNUNET_OK;
107} 114}
108 115
116
109/** 117/**
110 * Allow user to specify keywords. 118 * Allow user to specify keywords.
111 * 119 *
@@ -135,6 +143,7 @@ GNUNET_FS_GETOPT_KEYWORDS (char shortName,
135 return clo; 143 return clo;
136} 144}
137 145
146
138/** 147/**
139 * Command-line option parser function that allows the user to specify 148 * Command-line option parser function that allows the user to specify
140 * one or more '-m' options with metadata. Each specified entry of 149 * one or more '-m' options with metadata. Each specified entry of