2022-08-23 10:49:42 -06:00
|
|
|
#include <ctype.h> /* isdigit(3) */
|
2023-08-19 07:25:33 -06:00
|
|
|
#include <stdio.h> /* fprintf(3), stderr */
|
2022-08-23 10:49:42 -06:00
|
|
|
#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){
|
2023-08-19 07:25:33 -06:00
|
|
|
usage: fprintf(stderr, "Usage: %s [status]\n", argv[0] == NULL ? program_name : argv[0]);
|
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
|
|
|
}
|