| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/* --8<--8<--8<--8<-- |
|
2
|
|
|
|
|
|
|
* |
|
3
|
|
|
|
|
|
|
* Copyright (C) 2000-2009 Smithsonian Astrophysical Observatory |
|
4
|
|
|
|
|
|
|
* |
|
5
|
|
|
|
|
|
|
* This file is part of IPC-XPA |
|
6
|
|
|
|
|
|
|
* |
|
7
|
|
|
|
|
|
|
* IPC-XPA is free software: you can redistribute it and/or modify |
|
8
|
|
|
|
|
|
|
* it under the terms of the GNU General Public License as published by |
|
9
|
|
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or (at |
|
10
|
|
|
|
|
|
|
* your option) any later version. |
|
11
|
|
|
|
|
|
|
* |
|
12
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful, |
|
13
|
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
|
|
|
|
* GNU General Public License for more details. |
|
16
|
|
|
|
|
|
|
* |
|
17
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License |
|
18
|
|
|
|
|
|
|
* along with this program. If not, see . |
|
19
|
|
|
|
|
|
|
* |
|
20
|
|
|
|
|
|
|
* -->8-->8-->8-->8-- */ |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
23
|
|
|
|
|
|
|
extern "C" { |
|
24
|
|
|
|
|
|
|
#endif |
|
25
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
26
|
|
|
|
|
|
|
#include "perl.h" |
|
27
|
|
|
|
|
|
|
#include "XSUB.h" |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#include |
|
30
|
|
|
|
|
|
|
#include "util.h" |
|
31
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
#endif |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#define X_MAXSERVERS "max_servers" |
|
36
|
|
|
|
|
|
|
#define L_MAXSERVERS strlen(X_MAXSERVERS) |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#define X_MODE "mode" |
|
39
|
|
|
|
|
|
|
#define L_MODE strlen(X_MODE) |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
/* catch error from pre 2.1 server -- if we find this error, we know the |
|
42
|
|
|
|
|
|
|
access point is available */ |
|
43
|
|
|
|
|
|
|
#define OLD_SERVER(s) strstr(s, "invalid xpa command in initialization string") |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
typedef XPA IPC_XPA_RAW; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
MODULE = IPC::XPA PACKAGE = IPC::XPA |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
IPC_XPA_RAW |
|
50
|
|
|
|
|
|
|
_Open(mode) |
|
51
|
|
|
|
|
|
|
char* mode |
|
52
|
|
|
|
|
|
|
CODE: |
|
53
|
2
|
|
|
|
|
|
RETVAL = XPAOpen(mode); |
|
54
|
|
|
|
|
|
|
OUTPUT: |
|
55
|
|
|
|
|
|
|
RETVAL |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
IPC_XPA_RAW |
|
58
|
|
|
|
|
|
|
nullXPA() |
|
59
|
|
|
|
|
|
|
CODE: |
|
60
|
8
|
|
|
|
|
|
RETVAL = NULL; |
|
61
|
|
|
|
|
|
|
OUTPUT: |
|
62
|
|
|
|
|
|
|
RETVAL |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
void |
|
66
|
|
|
|
|
|
|
_Close(xpa) |
|
67
|
|
|
|
|
|
|
IPC_XPA_RAW xpa |
|
68
|
|
|
|
|
|
|
CODE: |
|
69
|
2
|
|
|
|
|
|
XPAClose(xpa); |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
void |
|
72
|
|
|
|
|
|
|
_Get(xpa, xtemplate, paramlist, mode, max_servers ) |
|
73
|
|
|
|
|
|
|
IPC_XPA_RAW xpa |
|
74
|
|
|
|
|
|
|
char* xtemplate |
|
75
|
|
|
|
|
|
|
char* paramlist |
|
76
|
|
|
|
|
|
|
char* mode |
|
77
|
|
|
|
|
|
|
int max_servers |
|
78
|
|
|
|
|
|
|
PREINIT: |
|
79
|
|
|
|
|
|
|
char **bufs; |
|
80
|
|
|
|
|
|
|
size_t *lens; |
|
81
|
|
|
|
|
|
|
char **names; |
|
82
|
|
|
|
|
|
|
char **messages; |
|
83
|
|
|
|
|
|
|
int i; |
|
84
|
|
|
|
|
|
|
int ns; |
|
85
|
|
|
|
|
|
|
PPCODE: |
|
86
|
|
|
|
|
|
|
/* allocate return arrays */ |
|
87
|
2
|
50
|
|
|
|
|
New( 0, bufs, max_servers, char *); |
|
88
|
2
|
50
|
|
|
|
|
New( 0, lens, max_servers, size_t); |
|
89
|
2
|
50
|
|
|
|
|
New( 0, names, max_servers, char *); |
|
90
|
2
|
50
|
|
|
|
|
New( 0, messages, max_servers, char *); |
|
91
|
|
|
|
|
|
|
/* send request to server */ |
|
92
|
2
|
|
|
|
|
|
ns = XPAGet(xpa, xtemplate, paramlist, mode, bufs, lens, |
|
93
|
|
|
|
|
|
|
names, messages, max_servers); |
|
94
|
|
|
|
|
|
|
/* convert result into something Perlish */ |
|
95
|
2
|
50
|
|
|
|
|
EXTEND(SP, 2*ns); |
|
|
|
50
|
|
|
|
|
|
|
96
|
4
|
100
|
|
|
|
|
for ( i = 0 ; i < ns ; i++ ) |
|
97
|
|
|
|
|
|
|
{ |
|
98
|
|
|
|
|
|
|
/* push the name of the server */ |
|
99
|
2
|
|
|
|
|
|
PUSHs( sv_2mortal(newSVpv(names[i],0)) ); |
|
100
|
|
|
|
|
|
|
/* push a reference to the hash onto the stack */ |
|
101
|
2
|
|
|
|
|
|
PUSHs( sv_2mortal(newRV_noinc((SV*) |
|
102
|
|
|
|
|
|
|
cdata2hash_Get(bufs[i],lens[i],names[i], |
|
103
|
|
|
|
|
|
|
messages[i] ))) ); |
|
104
|
2
|
|
|
|
|
|
free( names[i] ); |
|
105
|
2
|
|
|
|
|
|
free( messages[i] ); |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
/* free up memory that's no longer needed */ |
|
108
|
2
|
|
|
|
|
|
Safefree( bufs ); |
|
109
|
2
|
|
|
|
|
|
Safefree( lens ); |
|
110
|
2
|
|
|
|
|
|
Safefree( names ); |
|
111
|
2
|
|
|
|
|
|
Safefree( messages ); |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
#undef NMARGS |
|
115
|
|
|
|
|
|
|
#define NMARGS 3 |
|
116
|
|
|
|
|
|
|
void |
|
117
|
|
|
|
|
|
|
_Set(xpa, xtemplate, paramlist, mode, buf, len, max_servers ) |
|
118
|
|
|
|
|
|
|
IPC_XPA_RAW xpa |
|
119
|
|
|
|
|
|
|
char* xtemplate |
|
120
|
|
|
|
|
|
|
char* paramlist |
|
121
|
|
|
|
|
|
|
char* mode |
|
122
|
|
|
|
|
|
|
char* buf |
|
123
|
|
|
|
|
|
|
long len |
|
124
|
|
|
|
|
|
|
int max_servers |
|
125
|
|
|
|
|
|
|
PREINIT: |
|
126
|
|
|
|
|
|
|
char **bufs; |
|
127
|
|
|
|
|
|
|
int *lens; |
|
128
|
|
|
|
|
|
|
char **names; |
|
129
|
|
|
|
|
|
|
char **messages; |
|
130
|
|
|
|
|
|
|
int i; |
|
131
|
|
|
|
|
|
|
int ns; |
|
132
|
3
|
|
|
|
|
|
int n = 1; |
|
133
|
|
|
|
|
|
|
PPCODE: |
|
134
|
|
|
|
|
|
|
/* allocate return arrays */ |
|
135
|
3
|
50
|
|
|
|
|
New( 0, names, max_servers, char *); |
|
136
|
3
|
50
|
|
|
|
|
New( 0, messages, max_servers, char *); |
|
137
|
|
|
|
|
|
|
/* send request to server */ |
|
138
|
3
|
|
|
|
|
|
ns = XPASet(xpa, xtemplate, paramlist, mode, buf, len, |
|
139
|
|
|
|
|
|
|
names, messages, max_servers); |
|
140
|
|
|
|
|
|
|
/* convert result into something Perlish */ |
|
141
|
3
|
50
|
|
|
|
|
EXTEND(SP, 2*ns); |
|
|
|
50
|
|
|
|
|
|
|
142
|
6
|
100
|
|
|
|
|
for ( i = 0 ; i < ns ; i++ ) |
|
143
|
|
|
|
|
|
|
{ |
|
144
|
|
|
|
|
|
|
/* push the name of the server */ |
|
145
|
3
|
|
|
|
|
|
PUSHs( sv_2mortal(newSVpv(names[i],0)) ); |
|
146
|
|
|
|
|
|
|
/* Now, push a reference to the hash onto the stack */ |
|
147
|
3
|
|
|
|
|
|
PUSHs( sv_2mortal(newRV_noinc((SV*) |
|
148
|
|
|
|
|
|
|
cdata2hash_Set(names[i], messages[i] ))) ); |
|
149
|
3
|
|
|
|
|
|
free( names[i] ); |
|
150
|
3
|
|
|
|
|
|
free( messages[i] ); |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
/* free up memory that's no longer needed */ |
|
153
|
3
|
|
|
|
|
|
Safefree( names ); |
|
154
|
3
|
|
|
|
|
|
Safefree( messages ); |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
void |
|
158
|
|
|
|
|
|
|
_Info(xpa, xtemplate, paramlist, mode, max_servers ) |
|
159
|
|
|
|
|
|
|
IPC_XPA_RAW xpa |
|
160
|
|
|
|
|
|
|
char* xtemplate |
|
161
|
|
|
|
|
|
|
char* paramlist |
|
162
|
|
|
|
|
|
|
char* mode |
|
163
|
|
|
|
|
|
|
int max_servers |
|
164
|
|
|
|
|
|
|
PREINIT: |
|
165
|
|
|
|
|
|
|
char **names; |
|
166
|
|
|
|
|
|
|
char **messages; |
|
167
|
|
|
|
|
|
|
int i; |
|
168
|
|
|
|
|
|
|
int ns; |
|
169
|
|
|
|
|
|
|
PPCODE: |
|
170
|
|
|
|
|
|
|
/* allocate return arrays */ |
|
171
|
0
|
0
|
|
|
|
|
New( 0, names, max_servers, char *); |
|
172
|
0
|
0
|
|
|
|
|
New( 0, messages, max_servers, char *); |
|
173
|
|
|
|
|
|
|
/* send request to server */ |
|
174
|
0
|
|
|
|
|
|
ns = XPAInfo(xpa, xtemplate, paramlist, mode, |
|
175
|
|
|
|
|
|
|
names, messages, max_servers); |
|
176
|
|
|
|
|
|
|
/* convert result into something Perlish */ |
|
177
|
0
|
0
|
|
|
|
|
EXTEND(SP, 2*ns); |
|
|
|
0
|
|
|
|
|
|
|
178
|
0
|
0
|
|
|
|
|
for ( i = 0 ; i < ns ; i++ ) |
|
179
|
|
|
|
|
|
|
{ |
|
180
|
|
|
|
|
|
|
/* push the name of the server */ |
|
181
|
0
|
|
|
|
|
|
PUSHs( sv_2mortal(newSVpv(names[i],0)) ); |
|
182
|
|
|
|
|
|
|
/* Now, push a reference to the hash onto the stack */ |
|
183
|
0
|
|
|
|
|
|
PUSHs( sv_2mortal(newRV_noinc((SV*) |
|
184
|
|
|
|
|
|
|
cdata2hash_Set(names[i], messages[i] ))) ); |
|
185
|
0
|
|
|
|
|
|
free( names[i] ); |
|
186
|
0
|
|
|
|
|
|
free( messages[i] ); |
|
187
|
|
|
|
|
|
|
} |
|
188
|
|
|
|
|
|
|
/* free up memory that's no longer needed */ |
|
189
|
0
|
|
|
|
|
|
Safefree( names ); |
|
190
|
0
|
|
|
|
|
|
Safefree( messages ); |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
void |
|
193
|
|
|
|
|
|
|
_NSLookup(xpa, tname, ttype) |
|
194
|
|
|
|
|
|
|
IPC_XPA_RAW xpa |
|
195
|
|
|
|
|
|
|
char* tname |
|
196
|
|
|
|
|
|
|
char* ttype |
|
197
|
|
|
|
|
|
|
PREINIT: |
|
198
|
|
|
|
|
|
|
char **xclasses; |
|
199
|
|
|
|
|
|
|
char **names; |
|
200
|
|
|
|
|
|
|
char **methods; |
|
201
|
|
|
|
|
|
|
char **infos; |
|
202
|
|
|
|
|
|
|
int i; |
|
203
|
|
|
|
|
|
|
int ns; |
|
204
|
|
|
|
|
|
|
PPCODE: |
|
205
|
1
|
|
|
|
|
|
ns = XPANSLookup( xpa, tname, ttype, &xclasses, &names, |
|
206
|
|
|
|
|
|
|
&methods, &infos ); |
|
207
|
|
|
|
|
|
|
/* convert result into something Perlish */ |
|
208
|
1
|
50
|
|
|
|
|
EXTEND(SP, ns); |
|
|
|
50
|
|
|
|
|
|
|
209
|
2
|
100
|
|
|
|
|
for ( i = 0 ; i < ns ; i++ ) |
|
210
|
|
|
|
|
|
|
{ |
|
211
|
|
|
|
|
|
|
/* Now, push a reference to the hash onto the stack */ |
|
212
|
1
|
|
|
|
|
|
PUSHs( sv_2mortal(newRV_noinc((SV*) |
|
213
|
|
|
|
|
|
|
cdata2hash_Lookup(xclasses[i], |
|
214
|
|
|
|
|
|
|
names[i], |
|
215
|
|
|
|
|
|
|
methods[i], |
|
216
|
|
|
|
|
|
|
infos[i] |
|
217
|
|
|
|
|
|
|
))) ); |
|
218
|
1
|
|
|
|
|
|
free( xclasses[i] ); |
|
219
|
1
|
|
|
|
|
|
free( names[i] ); |
|
220
|
1
|
|
|
|
|
|
free( methods[i] ); |
|
221
|
1
|
|
|
|
|
|
free( infos[i] ); |
|
222
|
|
|
|
|
|
|
} |
|
223
|
1
|
50
|
|
|
|
|
if ( ns > 0 ) |
|
224
|
|
|
|
|
|
|
{ |
|
225
|
1
|
|
|
|
|
|
free( xclasses ); |
|
226
|
1
|
|
|
|
|
|
free( names ); |
|
227
|
1
|
|
|
|
|
|
free( methods ); |
|
228
|
1
|
|
|
|
|
|
free( infos ); |
|
229
|
|
|
|
|
|
|
} |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
void |
|
232
|
|
|
|
|
|
|
_Access(xpa, xtemplate, paramlist, mode, max_servers ) |
|
233
|
|
|
|
|
|
|
IPC_XPA_RAW xpa |
|
234
|
|
|
|
|
|
|
char* xtemplate |
|
235
|
|
|
|
|
|
|
char* paramlist |
|
236
|
|
|
|
|
|
|
char* mode |
|
237
|
|
|
|
|
|
|
int max_servers |
|
238
|
|
|
|
|
|
|
PREINIT: |
|
239
|
|
|
|
|
|
|
char **names; |
|
240
|
|
|
|
|
|
|
char **messages; |
|
241
|
|
|
|
|
|
|
int i; |
|
242
|
|
|
|
|
|
|
int ns; |
|
243
|
|
|
|
|
|
|
PPCODE: |
|
244
|
|
|
|
|
|
|
/* allocate return arrays */ |
|
245
|
7
|
50
|
|
|
|
|
New( 0, names, max_servers, char *); |
|
246
|
7
|
50
|
|
|
|
|
New( 0, messages, max_servers, char *); |
|
247
|
|
|
|
|
|
|
/* send request to server */ |
|
248
|
7
|
|
|
|
|
|
ns = XPAAccess(xpa, xtemplate, paramlist, mode, |
|
249
|
|
|
|
|
|
|
names, messages, max_servers); |
|
250
|
|
|
|
|
|
|
/* convert result into something Perlish */ |
|
251
|
7
|
50
|
|
|
|
|
EXTEND(SP, 2*ns); |
|
|
|
50
|
|
|
|
|
|
|
252
|
10
|
100
|
|
|
|
|
for ( i = 0 ; i < ns ; i++ ) |
|
253
|
|
|
|
|
|
|
{ |
|
254
|
|
|
|
|
|
|
/* push the name of the server */ |
|
255
|
3
|
|
|
|
|
|
PUSHs( sv_2mortal(newSVpv(names[i],0)) ); |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
/* older servers than 2.1 will react with an error |
|
258
|
|
|
|
|
|
|
to the access command; they're there (because |
|
259
|
|
|
|
|
|
|
we see the error) */ |
|
260
|
3
|
50
|
|
|
|
|
if ( messages[i] && OLD_SERVER(messages[i]) ) |
|
|
|
0
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
{ |
|
262
|
0
|
|
|
|
|
|
free( messages[i] ); |
|
263
|
0
|
|
|
|
|
|
messages[i] = NULL; |
|
264
|
|
|
|
|
|
|
} |
|
265
|
|
|
|
|
|
|
/* Now, push a reference to the hash onto the stack */ |
|
266
|
3
|
|
|
|
|
|
PUSHs( sv_2mortal(newRV_noinc((SV*) |
|
267
|
|
|
|
|
|
|
cdata2hash_Set(names[i], messages[i] ))) ); |
|
268
|
3
|
|
|
|
|
|
free( names[i] ); |
|
269
|
3
|
|
|
|
|
|
free( messages[i] ); |
|
270
|
|
|
|
|
|
|
} |
|
271
|
|
|
|
|
|
|
/* free up memory that's no longer needed */ |
|
272
|
7
|
|
|
|
|
|
Safefree( names ); |
|
273
|
7
|
|
|
|
|
|
Safefree( messages ); |