1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
/* $TOG: xfwp.c /main/57 1998/02/09 13:58:44 kaleb $ */
/*
Copyright 1996, 1998 The Open Group
All Rights Reserved.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xos.h>
#include <netinet/in.h>
#include <X11/ICE/ICElib.h>
#include "xfwp.h"
#include "io.h"
#include "misc.h"
#include "pm.h"
#include "transport.h"
/*
* Global variables
*/
struct clientDataStruct global_data; /* for ICE callbacks */
struct pm_conn_buf ** pm_conn_array;
struct server_list ** server_array;
struct client_conn_buf ** client_conn_array;
char **SitePolicies = NULL; /* list of site security policy strings */
int SitePolicyCount = 0; /* count of elements in SitePolicies */
Bool SitePolicyPermit = 0; /* True := permit iff server supports
* at least one listed policy,
* False := deny if server has any of
* the listed policies.
*/
int
main (
int argc,
char * argv[])
{
int * pm_listen_array;
fd_set readable, writable, rinit, winit;
int nfds = 0;
int nready = 0;
struct ICE_setup_info pm_conn_setup;
IceListenObj * listen_objects;
struct config * config_info;
/*
* setup the global client data struct; we need to do this in order
* to access program data in the ICE FWPprocessMessages() callback
* without making everything global! See FWPprotocolSetupProc() for
* the rest of what we are doing
*/
config_info = (struct config *) Malloc(sizeof(struct config));
global_data.config_info = config_info;
global_data.nfds = &nfds;
global_data.rinit = &rinit;
global_data.winit = &winit;
/*
* complete the setup
*/
doProcessInputArgs(config_info, argc, argv);
if ((doHandleConfigFile(config_info)) == FAILURE)
exit(1);
if ((doInitDataStructs(config_info,
&pm_conn_setup)) == FAILURE)
exit(1);
/*
* install the ICE i/o error handler
*/
doInstallIOErrorHandler();
/*
* zero the select() read/write masks
*/
FD_ZERO(&readable);
FD_ZERO(&writable);
FD_ZERO(&rinit);
FD_ZERO(&winit);
/*
* create listener socket(s) for PM connections
*/
if (!doSetupPMListen(config_info->pm_listen_port,
&config_info->num_pm_listen_ports,
&pm_listen_array,
&listen_objects,
&nfds,
&rinit))
exit(1);
while(1)
{
readable = rinit;
writable = winit;
doSelect (config_info,
&nfds,
&nready,
&readable,
&writable);
doCheckTimeouts (config_info,
&nready,
&rinit,
&winit,
&readable,
&writable);
doProcessSelect (&nfds,
&nready,
&readable,
&writable,
&rinit,
&winit,
pm_listen_array,
config_info,
&listen_objects);
}
}
|