Debian Codegraph @

xpa/xpa.h

raw symbols SCIP
1 /*
2 * Copyright (c) 1999-2003 Smithsonian Astrophysical Observatory
3 */
4
5 /*
6 *
7 * xpa.h - include file for the X Public Access mechanism
8 *
9 */
10
11 #ifndef __xpa_h
12 #define __xpa_h
13
14 #if HAVE_CONFIG_H
15 #include <conf.h>
16 #endif
17
18 #include <stdio.h>
19 #include <sys/types.h>
20 #include <prsetup.h>
21 #if HAVE_MINGW32
22 #include <winsock2.h>
23 #endif
24
25 #define XPA_MAJOR_VERSION 2
26 #define XPA_MINOR_VERSION 1
27 #define XPA_PATCH_LEVEL 15
28 #define XPA_VERSION "2.1.15"
29
30 /* #define XPA_DEBUG 1 */
31 #ifdef XPA_DEBUG
32 #define FPRINTF(x) fprintf x
33 #define PERROR(x) perror x
34 #else
35 #define FPRINTF(x)
36 #define PERROR(x)
37 #endif
38
39 /* types of xpa request */
40 #define XPA_SET 1
41 #define XPA_GET 2
42 #define XPA_INFO 3
43 #define XPA_ACCESS 4
44 /* not actually commands but ... */
45 #define XPA_DATA 5
46 #define XPA_ACCEPT 6
47 #define XPA_NAGLE 7
48
49 /* this is the number of actual commands we have above */
50 #define XPA_CMDS 4
51
52 /* comm modes */
53 #define COMM_RESERVED 1
54 #define COMM_CONNECT 2
55
56 /* the ever-present */
57 #ifndef SZ_LINE
58 #define SZ_LINE 4096
59 #endif
60
61 /* limit the length of the name and xclass strings */
62 /* at least 2 of these should fit into SZ_LINE with lots of room to spare */
63 #define XPA_NAMELEN 1024
64
65 /* defines the types of callback procedure we use */
66 typedef int (*SendCb)(
67 #ifdef ANSI_FUNC
68 void *client_data,
69 void *call_data,
70 char *paramlist,
71 char **buf,
72 size_t *len
73 #endif
74 );
75
76 typedef int (*ReceiveCb)(
77 #ifdef ANSI_FUNC
78 void *client_data,
79 void *call_data,
80 char *paramlist,
81 char *buf,
82 size_t len
83 #endif
84 );
85
86 typedef int (*InfoCb)(
87 #ifdef ANSI_FUNC
88 void *client_data,
89 void *call_data,
90 char *paramlist
91 #endif
92 );
93
94 typedef void *(*SelAdd)(
95 #ifdef ANSI_FUNC
96 void *client_data,
97 int fd
98 #endif
99 );
100
101 typedef void (*SelDel)(
102 #ifdef ANSI_FUNC
103 void *client_data
104 #endif
105 );
106
107 typedef void (*SelOn)(
108 #ifdef ANSI_FUNC
109 void *client_data
110 #endif
111 );
112
113 typedef void (*SelOff)(
114 #ifdef ANSI_FUNC
115 void *client_data
116 #endif
117 );
118
119 typedef void (*MyFree)(
120 #ifdef ANSI_FUNC
121 void *buf
122 #endif
123 );
124
125 typedef void Sigfunc(
126 #ifdef ANSI_FUNC
127 int
128 #endif
129 );
130
131 /*
132 *
133 *
134 * xpa access control record structure
135 *
136 */
137 typedef struct aclrec{
138 struct aclrec *next;
139 char *xclass;
140 char *name;
141 unsigned int ip;
142 char *acl;
143 int flag;
144 } *XACL, XACLRec;
145
146 /*
147 *
148 *
149 * port management record structure
150 *
151 */
152 typedef struct portrec{
153 struct portrec *next;
154 char *xclass;
155 char *name;
156 int port;
157 } *PORT, PORTRec;
158
159 /*
160 *
161 *
162 * xpa name server management
163 *
164 */
165 typedef struct nsrec{
166 struct nsrec *next;
167 char *method;
168 int nxpa;
169 int nproxy;
170 char *host;
171 int fd;
172 FILE *in;
173 FILE *out;
174 /* for AF_INET */
175 unsigned int ip;
176 int port;
177 /* for AF_UNIX */
178 char *name;
179 } *NS, NSRec;
180
181 /*
182 *
183 *
184 * xpa communication structure for each connection
185 *
186 */
187 typedef struct xpacommrec{
188 struct xpacommrec *next;
189 int status;
190 int message;
191 int n;
192 int cmd;
193 int mode;
194 int telnet;
195 int usebuf;
196 int useacl;
197 char *id;
198 char *info;
199 char *target;
200 char *paramlist;
201 int cmdfd;
202 int datafd;
203 char *cendian;
204 int ack;
205 /* buf and len passed to callbacks */
206 char *buf;
207 size_t len;
208 /* for AF_INET */
209 unsigned int cmdip;
210 int cmdport;
211 int dataport;
212 /* for AF_UNIX */
213 char *cmdname;
214 char *dataname;
215 int acl[XPA_CMDS+1];
216 /* for handling fd's in non-select event loops */
217 void *selcptr; /* cmdfd struct for seldel */
218 void *seldptr; /* datafd struct for seldel */
219 /* pointer to associated name server */
220 struct nsrec *ns;
221 /* myfree routine */
222 MyFree myfree;
223 void *myfree_ptr;
224 } *XPAComm, XPACommRec;
225
226 /*
227 *
228 *
229 * clipboard record structure
230 *
231 */
232 typedef struct cliprec{
233 struct cliprec *next;
234 unsigned int ip;
235 char *name;
236 char *value;
237 } *XPAClip, XPAClipRec;
238
239 /*
240 *
241 * record struct for receiving data from stdin
242 *
243 */
244 typedef struct xpainputrec{
245 struct xpainputrec *next;
246 size_t start;
247 size_t end;
248 size_t bytes;
249 char *buf;
250 } *XPAInput, XPAInputRec;
251
252 /*
253 *
254 *
255 * xpa command record structure
256 *
257 */
258 typedef struct xpacmdrec{
259 struct xpacmdrec *next;
260 struct xparec *xpa;
261 char *name;
262 char *help;
263 int ntokens;
264 /* send callback info */
265 SendCb send_callback;
266 void *send_data;
267 int send_mode;
268 /* receive callback info */
269 ReceiveCb receive_callback;
270 void *receive_data;
271 int receive_mode;
272 } *XPACmd, XPACmdRec;
273
274 /*
275 *
276 *
277 * xpa client record structure
278 *
279 */
280 typedef struct xpaclientrec{
281 struct xpaclientrec *next;
282 int status;
283 char *id;
284 char *xtemplate;
285 int type;
286 char *xclass;
287 char *name;
288 char *method;
289 char *info;
290 char *dataname;
291 unsigned int ip;
292 int cmdfd;
293 int datafd;
294 int mode;
295 int nsproxy;
296 /* xpaget parameters */
297 char **bufptr;
298 size_t *lenptr;
299 size_t bufsize;
300 int fd;
301 /* xpaset parameters */
302 char *buf;
303 size_t len;
304 size_t bytes;
305 /* fork parameters */
306 pid_t pid;
307 /* common parameters */
308 char **nameptr;
309 char **errptr;
310 } *XPAClient, XPAClientRec;
311
312 /*
313 *
314 *
315 * main xpa record structure
316 *
317 * explanation of send_mode and receive_mode flags:
318 *
319 * receive-specific callback modes:
320 *
321 * r (raw) -- don't read data into buf (callback will read)
322 *
323 * general callback modes:
324 *
325 * r (raw) -- write raw data without protocol info to client
326 * s (save) -- 's' save passed buf (don't free it)
327 *
328 */
329 typedef struct xparec{
330 /* xpa version */
331 char *version;
332 /* status of this xpa */
333 int status;
334 /* "g", "s", "i" are server types; "c" for client */
335 char *type;
336 /*
337 * THE SERVER SIDE
338 */
339 struct xparec *next;
340 char *xclass;
341 char *name;
342 char *help;
343 /* send callback info */
344 SendCb send_callback;
345 void *send_data;
346 int send_mode;
347 /* receive callback info */
348 ReceiveCb receive_callback;
349 void *receive_data;
350 int receive_mode;
351 /* info callback info */
352 InfoCb info_callback;
353 void *info_data;
354 int info_mode;
355 /* list of sub-commands for this access point */
356 XPACmd commands;
357 /* communication info */
358 int fd; /* listening socket file descriptor */
359 char *method; /* method string: host:ip or unix_filename */
360 NS nshead; /* name servers associated with this access point */
361 XPAComm commhead; /* linked list of communcation records */
362 XPAClip cliphead; /* linked list of cliboard records */
363 char *filename; /* file name (unix sockets) for listening */
364 char *sendian; /* endian-ness of server */
365 /* request-specific info */
366 XPAComm comm; /* current comm if we are processing a request */
367 /* select loop info */
368 SelDel seldel; /* routine to remove xpa socket from select loop */
369 SelAdd seladd; /* routine to add xpa command sockets to select loop */
370 SelOn selon; /* routine to enable xpa command sockets */
371 SelOff seloff; /* routine to disable xpa command sockets */
372 void *selptr; /* additional info for seldelete() */
373 /*
374 * THE CLIENT SIDE
375 */
376 int persist; /* flag whether this is a persistent client */
377 int nclient; /* number of clients -- used in processing headers */
378 int client_mode; /* global client mode */
379 XPAClient clienthead; /* linked list of active clients */
380 int ifd; /* input fd for XPASetFd() */
381 size_t inpbytes; /* total number of bytes in input lists */
382 XPAInput inphead; /* linked list of input structs */
383 } *XPA, XPARec;
384
385 /* macros to access the xpa struct */
386 #define xpa_name(xpa) ((xpa)->name)
387 #define xpa_class(xpa) ((xpa)->xclass)
388 #define xpa_method(xpa) ((xpa)->method)
389 #define xpa_sendian(xpa) ((xpa)->sendian)
390 #define xpa_comm(xpa) (xpa&&(xpa)->comm?(xpa)->comm:NULL)
391 #define xpa_cendian(xpa) (((xpa)->comm&&(xpa)->comm->cendian)?(xpa)->comm->cendian:"?")
392 #define xpa_cmdfd(xpa) ((xpa)->comm?(xpa)->comm->cmdfd:-1)
393 #define xpa_datafd(xpa) ((xpa)->comm?(xpa)->comm->datafd:-1)
394 #define xpa_ack(xpa) ((xpa)->comm?(xpa)->comm->ack:1)
395 #define xpa_status(xpa) ((xpa)->comm?(xpa)->comm->status:0)
396 #define xpa_id(xpa) (((xpa)->comm&&(xpa)->comm->id)?(xpa)->comm->id:"?")
397
398 extern char *xpaMessbuf[];
399
400 _PRbeg
401
402 XPA XPAListHead _PRx((void));
403 void XPAListAdd _PRx((XPA *head, XPA xpa));
404 void XPAListDel _PRx((XPA *head, XPA xpa));
405 int XPAActive _PRx((XPA xpa, XPAComm comm, int flag));
406 int XPAActiveFd _PRx((int fd));
407 int XPAAddSelect _PRx((XPA xpa, fd_set *readfdsptr));
408 int XPAProcessSelect _PRx((fd_set *readfdsptr, int maxreq));
409 void XPACloseData _PRx((XPA xpa, XPAComm comm));
410 int XPAHandler _PRx((XPA xpa, int fd));
411 void XPAMode _PRx((char *mode, int *flag, char *name, int mask, int def));
412 int XPAEndian _PRx((void));
413 char *XPATmpdir _PRx((void));
414 void XPACleanup _PRx((void));
415 int XPASetBuf _PRx((XPA xpa, char *buf, size_t len, int xcopy));
416 int XPASetFree _PRx((XPA xpa, MyFree myfree, void *myfree_ptr));
417 int XPAShortTimeout _PRx((void));
418 int XPALongTimeout _PRx((void));
419 int XPASendLTimeout _PRx((void *client_data, void *call_data,
420 char *paramlist, char **buf, size_t *len));
421 int XPAReceiveLTimeout _PRx((void *client_data, void *call_data,
422 char *paramlist, char *buf, size_t len));
423 int XPASendSTimeout _PRx((void *client_data, void *call_data,
424 char *paramlist, char **buf, size_t *len));
425 int XPAReceiveSTimeout _PRx((void *client_data, void *call_data,
426 char *paramlist, char *buf, size_t len));
427 int XPADebug _PRx((void));
428 int XPASigusr1 _PRx((void));
429 int XPAVerbosity _PRx((void));
430 void XPAInitEnv _PRx((void));
431 void XPAParseName _PRx((char *xpaname, char *xclass, char *name, int len));
432 int XPAParseIpPort _PRx((char *host, unsigned int *ip, unsigned short *port));
433 int XPAParseUnixSocket _PRx((char *host));
434 int _XPAValid _PRx((XPA head, XPA xpa, char *type));
435 int XPAValid _PRx((XPA xpa));
436 char *XPATimestamp _PRx((void));
437 int XPAError _PRx((XPA xpa, char *s));
438 int XPAOK _PRx((XPA xpa));
439 int XPAMessage _PRx((XPA xpa, char *s));
440 char *XPAArgvParamlist _PRx((int argc, char **argv, int start));
441 int XPAMethod _PRx((char *method));
442 int XPAAccess _PRx((XPA xpa, char *xtemplate, char *paramlist, char *mode,
443 char **names, char **messages, int n));
444 int XPANSLookup _PRx((XPA xpa, char *tname, char *ttype,
445 char ***xclasses, char ***names,
446 char ***methods, char ***infs));
447 int XPANSClose _PRx((XPA xpa, NS ns));
448 int XPANSKeepAlive _PRx((XPA xpa, int type));
449 int XPANSAdd _PRx((XPA xpa, char *host, char *mode));
450 int XPANSDel _PRx((XPA xpa, char *host, char *mode));
451 int XPAVersionCheck _PRx((char *serv, char *nsv));
452 void XPAVersionWarn _PRx((char *myv, char *nsv));
453 char *XPANSMethod _PRx((char *host, int flag));
454 XPA XPANew _PRx((char *xclass, char *name, char *help,
455 SendCb send_callback, void *send_data, char *send_mode,
456 ReceiveCb rec_callback, void *rec_data, char *rec_mode));
457 int XPAFree _PRx((XPA xpa));
458 XPA XPAInfoNew _PRx((char *xclass, char *name,
459 InfoCb info_callback, void *info_data, char *info_mode));
460 int XPAPoll _PRx((int msec, int maxreq));
461 int XPAMainLoop _PRx((void));
462 void XPASleep _PRx((int msec));
463 void XPAAtExit _PRx((void));
464 /* command.c */
465 void XPAInitReserved _PRx((void));
466 void XPAFreeReserved _PRx((void));
467 XPACmd XPACmdLookupReserved _PRx((XPA xpa, char *lbuf, int *lp));
468 XPACmd XPACmdLookup _PRx((XPA xpa, char *lbuf, int *lp));
469 int XPAReceiveCommands _PRx((void *client_data, void *call_data,
470 char *paramlist, char *buf, size_t len));
471 int XPASendCommands _PRx((void *client_data, void *call_data,
472 char *paramlist, char **buf, size_t *len));
473 XPA XPACmdNew _PRx((char *xclass, char *name));
474 XPACmd XPACmdAdd _PRx((XPA xpa, char *name, char *help,
475 SendCb send_callback, void *send_data, char *send_mode,
476 ReceiveCb rec_callback, void *rec_data, char *rec_mode));
477 int XPACmdDel _PRx((XPA xpa, XPACmd cmd));
478 int XPACmdInternalReceive _PRx((void *client_data, void *call_data,
479 char *paramlist, char *buf, size_t len));
480 int XPACmdInternalSend _PRx((void *client_data, void *call_data,
481 char *paramlist, char **buf, size_t *len));
482 XPA XPAGetReserved _PRx((void));
483 int XPAMtype _PRx((void));
484 /* client.c */
485 int XPAClientAddSelect _PRx((XPA xpa,
486 fd_set *readfdsptr, fd_set *writefdsptr));
487 int XPAClientProcessSelect _PRx((XPA xpa,
488 fd_set *readfdsptr, fd_set *writefdsptr,
489 int maxreq));
490 XPA XPAOpen _PRx((char *mode));
491 void XPAClose _PRx((XPA xpa));
492 int XPAGet _PRx((XPA xpa, char *xtemplate,
493 char *paramlist, char *mode,
494 char **bufs, size_t *lens, char **names, char **errs, int n));
495 int XPAGetFd _PRx((XPA xpa, char *xtemplate,
496 char *paramlist, char *mode,
497 int *fds, char **names, char **errs, int n));
498 int XPASet _PRx((XPA xpa, char *xtemplate,
499 char *paramlist, char *mode,
500 char *buf, size_t len, char **names, char **errs, int n));
501 int XPASetFd _PRx((XPA xpa, char *xtemplate,
502 char *paramlist, char *mode,
503 int fd, char **names, char **errs, int n));
504 int XPAInfo _PRx((XPA xpa, char *xtemplate,
505 char *paramlist, char *mode,
506 char **names, char **errs, int n));
507 int XPAClientValid _PRx((XPA xpa));
508 void XPASaveJmp _PRx((void *env));
509
510
511 /* acl.c */
512 int XPAReceiveAcl _PRx((void *client_data, void *call_data,
513 char *paramlist, char *buf, size_t len));
514 int XPASendAcl _PRx((void *client_data, void *call_data,
515 char *paramlist, char **buf, size_t *len));
516 int XPAAclEdit _PRx((char *lbuf));
517 int XPAAclAdd _PRx((char *lbuf));
518 int XPAAclDel _PRx((XACL acl));
519 void XPAAclFree _PRx((void));
520 int XPAAclNew _PRx((char *aname, int flag));
521 int XPAAclCheck _PRx((XPA xpa, unsigned int ip, char *acl));
522 /* port.c */
523 int XPAPortEdit _PRx((char *lbuf));
524 int XPAPortAdd _PRx((char *lbuf));
525 int XPAPortDel _PRx((PORT port));
526 void XPAPortFree _PRx((void));
527 int XPAPortNew _PRx((char *aname, int flag));
528 int XPAPort _PRx((XPA xpa));
529 /* remote.c */
530 int XPAReceiveRemote _PRx((void *client_data, void *call_data,
531 char *paramlist, char *buf, size_t len));
532 int XPASendRemote _PRx((void *client_data, void *call_data,
533 char *paramlist, char **buf, size_t *len));
534 int XPARemote _PRx((XPA xpa, char *host, char *acl, char *mode));
535 /* clipboard.c */
536 int XPAReceiveClipboard _PRx((void *client_data, void *call_data,
537 char *paramlist, char *buf, size_t len));
538 int XPASendClipboard _PRx((void *client_data, void *call_data,
539 char *paramlist, char **buf, size_t *len));
540 int ClipBoardFree _PRx((XPA xpa, XPAClip clip));
541 /* xt.c */
542 int XPAXtAddInput _PRx((void *app, XPA xpa));
543 /* tcl.c */
544 int XPATclAddInput _PRx((XPA xpa));
545 int Tclxpa_Init _PRx((void *vinterp));
546 /* gtkloop.c */
547 int XPAGtkAddInput _PRx((XPA xpa));
548 /* xpaio.c */
549 int XPAGets _PRx((XPA xpa, int fd, char *buf, int len, int timeout));
550 int XPAPuts _PRx((XPA xpa, int fd, char *buf, int timeout));
551 int XPAGetBuf _PRx((XPA xpa, int fd, char **buf, size_t *len, int timeout));
552 int XPAPutBuf _PRx((XPA xpa, int fd, char *buf, size_t len, int timeout));
553 int XPAIOCallsXPA _PRx((int flag));
554 char *XPALevelSpaces _PRx((void));
555 void XPALevelSet _PRx((int lev));
556 int XPALevelGet _PRx((void));
557
558 _PRend
559
560 #endif /* __xpa.h */