diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-01-07 23:01:56 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-01-07 23:01:56 +0000 |
commit | 4d13052a1303da4e4d0a376cf6b839ce9ebb6e7a (patch) | |
tree | 25e80cdb5d3d1952020f441adf89fbce7102a26e /pjsip/src/test-pjsip/main.c | |
parent | 8bdb232f47e4f3518f983a8921c6cdab388bbcbe (diff) |
Finished UAC tests and added argument parsing in main()
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@111 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/test-pjsip/main.c')
-rw-r--r-- | pjsip/src/test-pjsip/main.c | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/pjsip/src/test-pjsip/main.c b/pjsip/src/test-pjsip/main.c index 3c5f0800..7994504d 100644 --- a/pjsip/src/test-pjsip/main.c +++ b/pjsip/src/test-pjsip/main.c @@ -18,10 +18,54 @@ */ #include "test.h" #include <stdio.h> +#include <string.h> +#include <stdlib.h> + +static void usage() +{ + puts("Usage: test-pjsip"); + puts("Options:"); + puts(" -i,--interractive Key input at the end."); + puts(" -h,--help Show this screen"); + puts(" -l,--log-level N Set log level (0-6)"); +} int main(int argc, char *argv[]) { - int retval = test_main(); + int interractive = 0; + int retval; + char **opt_arg; + + /* Parse arguments. */ + opt_arg = argv+1; + while (*opt_arg) { + if (strcmp(*opt_arg, "-i") == 0 || + strcmp(*opt_arg, "--interractive") == 0) + { + interractive = 1; + } else if (strcmp(*opt_arg, "-h") == 0 || + strcmp(*opt_arg, "--help") == 0) + { + usage(); + return 1; + } else if (strcmp(*opt_arg, "-l") == 0 || + strcmp(*opt_arg, "--log-level") == 0) + { + ++opt_arg; + if (!opt_arg) { + usage(); + return 1; + } + log_level = atoi(*opt_arg); + } else { + usage(); + return 1; + } + + ++opt_arg; + } + + retval = test_main(); if (argc != 1) { char s[10]; |