diff options
Diffstat (limited to 'src/namestore/gnunet-namestore.c')
-rw-r--r-- | src/namestore/gnunet-namestore.c | 1735 |
1 files changed, 868 insertions, 867 deletions
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index cc1362a51..65c0f7726 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -37,7 +37,8 @@ | |||
37 | /** | 37 | /** |
38 | * Entry in record set for bulk processing. | 38 | * Entry in record set for bulk processing. |
39 | */ | 39 | */ |
40 | struct RecordSetEntry { | 40 | struct RecordSetEntry |
41 | { | ||
41 | /** | 42 | /** |
42 | * Kept in a linked list. | 43 | * Kept in a linked list. |
43 | */ | 44 | */ |
@@ -227,75 +228,75 @@ static struct RecordSetEntry *recordset; | |||
227 | * @param cls unused | 228 | * @param cls unused |
228 | */ | 229 | */ |
229 | static void | 230 | static void |
230 | do_shutdown(void *cls) | 231 | do_shutdown (void *cls) |
231 | { | 232 | { |
232 | (void)cls; | 233 | (void) cls; |
233 | if (NULL != get_default) | 234 | if (NULL != get_default) |
234 | { | 235 | { |
235 | GNUNET_IDENTITY_cancel(get_default); | 236 | GNUNET_IDENTITY_cancel (get_default); |
236 | get_default = NULL; | 237 | get_default = NULL; |
237 | } | 238 | } |
238 | if (NULL != idh) | 239 | if (NULL != idh) |
239 | { | 240 | { |
240 | GNUNET_IDENTITY_disconnect(idh); | 241 | GNUNET_IDENTITY_disconnect (idh); |
241 | idh = NULL; | 242 | idh = NULL; |
242 | } | 243 | } |
243 | if (NULL != el) | 244 | if (NULL != el) |
244 | { | 245 | { |
245 | GNUNET_IDENTITY_ego_lookup_cancel(el); | 246 | GNUNET_IDENTITY_ego_lookup_cancel (el); |
246 | el = NULL; | 247 | el = NULL; |
247 | } | 248 | } |
248 | if (NULL != list_it) | 249 | if (NULL != list_it) |
249 | { | 250 | { |
250 | GNUNET_NAMESTORE_zone_iteration_stop(list_it); | 251 | GNUNET_NAMESTORE_zone_iteration_stop (list_it); |
251 | list_it = NULL; | 252 | list_it = NULL; |
252 | } | 253 | } |
253 | if (NULL != add_qe) | 254 | if (NULL != add_qe) |
254 | { | 255 | { |
255 | GNUNET_NAMESTORE_cancel(add_qe); | 256 | GNUNET_NAMESTORE_cancel (add_qe); |
256 | add_qe = NULL; | 257 | add_qe = NULL; |
257 | } | 258 | } |
258 | if (NULL != set_qe) | 259 | if (NULL != set_qe) |
259 | { | 260 | { |
260 | GNUNET_NAMESTORE_cancel(set_qe); | 261 | GNUNET_NAMESTORE_cancel (set_qe); |
261 | set_qe = NULL; | 262 | set_qe = NULL; |
262 | } | 263 | } |
263 | if (NULL != add_qe_uri) | 264 | if (NULL != add_qe_uri) |
264 | { | 265 | { |
265 | GNUNET_NAMESTORE_cancel(add_qe_uri); | 266 | GNUNET_NAMESTORE_cancel (add_qe_uri); |
266 | add_qe_uri = NULL; | 267 | add_qe_uri = NULL; |
267 | } | 268 | } |
268 | if (NULL != get_qe) | 269 | if (NULL != get_qe) |
269 | { | 270 | { |
270 | GNUNET_NAMESTORE_cancel(get_qe); | 271 | GNUNET_NAMESTORE_cancel (get_qe); |
271 | get_qe = NULL; | 272 | get_qe = NULL; |
272 | } | 273 | } |
273 | if (NULL != del_qe) | 274 | if (NULL != del_qe) |
274 | { | 275 | { |
275 | GNUNET_NAMESTORE_cancel(del_qe); | 276 | GNUNET_NAMESTORE_cancel (del_qe); |
276 | del_qe = NULL; | 277 | del_qe = NULL; |
277 | } | 278 | } |
278 | if (NULL != ns) | 279 | if (NULL != ns) |
279 | { | 280 | { |
280 | GNUNET_NAMESTORE_disconnect(ns); | 281 | GNUNET_NAMESTORE_disconnect (ns); |
281 | ns = NULL; | 282 | ns = NULL; |
282 | } | 283 | } |
283 | memset(&zone_pkey, 0, sizeof(zone_pkey)); | 284 | memset (&zone_pkey, 0, sizeof(zone_pkey)); |
284 | if (NULL != uri) | 285 | if (NULL != uri) |
285 | { | 286 | { |
286 | GNUNET_free(uri); | 287 | GNUNET_free (uri); |
287 | uri = NULL; | 288 | uri = NULL; |
288 | } | 289 | } |
289 | if (NULL != zm) | 290 | if (NULL != zm) |
290 | { | 291 | { |
291 | GNUNET_NAMESTORE_zone_monitor_stop(zm); | 292 | GNUNET_NAMESTORE_zone_monitor_stop (zm); |
292 | zm = NULL; | 293 | zm = NULL; |
293 | } | 294 | } |
294 | if (NULL != data) | 295 | if (NULL != data) |
295 | { | 296 | { |
296 | GNUNET_free(data); | 297 | GNUNET_free (data); |
297 | data = NULL; | 298 | data = NULL; |
298 | } | 299 | } |
299 | } | 300 | } |
300 | 301 | ||
301 | 302 | ||
@@ -303,11 +304,11 @@ do_shutdown(void *cls) | |||
303 | * Check if we are finished, and if so, perform shutdown. | 304 | * Check if we are finished, and if so, perform shutdown. |
304 | */ | 305 | */ |
305 | static void | 306 | static void |
306 | test_finished() | 307 | test_finished () |
307 | { | 308 | { |
308 | if ((NULL == add_qe) && (NULL == add_qe_uri) && (NULL == get_qe) && | 309 | if ((NULL == add_qe) && (NULL == add_qe_uri) && (NULL == get_qe) && |
309 | (NULL == del_qe) && (NULL == reverse_qe) && (NULL == list_it)) | 310 | (NULL == del_qe) && (NULL == reverse_qe) && (NULL == list_it)) |
310 | GNUNET_SCHEDULER_shutdown(); | 311 | GNUNET_SCHEDULER_shutdown (); |
311 | } | 312 | } |
312 | 313 | ||
313 | 314 | ||
@@ -322,21 +323,21 @@ test_finished() | |||
322 | * @param emsg NULL on success, otherwise an error message | 323 | * @param emsg NULL on success, otherwise an error message |
323 | */ | 324 | */ |
324 | static void | 325 | static void |
325 | add_continuation(void *cls, int32_t success, const char *emsg) | 326 | add_continuation (void *cls, int32_t success, const char *emsg) |
326 | { | 327 | { |
327 | struct GNUNET_NAMESTORE_QueueEntry **qe = cls; | 328 | struct GNUNET_NAMESTORE_QueueEntry **qe = cls; |
328 | 329 | ||
329 | *qe = NULL; | 330 | *qe = NULL; |
330 | if (GNUNET_YES != success) | 331 | if (GNUNET_YES != success) |
331 | { | 332 | { |
332 | fprintf(stderr, | 333 | fprintf (stderr, |
333 | _("Adding record failed: %s\n"), | 334 | _ ("Adding record failed: %s\n"), |
334 | (GNUNET_NO == success) ? "record exists" : emsg); | 335 | (GNUNET_NO == success) ? "record exists" : emsg); |
335 | if (GNUNET_NO != success) | 336 | if (GNUNET_NO != success) |
336 | ret = 1; | 337 | ret = 1; |
337 | } | 338 | } |
338 | ret = 0; | 339 | ret = 0; |
339 | test_finished(); | 340 | test_finished (); |
340 | } | 341 | } |
341 | 342 | ||
342 | 343 | ||
@@ -351,25 +352,25 @@ add_continuation(void *cls, int32_t success, const char *emsg) | |||
351 | * @param emsg NULL on success, otherwise an error message | 352 | * @param emsg NULL on success, otherwise an error message |
352 | */ | 353 | */ |
353 | static void | 354 | static void |
354 | del_continuation(void *cls, int32_t success, const char *emsg) | 355 | del_continuation (void *cls, int32_t success, const char *emsg) |
355 | { | 356 | { |
356 | (void)cls; | 357 | (void) cls; |
357 | del_qe = NULL; | 358 | del_qe = NULL; |
358 | if (GNUNET_NO == success) | 359 | if (GNUNET_NO == success) |
359 | { | 360 | { |
360 | fprintf(stderr, | 361 | fprintf (stderr, |
361 | _("Deleting record failed, record does not exist%s%s\n"), | 362 | _ ("Deleting record failed, record does not exist%s%s\n"), |
362 | (NULL != emsg) ? ": " : "", | 363 | (NULL != emsg) ? ": " : "", |
363 | (NULL != emsg) ? emsg : ""); | 364 | (NULL != emsg) ? emsg : ""); |
364 | } | 365 | } |
365 | if (GNUNET_SYSERR == success) | 366 | if (GNUNET_SYSERR == success) |
366 | { | 367 | { |
367 | fprintf(stderr, | 368 | fprintf (stderr, |
368 | _("Deleting record failed%s%s\n"), | 369 | _ ("Deleting record failed%s%s\n"), |
369 | (NULL != emsg) ? ": " : "", | 370 | (NULL != emsg) ? ": " : "", |
370 | (NULL != emsg) ? emsg : ""); | 371 | (NULL != emsg) ? emsg : ""); |
371 | } | 372 | } |
372 | test_finished(); | 373 | test_finished (); |
373 | } | 374 | } |
374 | 375 | ||
375 | 376 | ||
@@ -377,11 +378,11 @@ del_continuation(void *cls, int32_t success, const char *emsg) | |||
377 | * Function called when we are done with a zone iteration. | 378 | * Function called when we are done with a zone iteration. |
378 | */ | 379 | */ |
379 | static void | 380 | static void |
380 | zone_iteration_finished(void *cls) | 381 | zone_iteration_finished (void *cls) |
381 | { | 382 | { |
382 | (void)cls; | 383 | (void) cls; |
383 | list_it = NULL; | 384 | list_it = NULL; |
384 | test_finished(); | 385 | test_finished (); |
385 | } | 386 | } |
386 | 387 | ||
387 | 388 | ||
@@ -389,13 +390,13 @@ zone_iteration_finished(void *cls) | |||
389 | * Function called when we encountered an error in a zone iteration. | 390 | * Function called when we encountered an error in a zone iteration. |
390 | */ | 391 | */ |
391 | static void | 392 | static void |
392 | zone_iteration_error_cb(void *cls) | 393 | zone_iteration_error_cb (void *cls) |
393 | { | 394 | { |
394 | (void)cls; | 395 | (void) cls; |
395 | list_it = NULL; | 396 | list_it = NULL; |
396 | fprintf(stderr, "Error iterating over zone\n"); | 397 | fprintf (stderr, "Error iterating over zone\n"); |
397 | ret = 1; | 398 | ret = 1; |
398 | test_finished(); | 399 | test_finished (); |
399 | } | 400 | } |
400 | 401 | ||
401 | 402 | ||
@@ -407,9 +408,9 @@ zone_iteration_error_cb(void *cls) | |||
407 | * @param rd array of records with data to store | 408 | * @param rd array of records with data to store |
408 | */ | 409 | */ |
409 | static void | 410 | static void |
410 | display_record(const char *rname, | 411 | display_record (const char *rname, |
411 | unsigned int rd_len, | 412 | unsigned int rd_len, |
412 | const struct GNUNET_GNSRECORD_Data *rd) | 413 | const struct GNUNET_GNSRECORD_Data *rd) |
413 | { | 414 | { |
414 | const char *typestr; | 415 | const char *typestr; |
415 | char *s; | 416 | char *s; |
@@ -418,69 +419,69 @@ display_record(const char *rname, | |||
418 | struct GNUNET_TIME_Relative rt; | 419 | struct GNUNET_TIME_Relative rt; |
419 | int have_record; | 420 | int have_record; |
420 | 421 | ||
421 | if ((NULL != name) && (0 != strcmp(name, rname))) | 422 | if ((NULL != name) && (0 != strcmp (name, rname))) |
422 | { | 423 | { |
423 | GNUNET_NAMESTORE_zone_iterator_next(list_it, 1); | 424 | GNUNET_NAMESTORE_zone_iterator_next (list_it, 1); |
424 | return; | 425 | return; |
425 | } | 426 | } |
426 | have_record = GNUNET_NO; | 427 | have_record = GNUNET_NO; |
427 | for (unsigned int i = 0; i < rd_len; i++) | 428 | for (unsigned int i = 0; i < rd_len; i++) |
428 | { | 429 | { |
429 | if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) && | 430 | if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) && |
430 | (0 != strcmp(rname, GNUNET_GNS_EMPTY_LABEL_AT))) | 431 | (0 != strcmp (rname, GNUNET_GNS_EMPTY_LABEL_AT))) |
431 | continue; | 432 | continue; |
432 | if ((type != rd[i].record_type) && (GNUNET_GNSRECORD_TYPE_ANY != type)) | 433 | if ((type != rd[i].record_type) && (GNUNET_GNSRECORD_TYPE_ANY != type)) |
433 | continue; | 434 | continue; |
434 | have_record = GNUNET_YES; | 435 | have_record = GNUNET_YES; |
435 | break; | 436 | break; |
436 | } | 437 | } |
437 | if (GNUNET_NO == have_record) | 438 | if (GNUNET_NO == have_record) |
438 | return; | 439 | return; |
439 | fprintf(stdout, "%s:\n", rname); | 440 | fprintf (stdout, "%s:\n", rname); |
440 | if (NULL != typestring) | 441 | if (NULL != typestring) |
441 | type = GNUNET_GNSRECORD_typename_to_number(typestring); | 442 | type = GNUNET_GNSRECORD_typename_to_number (typestring); |
442 | else | 443 | else |
443 | type = GNUNET_GNSRECORD_TYPE_ANY; | 444 | type = GNUNET_GNSRECORD_TYPE_ANY; |
444 | for (unsigned int i = 0; i < rd_len; i++) | 445 | for (unsigned int i = 0; i < rd_len; i++) |
446 | { | ||
447 | if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) && | ||
448 | (0 != strcmp (rname, GNUNET_GNS_EMPTY_LABEL_AT))) | ||
449 | continue; | ||
450 | if ((type != rd[i].record_type) && (GNUNET_GNSRECORD_TYPE_ANY != type)) | ||
451 | continue; | ||
452 | typestr = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type); | ||
453 | s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type, | ||
454 | rd[i].data, | ||
455 | rd[i].data_size); | ||
456 | if (NULL == s) | ||
457 | { | ||
458 | fprintf (stdout, | ||
459 | _ ("\tCorrupt or unsupported record of type %u\n"), | ||
460 | (unsigned int) rd[i].record_type); | ||
461 | continue; | ||
462 | } | ||
463 | if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) | ||
464 | { | ||
465 | rt.rel_value_us = rd[i].expiration_time; | ||
466 | ets = GNUNET_STRINGS_relative_time_to_string (rt, GNUNET_YES); | ||
467 | } | ||
468 | else | ||
445 | { | 469 | { |
446 | if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) && | 470 | at.abs_value_us = rd[i].expiration_time; |
447 | (0 != strcmp(rname, GNUNET_GNS_EMPTY_LABEL_AT))) | 471 | ets = GNUNET_STRINGS_absolute_time_to_string (at); |
448 | continue; | ||
449 | if ((type != rd[i].record_type) && (GNUNET_GNSRECORD_TYPE_ANY != type)) | ||
450 | continue; | ||
451 | typestr = GNUNET_GNSRECORD_number_to_typename(rd[i].record_type); | ||
452 | s = GNUNET_GNSRECORD_value_to_string(rd[i].record_type, | ||
453 | rd[i].data, | ||
454 | rd[i].data_size); | ||
455 | if (NULL == s) | ||
456 | { | ||
457 | fprintf(stdout, | ||
458 | _("\tCorrupt or unsupported record of type %u\n"), | ||
459 | (unsigned int)rd[i].record_type); | ||
460 | continue; | ||
461 | } | ||
462 | if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) | ||
463 | { | ||
464 | rt.rel_value_us = rd[i].expiration_time; | ||
465 | ets = GNUNET_STRINGS_relative_time_to_string(rt, GNUNET_YES); | ||
466 | } | ||
467 | else | ||
468 | { | ||
469 | at.abs_value_us = rd[i].expiration_time; | ||
470 | ets = GNUNET_STRINGS_absolute_time_to_string(at); | ||
471 | } | ||
472 | fprintf(stdout, | ||
473 | "\t%s: %s (%s)\t%s\t%s\n", | ||
474 | typestr, | ||
475 | s, | ||
476 | ets, | ||
477 | (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) ? "PRIVATE" | ||
478 | : "PUBLIC", | ||
479 | (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) ? "SHADOW" | ||
480 | : ""); | ||
481 | GNUNET_free(s); | ||
482 | } | 472 | } |
483 | fprintf(stdout, "%s", "\n"); | 473 | fprintf (stdout, |
474 | "\t%s: %s (%s)\t%s\t%s\n", | ||
475 | typestr, | ||
476 | s, | ||
477 | ets, | ||
478 | (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) ? "PRIVATE" | ||
479 | : "PUBLIC", | ||
480 | (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) ? "SHADOW" | ||
481 | : ""); | ||
482 | GNUNET_free (s); | ||
483 | } | ||
484 | fprintf (stdout, "%s", "\n"); | ||
484 | } | 485 | } |
485 | 486 | ||
486 | 487 | ||
@@ -494,16 +495,16 @@ display_record(const char *rname, | |||
494 | * @param rd array of records with data to store | 495 | * @param rd array of records with data to store |
495 | */ | 496 | */ |
496 | static void | 497 | static void |
497 | display_record_iterator(void *cls, | 498 | display_record_iterator (void *cls, |
498 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | 499 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
499 | const char *rname, | 500 | const char *rname, |
500 | unsigned int rd_len, | 501 | unsigned int rd_len, |
501 | const struct GNUNET_GNSRECORD_Data *rd) | 502 | const struct GNUNET_GNSRECORD_Data *rd) |
502 | { | 503 | { |
503 | (void)cls; | 504 | (void) cls; |
504 | (void)zone_key; | 505 | (void) zone_key; |
505 | display_record(rname, rd_len, rd); | 506 | display_record (rname, rd_len, rd); |
506 | GNUNET_NAMESTORE_zone_iterator_next(list_it, 1); | 507 | GNUNET_NAMESTORE_zone_iterator_next (list_it, 1); |
507 | } | 508 | } |
508 | 509 | ||
509 | 510 | ||
@@ -517,16 +518,16 @@ display_record_iterator(void *cls, | |||
517 | * @param rd array of records with data to store | 518 | * @param rd array of records with data to store |
518 | */ | 519 | */ |
519 | static void | 520 | static void |
520 | display_record_monitor(void *cls, | 521 | display_record_monitor (void *cls, |
521 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | 522 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
522 | const char *rname, | 523 | const char *rname, |
523 | unsigned int rd_len, | 524 | unsigned int rd_len, |
524 | const struct GNUNET_GNSRECORD_Data *rd) | 525 | const struct GNUNET_GNSRECORD_Data *rd) |
525 | { | 526 | { |
526 | (void)cls; | 527 | (void) cls; |
527 | (void)zone_key; | 528 | (void) zone_key; |
528 | display_record(rname, rd_len, rd); | 529 | display_record (rname, rd_len, rd); |
529 | GNUNET_NAMESTORE_zone_monitor_next(zm, 1); | 530 | GNUNET_NAMESTORE_zone_monitor_next (zm, 1); |
530 | } | 531 | } |
531 | 532 | ||
532 | 533 | ||
@@ -540,17 +541,17 @@ display_record_monitor(void *cls, | |||
540 | * @param rd array of records with data to store | 541 | * @param rd array of records with data to store |
541 | */ | 542 | */ |
542 | static void | 543 | static void |
543 | display_record_lookup(void *cls, | 544 | display_record_lookup (void *cls, |
544 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | 545 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
545 | const char *rname, | 546 | const char *rname, |
546 | unsigned int rd_len, | 547 | unsigned int rd_len, |
547 | const struct GNUNET_GNSRECORD_Data *rd) | 548 | const struct GNUNET_GNSRECORD_Data *rd) |
548 | { | 549 | { |
549 | (void)cls; | 550 | (void) cls; |
550 | (void)zone_key; | 551 | (void) zone_key; |
551 | get_qe = NULL; | 552 | get_qe = NULL; |
552 | display_record(rname, rd_len, rd); | 553 | display_record (rname, rd_len, rd); |
553 | test_finished(); | 554 | test_finished (); |
554 | } | 555 | } |
555 | 556 | ||
556 | 557 | ||
@@ -560,10 +561,10 @@ display_record_lookup(void *cls, | |||
560 | * @param cls NULL | 561 | * @param cls NULL |
561 | */ | 562 | */ |
562 | static void | 563 | static void |
563 | sync_cb(void *cls) | 564 | sync_cb (void *cls) |
564 | { | 565 | { |
565 | (void)cls; | 566 | (void) cls; |
566 | fprintf(stdout, "%s", "Monitor is now in sync.\n"); | 567 | fprintf (stdout, "%s", "Monitor is now in sync.\n"); |
567 | } | 568 | } |
568 | 569 | ||
569 | 570 | ||
@@ -573,10 +574,10 @@ sync_cb(void *cls) | |||
573 | * @param cls NULL | 574 | * @param cls NULL |
574 | */ | 575 | */ |
575 | static void | 576 | static void |
576 | monitor_error_cb(void *cls) | 577 | monitor_error_cb (void *cls) |
577 | { | 578 | { |
578 | (void)cls; | 579 | (void) cls; |
579 | fprintf(stderr, "%s", "Monitor disconnected and out of sync.\n"); | 580 | fprintf (stderr, "%s", "Monitor disconnected and out of sync.\n"); |
580 | } | 581 | } |
581 | 582 | ||
582 | 583 | ||
@@ -586,12 +587,12 @@ monitor_error_cb(void *cls) | |||
586 | * @param cls NULL | 587 | * @param cls NULL |
587 | */ | 588 | */ |
588 | static void | 589 | static void |
589 | lookup_error_cb(void *cls) | 590 | lookup_error_cb (void *cls) |
590 | { | 591 | { |
591 | (void)cls; | 592 | (void) cls; |
592 | get_qe = NULL; | 593 | get_qe = NULL; |
593 | fprintf(stderr, "%s", "Failed to lookup record.\n"); | 594 | fprintf (stderr, "%s", "Failed to lookup record.\n"); |
594 | test_finished(); | 595 | test_finished (); |
595 | } | 596 | } |
596 | 597 | ||
597 | 598 | ||
@@ -599,13 +600,13 @@ lookup_error_cb(void *cls) | |||
599 | * Function called if lookup fails. | 600 | * Function called if lookup fails. |
600 | */ | 601 | */ |
601 | static void | 602 | static void |
602 | add_error_cb(void *cls) | 603 | add_error_cb (void *cls) |
603 | { | 604 | { |
604 | (void)cls; | 605 | (void) cls; |
605 | add_qe = NULL; | 606 | add_qe = NULL; |
606 | GNUNET_break(0); | 607 | GNUNET_break (0); |
607 | ret = 1; | 608 | ret = 1; |
608 | test_finished(); | 609 | test_finished (); |
609 | } | 610 | } |
610 | 611 | ||
611 | 612 | ||
@@ -620,118 +621,118 @@ add_error_cb(void *cls) | |||
620 | * @param rd array of records with data to store | 621 | * @param rd array of records with data to store |
621 | */ | 622 | */ |
622 | static void | 623 | static void |
623 | get_existing_record(void *cls, | 624 | get_existing_record (void *cls, |
624 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | 625 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
625 | const char *rec_name, | 626 | const char *rec_name, |
626 | unsigned int rd_count, | 627 | unsigned int rd_count, |
627 | const struct GNUNET_GNSRECORD_Data *rd) | 628 | const struct GNUNET_GNSRECORD_Data *rd) |
628 | { | 629 | { |
629 | struct GNUNET_GNSRECORD_Data rdn[rd_count + 1]; | 630 | struct GNUNET_GNSRECORD_Data rdn[rd_count + 1]; |
630 | struct GNUNET_GNSRECORD_Data *rde; | 631 | struct GNUNET_GNSRECORD_Data *rde; |
631 | 632 | ||
632 | (void)cls; | 633 | (void) cls; |
633 | (void)zone_key; | 634 | (void) zone_key; |
634 | add_qe = NULL; | 635 | add_qe = NULL; |
635 | if (0 != strcmp(rec_name, name)) | 636 | if (0 != strcmp (rec_name, name)) |
636 | { | 637 | { |
637 | GNUNET_break(0); | 638 | GNUNET_break (0); |
638 | ret = 1; | 639 | ret = 1; |
639 | test_finished(); | 640 | test_finished (); |
640 | return; | 641 | return; |
641 | } | 642 | } |
642 | 643 | ||
643 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 644 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
644 | "Received %u records for name `%s'\n", | 645 | "Received %u records for name `%s'\n", |
645 | rd_count, | 646 | rd_count, |
646 | rec_name); | 647 | rec_name); |
647 | for (unsigned int i = 0; i < rd_count; i++) | 648 | for (unsigned int i = 0; i < rd_count; i++) |
648 | { | 649 | { |
649 | switch (rd[i].record_type) | 650 | switch (rd[i].record_type) |
650 | { | ||
651 | case GNUNET_DNSPARSER_TYPE_CNAME: | ||
652 | fprintf( | ||
653 | stderr, | ||
654 | _( | ||
655 | "A %s record exists already under `%s', no other records can be added.\n"), | ||
656 | "CNAME", | ||
657 | rec_name); | ||
658 | ret = 1; | ||
659 | test_finished(); | ||
660 | return; | ||
661 | |||
662 | case GNUNET_GNSRECORD_TYPE_PKEY: | ||
663 | fprintf( | ||
664 | stderr, | ||
665 | _( | ||
666 | "A %s record exists already under `%s', no other records can be added.\n"), | ||
667 | "PKEY", | ||
668 | rec_name); | ||
669 | ret = 1; | ||
670 | test_finished(); | ||
671 | return; | ||
672 | |||
673 | case GNUNET_DNSPARSER_TYPE_SOA: | ||
674 | if (GNUNET_DNSPARSER_TYPE_SOA == type) | ||
675 | { | ||
676 | fprintf( | ||
677 | stderr, | ||
678 | _( | ||
679 | "A SOA record exists already under `%s', cannot add a second SOA to the same zone.\n"), | ||
680 | rec_name); | ||
681 | ret = 1; | ||
682 | test_finished(); | ||
683 | return; | ||
684 | } | ||
685 | break; | ||
686 | } | ||
687 | } | ||
688 | switch (type) | ||
689 | { | 651 | { |
690 | case GNUNET_DNSPARSER_TYPE_CNAME: | 652 | case GNUNET_DNSPARSER_TYPE_CNAME: |
691 | if (0 != rd_count) | 653 | fprintf ( |
692 | { | 654 | stderr, |
693 | fprintf(stderr, | 655 | _ ( |
694 | _( | 656 | "A %s record exists already under `%s', no other records can be added.\n"), |
695 | "Records already exist under `%s', cannot add `%s' record.\n"), | 657 | "CNAME", |
696 | rec_name, | 658 | rec_name); |
697 | "CNAME"); | 659 | ret = 1; |
698 | ret = 1; | 660 | test_finished (); |
699 | test_finished(); | 661 | return; |
700 | return; | ||
701 | } | ||
702 | break; | ||
703 | 662 | ||
704 | case GNUNET_GNSRECORD_TYPE_PKEY: | 663 | case GNUNET_GNSRECORD_TYPE_PKEY: |
705 | if (0 != rd_count) | 664 | fprintf ( |
706 | { | 665 | stderr, |
707 | fprintf(stderr, | 666 | _ ( |
708 | _( | 667 | "A %s record exists already under `%s', no other records can be added.\n"), |
709 | "Records already exist under `%s', cannot add `%s' record.\n"), | 668 | "PKEY", |
710 | rec_name, | 669 | rec_name); |
711 | "PKEY"); | 670 | ret = 1; |
712 | ret = 1; | 671 | test_finished (); |
713 | test_finished(); | 672 | return; |
714 | return; | ||
715 | } | ||
716 | break; | ||
717 | 673 | ||
718 | case GNUNET_GNSRECORD_TYPE_GNS2DNS: | 674 | case GNUNET_DNSPARSER_TYPE_SOA: |
719 | for (unsigned int i = 0; i < rd_count; i++) | 675 | if (GNUNET_DNSPARSER_TYPE_SOA == type) |
720 | if (GNUNET_GNSRECORD_TYPE_GNS2DNS != rd[i].record_type) | 676 | { |
721 | { | 677 | fprintf ( |
722 | fprintf( | 678 | stderr, |
723 | stderr, | 679 | _ ( |
724 | _( | 680 | "A SOA record exists already under `%s', cannot add a second SOA to the same zone.\n"), |
725 | "Non-GNS2DNS records already exist under `%s', cannot add GNS2DNS record.\n"), | 681 | rec_name); |
726 | rec_name); | 682 | ret = 1; |
727 | ret = 1; | 683 | test_finished (); |
728 | test_finished(); | 684 | return; |
729 | return; | 685 | } |
730 | } | ||
731 | break; | 686 | break; |
732 | } | 687 | } |
733 | memset(rdn, 0, sizeof(struct GNUNET_GNSRECORD_Data)); | 688 | } |
734 | GNUNET_memcpy(&rdn[1], rd, rd_count * sizeof(struct GNUNET_GNSRECORD_Data)); | 689 | switch (type) |
690 | { | ||
691 | case GNUNET_DNSPARSER_TYPE_CNAME: | ||
692 | if (0 != rd_count) | ||
693 | { | ||
694 | fprintf (stderr, | ||
695 | _ ( | ||
696 | "Records already exist under `%s', cannot add `%s' record.\n"), | ||
697 | rec_name, | ||
698 | "CNAME"); | ||
699 | ret = 1; | ||
700 | test_finished (); | ||
701 | return; | ||
702 | } | ||
703 | break; | ||
704 | |||
705 | case GNUNET_GNSRECORD_TYPE_PKEY: | ||
706 | if (0 != rd_count) | ||
707 | { | ||
708 | fprintf (stderr, | ||
709 | _ ( | ||
710 | "Records already exist under `%s', cannot add `%s' record.\n"), | ||
711 | rec_name, | ||
712 | "PKEY"); | ||
713 | ret = 1; | ||
714 | test_finished (); | ||
715 | return; | ||
716 | } | ||
717 | break; | ||
718 | |||
719 | case GNUNET_GNSRECORD_TYPE_GNS2DNS: | ||
720 | for (unsigned int i = 0; i < rd_count; i++) | ||
721 | if (GNUNET_GNSRECORD_TYPE_GNS2DNS != rd[i].record_type) | ||
722 | { | ||
723 | fprintf ( | ||
724 | stderr, | ||
725 | _ ( | ||
726 | "Non-GNS2DNS records already exist under `%s', cannot add GNS2DNS record.\n"), | ||
727 | rec_name); | ||
728 | ret = 1; | ||
729 | test_finished (); | ||
730 | return; | ||
731 | } | ||
732 | break; | ||
733 | } | ||
734 | memset (rdn, 0, sizeof(struct GNUNET_GNSRECORD_Data)); | ||
735 | GNUNET_memcpy (&rdn[1], rd, rd_count * sizeof(struct GNUNET_GNSRECORD_Data)); | ||
735 | rde = &rdn[0]; | 736 | rde = &rdn[0]; |
736 | rde->data = data; | 737 | rde->data = data; |
737 | rde->data_size = data_size; | 738 | rde->data_size = data_size; |
@@ -745,14 +746,14 @@ get_existing_record(void *cls, | |||
745 | rde->flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 746 | rde->flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
746 | else if (GNUNET_NO != etime_is_rel) | 747 | else if (GNUNET_NO != etime_is_rel) |
747 | rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; | 748 | rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; |
748 | GNUNET_assert(NULL != name); | 749 | GNUNET_assert (NULL != name); |
749 | add_qe = GNUNET_NAMESTORE_records_store(ns, | 750 | add_qe = GNUNET_NAMESTORE_records_store (ns, |
750 | &zone_pkey, | 751 | &zone_pkey, |
751 | name, | 752 | name, |
752 | rd_count + 1, | 753 | rd_count + 1, |
753 | rde, | 754 | rde, |
754 | &add_continuation, | 755 | &add_continuation, |
755 | &add_qe); | 756 | &add_qe); |
756 | } | 757 | } |
757 | 758 | ||
758 | 759 | ||
@@ -760,11 +761,11 @@ get_existing_record(void *cls, | |||
760 | * Function called if we encountered an error in zone-to-name. | 761 | * Function called if we encountered an error in zone-to-name. |
761 | */ | 762 | */ |
762 | static void | 763 | static void |
763 | reverse_error_cb(void *cls) | 764 | reverse_error_cb (void *cls) |
764 | { | 765 | { |
765 | (void)cls; | 766 | (void) cls; |
766 | reverse_qe = NULL; | 767 | reverse_qe = NULL; |
767 | fprintf(stdout, "%s.zkey\n", reverse_pkey); | 768 | fprintf (stdout, "%s.zkey\n", reverse_pkey); |
768 | } | 769 | } |
769 | 770 | ||
770 | 771 | ||
@@ -779,22 +780,22 @@ reverse_error_cb(void *cls) | |||
779 | * @param rd array of records with data to store | 780 | * @param rd array of records with data to store |
780 | */ | 781 | */ |
781 | static void | 782 | static void |
782 | handle_reverse_lookup(void *cls, | 783 | handle_reverse_lookup (void *cls, |
783 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 784 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
784 | const char *label, | 785 | const char *label, |
785 | unsigned int rd_count, | 786 | unsigned int rd_count, |
786 | const struct GNUNET_GNSRECORD_Data *rd) | 787 | const struct GNUNET_GNSRECORD_Data *rd) |
787 | { | 788 | { |
788 | (void)cls; | 789 | (void) cls; |
789 | (void)zone; | 790 | (void) zone; |
790 | (void)rd_count; | 791 | (void) rd_count; |
791 | (void)rd; | 792 | (void) rd; |
792 | reverse_qe = NULL; | 793 | reverse_qe = NULL; |
793 | if (NULL == label) | 794 | if (NULL == label) |
794 | fprintf(stdout, "%s\n", reverse_pkey); | 795 | fprintf (stdout, "%s\n", reverse_pkey); |
795 | else | 796 | else |
796 | fprintf(stdout, "%s.%s\n", label, ego_name); | 797 | fprintf (stdout, "%s.%s\n", label, ego_name); |
797 | test_finished(); | 798 | test_finished (); |
798 | } | 799 | } |
799 | 800 | ||
800 | 801 | ||
@@ -802,13 +803,13 @@ handle_reverse_lookup(void *cls, | |||
802 | * Function called if lookup for deletion fails. | 803 | * Function called if lookup for deletion fails. |
803 | */ | 804 | */ |
804 | static void | 805 | static void |
805 | del_lookup_error_cb(void *cls) | 806 | del_lookup_error_cb (void *cls) |
806 | { | 807 | { |
807 | (void)cls; | 808 | (void) cls; |
808 | del_qe = NULL; | 809 | del_qe = NULL; |
809 | GNUNET_break(0); | 810 | GNUNET_break (0); |
810 | ret = 1; | 811 | ret = 1; |
811 | test_finished(); | 812 | test_finished (); |
812 | } | 813 | } |
813 | 814 | ||
814 | 815 | ||
@@ -824,80 +825,80 @@ del_lookup_error_cb(void *cls) | |||
824 | * @param rd existing records | 825 | * @param rd existing records |
825 | */ | 826 | */ |
826 | static void | 827 | static void |
827 | del_monitor(void *cls, | 828 | del_monitor (void *cls, |
828 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 829 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
829 | const char *label, | 830 | const char *label, |
830 | unsigned int rd_count, | 831 | unsigned int rd_count, |
831 | const struct GNUNET_GNSRECORD_Data *rd) | 832 | const struct GNUNET_GNSRECORD_Data *rd) |
832 | { | 833 | { |
833 | struct GNUNET_GNSRECORD_Data rdx[rd_count]; | 834 | struct GNUNET_GNSRECORD_Data rdx[rd_count]; |
834 | unsigned int rd_left; | 835 | unsigned int rd_left; |
835 | uint32_t type; | 836 | uint32_t type; |
836 | char *vs; | 837 | char *vs; |
837 | 838 | ||
838 | (void)cls; | 839 | (void) cls; |
839 | (void)zone; | 840 | (void) zone; |
840 | del_qe = NULL; | 841 | del_qe = NULL; |
841 | if (0 == rd_count) | 842 | if (0 == rd_count) |
842 | { | 843 | { |
843 | fprintf(stderr, | 844 | fprintf (stderr, |
844 | _( | 845 | _ ( |
845 | "There are no records under label `%s' that could be deleted.\n"), | 846 | "There are no records under label `%s' that could be deleted.\n"), |
846 | label); | 847 | label); |
847 | ret = 1; | 848 | ret = 1; |
848 | test_finished(); | 849 | test_finished (); |
849 | return; | 850 | return; |
850 | } | 851 | } |
851 | if ((NULL == value) && (NULL == typestring)) | 852 | if ((NULL == value) && (NULL == typestring)) |
852 | { | 853 | { |
853 | /* delete everything */ | 854 | /* delete everything */ |
854 | del_qe = GNUNET_NAMESTORE_records_store(ns, | 855 | del_qe = GNUNET_NAMESTORE_records_store (ns, |
855 | &zone_pkey, | 856 | &zone_pkey, |
856 | name, | 857 | name, |
857 | 0, | 858 | 0, |
858 | NULL, | 859 | NULL, |
859 | &del_continuation, | 860 | &del_continuation, |
860 | NULL); | 861 | NULL); |
861 | return; | 862 | return; |
862 | } | 863 | } |
863 | rd_left = 0; | 864 | rd_left = 0; |
864 | if (NULL != typestring) | 865 | if (NULL != typestring) |
865 | type = GNUNET_GNSRECORD_typename_to_number(typestring); | 866 | type = GNUNET_GNSRECORD_typename_to_number (typestring); |
866 | else | 867 | else |
867 | type = GNUNET_GNSRECORD_TYPE_ANY; | 868 | type = GNUNET_GNSRECORD_TYPE_ANY; |
868 | for (unsigned int i = 0; i < rd_count; i++) | 869 | for (unsigned int i = 0; i < rd_count; i++) |
869 | { | 870 | { |
870 | vs = NULL; | 871 | vs = NULL; |
871 | if (!(((GNUNET_GNSRECORD_TYPE_ANY == type) || | 872 | if (! (((GNUNET_GNSRECORD_TYPE_ANY == type) || |
872 | (rd[i].record_type == type)) && | 873 | (rd[i].record_type == type)) && |
873 | ((NULL == value) || | 874 | ((NULL == value) || |
874 | (NULL == | 875 | (NULL == |
875 | (vs = (GNUNET_GNSRECORD_value_to_string(rd[i].record_type, | 876 | (vs = (GNUNET_GNSRECORD_value_to_string (rd[i].record_type, |
876 | rd[i].data, | 877 | rd[i].data, |
877 | rd[i].data_size)))) || | 878 | rd[i].data_size)))) || |
878 | (0 == strcmp(vs, value))))) | 879 | (0 == strcmp (vs, value))))) |
879 | rdx[rd_left++] = rd[i]; | 880 | rdx[rd_left++] = rd[i]; |
880 | GNUNET_free_non_null(vs); | 881 | GNUNET_free_non_null (vs); |
881 | } | 882 | } |
882 | if (rd_count == rd_left) | 883 | if (rd_count == rd_left) |
883 | { | 884 | { |
884 | /* nothing got deleted */ | 885 | /* nothing got deleted */ |
885 | fprintf( | 886 | fprintf ( |
886 | stderr, | 887 | stderr, |
887 | _( | 888 | _ ( |
888 | "There are no records under label `%s' that match the request for deletion.\n"), | 889 | "There are no records under label `%s' that match the request for deletion.\n"), |
889 | label); | 890 | label); |
890 | test_finished(); | 891 | test_finished (); |
891 | return; | 892 | return; |
892 | } | 893 | } |
893 | /* delete everything but what we copied to 'rdx' */ | 894 | /* delete everything but what we copied to 'rdx' */ |
894 | del_qe = GNUNET_NAMESTORE_records_store(ns, | 895 | del_qe = GNUNET_NAMESTORE_records_store (ns, |
895 | &zone_pkey, | 896 | &zone_pkey, |
896 | name, | 897 | name, |
897 | rd_left, | 898 | rd_left, |
898 | rdx, | 899 | rdx, |
899 | &del_continuation, | 900 | &del_continuation, |
900 | NULL); | 901 | NULL); |
901 | } | 902 | } |
902 | 903 | ||
903 | 904 | ||
@@ -910,39 +911,39 @@ del_monitor(void *cls, | |||
910 | * @return #GNUNET_OK on success | 911 | * @return #GNUNET_OK on success |
911 | */ | 912 | */ |
912 | static int | 913 | static int |
913 | parse_expiration(const char *expirationstring, | 914 | parse_expiration (const char *expirationstring, |
914 | int *etime_is_rel, | 915 | int *etime_is_rel, |
915 | uint64_t *etime) | 916 | uint64_t *etime) |
916 | { | 917 | { |
917 | struct GNUNET_TIME_Relative etime_rel; | 918 | struct GNUNET_TIME_Relative etime_rel; |
918 | struct GNUNET_TIME_Absolute etime_abs; | 919 | struct GNUNET_TIME_Absolute etime_abs; |
919 | 920 | ||
920 | if (0 == strcmp(expirationstring, "never")) | 921 | if (0 == strcmp (expirationstring, "never")) |
921 | { | 922 | { |
922 | *etime = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; | 923 | *etime = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; |
923 | *etime_is_rel = GNUNET_NO; | 924 | *etime_is_rel = GNUNET_NO; |
924 | return GNUNET_OK; | 925 | return GNUNET_OK; |
925 | } | 926 | } |
926 | if (GNUNET_OK == | 927 | if (GNUNET_OK == |
927 | GNUNET_STRINGS_fancy_time_to_relative(expirationstring, &etime_rel)) | 928 | GNUNET_STRINGS_fancy_time_to_relative (expirationstring, &etime_rel)) |
928 | { | 929 | { |
929 | *etime_is_rel = GNUNET_YES; | 930 | *etime_is_rel = GNUNET_YES; |
930 | *etime = etime_rel.rel_value_us; | 931 | *etime = etime_rel.rel_value_us; |
931 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 932 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
932 | "Storing record with relative expiration time of %s\n", | 933 | "Storing record with relative expiration time of %s\n", |
933 | GNUNET_STRINGS_relative_time_to_string(etime_rel, GNUNET_NO)); | 934 | GNUNET_STRINGS_relative_time_to_string (etime_rel, GNUNET_NO)); |
934 | return GNUNET_OK; | 935 | return GNUNET_OK; |
935 | } | 936 | } |
936 | if (GNUNET_OK == | 937 | if (GNUNET_OK == |
937 | GNUNET_STRINGS_fancy_time_to_absolute(expirationstring, &etime_abs)) | 938 | GNUNET_STRINGS_fancy_time_to_absolute (expirationstring, &etime_abs)) |
938 | { | 939 | { |
939 | *etime_is_rel = GNUNET_NO; | 940 | *etime_is_rel = GNUNET_NO; |
940 | *etime = etime_abs.abs_value_us; | 941 | *etime = etime_abs.abs_value_us; |
941 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 942 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
942 | "Storing record with absolute expiration time of %s\n", | 943 | "Storing record with absolute expiration time of %s\n", |
943 | GNUNET_STRINGS_absolute_time_to_string(etime_abs)); | 944 | GNUNET_STRINGS_absolute_time_to_string (etime_abs)); |
944 | return GNUNET_OK; | 945 | return GNUNET_OK; |
945 | } | 946 | } |
946 | return GNUNET_SYSERR; | 947 | return GNUNET_SYSERR; |
947 | } | 948 | } |
948 | 949 | ||
@@ -958,19 +959,19 @@ parse_expiration(const char *expirationstring, | |||
958 | * @param emsg NULL on success, otherwise an error message | 959 | * @param emsg NULL on success, otherwise an error message |
959 | */ | 960 | */ |
960 | static void | 961 | static void |
961 | replace_cont(void *cls, int success, const char *emsg) | 962 | replace_cont (void *cls, int success, const char *emsg) |
962 | { | 963 | { |
963 | (void)cls; | 964 | (void) cls; |
964 | 965 | ||
965 | set_qe = NULL; | 966 | set_qe = NULL; |
966 | if (GNUNET_OK != success) | 967 | if (GNUNET_OK != success) |
967 | { | 968 | { |
968 | GNUNET_log(GNUNET_ERROR_TYPE_MESSAGE, | 969 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, |
969 | _("Failed to replace records: %s\n"), | 970 | _ ("Failed to replace records: %s\n"), |
970 | emsg); | 971 | emsg); |
971 | ret = 1; /* fail from 'main' */ | 972 | ret = 1; /* fail from 'main' */ |
972 | } | 973 | } |
973 | GNUNET_SCHEDULER_shutdown(); | 974 | GNUNET_SCHEDULER_shutdown (); |
974 | } | 975 | } |
975 | 976 | ||
976 | 977 | ||
@@ -981,261 +982,261 @@ replace_cont(void *cls, int success, const char *emsg) | |||
981 | * @param cfg configuration to use | 982 | * @param cfg configuration to use |
982 | */ | 983 | */ |
983 | static void | 984 | static void |
984 | run_with_zone_pkey(const struct GNUNET_CONFIGURATION_Handle *cfg) | 985 | run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) |
985 | { | 986 | { |
986 | struct GNUNET_GNSRECORD_Data rd; | 987 | struct GNUNET_GNSRECORD_Data rd; |
987 | 988 | ||
988 | if (!(add | del | list | (NULL != nickstring) | (NULL != uri) | | 989 | if (! (add | del | list | (NULL != nickstring) | (NULL != uri) |
989 | (NULL != reverse_pkey) | (NULL != recordset))) | 990 | | (NULL != reverse_pkey) | (NULL != recordset))) |
991 | { | ||
992 | /* nothing more to be done */ | ||
993 | fprintf (stderr, _ ("No options given\n")); | ||
994 | GNUNET_SCHEDULER_shutdown (); | ||
995 | return; | ||
996 | } | ||
997 | ns = GNUNET_NAMESTORE_connect (cfg); | ||
998 | if (NULL == ns) | ||
999 | { | ||
1000 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1001 | _ ("Failed to connect to namestore\n")); | ||
1002 | return; | ||
1003 | } | ||
1004 | |||
1005 | if (NULL != recordset) | ||
1006 | { | ||
1007 | /* replace entire record set */ | ||
1008 | unsigned int rd_count; | ||
1009 | struct GNUNET_GNSRECORD_Data *rd; | ||
1010 | |||
1011 | if (NULL == name) | ||
990 | { | 1012 | { |
991 | /* nothing more to be done */ | 1013 | fprintf (stderr, |
992 | fprintf(stderr, _("No options given\n")); | 1014 | _ ("Missing option `%s' for operation `%s'\n"), |
993 | GNUNET_SCHEDULER_shutdown(); | 1015 | "-R", |
1016 | _ ("replace")); | ||
1017 | GNUNET_SCHEDULER_shutdown (); | ||
1018 | ret = 1; | ||
994 | return; | 1019 | return; |
995 | } | 1020 | } |
996 | ns = GNUNET_NAMESTORE_connect(cfg); | 1021 | rd_count = 0; |
997 | if (NULL == ns) | 1022 | for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next) |
1023 | rd_count++; | ||
1024 | rd = GNUNET_new_array (rd_count, struct GNUNET_GNSRECORD_Data); | ||
1025 | rd_count = 0; | ||
1026 | for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next) | ||
998 | { | 1027 | { |
999 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1028 | rd[rd_count] = e->record; |
1000 | _("Failed to connect to namestore\n")); | 1029 | rd_count++; |
1001 | return; | ||
1002 | } | 1030 | } |
1031 | set_qe = GNUNET_NAMESTORE_records_store (ns, | ||
1032 | &zone_pkey, | ||
1033 | name, | ||
1034 | rd_count, | ||
1035 | rd, | ||
1036 | &replace_cont, | ||
1037 | NULL); | ||
1038 | GNUNET_free (rd); | ||
1039 | return; | ||
1040 | } | ||
1003 | 1041 | ||
1004 | if (NULL != recordset) | 1042 | if (add) |
1043 | { | ||
1044 | if (NULL == name) | ||
1005 | { | 1045 | { |
1006 | /* replace entire record set */ | 1046 | fprintf (stderr, |
1007 | unsigned int rd_count; | 1047 | _ ("Missing option `%s' for operation `%s'\n"), |
1008 | struct GNUNET_GNSRECORD_Data *rd; | 1048 | "-n", |
1009 | 1049 | _ ("add")); | |
1010 | if (NULL == name) | 1050 | GNUNET_SCHEDULER_shutdown (); |
1011 | { | 1051 | ret = 1; |
1012 | fprintf(stderr, | ||
1013 | _("Missing option `%s' for operation `%s'\n"), | ||
1014 | "-R", | ||
1015 | _("replace")); | ||
1016 | GNUNET_SCHEDULER_shutdown(); | ||
1017 | ret = 1; | ||
1018 | return; | ||
1019 | } | ||
1020 | rd_count = 0; | ||
1021 | for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next) | ||
1022 | rd_count++; | ||
1023 | rd = GNUNET_new_array(rd_count, struct GNUNET_GNSRECORD_Data); | ||
1024 | rd_count = 0; | ||
1025 | for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next) | ||
1026 | { | ||
1027 | rd[rd_count] = e->record; | ||
1028 | rd_count++; | ||
1029 | } | ||
1030 | set_qe = GNUNET_NAMESTORE_records_store(ns, | ||
1031 | &zone_pkey, | ||
1032 | name, | ||
1033 | rd_count, | ||
1034 | rd, | ||
1035 | &replace_cont, | ||
1036 | NULL); | ||
1037 | GNUNET_free(rd); | ||
1038 | return; | 1052 | return; |
1039 | } | 1053 | } |
1040 | 1054 | if (NULL == typestring) | |
1041 | if (add) | ||
1042 | { | 1055 | { |
1043 | if (NULL == name) | 1056 | fprintf (stderr, |
1044 | { | 1057 | _ ("Missing option `%s' for operation `%s'\n"), |
1045 | fprintf(stderr, | 1058 | "-t", |
1046 | _("Missing option `%s' for operation `%s'\n"), | 1059 | _ ("add")); |
1047 | "-n", | 1060 | GNUNET_SCHEDULER_shutdown (); |
1048 | _("add")); | 1061 | ret = 1; |
1049 | GNUNET_SCHEDULER_shutdown(); | 1062 | return; |
1050 | ret = 1; | ||
1051 | return; | ||
1052 | } | ||
1053 | if (NULL == typestring) | ||
1054 | { | ||
1055 | fprintf(stderr, | ||
1056 | _("Missing option `%s' for operation `%s'\n"), | ||
1057 | "-t", | ||
1058 | _("add")); | ||
1059 | GNUNET_SCHEDULER_shutdown(); | ||
1060 | ret = 1; | ||
1061 | return; | ||
1062 | } | ||
1063 | type = GNUNET_GNSRECORD_typename_to_number(typestring); | ||
1064 | if (UINT32_MAX == type) | ||
1065 | { | ||
1066 | fprintf(stderr, _("Unsupported type `%s'\n"), typestring); | ||
1067 | GNUNET_SCHEDULER_shutdown(); | ||
1068 | ret = 1; | ||
1069 | return; | ||
1070 | } | ||
1071 | if (NULL == value) | ||
1072 | { | ||
1073 | fprintf(stderr, | ||
1074 | _("Missing option `%s' for operation `%s'\n"), | ||
1075 | "-V", | ||
1076 | _("add")); | ||
1077 | ret = 1; | ||
1078 | GNUNET_SCHEDULER_shutdown(); | ||
1079 | return; | ||
1080 | } | ||
1081 | if (GNUNET_OK != | ||
1082 | GNUNET_GNSRECORD_string_to_value(type, value, &data, &data_size)) | ||
1083 | { | ||
1084 | fprintf(stderr, | ||
1085 | _("Value `%s' invalid for record type `%s'\n"), | ||
1086 | value, | ||
1087 | typestring); | ||
1088 | GNUNET_SCHEDULER_shutdown(); | ||
1089 | ret = 1; | ||
1090 | return; | ||
1091 | } | ||
1092 | if (NULL == expirationstring) | ||
1093 | { | ||
1094 | fprintf(stderr, | ||
1095 | _("Missing option `%s' for operation `%s'\n"), | ||
1096 | "-e", | ||
1097 | _("add")); | ||
1098 | GNUNET_SCHEDULER_shutdown(); | ||
1099 | ret = 1; | ||
1100 | return; | ||
1101 | } | ||
1102 | if (GNUNET_OK != parse_expiration(expirationstring, &etime_is_rel, &etime)) | ||
1103 | { | ||
1104 | fprintf(stderr, _("Invalid time format `%s'\n"), expirationstring); | ||
1105 | GNUNET_SCHEDULER_shutdown(); | ||
1106 | ret = 1; | ||
1107 | return; | ||
1108 | } | ||
1109 | add_qe = GNUNET_NAMESTORE_records_lookup(ns, | ||
1110 | &zone_pkey, | ||
1111 | name, | ||
1112 | &add_error_cb, | ||
1113 | NULL, | ||
1114 | &get_existing_record, | ||
1115 | NULL); | ||
1116 | } | 1063 | } |
1117 | if (del) | 1064 | type = GNUNET_GNSRECORD_typename_to_number (typestring); |
1065 | if (UINT32_MAX == type) | ||
1118 | { | 1066 | { |
1119 | if (NULL == name) | 1067 | fprintf (stderr, _ ("Unsupported type `%s'\n"), typestring); |
1120 | { | 1068 | GNUNET_SCHEDULER_shutdown (); |
1121 | fprintf(stderr, | 1069 | ret = 1; |
1122 | _("Missing option `%s' for operation `%s'\n"), | 1070 | return; |
1123 | "-n", | ||
1124 | _("del")); | ||
1125 | GNUNET_SCHEDULER_shutdown(); | ||
1126 | ret = 1; | ||
1127 | return; | ||
1128 | } | ||
1129 | del_qe = GNUNET_NAMESTORE_records_lookup(ns, | ||
1130 | &zone_pkey, | ||
1131 | name, | ||
1132 | &del_lookup_error_cb, | ||
1133 | NULL, | ||
1134 | &del_monitor, | ||
1135 | NULL); | ||
1136 | } | 1071 | } |
1137 | if (list) | 1072 | if (NULL == value) |
1138 | { | 1073 | { |
1139 | if (NULL != name) | 1074 | fprintf (stderr, |
1140 | get_qe = GNUNET_NAMESTORE_records_lookup(ns, | 1075 | _ ("Missing option `%s' for operation `%s'\n"), |
1141 | &zone_pkey, | 1076 | "-V", |
1142 | name, | 1077 | _ ("add")); |
1143 | &lookup_error_cb, | 1078 | ret = 1; |
1144 | NULL, | 1079 | GNUNET_SCHEDULER_shutdown (); |
1145 | &display_record_lookup, | 1080 | return; |
1146 | NULL); | 1081 | } |
1147 | else | 1082 | if (GNUNET_OK != |
1148 | list_it = GNUNET_NAMESTORE_zone_iteration_start(ns, | 1083 | GNUNET_GNSRECORD_string_to_value (type, value, &data, &data_size)) |
1149 | &zone_pkey, | 1084 | { |
1150 | &zone_iteration_error_cb, | 1085 | fprintf (stderr, |
1151 | NULL, | 1086 | _ ("Value `%s' invalid for record type `%s'\n"), |
1152 | &display_record_iterator, | 1087 | value, |
1153 | NULL, | 1088 | typestring); |
1154 | &zone_iteration_finished, | 1089 | GNUNET_SCHEDULER_shutdown (); |
1155 | NULL); | 1090 | ret = 1; |
1091 | return; | ||
1092 | } | ||
1093 | if (NULL == expirationstring) | ||
1094 | { | ||
1095 | fprintf (stderr, | ||
1096 | _ ("Missing option `%s' for operation `%s'\n"), | ||
1097 | "-e", | ||
1098 | _ ("add")); | ||
1099 | GNUNET_SCHEDULER_shutdown (); | ||
1100 | ret = 1; | ||
1101 | return; | ||
1102 | } | ||
1103 | if (GNUNET_OK != parse_expiration (expirationstring, &etime_is_rel, &etime)) | ||
1104 | { | ||
1105 | fprintf (stderr, _ ("Invalid time format `%s'\n"), expirationstring); | ||
1106 | GNUNET_SCHEDULER_shutdown (); | ||
1107 | ret = 1; | ||
1108 | return; | ||
1109 | } | ||
1110 | add_qe = GNUNET_NAMESTORE_records_lookup (ns, | ||
1111 | &zone_pkey, | ||
1112 | name, | ||
1113 | &add_error_cb, | ||
1114 | NULL, | ||
1115 | &get_existing_record, | ||
1116 | NULL); | ||
1117 | } | ||
1118 | if (del) | ||
1119 | { | ||
1120 | if (NULL == name) | ||
1121 | { | ||
1122 | fprintf (stderr, | ||
1123 | _ ("Missing option `%s' for operation `%s'\n"), | ||
1124 | "-n", | ||
1125 | _ ("del")); | ||
1126 | GNUNET_SCHEDULER_shutdown (); | ||
1127 | ret = 1; | ||
1128 | return; | ||
1156 | } | 1129 | } |
1130 | del_qe = GNUNET_NAMESTORE_records_lookup (ns, | ||
1131 | &zone_pkey, | ||
1132 | name, | ||
1133 | &del_lookup_error_cb, | ||
1134 | NULL, | ||
1135 | &del_monitor, | ||
1136 | NULL); | ||
1137 | } | ||
1138 | if (list) | ||
1139 | { | ||
1140 | if (NULL != name) | ||
1141 | get_qe = GNUNET_NAMESTORE_records_lookup (ns, | ||
1142 | &zone_pkey, | ||
1143 | name, | ||
1144 | &lookup_error_cb, | ||
1145 | NULL, | ||
1146 | &display_record_lookup, | ||
1147 | NULL); | ||
1148 | else | ||
1149 | list_it = GNUNET_NAMESTORE_zone_iteration_start (ns, | ||
1150 | &zone_pkey, | ||
1151 | &zone_iteration_error_cb, | ||
1152 | NULL, | ||
1153 | &display_record_iterator, | ||
1154 | NULL, | ||
1155 | &zone_iteration_finished, | ||
1156 | NULL); | ||
1157 | } | ||
1157 | if (NULL != reverse_pkey) | 1158 | if (NULL != reverse_pkey) |
1159 | { | ||
1160 | struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; | ||
1161 | |||
1162 | if (GNUNET_OK != | ||
1163 | GNUNET_CRYPTO_ecdsa_public_key_from_string (reverse_pkey, | ||
1164 | strlen (reverse_pkey), | ||
1165 | &pubkey)) | ||
1158 | { | 1166 | { |
1159 | struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; | 1167 | fprintf (stderr, |
1160 | 1168 | _ ("Invalid public key for reverse lookup `%s'\n"), | |
1161 | if (GNUNET_OK != | 1169 | reverse_pkey); |
1162 | GNUNET_CRYPTO_ecdsa_public_key_from_string(reverse_pkey, | 1170 | GNUNET_SCHEDULER_shutdown (); |
1163 | strlen(reverse_pkey), | ||
1164 | &pubkey)) | ||
1165 | { | ||
1166 | fprintf(stderr, | ||
1167 | _("Invalid public key for reverse lookup `%s'\n"), | ||
1168 | reverse_pkey); | ||
1169 | GNUNET_SCHEDULER_shutdown(); | ||
1170 | } | ||
1171 | reverse_qe = GNUNET_NAMESTORE_zone_to_name(ns, | ||
1172 | &zone_pkey, | ||
1173 | &pubkey, | ||
1174 | &reverse_error_cb, | ||
1175 | NULL, | ||
1176 | &handle_reverse_lookup, | ||
1177 | NULL); | ||
1178 | } | 1171 | } |
1172 | reverse_qe = GNUNET_NAMESTORE_zone_to_name (ns, | ||
1173 | &zone_pkey, | ||
1174 | &pubkey, | ||
1175 | &reverse_error_cb, | ||
1176 | NULL, | ||
1177 | &handle_reverse_lookup, | ||
1178 | NULL); | ||
1179 | } | ||
1179 | if (NULL != uri) | 1180 | if (NULL != uri) |
1181 | { | ||
1182 | char sh[105]; | ||
1183 | char sname[64]; | ||
1184 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; | ||
1185 | |||
1186 | GNUNET_STRINGS_utf8_tolower (uri, uri); | ||
1187 | if ((2 != (sscanf (uri, "gnunet://gns/%52s/%63s", sh, sname))) || | ||
1188 | (GNUNET_OK != | ||
1189 | GNUNET_CRYPTO_ecdsa_public_key_from_string (sh, strlen (sh), &pkey))) | ||
1180 | { | 1190 | { |
1181 | char sh[105]; | 1191 | fprintf (stderr, _ ("Invalid URI `%s'\n"), uri); |
1182 | char sname[64]; | 1192 | GNUNET_SCHEDULER_shutdown (); |
1183 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; | 1193 | ret = 1; |
1184 | 1194 | return; | |
1185 | GNUNET_STRINGS_utf8_tolower(uri, uri); | ||
1186 | if ((2 != (sscanf(uri, "gnunet://gns/%52s/%63s", sh, sname))) || | ||
1187 | (GNUNET_OK != | ||
1188 | GNUNET_CRYPTO_ecdsa_public_key_from_string(sh, strlen(sh), &pkey))) | ||
1189 | { | ||
1190 | fprintf(stderr, _("Invalid URI `%s'\n"), uri); | ||
1191 | GNUNET_SCHEDULER_shutdown(); | ||
1192 | ret = 1; | ||
1193 | return; | ||
1194 | } | ||
1195 | memset(&rd, 0, sizeof(rd)); | ||
1196 | rd.data = &pkey; | ||
1197 | rd.data_size = sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey); | ||
1198 | rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY; | ||
1199 | rd.expiration_time = etime; | ||
1200 | if (GNUNET_YES == etime_is_rel) | ||
1201 | rd.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | ||
1202 | if (1 == is_shadow) | ||
1203 | rd.flags |= GNUNET_GNSRECORD_RF_SHADOW_RECORD; | ||
1204 | add_qe_uri = GNUNET_NAMESTORE_records_store(ns, | ||
1205 | &zone_pkey, | ||
1206 | sname, | ||
1207 | 1, | ||
1208 | &rd, | ||
1209 | &add_continuation, | ||
1210 | &add_qe_uri); | ||
1211 | } | 1195 | } |
1196 | memset (&rd, 0, sizeof(rd)); | ||
1197 | rd.data = &pkey; | ||
1198 | rd.data_size = sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey); | ||
1199 | rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY; | ||
1200 | rd.expiration_time = etime; | ||
1201 | if (GNUNET_YES == etime_is_rel) | ||
1202 | rd.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | ||
1203 | if (1 == is_shadow) | ||
1204 | rd.flags |= GNUNET_GNSRECORD_RF_SHADOW_RECORD; | ||
1205 | add_qe_uri = GNUNET_NAMESTORE_records_store (ns, | ||
1206 | &zone_pkey, | ||
1207 | sname, | ||
1208 | 1, | ||
1209 | &rd, | ||
1210 | &add_continuation, | ||
1211 | &add_qe_uri); | ||
1212 | } | ||
1212 | if (NULL != nickstring) | 1213 | if (NULL != nickstring) |
1214 | { | ||
1215 | if (0 == strlen (nickstring)) | ||
1213 | { | 1216 | { |
1214 | if (0 == strlen(nickstring)) | 1217 | fprintf (stderr, _ ("Invalid nick `%s'\n"), nickstring); |
1215 | { | 1218 | GNUNET_SCHEDULER_shutdown (); |
1216 | fprintf(stderr, _("Invalid nick `%s'\n"), nickstring); | 1219 | ret = 1; |
1217 | GNUNET_SCHEDULER_shutdown(); | 1220 | return; |
1218 | ret = 1; | ||
1219 | return; | ||
1220 | } | ||
1221 | add_qe_uri = GNUNET_NAMESTORE_set_nick(ns, | ||
1222 | &zone_pkey, | ||
1223 | nickstring, | ||
1224 | &add_continuation, | ||
1225 | &add_qe_uri); | ||
1226 | } | 1221 | } |
1222 | add_qe_uri = GNUNET_NAMESTORE_set_nick (ns, | ||
1223 | &zone_pkey, | ||
1224 | nickstring, | ||
1225 | &add_continuation, | ||
1226 | &add_qe_uri); | ||
1227 | } | ||
1227 | if (monitor) | 1228 | if (monitor) |
1228 | { | 1229 | { |
1229 | zm = GNUNET_NAMESTORE_zone_monitor_start(cfg, | 1230 | zm = GNUNET_NAMESTORE_zone_monitor_start (cfg, |
1230 | &zone_pkey, | 1231 | &zone_pkey, |
1231 | GNUNET_YES, | 1232 | GNUNET_YES, |
1232 | &monitor_error_cb, | 1233 | &monitor_error_cb, |
1233 | NULL, | 1234 | NULL, |
1234 | &display_record_monitor, | 1235 | &display_record_monitor, |
1235 | NULL, | 1236 | NULL, |
1236 | &sync_cb, | 1237 | &sync_cb, |
1237 | NULL); | 1238 | NULL); |
1238 | } | 1239 | } |
1239 | } | 1240 | } |
1240 | 1241 | ||
1241 | 1242 | ||
@@ -1247,37 +1248,37 @@ run_with_zone_pkey(const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1247 | * @param ego an ego known to identity service, or NULL | 1248 | * @param ego an ego known to identity service, or NULL |
1248 | */ | 1249 | */ |
1249 | static void | 1250 | static void |
1250 | identity_cb(void *cls, const struct GNUNET_IDENTITY_Ego *ego) | 1251 | identity_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego) |
1251 | { | 1252 | { |
1252 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 1253 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; |
1253 | 1254 | ||
1254 | el = NULL; | 1255 | el = NULL; |
1255 | if ((NULL != name) && (0 != strchr(name, '.'))) | 1256 | if ((NULL != name) && (0 != strchr (name, '.'))) |
1256 | { | 1257 | { |
1257 | fprintf(stderr, | 1258 | fprintf (stderr, |
1258 | _("Label `%s' contains `.' which is not allowed\n"), | 1259 | _ ("Label `%s' contains `.' which is not allowed\n"), |
1259 | name); | 1260 | name); |
1260 | GNUNET_SCHEDULER_shutdown(); | 1261 | GNUNET_SCHEDULER_shutdown (); |
1261 | ret = -1; | 1262 | ret = -1; |
1262 | return; | 1263 | return; |
1263 | } | 1264 | } |
1264 | 1265 | ||
1265 | if (NULL == ego) | 1266 | if (NULL == ego) |
1267 | { | ||
1268 | if (NULL != ego_name) | ||
1266 | { | 1269 | { |
1267 | if (NULL != ego_name) | 1270 | fprintf (stderr, |
1268 | { | 1271 | _ ("Ego `%s' not known to identity service\n"), |
1269 | fprintf(stderr, | 1272 | ego_name); |
1270 | _("Ego `%s' not known to identity service\n"), | ||
1271 | ego_name); | ||
1272 | } | ||
1273 | GNUNET_SCHEDULER_shutdown(); | ||
1274 | ret = -1; | ||
1275 | return; | ||
1276 | } | 1273 | } |
1277 | zone_pkey = *GNUNET_IDENTITY_ego_get_private_key(ego); | 1274 | GNUNET_SCHEDULER_shutdown (); |
1278 | GNUNET_free_non_null(ego_name); | 1275 | ret = -1; |
1276 | return; | ||
1277 | } | ||
1278 | zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego); | ||
1279 | GNUNET_free_non_null (ego_name); | ||
1279 | ego_name = NULL; | 1280 | ego_name = NULL; |
1280 | run_with_zone_pkey(cfg); | 1281 | run_with_zone_pkey (cfg); |
1281 | } | 1282 | } |
1282 | 1283 | ||
1283 | 1284 | ||
@@ -1292,27 +1293,27 @@ identity_cb(void *cls, const struct GNUNET_IDENTITY_Ego *ego) | |||
1292 | * @param name unused | 1293 | * @param name unused |
1293 | */ | 1294 | */ |
1294 | static void | 1295 | static void |
1295 | default_ego_cb(void *cls, | 1296 | default_ego_cb (void *cls, |
1296 | struct GNUNET_IDENTITY_Ego *ego, | 1297 | struct GNUNET_IDENTITY_Ego *ego, |
1297 | void **ctx, | 1298 | void **ctx, |
1298 | const char *name) | 1299 | const char *name) |
1299 | { | 1300 | { |
1300 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 1301 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; |
1301 | 1302 | ||
1302 | (void)ctx; | 1303 | (void) ctx; |
1303 | (void)name; | 1304 | (void) name; |
1304 | get_default = NULL; | 1305 | get_default = NULL; |
1305 | if (NULL == ego) | 1306 | if (NULL == ego) |
1306 | { | 1307 | { |
1307 | fprintf(stderr, _("No default ego configured in identity service\n")); | 1308 | fprintf (stderr, _ ("No default ego configured in identity service\n")); |
1308 | GNUNET_SCHEDULER_shutdown(); | 1309 | GNUNET_SCHEDULER_shutdown (); |
1309 | ret = -1; | 1310 | ret = -1; |
1310 | return; | 1311 | return; |
1311 | } | 1312 | } |
1312 | else | 1313 | else |
1313 | { | 1314 | { |
1314 | identity_cb((void *)cfg, ego); | 1315 | identity_cb ((void *) cfg, ego); |
1315 | } | 1316 | } |
1316 | } | 1317 | } |
1317 | 1318 | ||
1318 | 1319 | ||
@@ -1329,19 +1330,19 @@ default_ego_cb(void *cls, | |||
1329 | * @param name name associated with @a ego | 1330 | * @param name name associated with @a ego |
1330 | */ | 1331 | */ |
1331 | static void | 1332 | static void |
1332 | id_connect_cb(void *cls, | 1333 | id_connect_cb (void *cls, |
1333 | struct GNUNET_IDENTITY_Ego *ego, | 1334 | struct GNUNET_IDENTITY_Ego *ego, |
1334 | void **ctx, | 1335 | void **ctx, |
1335 | const char *name) | 1336 | const char *name) |
1336 | { | 1337 | { |
1337 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 1338 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; |
1338 | 1339 | ||
1339 | (void)ctx; | 1340 | (void) ctx; |
1340 | (void)name; | 1341 | (void) name; |
1341 | if (NULL != ego) | 1342 | if (NULL != ego) |
1342 | return; | 1343 | return; |
1343 | get_default = | 1344 | get_default = |
1344 | GNUNET_IDENTITY_get(idh, "namestore", &default_ego_cb, (void *)cfg); | 1345 | GNUNET_IDENTITY_get (idh, "namestore", &default_ego_cb, (void *) cfg); |
1345 | } | 1346 | } |
1346 | 1347 | ||
1347 | 1348 | ||
@@ -1354,53 +1355,53 @@ id_connect_cb(void *cls, | |||
1354 | * @param cfg configuration | 1355 | * @param cfg configuration |
1355 | */ | 1356 | */ |
1356 | static void | 1357 | static void |
1357 | run(void *cls, | 1358 | run (void *cls, |
1358 | char *const *args, | 1359 | char *const *args, |
1359 | const char *cfgfile, | 1360 | const char *cfgfile, |
1360 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 1361 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
1361 | { | 1362 | { |
1362 | const char *pkey_str; | 1363 | const char *pkey_str; |
1363 | 1364 | ||
1364 | (void)cls; | 1365 | (void) cls; |
1365 | (void)args; | 1366 | (void) args; |
1366 | (void)cfgfile; | 1367 | (void) cfgfile; |
1367 | if (NULL != args[0]) | 1368 | if (NULL != args[0]) |
1368 | GNUNET_log( | 1369 | GNUNET_log ( |
1369 | GNUNET_ERROR_TYPE_WARNING, | 1370 | GNUNET_ERROR_TYPE_WARNING, |
1370 | _("Superfluous command line arguments (starting with `%s') ignored\n"), | 1371 | _ ("Superfluous command line arguments (starting with `%s') ignored\n"), |
1371 | args[0]); | 1372 | args[0]); |
1372 | if ((NULL != args[0]) && (NULL == uri)) | 1373 | if ((NULL != args[0]) && (NULL == uri)) |
1373 | uri = GNUNET_strdup(args[0]); | 1374 | uri = GNUNET_strdup (args[0]); |
1374 | 1375 | ||
1375 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, (void *)cfg); | 1376 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, (void *) cfg); |
1376 | pkey_str = getenv("GNUNET_NAMESTORE_EGO_PRIVATE_KEY"); | 1377 | pkey_str = getenv ("GNUNET_NAMESTORE_EGO_PRIVATE_KEY"); |
1377 | if (NULL != pkey_str) | 1378 | if (NULL != pkey_str) |
1379 | { | ||
1380 | if (GNUNET_OK != GNUNET_STRINGS_string_to_data (pkey_str, | ||
1381 | strlen (pkey_str), | ||
1382 | &zone_pkey, | ||
1383 | sizeof(zone_pkey))) | ||
1378 | { | 1384 | { |
1379 | if (GNUNET_OK != GNUNET_STRINGS_string_to_data(pkey_str, | 1385 | fprintf (stderr, |
1380 | strlen(pkey_str), | 1386 | "Malformed private key `%s' in $%s\n", |
1381 | &zone_pkey, | 1387 | pkey_str, |
1382 | sizeof(zone_pkey))) | 1388 | "GNUNET_NAMESTORE_EGO_PRIVATE_KEY"); |
1383 | { | 1389 | ret = 1; |
1384 | fprintf(stderr, | 1390 | GNUNET_SCHEDULER_shutdown (); |
1385 | "Malformed private key `%s' in $%s\n", | ||
1386 | pkey_str, | ||
1387 | "GNUNET_NAMESTORE_EGO_PRIVATE_KEY"); | ||
1388 | ret = 1; | ||
1389 | GNUNET_SCHEDULER_shutdown(); | ||
1390 | return; | ||
1391 | } | ||
1392 | run_with_zone_pkey(cfg); | ||
1393 | return; | 1391 | return; |
1394 | } | 1392 | } |
1393 | run_with_zone_pkey (cfg); | ||
1394 | return; | ||
1395 | } | ||
1395 | if (NULL == ego_name) | 1396 | if (NULL == ego_name) |
1396 | { | 1397 | { |
1397 | idh = GNUNET_IDENTITY_connect(cfg, &id_connect_cb, (void *)cfg); | 1398 | idh = GNUNET_IDENTITY_connect (cfg, &id_connect_cb, (void *) cfg); |
1398 | if (NULL == idh) | 1399 | if (NULL == idh) |
1399 | fprintf(stderr, _("Cannot connect to identity service\n")); | 1400 | fprintf (stderr, _ ("Cannot connect to identity service\n")); |
1400 | ret = -1; | 1401 | ret = -1; |
1401 | return; | 1402 | return; |
1402 | } | 1403 | } |
1403 | el = GNUNET_IDENTITY_ego_lookup(cfg, ego_name, &identity_cb, (void *)cfg); | 1404 | el = GNUNET_IDENTITY_ego_lookup (cfg, ego_name, &identity_cb, (void *) cfg); |
1404 | } | 1405 | } |
1405 | 1406 | ||
1406 | 1407 | ||
@@ -1422,10 +1423,10 @@ run(void *cls, | |||
1422 | * @return #GNUNET_OK on success | 1423 | * @return #GNUNET_OK on success |
1423 | */ | 1424 | */ |
1424 | static int | 1425 | static int |
1425 | multirecord_process(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 1426 | multirecord_process (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, |
1426 | void *scls, | 1427 | void *scls, |
1427 | const char *option, | 1428 | const char *option, |
1428 | const char *value) | 1429 | const char *value) |
1429 | { | 1430 | { |
1430 | struct RecordSetEntry **head = scls; | 1431 | struct RecordSetEntry **head = scls; |
1431 | struct RecordSetEntry *r; | 1432 | struct RecordSetEntry *r; |
@@ -1436,94 +1437,94 @@ multirecord_process(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
1436 | int etime_is_rel; | 1437 | int etime_is_rel; |
1437 | void *raw_data; | 1438 | void *raw_data; |
1438 | 1439 | ||
1439 | (void)ctx; | 1440 | (void) ctx; |
1440 | (void)option; | 1441 | (void) option; |
1441 | cp = GNUNET_strdup(value); | 1442 | cp = GNUNET_strdup (value); |
1442 | tok = strtok_r(cp, " ", &saveptr); | 1443 | tok = strtok_r (cp, " ", &saveptr); |
1443 | if (NULL == tok) | 1444 | if (NULL == tok) |
1444 | { | 1445 | { |
1445 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1446 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1446 | _("Empty record line argument is not allowed.\n")); | 1447 | _ ("Empty record line argument is not allowed.\n")); |
1447 | GNUNET_free(cp); | 1448 | GNUNET_free (cp); |
1448 | return GNUNET_SYSERR; | 1449 | return GNUNET_SYSERR; |
1449 | } | 1450 | } |
1450 | { | 1451 | { |
1451 | char *etime_in_s; | 1452 | char *etime_in_s; |
1452 | 1453 | ||
1453 | GNUNET_asprintf(&etime_in_s, "%s s", tok); | 1454 | GNUNET_asprintf (&etime_in_s, "%s s", tok); |
1454 | if (GNUNET_OK != | 1455 | if (GNUNET_OK != |
1455 | parse_expiration(etime_in_s, &etime_is_rel, &record.expiration_time)) | 1456 | parse_expiration (etime_in_s, &etime_is_rel, &record.expiration_time)) |
1456 | { | ||
1457 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
1458 | _("Invalid expiration time `%s' (must be without unit)\n"), | ||
1459 | tok); | ||
1460 | GNUNET_free(cp); | ||
1461 | GNUNET_free(etime_in_s); | ||
1462 | return GNUNET_SYSERR; | ||
1463 | } | ||
1464 | GNUNET_free(etime_in_s); | ||
1465 | } | ||
1466 | tok = strtok_r(NULL, " ", &saveptr); | ||
1467 | if (NULL == tok) | ||
1468 | { | 1457 | { |
1469 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1458 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1470 | _("Missing entries in record line `%s'.\n"), | 1459 | _ ("Invalid expiration time `%s' (must be without unit)\n"), |
1471 | value); | 1460 | tok); |
1472 | GNUNET_free(cp); | 1461 | GNUNET_free (cp); |
1462 | GNUNET_free (etime_in_s); | ||
1473 | return GNUNET_SYSERR; | 1463 | return GNUNET_SYSERR; |
1474 | } | 1464 | } |
1475 | record.record_type = GNUNET_GNSRECORD_typename_to_number(tok); | 1465 | GNUNET_free (etime_in_s); |
1466 | } | ||
1467 | tok = strtok_r (NULL, " ", &saveptr); | ||
1468 | if (NULL == tok) | ||
1469 | { | ||
1470 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1471 | _ ("Missing entries in record line `%s'.\n"), | ||
1472 | value); | ||
1473 | GNUNET_free (cp); | ||
1474 | return GNUNET_SYSERR; | ||
1475 | } | ||
1476 | record.record_type = GNUNET_GNSRECORD_typename_to_number (tok); | ||
1476 | if (UINT32_MAX == record.record_type) | 1477 | if (UINT32_MAX == record.record_type) |
1477 | { | 1478 | { |
1478 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Unknown record type `%s'\n"), tok); | 1479 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Unknown record type `%s'\n"), tok); |
1479 | GNUNET_free(cp); | 1480 | GNUNET_free (cp); |
1480 | return GNUNET_SYSERR; | 1481 | return GNUNET_SYSERR; |
1481 | } | 1482 | } |
1482 | tok = strtok_r(NULL, " ", &saveptr); | 1483 | tok = strtok_r (NULL, " ", &saveptr); |
1483 | if (NULL == tok) | 1484 | if (NULL == tok) |
1484 | { | 1485 | { |
1485 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1486 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1486 | _("Missing entries in record line `%s'.\n"), | 1487 | _ ("Missing entries in record line `%s'.\n"), |
1487 | value); | 1488 | value); |
1488 | GNUNET_free(cp); | 1489 | GNUNET_free (cp); |
1489 | return GNUNET_SYSERR; | 1490 | return GNUNET_SYSERR; |
1490 | } | 1491 | } |
1491 | record.flags = GNUNET_GNSRECORD_RF_NONE; | 1492 | record.flags = GNUNET_GNSRECORD_RF_NONE; |
1492 | if (etime_is_rel) | 1493 | if (etime_is_rel) |
1493 | record.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 1494 | record.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
1494 | if (NULL == strchr(tok, (unsigned char)'p')) /* p = public */ | 1495 | if (NULL == strchr (tok, (unsigned char) 'p')) /* p = public */ |
1495 | record.flags |= GNUNET_GNSRECORD_RF_PRIVATE; | 1496 | record.flags |= GNUNET_GNSRECORD_RF_PRIVATE; |
1496 | if (NULL != strchr(tok, (unsigned char)'s')) | 1497 | if (NULL != strchr (tok, (unsigned char) 's')) |
1497 | record.flags |= GNUNET_GNSRECORD_RF_SHADOW_RECORD; | 1498 | record.flags |= GNUNET_GNSRECORD_RF_SHADOW_RECORD; |
1498 | /* find beginning of record value */ | 1499 | /* find beginning of record value */ |
1499 | tok = strchr(&value[tok - cp], (unsigned char)' '); | 1500 | tok = strchr (&value[tok - cp], (unsigned char) ' '); |
1500 | if (NULL == tok) | 1501 | if (NULL == tok) |
1501 | { | 1502 | { |
1502 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1503 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1503 | _("Missing entries in record line `%s'.\n"), | 1504 | _ ("Missing entries in record line `%s'.\n"), |
1504 | value); | 1505 | value); |
1505 | GNUNET_free(cp); | 1506 | GNUNET_free (cp); |
1506 | return GNUNET_SYSERR; | 1507 | return GNUNET_SYSERR; |
1507 | } | 1508 | } |
1508 | GNUNET_free(cp); | 1509 | GNUNET_free (cp); |
1509 | tok++; /* skip space */ | 1510 | tok++; /* skip space */ |
1510 | if (GNUNET_OK != GNUNET_GNSRECORD_string_to_value(record.record_type, | 1511 | if (GNUNET_OK != GNUNET_GNSRECORD_string_to_value (record.record_type, |
1511 | tok, | 1512 | tok, |
1512 | &raw_data, | 1513 | &raw_data, |
1513 | &record.data_size)) | 1514 | &record.data_size)) |
1514 | { | 1515 | { |
1515 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1516 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1516 | _("Invalid record data for type %s: `%s'.\n"), | 1517 | _ ("Invalid record data for type %s: `%s'.\n"), |
1517 | GNUNET_GNSRECORD_number_to_typename(record.record_type), | 1518 | GNUNET_GNSRECORD_number_to_typename (record.record_type), |
1518 | tok); | 1519 | tok); |
1519 | return GNUNET_SYSERR; | 1520 | return GNUNET_SYSERR; |
1520 | } | 1521 | } |
1521 | 1522 | ||
1522 | r = GNUNET_malloc(sizeof(struct RecordSetEntry) + record.data_size); | 1523 | r = GNUNET_malloc (sizeof(struct RecordSetEntry) + record.data_size); |
1523 | r->next = *head; | 1524 | r->next = *head; |
1524 | record.data = &r[1]; | 1525 | record.data = &r[1]; |
1525 | memcpy(&r[1], raw_data, record.data_size); | 1526 | memcpy (&r[1], raw_data, record.data_size); |
1526 | GNUNET_free(raw_data); | 1527 | GNUNET_free (raw_data); |
1527 | r->record = record; | 1528 | r->record = record; |
1528 | *head = r; | 1529 | *head = r; |
1529 | return GNUNET_OK; | 1530 | return GNUNET_OK; |
@@ -1540,11 +1541,11 @@ multirecord_process(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
1540 | * @param[out] topKeywords set to the desired value | 1541 | * @param[out] topKeywords set to the desired value |
1541 | */ | 1542 | */ |
1542 | struct GNUNET_GETOPT_CommandLineOption | 1543 | struct GNUNET_GETOPT_CommandLineOption |
1543 | multirecord_option(char shortName, | 1544 | multirecord_option (char shortName, |
1544 | const char *name, | 1545 | const char *name, |
1545 | const char *argumentHelp, | 1546 | const char *argumentHelp, |
1546 | const char *description, | 1547 | const char *description, |
1547 | struct RecordSetEntry **rs) | 1548 | struct RecordSetEntry **rs) |
1548 | { | 1549 | { |
1549 | struct GNUNET_GETOPT_CommandLineOption clo = { .shortName = shortName, | 1550 | struct GNUNET_GETOPT_CommandLineOption clo = { .shortName = shortName, |
1550 | .name = name, | 1551 | .name = name, |
@@ -1553,7 +1554,7 @@ multirecord_option(char shortName, | |||
1553 | .require_argument = 1, | 1554 | .require_argument = 1, |
1554 | .processor = | 1555 | .processor = |
1555 | &multirecord_process, | 1556 | &multirecord_process, |
1556 | .scls = (void *)rs }; | 1557 | .scls = (void *) rs }; |
1557 | 1558 | ||
1558 | return clo; | 1559 | return clo; |
1559 | } | 1560 | } |
@@ -1567,112 +1568,112 @@ multirecord_option(char shortName, | |||
1567 | * @return 0 ok, 1 on error | 1568 | * @return 0 ok, 1 on error |
1568 | */ | 1569 | */ |
1569 | int | 1570 | int |
1570 | main(int argc, char *const *argv) | 1571 | main (int argc, char *const *argv) |
1571 | { | 1572 | { |
1572 | struct GNUNET_GETOPT_CommandLineOption options[] = | 1573 | struct GNUNET_GETOPT_CommandLineOption options[] = |
1573 | { GNUNET_GETOPT_option_flag('a', "add", gettext_noop("add record"), &add), | 1574 | { GNUNET_GETOPT_option_flag ('a', "add", gettext_noop ("add record"), &add), |
1574 | GNUNET_GETOPT_option_flag('d', | 1575 | GNUNET_GETOPT_option_flag ('d', |
1575 | "delete", | 1576 | "delete", |
1576 | gettext_noop("delete record"), | 1577 | gettext_noop ("delete record"), |
1577 | &del), | 1578 | &del), |
1578 | GNUNET_GETOPT_option_flag('D', | 1579 | GNUNET_GETOPT_option_flag ('D', |
1579 | "display", | 1580 | "display", |
1580 | gettext_noop("display records"), | 1581 | gettext_noop ("display records"), |
1581 | &list), | 1582 | &list), |
1582 | GNUNET_GETOPT_option_string( | 1583 | GNUNET_GETOPT_option_string ( |
1583 | 'e', | 1584 | 'e', |
1584 | "expiration", | 1585 | "expiration", |
1585 | "TIME", | 1586 | "TIME", |
1586 | gettext_noop( | 1587 | gettext_noop ( |
1587 | "expiration time for record to use (for adding only), \"never\" is possible"), | 1588 | "expiration time for record to use (for adding only), \"never\" is possible"), |
1588 | &expirationstring), | 1589 | &expirationstring), |
1589 | GNUNET_GETOPT_option_string('i', | 1590 | GNUNET_GETOPT_option_string ('i', |
1590 | "nick", | 1591 | "nick", |
1591 | "NICKNAME", | 1592 | "NICKNAME", |
1592 | gettext_noop( | 1593 | gettext_noop ( |
1593 | "set the desired nick name for the zone"), | 1594 | "set the desired nick name for the zone"), |
1594 | &nickstring), | 1595 | &nickstring), |
1595 | GNUNET_GETOPT_option_flag('m', | 1596 | GNUNET_GETOPT_option_flag ('m', |
1596 | "monitor", | 1597 | "monitor", |
1597 | gettext_noop( | 1598 | gettext_noop ( |
1598 | "monitor changes in the namestore"), | 1599 | "monitor changes in the namestore"), |
1599 | &monitor), | 1600 | &monitor), |
1600 | GNUNET_GETOPT_option_string('n', | 1601 | GNUNET_GETOPT_option_string ('n', |
1601 | "name", | 1602 | "name", |
1602 | "NAME", | 1603 | "NAME", |
1603 | gettext_noop( | 1604 | gettext_noop ( |
1604 | "name of the record to add/delete/display"), | 1605 | "name of the record to add/delete/display"), |
1605 | &name), | 1606 | &name), |
1606 | GNUNET_GETOPT_option_string('r', | 1607 | GNUNET_GETOPT_option_string ('r', |
1607 | "reverse", | 1608 | "reverse", |
1608 | "PKEY", | 1609 | "PKEY", |
1609 | gettext_noop( | 1610 | gettext_noop ( |
1610 | "determine our name for the given PKEY"), | 1611 | "determine our name for the given PKEY"), |
1611 | &reverse_pkey), | 1612 | &reverse_pkey), |
1612 | multirecord_option( | 1613 | multirecord_option ( |
1613 | 'R', | 1614 | 'R', |
1614 | "replace", | 1615 | "replace", |
1615 | "RECORDLINE", | 1616 | "RECORDLINE", |
1616 | gettext_noop( | 1617 | gettext_noop ( |
1617 | "set record set to values given by (possibly multiple) RECORDLINES; can be specified multiple times"), | 1618 | "set record set to values given by (possibly multiple) RECORDLINES; can be specified multiple times"), |
1618 | &recordset), | 1619 | &recordset), |
1619 | GNUNET_GETOPT_option_string('t', | 1620 | GNUNET_GETOPT_option_string ('t', |
1620 | "type", | 1621 | "type", |
1621 | "TYPE", | 1622 | "TYPE", |
1622 | gettext_noop( | 1623 | gettext_noop ( |
1623 | "type of the record to add/delete/display"), | 1624 | "type of the record to add/delete/display"), |
1624 | &typestring), | 1625 | &typestring), |
1625 | GNUNET_GETOPT_option_string('u', | 1626 | GNUNET_GETOPT_option_string ('u', |
1626 | "uri", | 1627 | "uri", |
1627 | "URI", | 1628 | "URI", |
1628 | gettext_noop("URI to import into our zone"), | 1629 | gettext_noop ("URI to import into our zone"), |
1629 | &uri), | 1630 | &uri), |
1630 | GNUNET_GETOPT_option_string('V', | 1631 | GNUNET_GETOPT_option_string ('V', |
1631 | "value", | 1632 | "value", |
1632 | "VALUE", | 1633 | "VALUE", |
1633 | gettext_noop( | 1634 | gettext_noop ( |
1634 | "value of the record to add/delete"), | 1635 | "value of the record to add/delete"), |
1635 | &value), | 1636 | &value), |
1636 | GNUNET_GETOPT_option_flag('p', | 1637 | GNUNET_GETOPT_option_flag ('p', |
1637 | "public", | 1638 | "public", |
1638 | gettext_noop("create or list public record"), | 1639 | gettext_noop ("create or list public record"), |
1639 | &is_public), | 1640 | &is_public), |
1640 | GNUNET_GETOPT_option_flag( | 1641 | GNUNET_GETOPT_option_flag ( |
1641 | 's', | 1642 | 's', |
1642 | "shadow", | 1643 | "shadow", |
1643 | gettext_noop( | 1644 | gettext_noop ( |
1644 | "create shadow record (only valid if all other records of the same type have expired"), | 1645 | "create shadow record (only valid if all other records of the same type have expired"), |
1645 | &is_shadow), | 1646 | &is_shadow), |
1646 | GNUNET_GETOPT_option_string('z', | 1647 | GNUNET_GETOPT_option_string ('z', |
1647 | "zone", | 1648 | "zone", |
1648 | "EGO", | 1649 | "EGO", |
1649 | gettext_noop( | 1650 | gettext_noop ( |
1650 | "name of the ego controlling the zone"), | 1651 | "name of the ego controlling the zone"), |
1651 | &ego_name), | 1652 | &ego_name), |
1652 | GNUNET_GETOPT_OPTION_END }; | 1653 | GNUNET_GETOPT_OPTION_END }; |
1653 | int lret; | 1654 | int lret; |
1654 | 1655 | ||
1655 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv)) | 1656 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
1656 | return 2; | 1657 | return 2; |
1657 | 1658 | ||
1658 | is_public = -1; | 1659 | is_public = -1; |
1659 | is_shadow = -1; | 1660 | is_shadow = -1; |
1660 | GNUNET_log_setup("gnunet-namestore", "WARNING", NULL); | 1661 | GNUNET_log_setup ("gnunet-namestore", "WARNING", NULL); |
1661 | if (GNUNET_OK != | 1662 | if (GNUNET_OK != |
1662 | (lret = GNUNET_PROGRAM_run(argc, | 1663 | (lret = GNUNET_PROGRAM_run (argc, |
1663 | argv, | 1664 | argv, |
1664 | "gnunet-namestore", | 1665 | "gnunet-namestore", |
1665 | _("GNUnet zone manipulation tool"), | 1666 | _ ("GNUnet zone manipulation tool"), |
1666 | options, | 1667 | options, |
1667 | &run, | 1668 | &run, |
1668 | NULL))) | 1669 | NULL))) |
1669 | { | 1670 | { |
1670 | GNUNET_free((void *)argv); | 1671 | GNUNET_free ((void *) argv); |
1671 | GNUNET_CRYPTO_ecdsa_key_clear(&zone_pkey); | 1672 | GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey); |
1672 | return lret; | 1673 | return lret; |
1673 | } | 1674 | } |
1674 | GNUNET_free((void *)argv); | 1675 | GNUNET_free ((void *) argv); |
1675 | GNUNET_CRYPTO_ecdsa_key_clear(&zone_pkey); | 1676 | GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey); |
1676 | return ret; | 1677 | return ret; |
1677 | } | 1678 | } |
1678 | 1679 | ||