blob: 2289f69633d774772f9c1532811bdea649685d6d [file] [log] [blame]
Benny Prijono5dcb38d2005-11-21 01:55:47 +00001/* $Id$ */
2/*
Benny Prijono844653c2008-12-23 17:27:53 +00003 * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
Benny Prijono32177c02008-06-20 22:44:47 +00004 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono5dcb38d2005-11-21 01:55:47 +00005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#include "test.h"
Benny Prijono0ca04b62005-12-30 23:50:15 +000021#include <stdio.h>
Benny Prijono9c1d9f52006-01-07 23:01:56 +000022#include <string.h>
23#include <stdlib.h>
24
Benny Prijonoe93e2872006-06-28 16:46:49 +000025extern const char *system_name;
26
Benny Prijono9c1d9f52006-01-07 23:01:56 +000027static void usage()
28{
29 puts("Usage: test-pjsip");
30 puts("Options:");
31 puts(" -i,--interractive Key input at the end.");
32 puts(" -h,--help Show this screen");
33 puts(" -l,--log-level N Set log level (0-6)");
34}
Benny Prijono5dcb38d2005-11-21 01:55:47 +000035
Benny Prijono0ca04b62005-12-30 23:50:15 +000036int main(int argc, char *argv[])
Benny Prijono5dcb38d2005-11-21 01:55:47 +000037{
Benny Prijono9c1d9f52006-01-07 23:01:56 +000038 int interractive = 0;
39 int retval;
40 char **opt_arg;
41
Nanang Izzuddin039081f2009-04-28 15:27:09 +000042 PJ_UNUSED_ARG(argc);
43
Benny Prijono9c1d9f52006-01-07 23:01:56 +000044 /* Parse arguments. */
45 opt_arg = argv+1;
46 while (*opt_arg) {
47 if (strcmp(*opt_arg, "-i") == 0 ||
48 strcmp(*opt_arg, "--interractive") == 0)
49 {
50 interractive = 1;
51 } else if (strcmp(*opt_arg, "-h") == 0 ||
52 strcmp(*opt_arg, "--help") == 0)
53 {
54 usage();
55 return 1;
56 } else if (strcmp(*opt_arg, "-l") == 0 ||
57 strcmp(*opt_arg, "--log-level") == 0)
58 {
59 ++opt_arg;
60 if (!opt_arg) {
61 usage();
62 return 1;
63 }
64 log_level = atoi(*opt_arg);
Benny Prijonoe93e2872006-06-28 16:46:49 +000065 } else if (strcmp(*opt_arg, "-s") == 0 ||
66 strcmp(*opt_arg, "--system") == 0)
67 {
68 ++opt_arg;
69 if (!opt_arg) {
70 usage();
71 return 1;
72 }
73 system_name = *opt_arg;
Benny Prijono9c1d9f52006-01-07 23:01:56 +000074 } else {
75 usage();
76 return 1;
77 }
78
79 ++opt_arg;
80 }
81
82 retval = test_main();
Benny Prijono0ca04b62005-12-30 23:50:15 +000083
Benny Prijonoe93e2872006-06-28 16:46:49 +000084 if (interractive) {
Benny Prijono0ca04b62005-12-30 23:50:15 +000085 char s[10];
Benny Prijonoe93e2872006-06-28 16:46:49 +000086 printf("<Press ENTER to quit>\n"); fflush(stdout);
Benny Prijono32d267b2009-01-01 22:08:21 +000087 if (fgets(s, sizeof(s), stdin) == NULL)
88 return retval;
Benny Prijono0ca04b62005-12-30 23:50:15 +000089 }
90
91 return retval;
Benny Prijono5dcb38d2005-11-21 01:55:47 +000092}