Benny Prijono | 5dcb38d | 2005-11-21 01:55:47 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
| 3 | * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | #include "test.h" |
Benny Prijono | 0ca04b6 | 2005-12-30 23:50:15 +0000 | [diff] [blame] | 20 | #include <stdio.h> |
Benny Prijono | 9c1d9f5 | 2006-01-07 23:01:56 +0000 | [diff] [blame] | 21 | #include <string.h> |
| 22 | #include <stdlib.h> |
| 23 | |
Benny Prijono | e93e287 | 2006-06-28 16:46:49 +0000 | [diff] [blame^] | 24 | extern const char *system_name; |
| 25 | |
Benny Prijono | 9c1d9f5 | 2006-01-07 23:01:56 +0000 | [diff] [blame] | 26 | static void usage() |
| 27 | { |
| 28 | puts("Usage: test-pjsip"); |
| 29 | puts("Options:"); |
| 30 | puts(" -i,--interractive Key input at the end."); |
| 31 | puts(" -h,--help Show this screen"); |
| 32 | puts(" -l,--log-level N Set log level (0-6)"); |
| 33 | } |
Benny Prijono | 5dcb38d | 2005-11-21 01:55:47 +0000 | [diff] [blame] | 34 | |
Benny Prijono | 0ca04b6 | 2005-12-30 23:50:15 +0000 | [diff] [blame] | 35 | int main(int argc, char *argv[]) |
Benny Prijono | 5dcb38d | 2005-11-21 01:55:47 +0000 | [diff] [blame] | 36 | { |
Benny Prijono | 9c1d9f5 | 2006-01-07 23:01:56 +0000 | [diff] [blame] | 37 | int interractive = 0; |
| 38 | int retval; |
| 39 | char **opt_arg; |
| 40 | |
| 41 | /* Parse arguments. */ |
| 42 | opt_arg = argv+1; |
| 43 | while (*opt_arg) { |
| 44 | if (strcmp(*opt_arg, "-i") == 0 || |
| 45 | strcmp(*opt_arg, "--interractive") == 0) |
| 46 | { |
| 47 | interractive = 1; |
| 48 | } else if (strcmp(*opt_arg, "-h") == 0 || |
| 49 | strcmp(*opt_arg, "--help") == 0) |
| 50 | { |
| 51 | usage(); |
| 52 | return 1; |
| 53 | } else if (strcmp(*opt_arg, "-l") == 0 || |
| 54 | strcmp(*opt_arg, "--log-level") == 0) |
| 55 | { |
| 56 | ++opt_arg; |
| 57 | if (!opt_arg) { |
| 58 | usage(); |
| 59 | return 1; |
| 60 | } |
| 61 | log_level = atoi(*opt_arg); |
Benny Prijono | e93e287 | 2006-06-28 16:46:49 +0000 | [diff] [blame^] | 62 | } else if (strcmp(*opt_arg, "-s") == 0 || |
| 63 | strcmp(*opt_arg, "--system") == 0) |
| 64 | { |
| 65 | ++opt_arg; |
| 66 | if (!opt_arg) { |
| 67 | usage(); |
| 68 | return 1; |
| 69 | } |
| 70 | system_name = *opt_arg; |
Benny Prijono | 9c1d9f5 | 2006-01-07 23:01:56 +0000 | [diff] [blame] | 71 | } else { |
| 72 | usage(); |
| 73 | return 1; |
| 74 | } |
| 75 | |
| 76 | ++opt_arg; |
| 77 | } |
| 78 | |
| 79 | retval = test_main(); |
Benny Prijono | 0ca04b6 | 2005-12-30 23:50:15 +0000 | [diff] [blame] | 80 | |
Benny Prijono | e93e287 | 2006-06-28 16:46:49 +0000 | [diff] [blame^] | 81 | if (interractive) { |
Benny Prijono | 0ca04b6 | 2005-12-30 23:50:15 +0000 | [diff] [blame] | 82 | char s[10]; |
Benny Prijono | e93e287 | 2006-06-28 16:46:49 +0000 | [diff] [blame^] | 83 | printf("<Press ENTER to quit>\n"); fflush(stdout); |
Benny Prijono | 0ca04b6 | 2005-12-30 23:50:15 +0000 | [diff] [blame] | 84 | fgets(s, sizeof(s), stdin); |
| 85 | } |
| 86 | |
| 87 | return retval; |
Benny Prijono | 5dcb38d | 2005-11-21 01:55:47 +0000 | [diff] [blame] | 88 | } |