aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-03-11 22:48:04 +0000
committerChristian Grothoff <christian@grothoff.org>2012-03-11 22:48:04 +0000
commite1ff0291a39991e4ce025ece424ca8fae82fd88b (patch)
treee6ee7cb6be3c393c67e43dbcab30199ddb26a34a /src/util
parent9f2d6b1be912f09e47c30b2ac7b79a9c5e7bdecc (diff)
downloadgnunet-e1ff0291a39991e4ce025ece424ca8fae82fd88b.tar.gz
gnunet-e1ff0291a39991e4ce025ece424ca8fae82fd88b.zip
-LRN: use plibc SSCANF instead of sscanf
Diffstat (limited to 'src/util')
-rw-r--r--src/util/configuration.c8
-rw-r--r--src/util/os_installation.c2
-rw-r--r--src/util/pseudonym.c2
-rw-r--r--src/util/service.c10
-rw-r--r--src/util/strings.c8
5 files changed, 15 insertions, 15 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c
index 6ec9a7183..d006ed3ef 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -197,19 +197,19 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
197 for (i = strlen (line) - 1; (i >= 0) && (isspace ((unsigned char) line[i])); 197 for (i = strlen (line) - 1; (i >= 0) && (isspace ((unsigned char) line[i]));
198 i--) 198 i--)
199 line[i] = '\0'; 199 line[i] = '\0';
200 if (1 == sscanf (line, "@INLINE@ %191[^\n]", value)) 200 if (1 == SSCANF (line, "@INLINE@ %191[^\n]", value))
201 { 201 {
202 /* @INLINE@ value */ 202 /* @INLINE@ value */
203 if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, value)) 203 if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, value))
204 ret = GNUNET_SYSERR; /* failed to parse included config */ 204 ret = GNUNET_SYSERR; /* failed to parse included config */
205 } 205 }
206 else if (1 == sscanf (line, "[%99[^]]]", value)) 206 else if (1 == SSCANF (line, "[%99[^]]]", value))
207 { 207 {
208 /* [value] */ 208 /* [value] */
209 GNUNET_free (section); 209 GNUNET_free (section);
210 section = GNUNET_strdup (value); 210 section = GNUNET_strdup (value);
211 } 211 }
212 else if (2 == sscanf (line, " %63[^= ] = %191[^\n]", tag, value)) 212 else if (2 == SSCANF (line, " %63[^= ] = %191[^\n]", tag, value))
213 { 213 {
214 /* tag = value */ 214 /* tag = value */
215 /* Strip LF */ 215 /* Strip LF */
@@ -233,7 +233,7 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
233 } 233 }
234 GNUNET_CONFIGURATION_set_value_string (cfg, section, tag, &value[i]); 234 GNUNET_CONFIGURATION_set_value_string (cfg, section, tag, &value[i]);
235 } 235 }
236 else if (1 == sscanf (line, " %63[^= ] =[^\n]", tag)) 236 else if (1 == SSCANF (line, " %63[^= ] =[^\n]", tag))
237 { 237 {
238 /* tag = */ 238 /* tag = */
239 GNUNET_CONFIGURATION_set_value_string (cfg, section, tag, ""); 239 GNUNET_CONFIGURATION_set_value_string (cfg, section, tag, "");
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index b82813d74..e790ce10e 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -62,7 +62,7 @@ get_path_from_proc_maps ()
62 while (NULL != fgets (line, sizeof (line), f)) 62 while (NULL != fgets (line, sizeof (line), f))
63 { 63 {
64 if ((1 == 64 if ((1 ==
65 sscanf (line, "%*x-%*x %*c%*c%*c%*c %*x %*2u:%*2u %*u%*[ ]%s", dir)) && 65 SSCANF (line, "%*x-%*x %*c%*c%*c%*c %*x %*2u:%*2u %*u%*[ ]%s", dir)) &&
66 (NULL != (lgu = strstr (dir, "libgnunetutil")))) 66 (NULL != (lgu = strstr (dir, "libgnunetutil"))))
67 { 67 {
68 lgu[0] = '\0'; 68 lgu[0] = '\0';
diff --git a/src/util/pseudonym.c b/src/util/pseudonym.c
index dd8ad08b3..2d0bf3fad 100644
--- a/src/util/pseudonym.c
+++ b/src/util/pseudonym.c
@@ -461,7 +461,7 @@ GNUNET_PSEUDONYM_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg,
461 461
462 idx = -1; 462 idx = -1;
463 slen = strlen (ns_uname); 463 slen = strlen (ns_uname);
464 while ((slen > 0) && (1 != sscanf (&ns_uname[slen - 1], "-%u", &idx))) 464 while ((slen > 0) && (1 != SSCANF (&ns_uname[slen - 1], "-%u", &idx)))
465 slen--; 465 slen--;
466 if (slen == 0) 466 if (slen == 0)
467 return GNUNET_SYSERR; 467 return GNUNET_SYSERR;
diff --git a/src/util/service.c b/src/util/service.c
index 243e7daa9..7583dccb6 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -106,7 +106,7 @@ parse_ipv4_specification (const char *routeList)
106 while (i < count) 106 while (i < count)
107 { 107 {
108 cnt = 108 cnt =
109 sscanf (&routeList[pos], "%u.%u.%u.%u/%u.%u.%u.%u;", &temps[0], 109 SSCANF (&routeList[pos], "%u.%u.%u.%u/%u.%u.%u.%u;", &temps[0],
110 &temps[1], &temps[2], &temps[3], &temps[4], &temps[5], 110 &temps[1], &temps[2], &temps[3], &temps[4], &temps[5],
111 &temps[6], &temps[7]); 111 &temps[6], &temps[7]);
112 if (cnt == 8) 112 if (cnt == 8)
@@ -133,7 +133,7 @@ parse_ipv4_specification (const char *routeList)
133 } 133 }
134 /* try second notation */ 134 /* try second notation */
135 cnt = 135 cnt =
136 sscanf (&routeList[pos], "%u.%u.%u.%u/%u;", &temps[0], &temps[1], 136 SSCANF (&routeList[pos], "%u.%u.%u.%u/%u;", &temps[0], &temps[1],
137 &temps[2], &temps[3], &slash); 137 &temps[2], &temps[3], &slash);
138 if (cnt == 5) 138 if (cnt == 5)
139 { 139 {
@@ -176,7 +176,7 @@ parse_ipv4_specification (const char *routeList)
176 /* try third notation */ 176 /* try third notation */
177 slash = 32; 177 slash = 32;
178 cnt = 178 cnt =
179 sscanf (&routeList[pos], "%u.%u.%u.%u;", &temps[0], &temps[1], 179 SSCANF (&routeList[pos], "%u.%u.%u.%u;", &temps[0], &temps[1],
180 &temps[2], &temps[3]); 180 &temps[2], &temps[3]);
181 if (cnt == 4) 181 if (cnt == 4)
182 { 182 {
@@ -1268,9 +1268,9 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
1268#ifndef MINGW 1268#ifndef MINGW
1269 errno = 0; 1269 errno = 0;
1270 if ((NULL != (lpid = getenv ("LISTEN_PID"))) && 1270 if ((NULL != (lpid = getenv ("LISTEN_PID"))) &&
1271 (1 == sscanf (lpid, "%u", &pid)) && (getpid () == (pid_t) pid) && 1271 (1 == SSCANF (lpid, "%u", &pid)) && (getpid () == (pid_t) pid) &&
1272 (NULL != (nfds = getenv ("LISTEN_FDS"))) && 1272 (NULL != (nfds = getenv ("LISTEN_FDS"))) &&
1273 (1 == sscanf (nfds, "%u", &cnt)) && (cnt > 0) && (cnt < FD_SETSIZE) && 1273 (1 == SSCANF (nfds, "%u", &cnt)) && (cnt > 0) && (cnt < FD_SETSIZE) &&
1274 (cnt + 4 < FD_SETSIZE)) 1274 (cnt + 4 < FD_SETSIZE))
1275 { 1275 {
1276 sctx->lsocks = 1276 sctx->lsocks =
diff --git a/src/util/strings.c b/src/util/strings.c
index a6a5c7542..0d58ec567 100644
--- a/src/util/strings.c
+++ b/src/util/strings.c
@@ -235,7 +235,7 @@ GNUNET_STRINGS_fancy_size_to_bytes (const char *fancy_size,
235 { 235 {
236 ret += last; 236 ret += last;
237 last = 0; 237 last = 0;
238 if (1 != sscanf (tok, "%llu", &last)) 238 if (1 != SSCANF (tok, "%llu", &last))
239 { 239 {
240 GNUNET_free (in); 240 GNUNET_free (in);
241 return GNUNET_SYSERR; /* expected number */ 241 return GNUNET_SYSERR; /* expected number */
@@ -314,7 +314,7 @@ GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_size,
314 { 314 {
315 ret += last; 315 ret += last;
316 last = 0; 316 last = 0;
317 if (1 != sscanf (tok, "%llu", &last)) 317 if (1 != SSCANF (tok, "%llu", &last))
318 { 318 {
319 GNUNET_free (in); 319 GNUNET_free (in);
320 return GNUNET_SYSERR; /* expected number */ 320 return GNUNET_SYSERR; /* expected number */
@@ -978,7 +978,7 @@ GNUNET_STRINGS_to_address_ipv6 (char *zt_addr, uint16_t addrlen,
978 port_colon = strrchr (zt_addr, ':'); 978 port_colon = strrchr (zt_addr, ':');
979 if (port_colon == NULL) 979 if (port_colon == NULL)
980 return GNUNET_SYSERR; 980 return GNUNET_SYSERR;
981 ret = sscanf (port_colon, ":%u", &port); 981 ret = SSCANF (port_colon, ":%u", &port);
982 if (ret != 1 || port > 65535) 982 if (ret != 1 || port > 65535)
983 return GNUNET_SYSERR; 983 return GNUNET_SYSERR;
984 port_colon[0] = '\0'; 984 port_colon[0] = '\0';
@@ -1012,7 +1012,7 @@ GNUNET_STRINGS_to_address_ipv4 (char *zt_addr, uint16_t addrlen,
1012 if (addrlen < 9) 1012 if (addrlen < 9)
1013 return GNUNET_SYSERR; 1013 return GNUNET_SYSERR;
1014 1014
1015 cnt = sscanf (zt_addr, "%u.%u.%u.%u:%u", &temps[0], &temps[1], &temps[2], &temps[3], &port); 1015 cnt = SSCANF (zt_addr, "%u.%u.%u.%u:%u", &temps[0], &temps[1], &temps[2], &temps[3], &port);
1016 if (cnt != 5) 1016 if (cnt != 5)
1017 return GNUNET_SYSERR; 1017 return GNUNET_SYSERR;
1018 1018