blob: 044cd51a043fe0b8a567be97873603cb52e7244f [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
42 /* Parse arguments. */
43 opt_arg = argv+1;
44 while (*opt_arg) {
45 if (strcmp(*opt_arg, "-i") == 0 ||
46 strcmp(*opt_arg, "--interractive") == 0)
47 {
48 interractive = 1;
49 } else if (strcmp(*opt_arg, "-h") == 0 ||
50 strcmp(*opt_arg, "--help") == 0)
51 {
52 usage();
53 return 1;
54 } else if (strcmp(*opt_arg, "-l") == 0 ||
55 strcmp(*opt_arg, "--log-level") == 0)
56 {
57 ++opt_arg;
58 if (!opt_arg) {
59 usage();
60 return 1;
61 }
62 log_level = atoi(*opt_arg);
Benny Prijonoe93e2872006-06-28 16:46:49 +000063 } else if (strcmp(*opt_arg, "-s") == 0 ||
64 strcmp(*opt_arg, "--system") == 0)
65 {
66 ++opt_arg;
67 if (!opt_arg) {
68 usage();
69 return 1;
70 }
71 system_name = *opt_arg;
Benny Prijono9c1d9f52006-01-07 23:01:56 +000072 } else {
73 usage();
74 return 1;
75 }
76
77 ++opt_arg;
78 }
79
80 retval = test_main();
Benny Prijono0ca04b62005-12-30 23:50:15 +000081
Benny Prijonoe93e2872006-06-28 16:46:49 +000082 if (interractive) {
Benny Prijono0ca04b62005-12-30 23:50:15 +000083 char s[10];
Benny Prijonoe93e2872006-06-28 16:46:49 +000084 printf("<Press ENTER to quit>\n"); fflush(stdout);
Benny Prijono32d267b2009-01-01 22:08:21 +000085 if (fgets(s, sizeof(s), stdin) == NULL)
86 return retval;
Benny Prijono0ca04b62005-12-30 23:50:15 +000087 }
88
89 return retval;
Benny Prijono5dcb38d2005-11-21 01:55:47 +000090}