static inline int
isspace(char c)
{
- return (c == ' ' || c == '\t' || c == '\n' || c == '\12');
+ return c == ' ' || c == '\t' || c == '\n' || c == '\12';
}
#endif
l = strtoul(c, &endptr, 0);
- if (l == ULONG_MAX || (l == 0 && endptr == c))
- return (0);
+ if (l == ULONG_MAX || (l == 0 && endptr == c)) {
+ return 0;
+ }
val = (in_addr_t)l;
* gone '.12' or something which would get past
* the next check.
*/
- if (endptr == c)
- return (0);
+ if (endptr == c) {
+ return 0;
+ }
parts[n] = val;
c = endptr;
/* Check the next character past the previous number's end */
switch (*c) {
- case '.' :
+ case '.':
/* Make sure we only do 3 dots .. */
- if (n == 3) /* Whoops. Quit. */
- return (0);
+ if (n == 3) { /* Whoops. Quit. */
+ return 0;
+ }
n++;
c++;
break;
gotend = 1;
break;
} else {
-
/* Invalid character, then fail. */
- return (0);
+ return 0;
}
}
-
}
/* Concoct the address according to the number of parts specified. */
switch (n) {
- case 0: /* a -- 32 bits */
+ case 0: /* a -- 32 bits */
/*
* Nothing is necessary here. Overflow checking was
* already done in strtoul().
*/
break;
- case 1: /* a.b -- 8.24 bits */
- if (val > 0xffffff || parts[0] > 0xff)
- return (0);
+ case 1: /* a.b -- 8.24 bits */
+ if (val > 0xffffff || parts[0] > 0xff) {
+ return 0;
+ }
val |= parts[0] << 24;
break;
- case 2: /* a.b.c -- 8.8.16 bits */
- if (val > 0xffff || parts[0] > 0xff || parts[1] > 0xff)
- return (0);
+ case 2: /* a.b.c -- 8.8.16 bits */
+ if (val > 0xffff || parts[0] > 0xff || parts[1] > 0xff) {
+ return 0;
+ }
val |= (parts[0] << 24) | (parts[1] << 16);
break;
- case 3: /* a.b.c.d -- 8.8.8.8 bits */
+ case 3: /* a.b.c.d -- 8.8.8.8 bits */
if (val > 0xff || parts[0] > 0xff || parts[1] > 0xff ||
- parts[2] > 0xff)
- return (0);
+ parts[2] > 0xff) {
+ return 0;
+ }
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
break;
}
- if (addr != NULL)
+ if (addr != NULL) {
addr->s_addr = htonl(val);
- return (1);
+ }
+ return 1;
}