blob: fea4cd6fa5cdf915d5a3e8b6d63144a1843ce374 [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"
20
21#include <pj/string.h>
22#include <pj/sock.h>
23#include <pj/log.h>
24
25extern int param_echo_sock_type;
26extern const char *param_echo_server;
27extern int param_echo_port;
28
29
30//#if defined(PJ_WIN32) && PJ_WIN32!=0
31#if 0
32#include <windows.h>
33static void boost(void)
34{
35 SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
36}
37#else
38#define boost()
39#endif
40
41#if defined(PJ_SUNOS) && PJ_SUNOS!=0
42#include <signal.h>
43static void init_signals()
44{
45 struct sigaction act;
46
47 memset(&act, 0, sizeof(act));
48 act.sa_handler = SIG_IGN;
49
50 sigaction(SIGALRM, &act, NULL);
51}
52
53#else
54#define init_signals()
55#endif
56
57int main(int argc, char *argv[])
58{
59 int rc;
60
61 boost();
62 init_signals();
63
64 while (argc > 1) {
65 char *arg = argv[--argc];
66
67 if (*arg=='-' && *(arg+1)=='p') {
68 pj_str_t port = pj_str(argv[--argc]);
69
70 param_echo_port = pj_strtoul(&port);
71
72 } else if (*arg=='-' && *(arg+1)=='s') {
73 param_echo_server = argv[--argc];
74
75 } else if (*arg=='-' && *(arg+1)=='t') {
76 pj_str_t type = pj_str(argv[--argc]);
77
78 if (pj_stricmp2(&type, "tcp")==0)
79 param_echo_sock_type = PJ_SOCK_STREAM;
80 else if (pj_stricmp2(&type, "udp")==0)
81 param_echo_sock_type = PJ_SOCK_DGRAM;
82 else {
83 PJ_LOG(3,("", "error: unknown socket type %s", type.ptr));
84 return 1;
85 }
86 }
87 }
88
89 rc = test_main();
90
91 return rc;
92}
93