You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
712 B
C
44 lines
712 B
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
#include <time.h>
|
|
#include <ctype.h>
|
|
|
|
#include "support.h"
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int i;
|
|
i = 0;
|
|
|
|
|
|
if(argc != 2)
|
|
{
|
|
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."));
|
|
}
|
|
|
|
|
|
sleep(i);
|
|
|
|
|
|
exit(0);
|
|
}
|