Ignore:
Timestamp:
Jan 7, 2006 11:01:56 PM (18 years ago)
Author:
bennylp
Message:

Finished UAC tests and added argument parsing in main()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/test-pjsip/main.c

    r106 r111  
    1919#include "test.h" 
    2020#include <stdio.h> 
     21#include <string.h> 
     22#include <stdlib.h> 
     23 
     24static void usage() 
     25{ 
     26    puts("Usage: test-pjsip"); 
     27    puts("Options:"); 
     28    puts(" -i,--interractive   Key input at the end."); 
     29    puts(" -h,--help           Show this screen"); 
     30    puts(" -l,--log-level N    Set log level (0-6)"); 
     31} 
    2132 
    2233int main(int argc, char *argv[]) 
    2334{ 
    24     int retval = test_main(); 
     35    int interractive = 0; 
     36    int retval; 
     37    char **opt_arg; 
     38 
     39    /* Parse arguments. */ 
     40    opt_arg = argv+1; 
     41    while (*opt_arg) { 
     42        if (strcmp(*opt_arg, "-i") == 0 || 
     43            strcmp(*opt_arg, "--interractive") == 0) 
     44        { 
     45            interractive = 1; 
     46        } else if (strcmp(*opt_arg, "-h") == 0 || 
     47                   strcmp(*opt_arg, "--help") == 0)  
     48        { 
     49            usage(); 
     50            return 1; 
     51        } else if (strcmp(*opt_arg, "-l") == 0 || 
     52                   strcmp(*opt_arg, "--log-level") == 0)  
     53        { 
     54            ++opt_arg; 
     55            if (!opt_arg) { 
     56                usage(); 
     57                return 1; 
     58            } 
     59            log_level = atoi(*opt_arg); 
     60        } else { 
     61            usage(); 
     62            return 1; 
     63        } 
     64 
     65        ++opt_arg; 
     66    } 
     67 
     68    retval = test_main(); 
    2569 
    2670    if (argc != 1) { 
Note: See TracChangeset for help on using the changeset viewer.