aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-dht-put.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
commitc4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch)
treecac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/dht/gnunet-dht-put.c
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
downloadgnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz
gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/dht/gnunet-dht-put.c')
-rw-r--r--src/dht/gnunet-dht-put.c150
1 files changed, 75 insertions, 75 deletions
diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c
index 330b2ac62..d8bffbf37 100644
--- a/src/dht/gnunet-dht-put.c
+++ b/src/dht/gnunet-dht-put.c
@@ -89,13 +89,13 @@ static char *data;
89 89
90 90
91static void 91static void
92shutdown_task(void *cls) 92shutdown_task (void *cls)
93{ 93{
94 if (NULL != dht_handle) 94 if (NULL != dht_handle)
95 { 95 {
96 GNUNET_DHT_disconnect(dht_handle); 96 GNUNET_DHT_disconnect (dht_handle);
97 dht_handle = NULL; 97 dht_handle = NULL;
98 } 98 }
99} 99}
100 100
101 101
@@ -105,9 +105,9 @@ shutdown_task(void *cls)
105 * @param cls closure 105 * @param cls closure
106 */ 106 */
107static void 107static void
108message_sent_cont(void *cls) 108message_sent_cont (void *cls)
109{ 109{
110 GNUNET_SCHEDULER_add_now(&shutdown_task, NULL); 110 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
111} 111}
112 112
113 113
@@ -120,52 +120,52 @@ message_sent_cont(void *cls)
120 * @param c configuration 120 * @param c configuration
121 */ 121 */
122static void 122static void
123run(void *cls, 123run (void *cls,
124 char *const *args, 124 char *const *args,
125 const char *cfgfile, 125 const char *cfgfile,
126 const struct GNUNET_CONFIGURATION_Handle *c) 126 const struct GNUNET_CONFIGURATION_Handle *c)
127{ 127{
128 enum GNUNET_DHT_RouteOption ro; 128 enum GNUNET_DHT_RouteOption ro;
129 129
130 cfg = c; 130 cfg = c;
131 if ((NULL == query_key) || (NULL == data)) 131 if ((NULL == query_key) || (NULL == data))
132 { 132 {
133 fprintf(stderr, "%s", _("Must provide KEY and DATA for DHT put!\n")); 133 fprintf (stderr, "%s", _ ("Must provide KEY and DATA for DHT put!\n"));
134 ret = 1; 134 ret = 1;
135 return; 135 return;
136 } 136 }
137 137
138 if (NULL == (dht_handle = GNUNET_DHT_connect(cfg, 1))) 138 if (NULL == (dht_handle = GNUNET_DHT_connect (cfg, 1)))
139 { 139 {
140 fprintf(stderr, _("Could not connect to DHT service!\n")); 140 fprintf (stderr, _ ("Could not connect to DHT service!\n"));
141 ret = 1; 141 ret = 1;
142 return; 142 return;
143 } 143 }
144 if (GNUNET_BLOCK_TYPE_ANY == query_type) /* Type of data not set */ 144 if (GNUNET_BLOCK_TYPE_ANY == query_type) /* Type of data not set */
145 query_type = GNUNET_BLOCK_TYPE_TEST; 145 query_type = GNUNET_BLOCK_TYPE_TEST;
146 146
147 GNUNET_CRYPTO_hash(query_key, strlen(query_key), &key); 147 GNUNET_CRYPTO_hash (query_key, strlen (query_key), &key);
148 148
149 if (verbose) 149 if (verbose)
150 fprintf(stderr, 150 fprintf (stderr,
151 _("Issuing put request for `%s' with data `%s'!\n"), 151 _ ("Issuing put request for `%s' with data `%s'!\n"),
152 query_key, 152 query_key,
153 data); 153 data);
154 ro = GNUNET_DHT_RO_NONE; 154 ro = GNUNET_DHT_RO_NONE;
155 if (demultixplex_everywhere) 155 if (demultixplex_everywhere)
156 ro |= GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE; 156 ro |= GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE;
157 if (record_route) 157 if (record_route)
158 ro |= GNUNET_DHT_RO_RECORD_ROUTE; 158 ro |= GNUNET_DHT_RO_RECORD_ROUTE;
159 GNUNET_DHT_put(dht_handle, 159 GNUNET_DHT_put (dht_handle,
160 &key, 160 &key,
161 replication, 161 replication,
162 ro, 162 ro,
163 query_type, 163 query_type,
164 strlen(data), 164 strlen (data),
165 data, 165 data,
166 GNUNET_TIME_relative_to_absolute(expiration), 166 GNUNET_TIME_relative_to_absolute (expiration),
167 &message_sent_cont, 167 &message_sent_cont,
168 NULL); 168 NULL);
169} 169}
170 170
171/** 171/**
@@ -176,58 +176,58 @@ run(void *cls,
176 * @return 0 ok, 1 on error 176 * @return 0 ok, 1 on error
177 */ 177 */
178int 178int
179main(int argc, char *const *argv) 179main (int argc, char *const *argv)
180{ 180{
181 struct GNUNET_GETOPT_CommandLineOption options[] = 181 struct GNUNET_GETOPT_CommandLineOption options[] =
182 { GNUNET_GETOPT_option_string('d', 182 { GNUNET_GETOPT_option_string ('d',
183 "data", 183 "data",
184 "DATA", 184 "DATA",
185 gettext_noop( 185 gettext_noop (
186 "the data to insert under the key"), 186 "the data to insert under the key"),
187 &data), 187 &data),
188 GNUNET_GETOPT_option_relative_time( 188 GNUNET_GETOPT_option_relative_time (
189 'e', 189 'e',
190 "expiration", 190 "expiration",
191 "EXPIRATION", 191 "EXPIRATION",
192 gettext_noop("how long to store this entry in the dht (in seconds)"), 192 gettext_noop ("how long to store this entry in the dht (in seconds)"),
193 &expiration), 193 &expiration),
194 GNUNET_GETOPT_option_string('k', 194 GNUNET_GETOPT_option_string ('k',
195 "key", 195 "key",
196 "KEY", 196 "KEY",
197 gettext_noop("the query key"), 197 gettext_noop ("the query key"),
198 &query_key), 198 &query_key),
199 GNUNET_GETOPT_option_flag('x', 199 GNUNET_GETOPT_option_flag ('x',
200 "demultiplex", 200 "demultiplex",
201 gettext_noop( 201 gettext_noop (
202 "use DHT's demultiplex everywhere option"), 202 "use DHT's demultiplex everywhere option"),
203 &demultixplex_everywhere), 203 &demultixplex_everywhere),
204 GNUNET_GETOPT_option_uint('r', 204 GNUNET_GETOPT_option_uint ('r',
205 "replication", 205 "replication",
206 "LEVEL", 206 "LEVEL",
207 gettext_noop("how many replicas to create"), 207 gettext_noop ("how many replicas to create"),
208 &replication), 208 &replication),
209 GNUNET_GETOPT_option_flag('R', 209 GNUNET_GETOPT_option_flag ('R',
210 "record", 210 "record",
211 gettext_noop("use DHT's record route option"), 211 gettext_noop ("use DHT's record route option"),
212 &record_route), 212 &record_route),
213 GNUNET_GETOPT_option_uint('t', 213 GNUNET_GETOPT_option_uint ('t',
214 "type", 214 "type",
215 "TYPE", 215 "TYPE",
216 gettext_noop("the type to insert data as"), 216 gettext_noop ("the type to insert data as"),
217 &query_type), 217 &query_type),
218 GNUNET_GETOPT_option_verbose(&verbose), 218 GNUNET_GETOPT_option_verbose (&verbose),
219 GNUNET_GETOPT_OPTION_END }; 219 GNUNET_GETOPT_OPTION_END };
220 220
221 221
222 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv)) 222 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
223 return 2; 223 return 2;
224 expiration = GNUNET_TIME_UNIT_HOURS; 224 expiration = GNUNET_TIME_UNIT_HOURS;
225 return (GNUNET_OK == 225 return (GNUNET_OK ==
226 GNUNET_PROGRAM_run( 226 GNUNET_PROGRAM_run (
227 argc, 227 argc,
228 argv, 228 argv,
229 "gnunet-dht-put", 229 "gnunet-dht-put",
230 gettext_noop( 230 gettext_noop (
231 "Issue a PUT request to the GNUnet DHT insert DATA under KEY."), 231 "Issue a PUT request to the GNUnet DHT insert DATA under KEY."),
232 options, 232 options,
233 &run, 233 &run,