diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2024-02-13 15:52:01 +0100 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2024-02-13 15:52:01 +0100 |
commit | 04c59fc58fbfd279306aaa22451754caa9b5a150 (patch) | |
tree | a48d584493b91bf99175a80ad06d8a15b4601614 | |
parent | d7a2af6d1dfaa4308b2ea3470dd540f33494c2fa (diff) | |
download | gnunet-04c59fc58fbfd279306aaa22451754caa9b5a150.tar.gz gnunet-04c59fc58fbfd279306aaa22451754caa9b5a150.zip |
uncrustify
-rw-r--r-- | src/cli/gns/gnunet-gns.c | 458 |
1 files changed, 229 insertions, 229 deletions
diff --git a/src/cli/gns/gnunet-gns.c b/src/cli/gns/gnunet-gns.c index a59d96f01..325df23dc 100644 --- a/src/cli/gns/gnunet-gns.c +++ b/src/cli/gns/gnunet-gns.c | |||
@@ -115,27 +115,27 @@ static int global_ret; | |||
115 | static void | 115 | static void |
116 | do_shutdown (void *cls) | 116 | do_shutdown (void *cls) |
117 | { | 117 | { |
118 | (void) cls; | 118 | (void) cls; |
119 | if (NULL != to_task) | 119 | if (NULL != to_task) |
120 | { | 120 | { |
121 | GNUNET_SCHEDULER_cancel (to_task); | 121 | GNUNET_SCHEDULER_cancel (to_task); |
122 | to_task = NULL; | 122 | to_task = NULL; |
123 | } | 123 | } |
124 | if (NULL != lr) | 124 | if (NULL != lr) |
125 | { | 125 | { |
126 | GNUNET_GNS_lookup_with_tld_cancel (lr); | 126 | GNUNET_GNS_lookup_with_tld_cancel (lr); |
127 | lr = NULL; | 127 | lr = NULL; |
128 | } | 128 | } |
129 | if (NULL != gns) | 129 | if (NULL != gns) |
130 | { | 130 | { |
131 | GNUNET_GNS_disconnect (gns); | 131 | GNUNET_GNS_disconnect (gns); |
132 | gns = NULL; | 132 | gns = NULL; |
133 | } | 133 | } |
134 | if (NULL != idna_name) | 134 | if (NULL != idna_name) |
135 | { | 135 | { |
136 | GNUNET_free (idna_name); | 136 | GNUNET_free (idna_name); |
137 | idna_name = NULL; | 137 | idna_name = NULL; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | 141 | ||
@@ -147,9 +147,9 @@ do_shutdown (void *cls) | |||
147 | static void | 147 | static void |
148 | do_timeout (void*cls) | 148 | do_timeout (void*cls) |
149 | { | 149 | { |
150 | to_task = NULL; | 150 | to_task = NULL; |
151 | global_ret = 3; // Timeout | 151 | global_ret = 3; // Timeout |
152 | GNUNET_SCHEDULER_shutdown (); | 152 | GNUNET_SCHEDULER_shutdown (); |
153 | } | 153 | } |
154 | 154 | ||
155 | 155 | ||
@@ -163,68 +163,68 @@ do_timeout (void*cls) | |||
163 | */ | 163 | */ |
164 | static void | 164 | static void |
165 | process_lookup_result (void *cls, | 165 | process_lookup_result (void *cls, |
166 | int was_gns, | 166 | int was_gns, |
167 | uint32_t rd_count, | 167 | uint32_t rd_count, |
168 | const struct GNUNET_GNSRECORD_Data *rd) | 168 | const struct GNUNET_GNSRECORD_Data *rd) |
169 | { | 169 | { |
170 | struct GNUNET_TIME_Relative block_exp; | 170 | struct GNUNET_TIME_Relative block_exp; |
171 | const char *name = cls; | 171 | const char *name = cls; |
172 | const char *typename; | 172 | const char *typename; |
173 | char *string_val; | 173 | char *string_val; |
174 | 174 | ||
175 | lr = NULL; | 175 | lr = NULL; |
176 | if (GNUNET_NO == was_gns) | 176 | if (GNUNET_NO == was_gns) |
177 | { | 177 | { |
178 | global_ret = 4; /* not for GNS */ | 178 | global_ret = 4; /* not for GNS */ |
179 | GNUNET_SCHEDULER_shutdown (); | 179 | GNUNET_SCHEDULER_shutdown (); |
180 | return; | 180 | return; |
181 | } | 181 | } |
182 | block_exp = GNUNET_TIME_absolute_get_remaining ( | 182 | block_exp = GNUNET_TIME_absolute_get_remaining ( |
183 | GNUNET_GNSRECORD_record_get_expiration_time ( | 183 | GNUNET_GNSRECORD_record_get_expiration_time ( |
184 | rd_count, | 184 | rd_count, |
185 | rd, | 185 | rd, |
186 | GNUNET_TIME_UNIT_ZERO_ABS)); | 186 | GNUNET_TIME_UNIT_ZERO_ABS)); |
187 | if (! raw) | 187 | if (! raw) |
188 | { | 188 | { |
189 | printf ("<<< %u record(s) found:\n\n", rd_count); | 189 | printf ("<<< %u record(s) found:\n\n", rd_count); |
190 | } | 190 | } |
191 | for (uint32_t i = 0; i < rd_count; i++) | 191 | for (uint32_t i = 0; i < rd_count; i++) |
192 | { | 192 | { |
193 | typename = GNUNET_GNSRECORD_number_to_typename (rd[i]. | 193 | typename = GNUNET_GNSRECORD_number_to_typename (rd[i]. |
194 | record_type); | 194 | record_type); |
195 | string_val = GNUNET_GNSRECORD_value_to_string (rd[i].record_type | 195 | string_val = GNUNET_GNSRECORD_value_to_string (rd[i].record_type |
196 | , | 196 | , |
197 | rd[i].data, | 197 | rd[i].data, |
198 | rd[i].data_size); | 198 | rd[i].data_size); |
199 | if (NULL == string_val) | 199 | if (NULL == string_val) |
200 | { | 200 | { |
201 | fprintf (stderr, | 201 | fprintf (stderr, |
202 | "Record %u of type %d malformed, skipping\n", | 202 | "Record %u of type %d malformed, skipping\n", |
203 | (unsigned int) i, | 203 | (unsigned int) i, |
204 | (int) rd[i].record_type); | 204 | (int) rd[i].record_type); |
205 | continue; | 205 | continue; |
206 | } | 206 | } |
207 | if (raw) | 207 | if (raw) |
208 | printf ("%s\n", string_val); | 208 | printf ("%s\n", string_val); |
209 | else | 209 | else |
210 | printf ("%s: `%s' %s\n", | 210 | printf ("%s: `%s' %s\n", |
211 | typename, | 211 | typename, |
212 | string_val, | 212 | string_val, |
213 | (0 != (rd[i].flags | 213 | (0 != (rd[i].flags |
214 | & | 214 | & |
215 | GNUNET_GNSRECORD_RF_SUPPLEMENTAL) | 215 | GNUNET_GNSRECORD_RF_SUPPLEMENTAL) |
216 | ) ? | 216 | ) ? |
217 | "(supplemental)" : ""); | 217 | "(supplemental)" : ""); |
218 | GNUNET_free (string_val); | 218 | GNUNET_free (string_val); |
219 | } | 219 | } |
220 | if (! raw) | 220 | if (! raw) |
221 | { | 221 | { |
222 | if (0 != rd_count) | 222 | if (0 != rd_count) |
223 | printf ("\nRecord set expires in %s.\n", | 223 | printf ("\nRecord set expires in %s.\n", |
224 | GNUNET_STRINGS_relative_time_to_string ( | 224 | GNUNET_STRINGS_relative_time_to_string ( |
225 | block_exp, GNUNET_YES)); | 225 | block_exp, GNUNET_YES)); |
226 | } | 226 | } |
227 | GNUNET_SCHEDULER_shutdown (); | 227 | GNUNET_SCHEDULER_shutdown (); |
228 | } | 228 | } |
229 | 229 | ||
230 | 230 | ||
@@ -242,100 +242,100 @@ run (void *cls, | |||
242 | const char *cfgfile, | 242 | const char *cfgfile, |
243 | const struct GNUNET_CONFIGURATION_Handle *c) | 243 | const struct GNUNET_CONFIGURATION_Handle *c) |
244 | { | 244 | { |
245 | (void) cls; | 245 | (void) cls; |
246 | (void) args; | 246 | (void) args; |
247 | (void) cfgfile; | 247 | (void) cfgfile; |
248 | 248 | ||
249 | cfg = c; | 249 | cfg = c; |
250 | to_task = NULL; | 250 | to_task = NULL; |
251 | { | 251 | { |
252 | char *colon; | 252 | char *colon; |
253 | 253 | ||
254 | if (NULL != (colon = strchr (lookup_name, ':'))) | 254 | if (NULL != (colon = strchr (lookup_name, ':'))) |
255 | *colon = '\0'; | 255 | *colon = '\0'; |
256 | } | 256 | } |
257 | 257 | ||
258 | /** | 258 | /** |
259 | * If DNS compatibility is requested, we first verify that the | 259 | * If DNS compatibility is requested, we first verify that the |
260 | * lookup_name is in a DNS format. If yes, we convert it to UTF-8. | 260 | * lookup_name is in a DNS format. If yes, we convert it to UTF-8. |
261 | */ | 261 | */ |
262 | if (GNUNET_YES == dns_compat) | 262 | if (GNUNET_YES == dns_compat) |
263 | { | 263 | { |
264 | Idna_rc rc; | 264 | Idna_rc rc; |
265 | 265 | ||
266 | if (GNUNET_OK != GNUNET_DNSPARSER_check_name (lookup_name)) | 266 | if (GNUNET_OK != GNUNET_DNSPARSER_check_name (lookup_name)) |
267 | { | 267 | { |
268 | fprintf (stderr, | 268 | fprintf (stderr, |
269 | _ ("`%s' is not a valid DNS domain name\n"), | 269 | _ ("`%s' is not a valid DNS domain name\n"), |
270 | lookup_name); | 270 | lookup_name); |
271 | global_ret = 3; | 271 | global_ret = 3; |
272 | return; | 272 | return; |
273 | } | 273 | } |
274 | if (IDNA_SUCCESS != | 274 | if (IDNA_SUCCESS != |
275 | (rc = idna_to_unicode_8z8z (lookup_name, &idna_name, | 275 | (rc = idna_to_unicode_8z8z (lookup_name, &idna_name, |
276 | IDNA_ALLOW_UNASSIGNED))) | 276 | IDNA_ALLOW_UNASSIGNED))) |
277 | { | 277 | { |
278 | fprintf (stderr, | 278 | fprintf (stderr, |
279 | _ ( | 279 | _ ( |
280 | "Failed to convert DNS IDNA name `%s' to UTF-8: %s\n"), | 280 | "Failed to convert DNS IDNA name `%s' to UTF-8: %s\n"), |
281 | lookup_name, | 281 | lookup_name, |
282 | idna_strerror (rc)); | 282 | idna_strerror (rc)); |
283 | global_ret = 4; | 283 | global_ret = 4; |
284 | return; | 284 | return; |
285 | } | 285 | } |
286 | lookup_name = idna_name; | 286 | lookup_name = idna_name; |
287 | } | 287 | } |
288 | 288 | ||
289 | if (GNUNET_YES != | 289 | if (GNUNET_YES != |
290 | GNUNET_CLIENT_test (cfg, | 290 | GNUNET_CLIENT_test (cfg, |
291 | "arm")) | 291 | "arm")) |
292 | { | 292 | { |
293 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 293 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
294 | _ ( | 294 | _ ( |
295 | "Cannot resolve using GNS: GNUnet peer not running\n")); | 295 | "Cannot resolve using GNS: GNUnet peer not running\n")); |
296 | global_ret = 5; | 296 | global_ret = 5; |
297 | return; | 297 | return; |
298 | } | 298 | } |
299 | to_task = GNUNET_SCHEDULER_add_delayed (timeout, | 299 | to_task = GNUNET_SCHEDULER_add_delayed (timeout, |
300 | &do_timeout, | 300 | &do_timeout, |
301 | NULL); | 301 | NULL); |
302 | gns = GNUNET_GNS_connect (cfg); | 302 | gns = GNUNET_GNS_connect (cfg); |
303 | if (NULL == gns) | 303 | if (NULL == gns) |
304 | { | 304 | { |
305 | fprintf (stderr, | 305 | fprintf (stderr, |
306 | _ ("Failed to connect to GNS\n")); | 306 | _ ("Failed to connect to GNS\n")); |
307 | global_ret = 2; | 307 | global_ret = 2; |
308 | return; | 308 | return; |
309 | } | 309 | } |
310 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | 310 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
311 | NULL); | 311 | NULL); |
312 | if (NULL != lookup_type) | 312 | if (NULL != lookup_type) |
313 | rtype = GNUNET_GNSRECORD_typename_to_number (lookup_type); | 313 | rtype = GNUNET_GNSRECORD_typename_to_number (lookup_type); |
314 | else | 314 | else |
315 | rtype = GNUNET_DNSPARSER_TYPE_A; | 315 | rtype = GNUNET_DNSPARSER_TYPE_A; |
316 | if (UINT32_MAX == rtype) | 316 | if (UINT32_MAX == rtype) |
317 | { | 317 | { |
318 | fprintf (stderr, | 318 | fprintf (stderr, |
319 | _ ("Invalid typename specified, assuming `ANY'\n")); | 319 | _ ("Invalid typename specified, assuming `ANY'\n")); |
320 | rtype = GNUNET_GNSRECORD_TYPE_ANY; | 320 | rtype = GNUNET_GNSRECORD_TYPE_ANY; |
321 | } | 321 | } |
322 | if (! raw) | 322 | if (! raw) |
323 | { | 323 | { |
324 | printf (">>> Looking for `%s' records under `%s'\n", | 324 | printf (">>> Looking for `%s' records under `%s'\n", |
325 | lookup_type, lookup_name); | 325 | lookup_type, lookup_name); |
326 | } | 326 | } |
327 | lr = GNUNET_GNS_lookup_with_tld (gns, | 327 | lr = GNUNET_GNS_lookup_with_tld (gns, |
328 | lookup_name, | 328 | lookup_name, |
329 | rtype, | 329 | rtype, |
330 | GNUNET_GNS_LO_DEFAULT, | 330 | GNUNET_GNS_LO_DEFAULT, |
331 | &process_lookup_result, | 331 | &process_lookup_result, |
332 | lookup_name); | 332 | lookup_name); |
333 | if (NULL == lr) | 333 | if (NULL == lr) |
334 | { | 334 | { |
335 | global_ret = 2; | 335 | global_ret = 2; |
336 | GNUNET_SCHEDULER_shutdown (); | 336 | GNUNET_SCHEDULER_shutdown (); |
337 | return; | 337 | return; |
338 | } | 338 | } |
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
@@ -349,56 +349,56 @@ run (void *cls, | |||
349 | int | 349 | int |
350 | main (int argc, char *const *argv) | 350 | main (int argc, char *const *argv) |
351 | { | 351 | { |
352 | timeout = GNUNET_TIME_UNIT_FOREVER_REL; | 352 | timeout = GNUNET_TIME_UNIT_FOREVER_REL; |
353 | struct GNUNET_GETOPT_CommandLineOption options[] = | 353 | struct GNUNET_GETOPT_CommandLineOption options[] = |
354 | { GNUNET_GETOPT_option_mandatory ( | 354 | { GNUNET_GETOPT_option_mandatory ( |
355 | GNUNET_GETOPT_option_string ('u', | 355 | GNUNET_GETOPT_option_string ('u', |
356 | "lookup", | 356 | "lookup", |
357 | "NAME", | 357 | "NAME", |
358 | gettext_noop ( | 358 | gettext_noop ( |
359 | "Lookup a record for the given name"), | 359 | "Lookup a record for the given name"), |
360 | &lookup_name)), | 360 | &lookup_name)), |
361 | GNUNET_GETOPT_option_string ('t', | 361 | GNUNET_GETOPT_option_string ('t', |
362 | "type", | 362 | "type", |
363 | "TYPE", | 363 | "TYPE", |
364 | gettext_noop ( | 364 | gettext_noop ( |
365 | "Specify the type of the record to lookup"), | 365 | "Specify the type of the record to lookup"), |
366 | &lookup_type), | 366 | &lookup_type), |
367 | GNUNET_GETOPT_option_relative_time ('T', | 367 | GNUNET_GETOPT_option_relative_time ('T', |
368 | "timeout", | 368 | "timeout", |
369 | "TIMEOUT", | 369 | "TIMEOUT", |
370 | gettext_noop ( | 370 | gettext_noop ( |
371 | "Specify a timeout for the lookup"), | 371 | "Specify a timeout for the lookup"), |
372 | &timeout), | 372 | &timeout), |
373 | GNUNET_GETOPT_option_flag ('r', | 373 | GNUNET_GETOPT_option_flag ('r', |
374 | "raw", | 374 | "raw", |
375 | gettext_noop ("No unneeded output"), | 375 | gettext_noop ("No unneeded output"), |
376 | &raw), | 376 | &raw), |
377 | GNUNET_GETOPT_option_flag ('d', | 377 | GNUNET_GETOPT_option_flag ('d', |
378 | "dns", | 378 | "dns", |
379 | gettext_noop ( | 379 | gettext_noop ( |
380 | "DNS Compatibility: Name is passed in IDNA instead of UTF-8"), | 380 | "DNS Compatibility: Name is passed in IDNA instead of UTF-8"), |
381 | &dns_compat), | 381 | &dns_compat), |
382 | GNUNET_GETOPT_OPTION_END }; | 382 | GNUNET_GETOPT_OPTION_END }; |
383 | int ret; | 383 | int ret; |
384 | 384 | ||
385 | if (GNUNET_OK != | 385 | if (GNUNET_OK != |
386 | GNUNET_STRINGS_get_utf8_args (argc, argv, | 386 | GNUNET_STRINGS_get_utf8_args (argc, argv, |
387 | &argc, &argv)) | 387 | &argc, &argv)) |
388 | return 2; | 388 | return 2; |
389 | 389 | ||
390 | GNUNET_log_setup ("gnunet-gns", "WARNING", NULL); | 390 | GNUNET_log_setup ("gnunet-gns", "WARNING", NULL); |
391 | ret = GNUNET_PROGRAM_run (argc, | 391 | ret = GNUNET_PROGRAM_run (argc, |
392 | argv, | 392 | argv, |
393 | "gnunet-gns", | 393 | "gnunet-gns", |
394 | _ ("GNUnet GNS resolver tool"), | 394 | _ ("GNUnet GNS resolver tool"), |
395 | options, | 395 | options, |
396 | &run, | 396 | &run, |
397 | NULL); | 397 | NULL); |
398 | GNUNET_free_nz ((void *) argv); | 398 | GNUNET_free_nz ((void *) argv); |
399 | if (GNUNET_OK != ret) | 399 | if (GNUNET_OK != ret) |
400 | return 1; | 400 | return 1; |
401 | return global_ret; | 401 | return global_ret; |
402 | } | 402 | } |
403 | 403 | ||
404 | 404 | ||