~noskcaj/ubuntu/saucy/sflphone/merge-1.2.3-2

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.0.1/pjsip/src/test/main.c

  • Committer: Jackson Doak
  • Date: 2013-07-10 21:04:46 UTC
  • mfrom: (20.1.3 sid)
  • Revision ID: noskcaj@ubuntu.com-20130710210446-y8f587vza807icr9
Properly merged from upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: main.c 3553 2011-05-05 06:14:19Z nanang $ */
 
2
/*
 
3
 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
 
4
 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
 
5
 *
 
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"
 
21
#include <stdio.h>
 
22
#include <string.h>
 
23
#include <stdlib.h>
 
24
 
 
25
extern const char *system_name;
 
26
 
 
27
static 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
}
 
35
 
 
36
int main(int argc, char *argv[])
 
37
{
 
38
    int interractive = 0;
 
39
    int retval;
 
40
    char **opt_arg;
 
41
 
 
42
    PJ_UNUSED_ARG(argc);
 
43
 
 
44
    /* 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);
 
65
        } 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;
 
74
        } else {
 
75
            usage();
 
76
            return 1;
 
77
        }
 
78
 
 
79
        ++opt_arg;
 
80
    }
 
81
 
 
82
    retval = test_main();
 
83
 
 
84
    if (interractive) {
 
85
        char s[10];
 
86
        printf("<Press ENTER to quit>\n"); fflush(stdout);
 
87
        if (fgets(s, sizeof(s), stdin) == NULL)
 
88
            return retval;
 
89
    }
 
90
 
 
91
    return retval;
 
92
}