manpp: handle groff \N[dd] escape sequence
[rofl0r-hardcore-utils.git] / sleep.c
blob110c5376d135ae07c89b2e5c09975e39fb18b847
1 #define _POSIX_C_SOURCE 200809L
2 #include <sys/time.h>
3 #include <time.h>
4 #include <stdlib.h>
6 int main(int argc, char** argv) {
7 int i;
8 char* end;
9 int times;
10 for(i = 1; i < argc; i++) {
11 double s = strtod(argv[i], &end);
12 switch(*end) {
13 case 'm':
14 times = 60;
15 break;
16 case 'h':
17 times = 60 * 60;
18 break;
19 case 'd':
20 times = 60 * 60 * 24;
21 break;
22 default:
23 times = 1;
25 while(times--) {
26 long long sec = s;
27 long long ns = (s - (double) sec) * 1000000000.f;
28 nanosleep(&(struct timespec) { .tv_sec = sec, .tv_nsec = ns }, NULL);
31 return 0;