|
|
|
@ -2,7 +2,7 @@
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
|
|
#include "support.h"
|
|
|
|
|
|
|
|
|
@ -18,15 +18,22 @@ int main(int argc, char **argv)
|
|
|
|
|
throw(NEEDARG_FAIL, mastrcat(argv[0], " int"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* have we received a positive integer? */
|
|
|
|
|
/* subtract one from strlen result to account for zero indexing */
|
|
|
|
|
for(i = (strlen(argv[1])-1); i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
if(!isdigit(argv[1][i]))
|
|
|
|
|
{
|
|
|
|
|
throw(NEEDARG_FAIL, mastrcat(argv[0], " int"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
i = (int) (strtol(argv[1], (char **) NULL, 10));
|
|
|
|
|
if(errno == ERANGE)
|
|
|
|
|
{
|
|
|
|
|
throw(TIME_FAIL, mastrcat(argv[0], " ERANGE error."));
|
|
|
|
|
}
|
|
|
|
|
if(i < 0)
|
|
|
|
|
{
|
|
|
|
|
throw(MISC_FAIL, mastrcat(argv[0], ": need positive number."));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sleep(i);
|
|
|
|
|