diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-05-14 08:09:42 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-05-14 08:09:42 +0000 |
commit | 62b5f9d7d649be845774ed4d876deb586f538c74 (patch) | |
tree | 1869ac86111aab6ad27edbc521222d94c387ffa1 /src | |
parent | 745109bb6a59a312e118c3242ce4ed861566fe79 (diff) | |
download | gnunet-62b5f9d7d649be845774ed4d876deb586f538c74.tar.gz gnunet-62b5f9d7d649be845774ed4d876deb586f538c74.zip |
adding function to read float from cfg
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_configuration_lib.h | 16 | ||||
-rw-r--r-- | src/util/configuration.c | 27 |
2 files changed, 43 insertions, 0 deletions
diff --git a/src/include/gnunet_configuration_lib.h b/src/include/gnunet_configuration_lib.h index 0448a5865..ac14dde64 100644 --- a/src/include/gnunet_configuration_lib.h +++ b/src/include/gnunet_configuration_lib.h | |||
@@ -268,6 +268,22 @@ GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle | |||
268 | 268 | ||
269 | 269 | ||
270 | /** | 270 | /** |
271 | * Get a configuration value that should be a floating point number. | ||
272 | * | ||
273 | * @param cfg configuration to inspect | ||
274 | * @param section section of interest | ||
275 | * @param option option of interest | ||
276 | * @param number where to store the floating value of the option | ||
277 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
278 | */ | ||
279 | int | ||
280 | GNUNET_CONFIGURATION_get_value_float (const struct GNUNET_CONFIGURATION_Handle | ||
281 | *cfg, const char *section, | ||
282 | const char *option, | ||
283 | float *number); | ||
284 | |||
285 | |||
286 | /** | ||
271 | * Get a configuration value that should be a relative time. | 287 | * Get a configuration value that should be a relative time. |
272 | * | 288 | * |
273 | * @param cfg configuration to inspect | 289 | * @param cfg configuration to inspect |
diff --git a/src/util/configuration.c b/src/util/configuration.c index 3d9281e8d..8444c2d7d 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c | |||
@@ -879,6 +879,33 @@ GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle | |||
879 | return GNUNET_OK; | 879 | return GNUNET_OK; |
880 | } | 880 | } |
881 | 881 | ||
882 | /** | ||
883 | * Get a configuration value that should be a floating point number. | ||
884 | * | ||
885 | * @param cfg configuration to inspect | ||
886 | * @param section section of interest | ||
887 | * @param option option of interest | ||
888 | * @param number where to store the floating value of the option | ||
889 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
890 | */ | ||
891 | int | ||
892 | GNUNET_CONFIGURATION_get_value_float (const struct GNUNET_CONFIGURATION_Handle | ||
893 | *cfg, const char *section, | ||
894 | const char *option, | ||
895 | float *number) | ||
896 | { | ||
897 | struct ConfigEntry *e; | ||
898 | |||
899 | if (NULL == (e = find_entry (cfg, section, option))) | ||
900 | return GNUNET_SYSERR; | ||
901 | if (NULL == e->val) | ||
902 | return GNUNET_SYSERR; | ||
903 | if (1 != SSCANF (e->val, "%f", number)) | ||
904 | return GNUNET_SYSERR; | ||
905 | return GNUNET_OK; | ||
906 | } | ||
907 | |||
908 | |||
882 | 909 | ||
883 | /** | 910 | /** |
884 | * Get a configuration value that should be a relative time. | 911 | * Get a configuration value that should be a relative time. |