diff options
Diffstat (limited to 'src/ats/plugin_ats2_common.c')
-rw-r--r-- | src/ats/plugin_ats2_common.c | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/src/ats/plugin_ats2_common.c b/src/ats/plugin_ats2_common.c index faa2f0edf..c12d2a06f 100644 --- a/src/ats/plugin_ats2_common.c +++ b/src/ats/plugin_ats2_common.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2011-2015, 2018 GNUnet e.V. | 3 | Copyright (C) 2011-2015, 2018 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation, either version 3 of the License, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -40,59 +40,59 @@ | |||
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 | */ |
42 | static void | 42 | static void |
43 | get_quota (const struct GNUNET_CONFIGURATION_Handle *cfg, | 43 | get_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 ("a_s, | 52 | GNUNET_asprintf("a_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 | "a_str)) | 60 | "a_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; | ||
75 | } | ||
76 | if ((GNUNET_NO == res) && | ||
77 | (GNUNET_OK == | ||
78 | GNUNET_STRINGS_fancy_size_to_bytes(quota_str, | ||
79 | quota))) | ||
74 | res = GNUNET_YES; | 80 | res = GNUNET_YES; |
75 | } | 81 | if ((GNUNET_NO == res) && |
76 | if ( (GNUNET_NO == res) && | 82 | (1 == |
77 | (GNUNET_OK == | 83 | sscanf(quota_str, |
78 | GNUNET_STRINGS_fancy_size_to_bytes (quota_str, | 84 | "%llu", |
79 | quota)) ) | 85 | quota))) |
80 | res = GNUNET_YES; | ||
81 | if ( (GNUNET_NO == res) && | ||
82 | (1 == | ||
83 | sscanf (quota_str, | ||
84 | "%llu", | ||
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 | _("Could not load %s quota for network `%s': `%s', assigning default bandwidth %llu\n"), |
91 | direction, | 91 | direction, |
92 | nts, | 92 | nts, |
93 | quota_str, | 93 | quota_str, |
94 | (unsigned long long) DEFAULT_BANDWIDTH); | 94 | (unsigned long long)DEFAULT_BANDWIDTH); |
95 | *quota = DEFAULT_BANDWIDTH; | 95 | *quota = DEFAULT_BANDWIDTH; |
96 | } | 96 | } |
97 | GNUNET_free (quota_str); | 97 | GNUNET_free(quota_str); |
98 | } | 98 | } |