blob: ddfb1e7d49ac616b06bd51c2ed4a9498f976bd43 [file] [log] [blame]
Benny Prijono5dcb38d2005-11-21 01:55:47 +00001/* $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 Prijono0ca04b62005-12-30 23:50:15 +000020#include <stdio.h>
Benny Prijono9c1d9f52006-01-07 23:01:56 +000021#include <string.h>
22#include <stdlib.h>
23
Benny Prijonoe93e2872006-06-28 16:46:49 +000024extern const char *system_name;
25
Benny Prijono9c1d9f52006-01-07 23:01:56 +000026static 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 Prijono5dcb38d2005-11-21 01:55:47 +000034
Benny Prijono0ca04b62005-12-30 23:50:15 +000035int main(int argc, char *argv[])
Benny Prijono5dcb38d2005-11-21 01:55:47 +000036{
Benny Prijono9c1d9f52006-01-07 23:01:56 +000037 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 Prijonoe93e2872006-06-28 16:46:49 +000062 } 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 Prijono9c1d9f52006-01-07 23:01:56 +000071 } else {
72 usage();
73 return 1;
74 }
75
76 ++opt_arg;
77 }
78
79 retval = test_main();
Benny Prijono0ca04b62005-12-30 23:50:15 +000080
Benny Prijonoe93e2872006-06-28 16:46:49 +000081 if (interractive) {
Benny Prijono0ca04b62005-12-30 23:50:15 +000082 char s[10];
Benny Prijonoe93e2872006-06-28 16:46:49 +000083 printf("<Press ENTER to quit>\n"); fflush(stdout);
Benny Prijono0ca04b62005-12-30 23:50:15 +000084 fgets(s, sizeof(s), stdin);
85 }
86
87 return retval;
Benny Prijono5dcb38d2005-11-21 01:55:47 +000088}