more cleaning
This commit is contained in:
25
retval/retval.c
Normal file
25
retval/retval.c
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <ctype.h> /* isdigit(3) */
|
||||
#include <sysexits.h> /* EX_USAGE */
|
||||
#include <unistd.h> /* write(2) */
|
||||
#include "libio.h" /* fdprint(3), parse_uint(3) */
|
||||
|
||||
static char *program_name = "retval";
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
unsigned int s;
|
||||
|
||||
if(argc < 2){
|
||||
usage: write(2, "Usage: ", 7);
|
||||
fdprint(2, argv[0] == NULL ? program_name : argv[0]);
|
||||
write(2, " [status]\n", 10);
|
||||
return EX_USAGE;
|
||||
}
|
||||
|
||||
for(s = 0; argv[1][s] != '\0'; ++s)
|
||||
if(!isdigit(argv[1][s]))
|
||||
goto usage;
|
||||
|
||||
s = parse_uint(argv[1]);
|
||||
|
||||
return s;
|
||||
}
|
||||
Reference in New Issue
Block a user