aboutsummaryrefslogtreecommitdiff
path: root/src/util/configuration.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-03 21:10:27 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-03 21:10:27 +0000
commit236e47e55554310cc19b8c37c7b844d53a239f28 (patch)
treedaeba73a49d600e9d7fb441fe67f32686e38415b /src/util/configuration.c
parentf9b6dfb41e151628673595fd880318ec502ae4ed (diff)
downloadgnunet-236e47e55554310cc19b8c37c7b844d53a239f28.tar.gz
gnunet-236e47e55554310cc19b8c37c7b844d53a239f28.zip
implementing time and size parsers for #1875
Diffstat (limited to 'src/util/configuration.c')
-rw-r--r--src/util/configuration.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c
index a269ed036..ba3aa7f45 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -731,16 +731,34 @@ GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle
731 e = findEntry (cfg, section, option); 731 e = findEntry (cfg, section, option);
732 if (e == NULL) 732 if (e == NULL)
733 return GNUNET_SYSERR; 733 return GNUNET_SYSERR;
734 if ((0 == strcasecmp (e->val, "infinity")) || 734
735 (0 == strcasecmp (e->val, "forever"))) 735 return GNUNET_STRINGS_fancy_time_to_relative (e->val,
736 { 736 time);
737 *time = GNUNET_TIME_UNIT_FOREVER_REL; 737}
738 return GNUNET_OK; 738
739 } 739
740 if (1 != SSCANF (e->val, "%llu", &num)) 740/**
741 * Get a configuration value that should be a size in bytes.
742 *
743 * @param cfg configuration to inspect
744 * @param section section of interest
745 * @param option option of interest
746 * @param size set to the size in bytes as stored in the configuration
747 * @return GNUNET_OK on success, GNUNET_SYSERR on error
748 */
749int
750GNUNET_CONFIGURATION_get_value_size (const struct GNUNET_CONFIGURATION_Handle
751 *cfg, const char *section,
752 const char *option,
753 unsigned long long *size)
754{
755 struct ConfigEntry *e;
756
757 e = findEntry (cfg, section, option);
758 if (e == NULL)
741 return GNUNET_SYSERR; 759 return GNUNET_SYSERR;
742 time->rel_value = (uint64_t) num; 760 return GNUNET_STRINGS_fancy_size_to_bytes (e->val,
743 return GNUNET_OK; 761 size);
744} 762}
745 763
746 764