diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-07-09 07:18:53 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-07-09 07:18:53 +0000 |
commit | a13d301ba2910e6df6c93eb4a15106a0323e46cc (patch) | |
tree | acf9f3c3189d65fff3a4a08f2bb33fe3be0b2153 /src/namestore/gnunet-namestore.c | |
parent | cdb6307117f72f42da7889debc4b4e903e4ca953 (diff) | |
download | gnunet-a13d301ba2910e6df6c93eb4a15106a0323e46cc.tar.gz gnunet-a13d301ba2910e6df6c93eb4a15106a0323e46cc.zip |
add '-m' option to gnunet-namestore, extend namestore monitor API with notification about being in sync
Diffstat (limited to 'src/namestore/gnunet-namestore.c')
-rw-r--r-- | src/namestore/gnunet-namestore.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index c43b18593..95f0b520f 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -163,6 +163,15 @@ static struct GNUNET_TIME_Absolute etime_abs; | |||
163 | */ | 163 | */ |
164 | static int etime_is_rel = GNUNET_SYSERR; | 164 | static int etime_is_rel = GNUNET_SYSERR; |
165 | 165 | ||
166 | /** | ||
167 | * Monitor handle. | ||
168 | */ | ||
169 | static struct GNUNET_NAMESTORE_ZoneMonitor *zm; | ||
170 | |||
171 | /** | ||
172 | * Enables monitor mode. | ||
173 | */ | ||
174 | static int monitor; | ||
166 | 175 | ||
167 | /** | 176 | /** |
168 | * Task run on shutdown. Cleans up everything. | 177 | * Task run on shutdown. Cleans up everything. |
@@ -215,6 +224,11 @@ do_shutdown (void *cls, | |||
215 | GNUNET_free (uri); | 224 | GNUNET_free (uri); |
216 | uri = NULL; | 225 | uri = NULL; |
217 | } | 226 | } |
227 | if (NULL != zm) | ||
228 | { | ||
229 | GNUNET_NAMESTORE_zone_monitor_stop (zm); | ||
230 | zm = NULL; | ||
231 | } | ||
218 | } | 232 | } |
219 | 233 | ||
220 | 234 | ||
@@ -358,6 +372,18 @@ display_record (void *cls, | |||
358 | 372 | ||
359 | 373 | ||
360 | /** | 374 | /** |
375 | * Function called once we are in sync in monitor mode. | ||
376 | * | ||
377 | * @param cls NULL | ||
378 | */ | ||
379 | static void | ||
380 | sync_cb (void *cls) | ||
381 | { | ||
382 | FPRINTF (stdout, "%s", "Monitor is now in sync.\n"); | ||
383 | } | ||
384 | |||
385 | |||
386 | /** | ||
361 | * We're storing a record; this function is given the existing record | 387 | * We're storing a record; this function is given the existing record |
362 | * so that we can merge the information. | 388 | * so that we can merge the information. |
363 | * | 389 | * |
@@ -643,6 +669,14 @@ key_generation_cb (void *cls, | |||
643 | &add_qe_uri); | 669 | &add_qe_uri); |
644 | } | 670 | } |
645 | GNUNET_free_non_null (data); | 671 | GNUNET_free_non_null (data); |
672 | if (monitor) | ||
673 | { | ||
674 | zm = GNUNET_NAMESTORE_zone_monitor_start (cfg, | ||
675 | &zone, | ||
676 | &display_record, | ||
677 | &sync_cb, | ||
678 | NULL); | ||
679 | } | ||
646 | } | 680 | } |
647 | 681 | ||
648 | 682 | ||
@@ -740,6 +774,9 @@ main (int argc, char *const *argv) | |||
740 | {'e', "expiration", "TIME", | 774 | {'e', "expiration", "TIME", |
741 | gettext_noop ("expiration time for record to use (for adding only), \"never\" is possible"), 1, | 775 | gettext_noop ("expiration time for record to use (for adding only), \"never\" is possible"), 1, |
742 | &GNUNET_GETOPT_set_string, &expirationstring}, | 776 | &GNUNET_GETOPT_set_string, &expirationstring}, |
777 | {'m', "monitor", NULL, | ||
778 | gettext_noop ("monitor changes in the namestore"), 0, | ||
779 | &GNUNET_GETOPT_set_one, &monitor}, | ||
743 | {'n', "name", "NAME", | 780 | {'n', "name", "NAME", |
744 | gettext_noop ("name of the record to add/delete/display"), 1, | 781 | gettext_noop ("name of the record to add/delete/display"), 1, |
745 | &GNUNET_GETOPT_set_string, &name}, | 782 | &GNUNET_GETOPT_set_string, &name}, |