1
0
src/retval/retval.c

26 lines
528 B
C
Raw Normal View History

2022-08-23 10:49:42 -06:00
#include <ctype.h> /* isdigit(3) */
#include <sysexits.h> /* EX_USAGE */
#include <unistd.h> /* write(2) */
#include "libio.h" /* fdprint(3), parse_uint(3) */
2022-05-14 18:55:12 -06:00
2022-08-23 10:49:42 -06:00
static char *program_name = "retval";
2022-05-14 18:55:12 -06:00
2022-08-23 10:49:42 -06:00
int main(int argc, char *argv[]){
unsigned int s;
2022-05-14 18:55:12 -06:00
2022-08-23 10:49:42 -06:00
if(argc < 2){
usage: write(2, "Usage: ", 7);
fdprint(2, argv[0] == NULL ? program_name : argv[0]);
write(2, " [status]\n", 10);
2022-05-14 18:55:12 -06:00
return EX_USAGE;
}
2022-08-23 10:49:42 -06:00
for(s = 0; argv[1][s] != '\0'; ++s)
if(!isdigit(argv[1][s]))
goto usage;
s = parse_uint(argv[1]);
2022-05-14 18:55:12 -06:00
2022-08-23 10:49:42 -06:00
return s;
2022-05-14 18:55:12 -06:00
}