Commit 0289c039 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Implement parse_msec.

parent 3e1e8b9f
......@@ -133,6 +133,48 @@ timeval_min_sec(struct timeval *d, int secs)
}
}
int
parse_msec(const char *string)
{
unsigned int in, fl;
int i, j;
in = fl = 0;
i = 0;
while(string[i] == ' ' || string[i] == '\t')
i++;
while(string[i] >= '0' && string[i] <= '9') {
in = in * 10 + string[i] - '0';
i++;
}
if(string[i] == '.') {
i++;
j = 0;
while(string[i] >= '0' && string[i] <= '9') {
fl = fl * 10 + string[i] - '0';
i++;
j++;
}
while(j > 3) {
fl /= 10;
j--;
}
while(j < 3) {
fl *= 10;
j++;
}
}
while(string[i] == ' ' || string[i] == '\t')
i++;
if(string[i] == '\0')
return in * 1000 + fl;
return -1;
}
void
do_debugf(int level, const char *format, ...)
{
......
......@@ -36,6 +36,7 @@ int timeval_compare(const struct timeval *s1, const struct timeval *s2)
ATTRIBUTE ((pure));
void timeval_min(struct timeval *d, const struct timeval *s);
void timeval_min_sec(struct timeval *d, int secs);
int parse_msec(const char *string);
void do_debugf(int leve, const char *format, ...)
ATTRIBUTE ((format (printf, 2, 3)));
int in_prefix(const unsigned char *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