28 lines
386 B
C
28 lines
386 B
C
|
#ifndef _DURATION_H
|
||
|
#define _DURATION_H
|
||
|
|
||
|
#include <string.h>
|
||
|
|
||
|
unsigned long long parse_uint(const char *str) {
|
||
|
char *p = NULL;
|
||
|
|
||
|
unsigned long long res = strtoull(str, &p, 0);
|
||
|
if (*p)
|
||
|
return 0;
|
||
|
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
unsigned long long mu_parse_duration(const char *arg) {
|
||
|
if (strchr(arg, '.')) {
|
||
|
|
||
|
}
|
||
|
|
||
|
else
|
||
|
return parse_uint(arg) * 1000000;
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
#endif
|