| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 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 |
|
| 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 |
|
| 40 |
#define XPA_SET 1 |
| 41 |
#define XPA_GET 2 |
| 42 |
#define XPA_INFO 3 |
| 43 |
#define XPA_ACCESS 4 |
| 44 |
|
| 45 |
#define XPA_DATA 5 |
| 46 |
#define XPA_ACCEPT 6 |
| 47 |
#define XPA_NAGLE 7 |
| 48 |
|
| 49 |
|
| 50 |
#define XPA_CMDS 4 |
| 51 |
|
| 52 |
|
| 53 |
#define COMM_RESERVED 1 |
| 54 |
#define COMM_CONNECT 2 |
| 55 |
|
| 56 |
|
| 57 |
#ifndef SZ_LINE |
| 58 |
#define SZ_LINE 4096 |
| 59 |
#endif |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
#define XPA_NAMELEN 1024 |
| 64 |
|
| 65 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 175 |
unsigned int ip; |
| 176 |
int port; |
| 177 |
|
| 178 |
char *name; |
| 179 |
} *NS, NSRec; |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 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 |
|
| 206 |
char *buf; |
| 207 |
size_t len; |
| 208 |
|
| 209 |
unsigned int cmdip; |
| 210 |
int cmdport; |
| 211 |
int dataport; |
| 212 |
|
| 213 |
char *cmdname; |
| 214 |
char *dataname; |
| 215 |
int acl[XPA_CMDS+1]; |
| 216 |
|
| 217 |
void *selcptr; |
| 218 |
void *seldptr; |
| 219 |
|
| 220 |
struct nsrec *ns; |
| 221 |
|
| 222 |
MyFree myfree; |
| 223 |
void *myfree_ptr; |
| 224 |
} *XPAComm, XPACommRec; |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 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 |
|
| 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 |
|
| 256 |
|
| 257 |
|
| 258 |
typedef struct xpacmdrec{ |
| 259 |
struct xpacmdrec *next; |
| 260 |
struct xparec *xpa; |
| 261 |
char *name; |
| 262 |
char *help; |
| 263 |
int ntokens; |
| 264 |
|
| 265 |
SendCb send_callback; |
| 266 |
void *send_data; |
| 267 |
int send_mode; |
| 268 |
|
| 269 |
ReceiveCb receive_callback; |
| 270 |
void *receive_data; |
| 271 |
int receive_mode; |
| 272 |
} *XPACmd, XPACmdRec; |
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 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 |
|
| 297 |
char **bufptr; |
| 298 |
size_t *lenptr; |
| 299 |
size_t bufsize; |
| 300 |
int fd; |
| 301 |
|
| 302 |
char *buf; |
| 303 |
size_t len; |
| 304 |
size_t bytes; |
| 305 |
|
| 306 |
pid_t pid; |
| 307 |
|
| 308 |
char **nameptr; |
| 309 |
char **errptr; |
| 310 |
} *XPAClient, XPAClientRec; |
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
typedef struct xparec{ |
| 330 |
|
| 331 |
char *version; |
| 332 |
|
| 333 |
int status; |
| 334 |
|
| 335 |
char *type; |
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
struct xparec *next; |
| 340 |
char *xclass; |
| 341 |
char *name; |
| 342 |
char *help; |
| 343 |
|
| 344 |
SendCb send_callback; |
| 345 |
void *send_data; |
| 346 |
int send_mode; |
| 347 |
|
| 348 |
ReceiveCb receive_callback; |
| 349 |
void *receive_data; |
| 350 |
int receive_mode; |
| 351 |
|
| 352 |
InfoCb info_callback; |
| 353 |
void *info_data; |
| 354 |
int info_mode; |
| 355 |
|
| 356 |
XPACmd commands; |
| 357 |
|
| 358 |
int fd; |
| 359 |
char *method; |
| 360 |
NS nshead; |
| 361 |
XPAComm commhead; |
| 362 |
XPAClip cliphead; |
| 363 |
char *filename; |
| 364 |
char *sendian; |
| 365 |
|
| 366 |
XPAComm comm; |
| 367 |
|
| 368 |
SelDel seldel; |
| 369 |
SelAdd seladd; |
| 370 |
SelOn selon; |
| 371 |
SelOff seloff; |
| 372 |
void *selptr; |
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
int persist; |
| 377 |
int nclient; |
| 378 |
int client_mode; |
| 379 |
XPAClient clienthead; |
| 380 |
int ifd; |
| 381 |
size_t inpbytes; |
| 382 |
XPAInput inphead; |
| 383 |
} *XPA, XPARec; |
| 384 |
|
| 385 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 542 |
int XPAXtAddInput _PRx((void *app, XPA xpa)); |
| 543 |
|
| 544 |
int XPATclAddInput _PRx((XPA xpa)); |
| 545 |
int Tclxpa_Init _PRx((void *vinterp)); |
| 546 |
|
| 547 |
int XPAGtkAddInput _PRx((XPA xpa)); |
| 548 |
|
| 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 |