aboutsummaryrefslogtreecommitdiff
path: root/src/namestore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-26 21:06:47 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-26 21:06:47 +0000
commitf33c54cfc9793c8b513559f06abf91d96288f210 (patch)
treea3e35d995d25b6796fd42fc1cd93c6a66b4cd9c1 /src/namestore
parent7eb4acd33e73f992391d459538576845719f21cf (diff)
downloadgnunet-f33c54cfc9793c8b513559f06abf91d96288f210.tar.gz
gnunet-f33c54cfc9793c8b513559f06abf91d96288f210.zip
-allow blank specification of URI-only
Diffstat (limited to 'src/namestore')
-rw-r--r--src/namestore/gnunet-namestore.c63
-rw-r--r--src/namestore/namestore.conf.in2
2 files changed, 42 insertions, 23 deletions
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index f839df3f5..27978be03 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -118,6 +118,11 @@ static char *typestring;
118 */ 118 */
119static char *expirationstring; 119static char *expirationstring;
120 120
121/**
122 * Global return value
123 */
124static int ret;
125
121 126
122/** 127/**
123 * Task run on shutdown. Cleans up everything. 128 * Task run on shutdown. Cleans up everything.
@@ -163,10 +168,14 @@ add_continuation (void *cls,
163 const char *emsg) 168 const char *emsg)
164{ 169{
165 add_qe = NULL; 170 add_qe = NULL;
166 if (success != GNUNET_YES) 171 if (GNUNET_YES != success)
172 {
167 fprintf (stderr, 173 fprintf (stderr,
168 _("Adding record failed: %s\n"), 174 _("Adding record failed: %s\n"),
169 (success == GNUNET_NO) ? "record exists" : emsg); 175 (GNUNET_NO == success) ? "record exists" : emsg);
176 if (GNUNET_NO != success)
177 ret = 1;
178 }
170 if ( (NULL == del_qe) && 179 if ( (NULL == del_qe) &&
171 (NULL == list_it) ) 180 (NULL == list_it) )
172 GNUNET_SCHEDULER_shutdown (); 181 GNUNET_SCHEDULER_shutdown ();
@@ -280,19 +289,21 @@ run (void *cls, char *const *args, const char *cfgfile,
280 int etime_is_rel = GNUNET_SYSERR; 289 int etime_is_rel = GNUNET_SYSERR;
281 struct GNUNET_NAMESTORE_RecordData rd; 290 struct GNUNET_NAMESTORE_RecordData rd;
282 291
292 if ( (NULL != args[0]) && (NULL == uri) )
293 uri = GNUNET_strdup (args[0]);
283 if (NULL == keyfile) 294 if (NULL == keyfile)
284 { 295 {
285 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", 296 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
286 "ZONEKEY", &keyfile)) 297 "ZONEKEY", &keyfile))
287 { 298 {
288 fprintf (stderr,
289 _("Option `%s' not given, but I need a zone key file!\n"),
290 "z");
291 return;
292 }
293 fprintf (stderr, 299 fprintf (stderr,
294 _("Using default zone file `%s'\n"), 300 _("Option `%s' not given, but I need a zone key file!\n"),
295 keyfile); 301 "z");
302 return;
303 }
304 fprintf (stderr,
305 _("Using default zone file `%s'\n"),
306 keyfile);
296 } 307 }
297 zone_pkey = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); 308 zone_pkey = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
298 GNUNET_free (keyfile); 309 GNUNET_free (keyfile);
@@ -333,6 +344,7 @@ run (void *cls, char *const *args, const char *cfgfile,
333 { 344 {
334 fprintf (stderr, _("Unsupported type `%s'\n"), typestring); 345 fprintf (stderr, _("Unsupported type `%s'\n"), typestring);
335 GNUNET_SCHEDULER_shutdown (); 346 GNUNET_SCHEDULER_shutdown ();
347 ret = 1;
336 return; 348 return;
337 } 349 }
338 if ((NULL == typestring) && (add | del)) 350 if ((NULL == typestring) && (add | del))
@@ -341,6 +353,7 @@ run (void *cls, char *const *args, const char *cfgfile,
341 _("Missing option `%s' for operation `%s'\n"), 353 _("Missing option `%s' for operation `%s'\n"),
342 "-t", _("add/del")); 354 "-t", _("add/del"));
343 GNUNET_SCHEDULER_shutdown (); 355 GNUNET_SCHEDULER_shutdown ();
356 ret = 1;
344 return; 357 return;
345 } 358 }
346 if (NULL != value) 359 if (NULL != value)
@@ -355,6 +368,7 @@ run (void *cls, char *const *args, const char *cfgfile,
355 value, 368 value,
356 typestring); 369 typestring);
357 GNUNET_SCHEDULER_shutdown (); 370 GNUNET_SCHEDULER_shutdown ();
371 ret = 1;
358 return; 372 return;
359 } 373 }
360 } else if (add | del) 374 } else if (add | del)
@@ -362,6 +376,7 @@ run (void *cls, char *const *args, const char *cfgfile,
362 fprintf (stderr, 376 fprintf (stderr,
363 _("Missing option `%s' for operation `%s'\n"), 377 _("Missing option `%s' for operation `%s'\n"),
364 "-V", _("add/del")); 378 "-V", _("add/del"));
379 ret = 1;
365 GNUNET_SCHEDULER_shutdown (); 380 GNUNET_SCHEDULER_shutdown ();
366 return; 381 return;
367 } 382 }
@@ -390,6 +405,7 @@ run (void *cls, char *const *args, const char *cfgfile,
390 _("Invalid time format `%s'\n"), 405 _("Invalid time format `%s'\n"),
391 expirationstring); 406 expirationstring);
392 GNUNET_SCHEDULER_shutdown (); 407 GNUNET_SCHEDULER_shutdown ();
408 ret = 1;
393 return; 409 return;
394 } 410 }
395 } 411 }
@@ -399,6 +415,7 @@ run (void *cls, char *const *args, const char *cfgfile,
399 _("Missing option `%s' for operation `%s'\n"), 415 _("Missing option `%s' for operation `%s'\n"),
400 "-e", _("add")); 416 "-e", _("add"));
401 GNUNET_SCHEDULER_shutdown (); 417 GNUNET_SCHEDULER_shutdown ();
418 ret = 1;
402 return; 419 return;
403 } 420 }
404 if (add) 421 if (add)
@@ -409,6 +426,7 @@ run (void *cls, char *const *args, const char *cfgfile,
409 _("Missing option `%s' for operation `%s'\n"), 426 _("Missing option `%s' for operation `%s'\n"),
410 "-n", _("add")); 427 "-n", _("add"));
411 GNUNET_SCHEDULER_shutdown (); 428 GNUNET_SCHEDULER_shutdown ();
429 ret = 1;
412 return; 430 return;
413 } 431 }
414 rd.data = data; 432 rd.data = data;
@@ -427,6 +445,7 @@ run (void *cls, char *const *args, const char *cfgfile,
427 _("No valid expiration time for operation `%s'\n"), 445 _("No valid expiration time for operation `%s'\n"),
428 _("add")); 446 _("add"));
429 GNUNET_SCHEDULER_shutdown (); 447 GNUNET_SCHEDULER_shutdown ();
448 ret = 1;
430 return; 449 return;
431 } 450 }
432 if (1 != nonauthority) 451 if (1 != nonauthority)
@@ -448,6 +467,7 @@ run (void *cls, char *const *args, const char *cfgfile,
448 _("Missing option `%s' for operation `%s'\n"), 467 _("Missing option `%s' for operation `%s'\n"),
449 "-n", _("del")); 468 "-n", _("del"));
450 GNUNET_SCHEDULER_shutdown (); 469 GNUNET_SCHEDULER_shutdown ();
470 ret = 1;
451 return; 471 return;
452 } 472 }
453 rd.data = data; 473 rd.data = data;
@@ -493,13 +513,12 @@ run (void *cls, char *const *args, const char *cfgfile,
493 GNUNET_CRYPTO_short_hash_from_string (sh, &sc)) ) 513 GNUNET_CRYPTO_short_hash_from_string (sh, &sc)) )
494 { 514 {
495 fprintf (stderr, 515 fprintf (stderr,
496 _("Invalid URI `%s'"), 516 _("Invalid URI `%s'\n"),
497 uri); 517 uri);
498 GNUNET_SCHEDULER_shutdown (); 518 GNUNET_SCHEDULER_shutdown ();
519 ret = 1;
499 return; 520 return;
500 } 521 }
501
502
503 rd.data = &sc; 522 rd.data = &sc;
504 rd.data_size = sizeof (struct GNUNET_CRYPTO_ShortHashCode); 523 rd.data_size = sizeof (struct GNUNET_CRYPTO_ShortHashCode);
505 rd.record_type = GNUNET_NAMESTORE_TYPE_PKEY; 524 rd.record_type = GNUNET_NAMESTORE_TYPE_PKEY;
@@ -576,18 +595,16 @@ main (int argc, char *const *argv)
576 GNUNET_GETOPT_OPTION_END 595 GNUNET_GETOPT_OPTION_END
577 }; 596 };
578 597
579 int ret;
580
581 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 598 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
582 return 2; 599 return 2;
583 600
584 GNUNET_log_setup ("gnunet-namestore", "WARNING", NULL); 601 GNUNET_log_setup ("gnunet-namestore", "WARNING", NULL);
585 ret = 602 if (GNUNET_OK !=
586 (GNUNET_OK == 603 GNUNET_PROGRAM_run (argc, argv, "gnunet-namestore",
587 GNUNET_PROGRAM_run (argc, argv, "gnunet-namestore", 604 _("GNUnet zone manipulation tool"),
588 _("GNUnet zone manipulation tool"), 605 options,
589 options, 606 &run, NULL))
590 &run, NULL)) ? 0 : 1; 607 return 1;
591 608
592 return ret; 609 return ret;
593} 610}
diff --git a/src/namestore/namestore.conf.in b/src/namestore/namestore.conf.in
index ca6156fa3..c9b106943 100644
--- a/src/namestore/namestore.conf.in
+++ b/src/namestore/namestore.conf.in
@@ -20,3 +20,5 @@ FILENAME = $SERVICEHOME/namestore/sqlite.db
20CONFIG = connect_timeout=10; dbname=gnunet 20CONFIG = connect_timeout=10; dbname=gnunet
21TEMPORARY_TABLE = NO 21TEMPORARY_TABLE = NO
22 22
23[uri]
24gns = gnunet-namestore