From ef7de3f35f2ef572c106a972b7b16b0e947e620b Mon Sep 17 00:00:00 2001 From: matteo Date: Sat, 15 Mar 2003 06:00:31 +0000 Subject: Sat Mar 15 07:00:01 CET 2003 git-svn-id: http://svn.digium.com/svn/zaptel/trunk@154 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- patlooptest.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'patlooptest.c') diff --git a/patlooptest.c b/patlooptest.c index 605f254..405ccf8 100755 --- a/patlooptest.c +++ b/patlooptest.c @@ -9,6 +9,7 @@ #include #include #include +#include #define BLOCK_SIZE 2039 @@ -38,8 +39,10 @@ int main(int argc, char *argv[]) int setup=0; int errors=0; int bytes=0; - if (argc < 2) { - fprintf(stderr, "Usage: markhdlctest \n"); + int timeout=0; + time_t start_time=0; + if (argc < 2 || argc > 3 ) { + fprintf(stderr, "Usage: %s \n",argv[0]); exit(1); } fd = open(argv[1], O_RDWR, 0600); @@ -63,6 +66,11 @@ int main(int argc, char *argv[]) perror("tor_flush"); exit(255); } + if(argc==3){ + timeout=atoi(argv[2]); + start_time=time(NULL); + printf("Using Timeout of %d Seconds\n",timeout); + } for(;;) { res = bs; @@ -105,6 +113,10 @@ int main(int argc, char *argv[]) #if 0 printf("(%d) Wrote %d bytes\n", packets++, res); #endif + if(timeout && (time(NULL)-start_time)>timeout){ + printf("Timeout achieved Ending Program\n"); + return errors; + } } } -- cgit v1.2.3