aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/gnunet-namestore.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-19 21:59:30 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-19 21:59:30 +0000
commit5c9791cbb128494bcaf1544c3e89195e4007207c (patch)
tree86c9ba0a140c34efbe7462cfa25a167a84f0a211 /src/namestore/gnunet-namestore.c
parent0970f98adb25e2ec8076ddf61b3437b5003af0b2 (diff)
downloadgnunet-5c9791cbb128494bcaf1544c3e89195e4007207c.tar.gz
gnunet-5c9791cbb128494bcaf1544c3e89195e4007207c.zip
-towards enabling relative expiration times in namestore
Diffstat (limited to 'src/namestore/gnunet-namestore.c')
-rw-r--r--src/namestore/gnunet-namestore.c45
1 files changed, 37 insertions, 8 deletions
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index 624981201..aa3af1a73 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -32,6 +32,7 @@
32#include <gnunet_dnsparser_lib.h> 32#include <gnunet_dnsparser_lib.h>
33#include <gnunet_namestore_service.h> 33#include <gnunet_namestore_service.h>
34 34
35
35/** 36/**
36 * Handle to the namestore. 37 * Handle to the namestore.
37 */ 38 */
@@ -264,7 +265,9 @@ run (void *cls, char *const *args, const char *cfgfile,
264 uint32_t type; 265 uint32_t type;
265 void *data = NULL; 266 void *data = NULL;
266 size_t data_size = 0; 267 size_t data_size = 0;
267 struct GNUNET_TIME_Relative etime; 268 struct GNUNET_TIME_Relative etime_rel;
269 struct GNUNET_TIME_Absolute etime_abs;
270 int etime_is_rel = GNUNET_SYSERR;
268 struct GNUNET_NAMESTORE_RecordData rd; 271 struct GNUNET_NAMESTORE_RecordData rd;
269 272
270 if (NULL == keyfile) 273 if (NULL == keyfile)
@@ -356,11 +359,22 @@ run (void *cls, char *const *args, const char *cfgfile,
356 { 359 {
357 if (0 == strcmp (expirationstring, "never")) 360 if (0 == strcmp (expirationstring, "never"))
358 { 361 {
359 etime = GNUNET_TIME_UNIT_FOREVER_REL; 362 etime_abs = GNUNET_TIME_UNIT_FOREVER_ABS;
363 etime_is_rel = GNUNET_NO;
364 }
365 else if (GNUNET_OK ==
366 GNUNET_STRINGS_fancy_time_to_relative (expirationstring,
367 &etime_rel))
368 {
369 etime_is_rel = GNUNET_YES;
360 } 370 }
361 else if (GNUNET_OK != 371 else if (GNUNET_OK ==
362 GNUNET_STRINGS_fancy_time_to_relative (expirationstring, 372 GNUNET_STRINGS_fancy_time_to_absolute (expirationstring,
363 &etime)) 373 &etime_abs))
374 {
375 etime_is_rel = GNUNET_NO;
376 }
377 else
364 { 378 {
365 fprintf (stderr, 379 fprintf (stderr,
366 _("Invalid time format `%s'\n"), 380 _("Invalid time format `%s'\n"),
@@ -368,7 +382,8 @@ run (void *cls, char *const *args, const char *cfgfile,
368 GNUNET_SCHEDULER_shutdown (); 382 GNUNET_SCHEDULER_shutdown ();
369 return; 383 return;
370 } 384 }
371 } else if (add) 385 }
386 else if (add)
372 { 387 {
373 fprintf (stderr, 388 fprintf (stderr,
374 _("Missing option `%s' for operation `%s'\n"), 389 _("Missing option `%s' for operation `%s'\n"),
@@ -389,7 +404,21 @@ run (void *cls, char *const *args, const char *cfgfile,
389 rd.data = data; 404 rd.data = data;
390 rd.data_size = data_size; 405 rd.data_size = data_size;
391 rd.record_type = type; 406 rd.record_type = type;
392 rd.expiration = GNUNET_TIME_relative_to_absolute (etime); 407 if (GNUNET_YES == etime_is_rel)
408 {
409 rd.expiration_time = etime_rel.rel_value;
410 rd.flags |= GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION;
411 }
412 else if (GNUNET_NO == etime_is_rel)
413 rd.expiration_time = etime_abs.abs_value;
414 else
415 {
416 fprintf (stderr,
417 _("No valid expiration time for operation `%s'\n"),
418 _("add"));
419 GNUNET_SCHEDULER_shutdown ();
420 return;
421 }
393 if (1 != nonauthority) 422 if (1 != nonauthority)
394 rd.flags |= GNUNET_NAMESTORE_RF_AUTHORITY; 423 rd.flags |= GNUNET_NAMESTORE_RF_AUTHORITY;
395 if (1 != public) 424 if (1 != public)
@@ -414,7 +443,7 @@ run (void *cls, char *const *args, const char *cfgfile,
414 rd.data = data; 443 rd.data = data;
415 rd.data_size = data_size; 444 rd.data_size = data_size;
416 rd.record_type = type; 445 rd.record_type = type;
417 rd.expiration.abs_value = 0; 446 rd.expiration_time = 0;
418 rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; 447 rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
419 del_qe = GNUNET_NAMESTORE_record_remove (ns, 448 del_qe = GNUNET_NAMESTORE_record_remove (ns,
420 zone_pkey, 449 zone_pkey,