diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-07 12:45:04 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-07 12:45:04 +0000 |
commit | ab3c2a6c36e4f0f78ccd082b731262d637d819d3 (patch) | |
tree | c7cede937bba981ae118ba4112be5d05ec5a7a73 /src/namestore/gnunet-namestore.c | |
parent | cf9c46282c0a339cb08c145340f22f31be6519da (diff) | |
download | gnunet-ab3c2a6c36e4f0f78ccd082b731262d637d819d3.tar.gz gnunet-ab3c2a6c36e4f0f78ccd082b731262d637d819d3.zip |
namestore api change: include block expiration time in record create
Diffstat (limited to 'src/namestore/gnunet-namestore.c')
-rw-r--r-- | src/namestore/gnunet-namestore.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index f48d1c23d..9829eaaa4 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -103,7 +103,11 @@ static char *typestring; | |||
103 | * Desired expiration time. | 103 | * Desired expiration time. |
104 | */ | 104 | */ |
105 | static char *expirationstring; | 105 | static char *expirationstring; |
106 | 106 | ||
107 | /** | ||
108 | * Desired block expiration time. | ||
109 | */ | ||
110 | static char *blockexpirationstring; | ||
107 | 111 | ||
108 | /** | 112 | /** |
109 | * Task run on shutdown. Cleans up everything. | 113 | * Task run on shutdown. Cleans up everything. |
@@ -257,6 +261,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
257 | void *data = NULL; | 261 | void *data = NULL; |
258 | size_t data_size = 0; | 262 | size_t data_size = 0; |
259 | struct GNUNET_TIME_Relative etime; | 263 | struct GNUNET_TIME_Relative etime; |
264 | struct GNUNET_TIME_Relative btime; | ||
260 | struct GNUNET_NAMESTORE_RecordData rd; | 265 | struct GNUNET_NAMESTORE_RecordData rd; |
261 | 266 | ||
262 | if (NULL == keyfile) | 267 | if (NULL == keyfile) |
@@ -354,6 +359,27 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
354 | GNUNET_SCHEDULER_shutdown (); | 359 | GNUNET_SCHEDULER_shutdown (); |
355 | return; | 360 | return; |
356 | } | 361 | } |
362 | if (NULL != blockexpirationstring) | ||
363 | { | ||
364 | if (GNUNET_OK != | ||
365 | GNUNET_STRINGS_fancy_time_to_relative (blockexpirationstring, | ||
366 | &btime)) | ||
367 | { | ||
368 | fprintf (stderr, | ||
369 | _("Invalid time format `%s'\n"), | ||
370 | blockexpirationstring); | ||
371 | GNUNET_SCHEDULER_shutdown (); | ||
372 | return; | ||
373 | } | ||
374 | } else if (add | del) | ||
375 | { | ||
376 | fprintf (stderr, | ||
377 | _("Missing option `%s' for operation `%s'\n"), | ||
378 | "-b", _("add/del")); | ||
379 | GNUNET_SCHEDULER_shutdown (); | ||
380 | return; | ||
381 | } | ||
382 | |||
357 | if (add) | 383 | if (add) |
358 | { | 384 | { |
359 | if (NULL == name) | 385 | if (NULL == name) |
@@ -371,6 +397,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
371 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; // FIXME: not always... | 397 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; // FIXME: not always... |
372 | add_qe = GNUNET_NAMESTORE_record_create (ns, | 398 | add_qe = GNUNET_NAMESTORE_record_create (ns, |
373 | zone_pkey, | 399 | zone_pkey, |
400 | GNUNET_TIME_relative_to_absolute (btime), | ||
374 | name, | 401 | name, |
375 | &rd, | 402 | &rd, |
376 | &add_continuation, | 403 | &add_continuation, |
@@ -391,7 +418,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
391 | rd.record_type = type; | 418 | rd.record_type = type; |
392 | rd.expiration = GNUNET_TIME_relative_to_absolute (etime); | 419 | rd.expiration = GNUNET_TIME_relative_to_absolute (etime); |
393 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; // FIXME: not always... | 420 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; // FIXME: not always... |
394 | del_qe = GNUNET_NAMESTORE_record_create (ns, | 421 | del_qe = GNUNET_NAMESTORE_record_remove (ns, |
395 | zone_pkey, | 422 | zone_pkey, |
396 | name, | 423 | name, |
397 | &rd, | 424 | &rd, |
@@ -423,7 +450,10 @@ main (int argc, char *const *argv) | |||
423 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 450 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { |
424 | {'a', "add", NULL, | 451 | {'a', "add", NULL, |
425 | gettext_noop ("add record"), 0, | 452 | gettext_noop ("add record"), 0, |
426 | &GNUNET_GETOPT_set_one, &add}, | 453 | &GNUNET_GETOPT_set_one, &add}, |
454 | {'b', "name-expiration", "TIME", | ||
455 | gettext_noop ("expiration time for name to use (for adding only)"), 1, | ||
456 | &GNUNET_GETOPT_set_string, &blockexpirationstring}, | ||
427 | {'d', "delete", NULL, | 457 | {'d', "delete", NULL, |
428 | gettext_noop ("delete record"), 0, | 458 | gettext_noop ("delete record"), 0, |
429 | &GNUNET_GETOPT_set_one, &del}, | 459 | &GNUNET_GETOPT_set_one, &del}, |
@@ -431,7 +461,7 @@ main (int argc, char *const *argv) | |||
431 | gettext_noop ("display records"), 0, | 461 | gettext_noop ("display records"), 0, |
432 | &GNUNET_GETOPT_set_one, &list}, | 462 | &GNUNET_GETOPT_set_one, &list}, |
433 | {'e', "expiration", "TIME", | 463 | {'e', "expiration", "TIME", |
434 | gettext_noop ("expiration time to use (for adding only)"), 1, | 464 | gettext_noop ("expiration time for record to use (for adding only)"), 1, |
435 | &GNUNET_GETOPT_set_string, &expirationstring}, | 465 | &GNUNET_GETOPT_set_string, &expirationstring}, |
436 | {'n', "name", "NAME", | 466 | {'n', "name", "NAME", |
437 | gettext_noop ("name of the record to add/delete/display"), 1, | 467 | gettext_noop ("name of the record to add/delete/display"), 1, |