blob: 840621ee2766979fda5fc85687c182767937c22d [file] [log] [blame]
Benny Prijonodd859a62005-11-01 16:42:51 +00001/* $Header: /pjproject-0.3/pjlib/src/pjlib-test/main.c 4 29/10/05 21:32 Bennylp $
2 */
3/*
4 * $Log: /pjproject-0.3/pjlib/src/pjlib-test/main.c $
5 *
6 * 4 29/10/05 21:32 Bennylp
7 * Boost process priority in Win32
8 *
9 * 3 10/29/05 11:51a Bennylp
10 * Version 0.3-pre2.
11 *
12 * 2 10/14/05 12:26a Bennylp
13 * Finished error code framework, some fixes in ioqueue, etc. Pretty
14 * major.
15 *
16 */
17#include "test.h"
18
19#include <pj/string.h>
20#include <pj/sock.h>
21#include <pj/log.h>
22
23extern int param_echo_sock_type;
24extern const char *param_echo_server;
25extern int param_echo_port;
26
27
28#if defined(PJ_WIN32) && PJ_WIN32!=0
29#include <windows.h>
30static void boost(void)
31{
32 SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
33}
34#else
35#define boost()
36#endif
37
38#if defined(PJ_SUNOS) && PJ_SUNOS!=0
39#include <signal.h>
40static void init_signals()
41{
42 struct sigaction act;
43
44 memset(&act, 0, sizeof(act));
45 act.sa_handler = SIG_IGN;
46
47 sigaction(SIGALRM, &act, NULL);
48}
49
50#else
51#define init_signals()
52#endif
53
54int main(int argc, char *argv[])
55{
56 int rc;
57
58 boost();
59 init_signals();
60
61 while (argc > 1) {
62 char *arg = argv[--argc];
63
64 if (*arg=='-' && *(arg+1)=='p') {
65 pj_str_t port = pj_str(argv[--argc]);
66
67 param_echo_port = pj_strtoul(&port);
68
69 } else if (*arg=='-' && *(arg+1)=='s') {
70 param_echo_server = argv[--argc];
71
72 } else if (*arg=='-' && *(arg+1)=='t') {
73 pj_str_t type = pj_str(argv[--argc]);
74
75 if (pj_stricmp2(&type, "tcp")==0)
76 param_echo_sock_type = PJ_SOCK_STREAM;
77 else if (pj_stricmp2(&type, "udp")==0)
78 param_echo_sock_type = PJ_SOCK_DGRAM;
79 else {
80 PJ_LOG(3,("", "error: unknown socket type %s", type.ptr));
81 return 1;
82 }
83 }
84 }
85
86 rc = test_main();
87
88 return rc;
89}
90