summaryrefslogtreecommitdiff
path: root/patlooptest.c
diff options
context:
space:
mode:
authormatteo <matteo@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2003-03-15 06:00:31 +0000
committermatteo <matteo@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2003-03-15 06:00:31 +0000
commitef7de3f35f2ef572c106a972b7b16b0e947e620b (patch)
tree400ea4dfa23ba351b1f8cb19353a8fa56fdc989f /patlooptest.c
parentb7171ef3ad852bec92c85aeb388c3454c44d9ab8 (diff)
Sat Mar 15 07:00:01 CET 2003
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@154 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'patlooptest.c')
-rwxr-xr-xpatlooptest.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/patlooptest.c b/patlooptest.c
index 605f254..405ccf8 100755
--- a/patlooptest.c
+++ b/patlooptest.c
@@ -9,6 +9,7 @@
#include <sys/ioctl.h>
#include <unistd.h>
#include <stdlib.h>
+#include <time.h>
#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 <zaptel device>\n");
+ int timeout=0;
+ time_t start_time=0;
+ if (argc < 2 || argc > 3 ) {
+ fprintf(stderr, "Usage: %s <zaptel device (optional timeout)>\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;
+ }
}
}