aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-06-11 05:30:19 +0000
committerChristian Grothoff <christian@grothoff.org>2009-06-11 05:30:19 +0000
commit8db4f9403d80faa67eaf85a2d077c35670596c4d (patch)
tree8aca077b466b92c2d6a296e186bad56f78f08f88 /src
parent4acd295ad6076d3c33f62d40324106d3308850ca (diff)
downloadgnunet-8db4f9403d80faa67eaf85a2d077c35670596c4d.tar.gz
gnunet-8db4f9403d80faa67eaf85a2d077c35670596c4d.zip
get time cfg api added
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_configuration_lib.h12
-rw-r--r--src/util/configuration.c18
-rw-r--r--src/util/service.c10
3 files changed, 35 insertions, 5 deletions
diff --git a/src/include/gnunet_configuration_lib.h b/src/include/gnunet_configuration_lib.h
index fefc6884a..3f7d099ce 100644
--- a/src/include/gnunet_configuration_lib.h
+++ b/src/include/gnunet_configuration_lib.h
@@ -38,6 +38,7 @@ extern "C"
38#endif 38#endif
39 39
40#include "gnunet_common.h" 40#include "gnunet_common.h"
41#include "gnunet_time_lib.h"
41 42
42/** 43/**
43 * A configuration object. 44 * A configuration object.
@@ -99,6 +100,17 @@ int GNUNET_CONFIGURATION_get_value_number (struct GNUNET_CONFIGURATION_Handle
99 unsigned long long *number); 100 unsigned long long *number);
100 101
101/** 102/**
103 * Get a configuration value that should be a relative time.
104 *
105 * @param time set to the time value stored in the configuration
106 * @return GNUNET_OK on success, GNUNET_SYSERR on error
107 */
108int GNUNET_CONFIGURATION_get_value_time (struct GNUNET_CONFIGURATION_Handle
109 *cfg, const char *section,
110 const char *option,
111 struct GNUNET_TIME_Relative *time);
112
113/**
102 * Test if we have a value for a particular option 114 * Test if we have a value for a particular option
103 * @return GNUNET_YES if so, GNUNET_NO if not. 115 * @return GNUNET_YES if so, GNUNET_NO if not.
104 */ 116 */
diff --git a/src/util/configuration.c b/src/util/configuration.c
index 4413b0377..eacbdbf05 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -402,6 +402,24 @@ GNUNET_CONFIGURATION_get_value_number (struct GNUNET_CONFIGURATION_Handle
402} 402}
403 403
404int 404int
405GNUNET_CONFIGURATION_get_value_time (struct GNUNET_CONFIGURATION_Handle
406 *cfg, const char *section,
407 const char *option,
408 struct GNUNET_TIME_Relative *time)
409{
410 unsigned long long num;
411 int ret;
412
413 ret = GNUNET_CONFIGURATION_get_value_number (cfg,
414 section,
415 option,
416 &num);
417 if (ret == GNUNET_OK)
418 time->value = (uint64_t) num;
419 return ret;
420}
421
422int
405GNUNET_CONFIGURATION_get_value_string (struct GNUNET_CONFIGURATION_Handle 423GNUNET_CONFIGURATION_get_value_string (struct GNUNET_CONFIGURATION_Handle
406 *cfg, const char *section, 424 *cfg, const char *section,
407 const char *option, char **value) 425 const char *option, char **value)
diff --git a/src/util/service.c b/src/util/service.c
index 8d72a749a..732dbe9af 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -754,7 +754,7 @@ static int
754setup_service (struct GNUNET_SERVICE_Context *sctx) 754setup_service (struct GNUNET_SERVICE_Context *sctx)
755{ 755{
756 unsigned long long maxbuf; 756 unsigned long long maxbuf;
757 unsigned long long idleout; 757 struct GNUNET_TIME_Relative idleout;
758 char *hostname; 758 char *hostname;
759 unsigned long long port; 759 unsigned long long port;
760 int disablev6; 760 int disablev6;
@@ -768,12 +768,12 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
768 sctx->serviceName, "TIMEOUT")) 768 sctx->serviceName, "TIMEOUT"))
769 { 769 {
770 if (GNUNET_OK != 770 if (GNUNET_OK !=
771 GNUNET_CONFIGURATION_get_value_number (sctx->cfg, 771 GNUNET_CONFIGURATION_get_value_time (sctx->cfg,
772 sctx->serviceName, 772 sctx->serviceName,
773 "TIMEOUT", &idleout)) 773 "TIMEOUT", &idleout))
774 return GNUNET_SYSERR; 774 return GNUNET_SYSERR;
775 775
776 sctx->timeout.value = idleout; 776 sctx->timeout = idleout;
777 } 777 }
778 else 778 else
779 sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL; 779 sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL;