Commit 7a7cacd2 authored by Baptiste Jonglez's avatar Baptiste Jonglez

Rename parse_msec() and getmsec() to parse_thousands() and getthousands()

parse_msec() is not specific to milliseconds, it can parse any
fixed-point string.  It can be used, for instance, to parse a
fixed-point string written in milliseconds and interpret it as an
integer in microseconds.
parent 9d0023e7
......@@ -148,13 +148,13 @@ main(int argc, char **argv)
goto usage;
break;
case 'h':
default_wireless_hello_interval = parse_msec(optarg);
default_wireless_hello_interval = parse_thousands(optarg);
if(default_wireless_hello_interval <= 0 ||
default_wireless_hello_interval > 0xFFFF * 10)
goto usage;
break;
case 'H':
default_wired_hello_interval = parse_msec(optarg);
default_wired_hello_interval = parse_thousands(optarg);
if(default_wired_hello_interval <= 0 ||
default_wired_hello_interval > 0xFFFF * 10)
goto usage;
......
......@@ -148,14 +148,14 @@ getint(int c, int *int_r, gnc_t gnc, void *closure)
}
static int
getmsec(int c, int *int_r, gnc_t gnc, void *closure)
getthousands(int c, int *int_r, gnc_t gnc, void *closure)
{
char *t;
int i;
c = getword(c, &t, gnc, closure);
if(c < -1)
return c;
i = parse_msec(t);
i = parse_thousands(t);
if(i < 0) {
free(t);
return -2;
......@@ -408,13 +408,13 @@ parse_anonymous_ifconf(int c, gnc_t gnc, void *closure,
if_conf->cost = cost;
} else if(strcmp(token, "hello-interval") == 0) {
int interval;
c = getmsec(c, &interval, gnc, closure);
c = getthousands(c, &interval, gnc, closure);
if(c < -1 || interval <= 0 || interval > 10 * 0xFFFF)
goto error;
if_conf->hello_interval = interval;
} else if(strcmp(token, "update-interval") == 0) {
int interval;
c = getmsec(c, &interval, gnc, closure);
c = getthousands(c, &interval, gnc, closure);
if(c < -1 || interval <= 0 || interval > 10 * 0xFFFF)
goto error;
if_conf->update_interval = interval;
......
......@@ -152,8 +152,10 @@ parse_nat(const char *string)
return (int)l;
}
/* Given a fixed-point string such as "42.1337", returns 1000 times
the value of the string, here 42133. */
int
parse_msec(const char *string)
parse_thousands(const char *string)
{
unsigned int in, fl;
int i, j;
......
......@@ -78,7 +78,7 @@ int timeval_compare(const struct timeval *s1, const struct timeval *s2)
void timeval_min(struct timeval *d, const struct timeval *s);
void timeval_min_sec(struct timeval *d, time_t secs);
int parse_nat(const char *string) ATTRIBUTE ((pure));
int parse_msec(const char *string) ATTRIBUTE ((pure));
int parse_thousands(const char *string) ATTRIBUTE ((pure));
void do_debugf(int level, const char *format, ...)
ATTRIBUTE ((format (printf, 2, 3))) COLD;
int in_prefix(const unsigned char *restrict address,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment