2 Copyright © 2013 Alastair Stuart
4 This program is open source software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
23 #define VERSION "0.01"
25 void usage(char* program
)
27 printf("Usage: %s [number]\n", program
);
28 printf("Pauses for [number] seconds.\n"
30 " --help Print this message.\n"
31 " --version Show version info.\n");
34 int main(int argc
, char* argv
[])
36 static struct option long_options
[] = {
37 {"help", no_argument
, NULL
, 1},
38 {"version", no_argument
, NULL
, 2},
43 while ((c
= getopt_long(argc
, argv
, "R",
44 long_options
, NULL
)) != -1)
52 printf("sleep (mutos) v"VERSION
"\n");
55 fprintf(stderr
,"Run '%s --help' for usage.\n",
61 if ((argc
- optind
) == 0) {
62 fprintf(stderr
, "%s: missing operand\n"
63 "Run '%s --help' for usage.\n",
68 if ((argc
- optind
) > 1) {
69 fprintf(stderr
, "%s: too many operands\n"
70 "Run '%s --help' for usage.\n",
76 for (size_t i
= 0; i
< strlen(argv
[optind
]); i
++)
78 if (!isdigit(argv
[optind
][i
])) {
79 fprintf(stderr
, "%s: invalid number: %s\n",
80 argv
[0], argv
[optind
]);
85 sleep(atoi(argv
[optind
]));