fixed
This commit is contained in:
parent
7a048f8787
commit
f8dd7660ae
143 changed files with 74 additions and 248 deletions
48
include/duration.h
Normal file
48
include/duration.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
#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);
|
||||
|
||||
/* Parse suffix */
|
||||
if (*p) {
|
||||
switch (p[0]) {
|
||||
case 'm':
|
||||
res *= 60;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
res *= 3600;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
res *= 86400;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
unsigned long long mu_parse_duration(const char *arg) {
|
||||
if (strchr(arg, '.')) {
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
else {
|
||||
/* Sec */
|
||||
return parse_uint(arg) * 1000000;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue