diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..27c5235 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,5 @@ +micro-utils: + 8nlight (8nlight @ disroot org) + +Thanks: + builder, echo: Kind_Foxie (fedi: KindFoxie @ lamp leemon network) diff --git a/coreutils/sleep.c b/coreutils/sleep.c index d17ada7..38aeb82 100644 --- a/coreutils/sleep.c +++ b/coreutils/sleep.c @@ -15,6 +15,11 @@ int main(const int argc, const char **argv) { for (;;) sleep(INT_MAX); - usleep(mu_parse_duration(argv[1])); + unsigned long long sec = 0; + + for (int i = 1; i < argc; i++) + sec += mu_parse_duration(argv[i]); + + usleep(sec); return 0; } diff --git a/libmu/duration.h b/libmu/duration.h index 82a85b3..14a491e 100644 --- a/libmu/duration.h +++ b/libmu/duration.h @@ -7,19 +7,40 @@ unsigned long long parse_uint(const char *str) { char *p = NULL; unsigned long long res = strtoull(str, &p, 0); - if (*p) - return 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 + else { + /* Sec */ return parse_uint(arg) * 1000000; + } return 0; } diff --git a/libmu/make_path.h b/libmu/make_path.h index fad705c..9c99a9f 100644 --- a/libmu/make_path.h +++ b/libmu/make_path.h @@ -20,6 +20,7 @@ char *mu_make_path(const char *restrict prog_name, const char *restrict src, con else snprintf(full_path, len, "%s/%s", src, dst); + return full_path; } diff --git a/libmu/parse_mode.h b/libmu/parse_mode.h index 612080f..66877c8 100644 --- a/libmu/parse_mode.h +++ b/libmu/parse_mode.h @@ -25,6 +25,8 @@ mode_t mu_parse_mode(const char *s, mode_t cur_mode) { return 0; mode = 0; + + /* Default + */ int append = 1; mode_t mask = 0;