aboutsummaryrefslogtreecommitdiff
path: root/src/ats/plugin_ats2_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats/plugin_ats2_common.c')
-rw-r--r--src/ats/plugin_ats2_common.c83
1 files changed, 42 insertions, 41 deletions
diff --git a/src/ats/plugin_ats2_common.c b/src/ats/plugin_ats2_common.c
index c12d2a06f..da20a342c 100644
--- a/src/ats/plugin_ats2_common.c
+++ b/src/ats/plugin_ats2_common.c
@@ -40,59 +40,60 @@
40 * @param quota[out] set to quota, #DEFAULT_BANDWIDTH if @a cfg does not say anything useful 40 * @param quota[out] set to quota, #DEFAULT_BANDWIDTH if @a cfg does not say anything useful
41 */ 41 */
42static void 42static void
43get_quota(const struct GNUNET_CONFIGURATION_Handle *cfg, 43get_quota (const struct GNUNET_CONFIGURATION_Handle *cfg,
44 const char *nts, 44 const char *nts,
45 const char *direction, 45 const char *direction,
46 unsigned long long *quota) 46 unsigned long long *quota)
47{ 47{
48 char *quota_str; 48 char *quota_str;
49 char *quota_s; 49 char *quota_s;
50 int res; 50 int res;
51 51
52 GNUNET_asprintf(&quota_s, 52 GNUNET_asprintf (&quota_s,
53 "%s_QUOTA_%s", 53 "%s_QUOTA_%s",
54 nts, 54 nts,
55 direction); 55 direction);
56 if (GNUNET_OK != 56 if (GNUNET_OK !=
57 GNUNET_CONFIGURATION_get_value_string(cfg, 57 GNUNET_CONFIGURATION_get_value_string (cfg,
58 "ATS", 58 "ATS",
59 quota_s, 59 quota_s,
60 &quota_str)) 60 &quota_str))
61 { 61 {
62 GNUNET_log_config_missing(GNUNET_ERROR_TYPE_WARNING, 62 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
63 "ATS", 63 "ATS",
64 quota_s); 64 quota_s);
65 GNUNET_free(quota_s); 65 GNUNET_free (quota_s);
66 return; 66 return;
67 } 67 }
68 GNUNET_free(quota_s); 68 GNUNET_free (quota_s);
69 res = GNUNET_NO; 69 res = GNUNET_NO;
70 if (0 == strcmp(quota_str, 70 if (0 == strcmp (quota_str,
71 "unlimited")) 71 "unlimited"))
72 { 72 {
73 *quota = ULONG_MAX; 73 *quota = ULONG_MAX;
74 res = GNUNET_YES; 74 res = GNUNET_YES;
75 } 75 }
76 if ((GNUNET_NO == res) && 76 if ((GNUNET_NO == res) &&
77 (GNUNET_OK == 77 (GNUNET_OK ==
78 GNUNET_STRINGS_fancy_size_to_bytes(quota_str, 78 GNUNET_STRINGS_fancy_size_to_bytes (quota_str,
79 quota))) 79 quota)))
80 res = GNUNET_YES; 80 res = GNUNET_YES;
81 if ((GNUNET_NO == res) && 81 if ((GNUNET_NO == res) &&
82 (1 == 82 (1 ==
83 sscanf(quota_str, 83 sscanf (quota_str,
84 "%llu", 84 "%llu",
85 quota))) 85 quota)))
86 res = GNUNET_YES; 86 res = GNUNET_YES;
87 if (GNUNET_NO == res) 87 if (GNUNET_NO == res)
88 { 88 {
89 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 89 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
90 _("Could not load %s quota for network `%s': `%s', assigning default bandwidth %llu\n"), 90 _ (
91 direction, 91 "Could not load %s quota for network `%s': `%s', assigning default bandwidth %llu\n"),
92 nts, 92 direction,
93 quota_str, 93 nts,
94 (unsigned long long)DEFAULT_BANDWIDTH); 94 quota_str,
95 *quota = DEFAULT_BANDWIDTH; 95 (unsigned long long) DEFAULT_BANDWIDTH);
96 } 96 *quota = DEFAULT_BANDWIDTH;
97 GNUNET_free(quota_str); 97 }
98 GNUNET_free (quota_str);
98} 99}