Annotation of Amaya/amaya/AHTBridge.c, revision 1.40
1.9 cvs 1: /*
2: *
3: * (c) COPYRIGHT MIT and INRIA, 1996.
4: * Please first read the full copyright statement in file COPYRIGHT.
5: *
6: */
7:
1.14 cvs 8: /*
9: * AHTBridge.c : This module implements the callback setup and
10: * handlers between the Xt, libwww, and Amaya procedures. It's responsible
11: * for assigning, modifying, and supressing Xt events to the active
12: * requests.
13: *
14: * Author: J Kahan
1.28 cvs 15: * R. Guetari/J. Kahan Windows NT/95 routines
1.14 cvs 16: *
17: */
1.23 cvs 18: #ifndef AMAYA_JAVA
19:
1.16 cvs 20: #define THOT_EXPORT extern
1.4 cvs 21: #include "amaya.h"
1.10 cvs 22: #include "AHTBridge_f.h"
23: #include "AHTFWrite_f.h"
24: #include "query_f.h"
25: #include "answer_f.h"
1.4 cvs 26:
1.22 cvs 27: #ifndef _WINDOWS
1.4 cvs 28: /* Amaya's X appcontext */
1.38 cvs 29:
1.16 cvs 30: extern ThotAppContext app_cont;
1.4 cvs 31:
1.32 cvs 32: /* Private functions */
1.4 cvs 33: #ifdef __STDC__
1.18 cvs 34: static void RequestRegisterReadXtevent (AHTReqContext *, SOCKET);
1.7 cvs 35: static void RequestKillReadXtevent (AHTReqContext *);
1.18 cvs 36: static void RequestRegisterWriteXtevent (AHTReqContext *, SOCKET);
1.7 cvs 37: static void RequestKillWriteXtevent (AHTReqContext *);
1.18 cvs 38: static void RequestRegisterExceptXtevent (AHTReqContext *, SOCKET);
1.7 cvs 39: static void RequestKillExceptXtevent (AHTReqContext *);
1.27 cvs 40: #else /* __STDC__ */
1.18 cvs 41: static void RequesAddReadXtevent ();
1.7 cvs 42: static void RequestKillReadXtevent ();
1.18 cvs 43: static void RequesAddWriteXtevent ();
1.7 cvs 44: static void RequestKillWriteXtevent ();
1.18 cvs 45: static void RequestRegisterExceptXtevent ();
1.7 cvs 46: static void RequestKillExceptXtevent ();
1.27 cvs 47: #endif /* __STDC__ */
1.24 cvs 48: #endif /* _WINDOWS */
49:
1.32 cvs 50: /* Private variables */
1.4 cvs 51:
52: /*
53: * this set of SockOps map our WinSock "socket event SockOps" into
54: * our read and write sets. Note that under the canonical Unix model,
55: * a non-blocking socket passed to an accept() call will appear as readable,
56: * whilst a non-blocking call to connect() will appear as writeable. In add.
57: * if the connection has been closed, the socket will appear readable under
58: * BSD Unix semantics
59: */
1.32 cvs 60:
1.10 cvs 61: static const SockOps ReadBits = FD_READ | FD_ACCEPT | FD_CLOSE;
62: static const SockOps WriteBits = FD_WRITE | FD_CONNECT;
63: static const SockOps ExceptBits = FD_OOB;
1.4 cvs 64:
1.38 cvs 65: #define SOCK_TABLE_SIZE 67
66: #define HASH(s) ((s) % SOCK_TABLE_SIZE)
67: static XtInputId persSockets[SOCK_TABLE_SIZE];
1.35 cvs 68:
1.32 cvs 69: /* Private functions */
1.4 cvs 70:
1.10 cvs 71: /*--------------------------------------------------------------------
72: AHTCallback_bridge
1.11 cvs 73: this function acts as a bridge between Xt and libwww. From the Xt
74: point of view, this function is the callback handler whenever there's
75: any activity on the sockets associated with the active requests. From
76: the libwww point of view, this is the function that takes the initiative
77: to invoke the callback function associated with an active request,
78: whenever there's an activity in the socket associated to it.
79: In this latter aspect, this function is similar to the library's
80: own __DoCallback() function.
81: Upon activation, the function looks up the request associated with the
82: active socket and then looks up the cbf associated with that request.
83: Upon completion of the execution of the request's cbf, it verifies
84: the state of the request and, if it's an asynchronous request, deletes
85: the memory allocated to it.
1.10 cvs 86: -------------------------------------------------------------------*/
1.37 cvs 87: #ifndef _WINDOWS
1.4 cvs 88: #ifdef __STDC__
1.12 cvs 89: void *AHTCallback_bridge (caddr_t cd, int *s, XtInputId * id)
1.26 cvs 90: #else /* __STDC__ */
1.12 cvs 91: void *AHTCallback_bridge (cd, s, id)
1.7 cvs 92: caddr_t cd;
93: int *s;
94: XtInputId *id;
1.4 cvs 95: #endif /* __STDC__ */
96: {
1.11 cvs 97: int status; /* the status result of the libwwww call */
1.7 cvs 98: HTRequest *rqp = NULL;
99: AHTReqContext *me;
1.11 cvs 100: SockOps ops;
1.38 cvs 101: int v;
1.40 ! cvs 102: int socket = *s;
! 103: HTEventCallback *cbf;
1.4 cvs 104:
1.10 cvs 105: /* Libwww 5.0a does not take into account the ops parameter
1.11 cvs 106: in the invocation of for this function call */
1.38 cvs 107:
1.13 cvs 108: ops = FD_WRITE;
1.40 ! cvs 109: cbf = (HTEventCallback *) __RetrieveCBF (socket, ops, &rqp);
1.36 cvs 110:
1.38 cvs 111: /* if rqp is NULL, we are dealing with a persistent socket shutdown */
112: if (!(cbf) || !(rqp) || rqp->priority == HT_PRIORITY_OFF)
113: {
1.36 cvs 114: #ifdef DEBUG_LIBWWW
1.38 cvs 115: HTTrace ("Callback.... No callback found\n");
1.36 cvs 116: #endif
1.38 cvs 117: /* remove the Xt input which caused this callback */
118: # ifdef WWW_XWINDOWS
119: XtRemoveInput (*id);
120: # endif
121:
122: /* if it's a persistent socket, remove it from the table */
1.40 ! cvs 123: v = HASH (socket);
1.38 cvs 124: if (persSockets[v])
125: {
126: persSockets[v] = 0;
127: if (cbf)
1.40 ! cvs 128: (*cbf) (socket, 0, FD_CLOSE);
1.38 cvs 129: }
130: return (0);
131: }
132:
1.7 cvs 133: me = HTRequest_context (rqp);
1.38 cvs 134:
1.36 cvs 135: #ifdef DEBUG_LIBWWW
1.38 cvs 136: fprintf (stderr, "AHTBridge: Processing url %s \n", me->urlName);
1.36 cvs 137: #endif
1.38 cvs 138:
1.32 cvs 139: switch ((XtInputId) cd) {
1.38 cvs 140: case XtInputReadMask:
1.19 cvs 141: ops = me->read_ops;
142: ops = FD_READ;
143: break;
1.32 cvs 144: case XtInputWriteMask:
1.7 cvs 145: ops = me->write_ops;
146: ops = FD_WRITE;
147: break;
1.32 cvs 148: case XtInputExceptMask:
1.7 cvs 149: ops = me->except_ops;
150: ops = FD_OOB;
151: break;
1.32 cvs 152: default:
153: break;
154: } /* switch */
1.17 cvs 155:
1.32 cvs 156: /* Invokes the callback associated to the requests */
157:
158: /* first we change the status of the request, to say it
159: has entered a critical section */
1.38 cvs 160:
1.35 cvs 161: /* JK: Clean this up */
1.32 cvs 162: if ((HTRequest_outputStream(me->request) == (HTStream *) NULL))
1.38 cvs 163: fprintf(stderr,"\n **ERROR** opening %s\n\n", me->urlName);
1.32 cvs 164:
165: me->reqStatus = HT_BUSY;
1.38 cvs 166:
1.40 ! cvs 167: if ((status = (*cbf) (socket, rqp, ops)) != HT_OK)
1.36 cvs 168: #ifdef DEBUG_LIBWWW
169: HTTrace ("Callback.... returned a value != HT_OK");
170: #endif
1.7 cvs 171: /* Several states can happen after this callback. They
172: * are indicated by the me->reqStatus structure member and
173: * the fds external variables. The following lines examine
174: * the states and correspondly update the Xt event register
175: *
176: * Regarding the me->reqStatus member, we have the following
177: * possible states:
178: *
179: * HT_BUSY: Request has blocked
180: * HT_WAITING: Request has been reissued
181: * HT_ABORT: Request has been stopped
182: * HT_END: Request has ended
183: */
184:
1.32 cvs 185: if (me->reqStatus == HT_ABORT) {
1.11 cvs 186: /* Has the user stopped the request? */
1.38 cvs 187: me->reqStatus = HT_WAITING;
188: StopRequest (me->docid);
189: return (0);
1.32 cvs 190: }
1.7 cvs 191:
1.32 cvs 192: if (me->reqStatus == HT_WAITING) {
1.38 cvs 193: /* the request is being reissued */
194: /*
195: * (1) The old request has ended and the library
196: * assigned the old socket number to a pending
197: * request.
198: *
199: * (2) The request has been reissued after an
200: * authentication or redirection directive and
201: * we are using the same old socket number.
202: */
203:
1.36 cvs 204: #ifdef DEBUG_LIBWWW
1.38 cvs 205: fprintf (stderr, "*** detected a reissue of request \n");
1.36 cvs 206: #endif
1.38 cvs 207: return (0);
1.32 cvs 208: }
1.4 cvs 209:
1.32 cvs 210: /* we verify if the request exists. If it has ended, we will have
211: a reqStatus with an HT_END value */
1.7 cvs 212:
1.36 cvs 213: if ((me->reqStatus == HT_END) ||
214: (me->reqStatus == HT_ERR)) {
215: /* request has ended */
216: #ifdef DEBUG_LIBWWW
1.40 ! cvs 217: fprintf (stderr, "(BF) removing Xtinput %lu !RWE, sock %d (Request has ended)\n", *id, socket);
1.36 cvs 218: #endif
1.38 cvs 219: if ((me->mode & AMAYA_ASYNC) || (me->mode & AMAYA_IASYNC)) {
1.36 cvs 220: AHTPrintPendingRequestStatus (me->docid, YES);
1.32 cvs 221: /* free the memory allocated for async requests */
222: AHTReqContext_delete (me);
1.38 cvs 223: } else if (me->reqStatus != HT_END && HTError_hasSeverity (HTRequest_error (me->request), ERR_NON_FATAL))
224: /* did the SYNC request end because of an error? If yes, report it back to the caller */
225: me->reqStatus = HT_ERR;
226: return (0);
1.32 cvs 227: }
1.38 cvs 228:
1.36 cvs 229: /* The request is still alive, so change it's status to indicate
230: it's out of the critical section */
1.7 cvs 231: me->reqStatus = HT_WAITING;
232: return (0);
1.4 cvs 233: }
1.37 cvs 234: #endif /* !_WINDOWS */
1.4 cvs 235:
1.32 cvs 236: #ifdef _WINDOWS
1.29 cvs 237: /*----------------------------------------------------------------
1.32 cvs 238: WIN_Activate_Request
1.29 cvs 239: when there are more open requests than available sockets, the
240: requests are put in a "pending state." When a socket becomes
241: available, libwww associates it with a pending request and then
242: calls this callback function. This function is responsible for
243: opening the temporary file where the GET and POST results
244: will be stored. The function is also responsible for
245: registering the socket with the Xt event loop.
246: Consult the libwww manual for more details on the signature
247: of this function.
248: ----------------------------------------------------------------*/
249: #ifdef __STDC__
1.32 cvs 250: int WIN_Activate_Request (HTRequest * request, HTAlertOpcode op, int msgnum, const char *dfault, void *input, HTAlertPar * reply)
1.29 cvs 251: #else
1.32 cvs 252: int WIN_Activate_Request (request, op, msgnum, dfault, input, reply)
1.29 cvs 253: HTRequest *request;
254: HTAlertOpcode op;
255: int msgnum;
256: const char *dfault;
257: void *input;
258: HTAlertPar *reply;
259:
260: #endif /* __STDC__ */
261: {
262: AHTReqContext *me = HTRequest_context (request);
263:
1.32 cvs 264: if (me->reqStatus == HT_NEW) {
1.40 ! cvs 265: if (!(me->output) &&
! 266: (me->output != stdout) &&
1.38 cvs 267: me->outputfile &&
268: (me->output = fopen (me->outputfile, "wb")) == NULL) {
269: /* the request is associated with a file */
270: me->outputfile[0] = EOS; /* file could not be opened */
271: TtaSetStatus (me->docid, 1,
272: TtaGetMessage (AMAYA, AM_CANNOT_CREATE_FILE),
273: me->outputfile);
274: me->reqStatus = HT_ERR;
275: if (me->error_html)
276: DocNetworkStatus[me->docid] |= AMAYA_NET_ERROR; /* so we can show the error message */
1.32 cvs 277: } else {
1.36 cvs 278: if (THD_TRACE)
279: fprintf (stderr, "WIN_Activate_Request: Activating pending %s . Open fd %d\n", me->urlName, (int) me->output);
280: HTRequest_setOutputStream (me->request, AHTFWriter_new (me->request, me->output, YES));
1.32 cvs 281: /*change the status of the request */
282: me->reqStatus = HT_WAITING;
283: }
284: }
285: else if (me->reqStatus == HT_WAITING) {
1.36 cvs 286:
287: /*change the status of the request */
288: rewind (me->output);
289: if (HTRequest_outputStream (me->request) == NULL)
290: HTRequest_setOutputStream (me->request, AHTFWriter_new (me->request, me->output, YES));
1.32 cvs 291: }
292: else {
1.36 cvs 293: me->reqStatus = HT_ERR;
1.32 cvs 294: }
295:
1.36 cvs 296: return ((me->reqStatus != HT_ERR) ? HT_OK : HT_ERROR);
1.32 cvs 297: }
298:
1.38 cvs 299: #else /* _WINDOWS */
1.32 cvs 300:
301: /*----------------------------------------------------------------
302: Add_NewSocket_to_Loop
303: when there are more open requests than available sockets, the
304: requests are put in a "pending state." When a socket becomes
305: available, libwww associates it with a pending request and then
306: calls this callback function. This function is responsible for
307: opening the temporary file where the GET and POST results
308: will be stored. The function is also responsible for
309: registering the socket with the Xt event loop.
310: Consult the libwww manual for more details on the signature
311: of this function.
312: ----------------------------------------------------------------*/
313: #ifdef __STDC__
314: int Add_NewSocket_to_Loop (HTRequest * request, HTAlertOpcode op, int msgnum, const char *dfault, void *input, HTAlertPar * reply)
315: #else
316: int Add_NewSocket_to_Loop (request, op, msgnum, dfault, input, reply)
317: HTRequest *request;
318: HTAlertOpcode op;
319: int msgnum;
320: const char *dfault;
321: void *input;
322: HTAlertPar *reply;
1.29 cvs 323:
1.32 cvs 324: #endif /* __STDC__ */
325: {
326: AHTReqContext *me = HTRequest_context (request);
1.38 cvs 327: int status = HT_OK;
1.4 cvs 328:
1.36 cvs 329: #ifdef DEBUG_LIBWWW
1.32 cvs 330: fprintf (stderr, "(Activating a request\n");
1.36 cvs 331: #endif
1.30 cvs 332:
1.40 ! cvs 333: /* request was aborted (redirection, authentication) and now is is
! 334: being automatically reissued */
! 335:
! 336: if (me->reqStatus == HT_BUSY && me->output) {
! 337: fclose (me->output);
! 338: me->output = NULL;
! 339: }
! 340:
! 341: /* the request is active, open the output file */
! 342: if (!(me->output) &&
! 343: (me->output != stdout) &&
! 344: me->outputfile &&
! 345: !(me->output = fopen (me->outputfile, "w"))) {
! 346: me->outputfile[0] = EOS;
! 347: /* file could not be opened */
! 348: TtaSetStatus (me->docid, 1,
! 349: TtaGetMessage (AMAYA, AM_CANNOT_CREATE_FILE),
! 350: me->outputfile);
! 351: me->reqStatus = HT_ERR;
! 352: status = HT_ERROR;
! 353: /* should the error be shown on the Amaya doc window? */
! 354: if (me->error_html)
! 355: DocNetworkStatus[me->docid] |= AMAYA_NET_ERROR;
! 356: }
1.38 cvs 357:
1.36 cvs 358: #ifdef DEBUG_LIBWWW
1.40 ! cvs 359: fprintf (stderr, "ADDNEWSOCK: associated %s to FD %p\n",
! 360: me->urlName, me->output);
1.32 cvs 361: #endif
1.40 ! cvs 362: if (me->output) {
! 363: if (THD_TRACE)
! 364: fprintf (stderr, "Add_NewSocket_to_Loop: Activating "
! 365: "pending %s . Open fd %d\n",
! 366: me->urlName, (int) me->output);
! 367:
! 368: HTRequest_setOutputStream (me->request,
! 369: AHTFWriter_new (me->request,
! 370: me->output,
! 371: YES));
! 372: me->reqStatus = HT_WAITING;
! 373: }
! 374:
1.32 cvs 375:
1.40 ! cvs 376: return (status);
1.4 cvs 377: }
1.32 cvs 378: #endif /* _WINDOWS */
1.4 cvs 379:
1.11 cvs 380: /*----------------------------------------------------------------------
381: AHTEvent_register
382: callback called by libwww whenever a socket is open and associated
383: to a request. It sets the pertinent Xt events so that the Xt Event
384: loops gets an interruption whenever there's action of the socket.
385: In addition, it registers the request with libwww.
386: ----------------------------------------------------------------------*/
1.4 cvs 387: #ifdef __STDC__
1.7 cvs 388: int AHTEvent_register (SOCKET sock, HTRequest * rqp, SockOps ops, HTEventCallback * cbf, HTPriority p)
1.4 cvs 389: #else
1.7 cvs 390: int AHTEvent_register (sock, rqp, ops, cbf, p)
391: SOCKET sock;
392: HTRequest *rqp;
393: SockOps ops;
394: HTEventCallback *cbf;
395: HTPriority p;
396:
397: #endif /* __STDC__ */
1.4 cvs 398: {
1.40 ! cvs 399: AHTReqContext *me; /* current request */
! 400: int status; /* libwww status associated with
! 401: the socket number */
1.38 cvs 402: #ifndef _WINDOWS
1.40 ! cvs 403: int v;
1.38 cvs 404: #endif /* _WINDOWS */
1.7 cvs 405:
1.40 ! cvs 406: if (sock == INVSOC)
! 407: return (0);
1.4 cvs 408:
1.40 ! cvs 409: /* get the request associated to the socket number */
1.7 cvs 410:
1.40 ! cvs 411: if (rqp == NULL)
! 412: {
1.37 cvs 413: #ifndef _WINDOWS
1.40 ! cvs 414: if (ops == FD_CLOSE)
! 415: {
1.36 cvs 416: #ifdef DEBUG_LIBWWW
1.40 ! cvs 417: fprintf(stderr, "HTEvent_register: ***** RQP is NULL @@@@@\n");
1.37 cvs 418: #endif /* DEBUG_LIBWWW */
1.40 ! cvs 419: v = HASH (sock);
! 420: if (persSockets[v] != 0)
! 421: {
! 422: XtRemoveInput (persSockets[v]);
! 423: }
1.38 cvs 424:
1.40 ! cvs 425: persSockets[v] = XtAppAddInput (app_cont,
! 426: sock,
! 427: (XtPointer) XtInputReadMask,
! 428: (XtInputCallbackProc) AHTCallback_bridge,
! 429: (XtPointer) XtInputReadMask);
! 430: } /* *fd_close */
1.39 cvs 431: #endif /* !_WINDOWS */
1.40 ! cvs 432: }
! 433: else /* rqp */
! 434: {
! 435: me = HTRequest_context (rqp);
1.38 cvs 436:
1.36 cvs 437: #ifndef _WINDOWS
1.40 ! cvs 438: v = HASH (sock);
! 439: if (persSockets[v] != 0) {
! 440: XtRemoveInput (persSockets[v]);
! 441: persSockets[v] = 0;
! 442: }
1.36 cvs 443: #endif /* _WINDOWS */
1.40 ! cvs 444: /* verify if we need to open the output file */
! 445: if (me->reqStatus == HT_NEW)
! 446: {
1.37 cvs 447: #ifdef _WINDOWS
1.40 ! cvs 448: /* Erase any trailing events */
! 449: HTEventrg_unregister (sock, FD_ALL);
1.37 cvs 450: #endif
1.40 ! cvs 451: /* we are opening a pending request */
1.38 cvs 452: #ifndef _WINDOWS
1.40 ! cvs 453: if (!(me->output) &&
! 454: (me->output != stdout) &&
! 455: (me->output = fopen (me->outputfile, "w")) == NULL)
1.38 cvs 456: #else
1.40 ! cvs 457: if (!(me->output) &&
! 458: (me->output != stdout) &&
! 459: (me->output = fopen (me->outputfile, "wb")) == NULL)
1.38 cvs 460: #endif /* !_WINDOWS */
1.40 ! cvs 461: {
! 462: me->outputfile[0] = '\0'; /* file could not be opened */
! 463: TtaSetStatus (me->docid, 1,
! 464: TtaGetMessage (AMAYA, AM_CANNOT_CREATE_FILE),
! 465: me->outputfile);
! 466: me->reqStatus = HT_ERR;
! 467: return (HT_ERROR);
! 468: }
1.36 cvs 469: #ifdef DEBUG_LIBWWW
1.40 ! cvs 470: fprintf (stderr, "ADDNEWSOCK: associated %s to FILE %p\n",
! 471: me->urlName, me->output);
1.38 cvs 472: #endif /* DEBUG_LIBWWW */
1.40 ! cvs 473: HTRequest_setOutputStream (me->request,
1.38 cvs 474: AHTFWriter_new (me->request, me->output, YES));
475: me->reqStatus = HT_WAITING;
1.40 ! cvs 476: }
1.38 cvs 477:
478: if (THD_TRACE)
479: fprintf (stderr, "AHTEvent_register: URL %s, SOCK %d, ops %lu \n",
480: me->urlName, sock, ops);
481:
1.33 cvs 482: #ifndef _WINDOWS
1.38 cvs 483: if (ops & ReadBits)
484: {
485: me->read_ops = ops;
486: RequestRegisterReadXtevent (me, sock);
487: }
488:
489: if (ops & WriteBits)
490: {
491: me->write_ops = ops;
492: RequestRegisterWriteXtevent (me, sock);
493: }
494:
495: if (ops & ExceptBits)
496: {
497: me->except_ops = ops;
498: RequestRegisterExceptXtevent (me, sock);
499: }
1.33 cvs 500: #endif /* !_WINDOWS */
1.38 cvs 501:
502: } /* if *rqp */
503:
1.37 cvs 504: status = HTEventrg_register (sock, rqp, ops,
1.38 cvs 505: cbf, p);
1.7 cvs 506: return (status);
1.4 cvs 507: }
1.34 cvs 508:
509: /*----------------------------------------------------------------------
510: AHTEvent_unregister
511: callback called by libwww each time a request is unregistered. This
512: function takes care of unregistering the pertinent Xt events
513: associated with the request's socket. In addition, it unregisters
514: the request from libwww.
515: ----------------------------------------------------------------------*/
516: #ifdef __STDC__
517: int AHTEvent_unregister (SOCKET sock, SockOps ops)
518: #else
519: int AHTEvent_unregister (sock, ops)
520: SOCKET sock;
521: SockOps ops;
522:
523: #endif /* __STDC__ */
524: {
525: int status;
526: HTRequest *rqp = NULL;
1.39 cvs 527: #ifndef _WINDOWS
1.34 cvs 528: AHTReqContext *me;
1.38 cvs 529: int v;
530: #endif /* _WINDOWS */
531:
1.34 cvs 532:
533: /* Libwww 5.0a does not take into account the third parameter
534: ** for this function call */
535:
1.36 cvs 536: #ifndef _WINDOWS
537: HTEventCallback *cbf = (HTEventCallback *) __RetrieveCBF (sock, (SockOps) NULL, &rqp);
1.38 cvs 538: #endif /* _WINDOWS */
539:
540: if (sock == INVSOC)
541: return HT_OK;
542:
543: #ifndef _WINDOWS
1.36 cvs 544: #ifdef DEBUG_LIBWWW
545: fprintf (stderr, "AHTEventUnregister: cbf = %d, sock = %d, rqp = %d, ops= %x", cbf, sock, rqp, ops);
1.38 cvs 546: #endif /* DEBUG_LIBWWW */
547:
548: v = HASH (sock);
549: if (persSockets[v] != 0) {
550: XtRemoveInput (persSockets[v]);
551: persSockets[v] = 0;
1.36 cvs 552: }
1.34 cvs 553:
1.7 cvs 554: if (cbf)
555: {
1.38 cvs 556: if (rqp && (me = HTRequest_context (rqp)) )
1.36 cvs 557: {
558: if (ops & ReadBits)
559: RequestKillReadXtevent (me);
560:
561: if (ops & WriteBits)
562: RequestKillWriteXtevent (me);
563:
564: if (ops & ExceptBits)
565: RequestKillExceptXtevent (me);
566: }
1.7 cvs 567: }
1.36 cvs 568: #endif /* !_WINDOWS */
1.35 cvs 569:
1.7 cvs 570: status = HTEventrg_unregister (sock, ops);
1.35 cvs 571:
1.7 cvs 572: return (status);
1.4 cvs 573: }
1.35 cvs 574:
575: #ifndef _WINDOWS
1.4 cvs 576:
1.11 cvs 577: /*----------------------------------------------------------------------
578: RequestKillAllXtevents
579: front-end for kill all Xt events associated with the request pointed
580: to by "me".
581: ----------------------------------------------------------------------*/
1.4 cvs 582: #ifdef __STDC__
1.7 cvs 583: void RequestKillAllXtevents (AHTReqContext * me)
1.4 cvs 584: #else
1.7 cvs 585: void RequestKillAllXtevents (me)
586: AHTReqContext *me;
587: #endif /* __STDC__ */
1.4 cvs 588: {
1.7 cvs 589: if (THD_TRACE)
590: fprintf (stderr, "Request_kill: Clearing Xtinputs\n");
1.4 cvs 591:
1.7 cvs 592: RequestKillReadXtevent (me);
593: RequestKillWriteXtevent (me);
594: RequestKillExceptXtevent (me);
1.4 cvs 595: }
596:
1.11 cvs 597: /*----------------------------------------------------------------------
1.18 cvs 598: RequestRegisterReadXtevent
599: Registers with Xt the read events associated with socket sock
600: ----------------------------------------------------------------------*/
601: #ifdef __STDC__
602: static void RequestRegisterReadXtevent (AHTReqContext * me, SOCKET sock)
603: #else
604: static void RequestRegisterReadXtevent (me, sock)
605: AHTReqContext *me;
606: SOCKET sock;
607: #endif /* __STDC__ */
608: {
609: if (me->read_xtinput_id)
610: {
611: if (THD_TRACE)
612: fprintf (stderr, "Request_kill: Clearing Xtinput %lu Socket %d R\n", me->read_xtinput_id, sock);
613: XtRemoveInput (me->read_xtinput_id);
614: }
615:
616: me->read_xtinput_id =
617: XtAppAddInput (app_cont,
618: sock,
619: (XtPointer) XtInputReadMask,
620: (XtInputCallbackProc) AHTCallback_bridge,
621: (XtPointer) XtInputReadMask);
622:
1.26 cvs 623: if (THD_TRACE)
1.18 cvs 624: fprintf (stderr, "(BT) adding Xtinput %lu Socket %d R\n",
625: me->read_xtinput_id, sock);
626:
627: }
628:
629: /*----------------------------------------------------------------------
1.11 cvs 630: RequestKillReadXtevent
631: kills any read Xt event associated with the request pointed to by "me".
632: ----------------------------------------------------------------------*/
1.4 cvs 633: #ifdef __STDC__
1.7 cvs 634: static void RequestKillReadXtevent (AHTReqContext * me)
1.4 cvs 635: #else
1.7 cvs 636: static void RequestKillReadXtevent (me)
637: AHTReqContext *me;
638: #endif /* __STDC__ */
1.4 cvs 639: {
1.7 cvs 640: if (me->read_xtinput_id)
641: {
642: if (THD_TRACE)
1.18 cvs 643: fprintf (stderr, "Request_kill: Clearing Xtinput %lu R\n", me->read_xtinput_id);
1.7 cvs 644: XtRemoveInput (me->read_xtinput_id);
645: me->read_xtinput_id = (XtInputId) NULL;
646: }
1.18 cvs 647: }
648:
649: /*----------------------------------------------------------------------
650: RequestRegisterWriteXtevent
651: Registers with Xt the write events associated with socket sock
652: ----------------------------------------------------------------------*/
653: #ifdef __STDC__
654: static void RequestRegisterWriteXtevent (AHTReqContext * me, SOCKET sock)
655: #else
656: static void RequestRegisterWriteXtevent (me, sock)
657: AHTReqContext *me;
658: SOCKET sock;
659:
660: #endif /* __STDC__ */
661: {
662: if (me->write_xtinput_id)
663: {
664: if (THD_TRACE)
665: fprintf (stderr, "Request_kill: Clearing Xtinput %lu Socket %d W\n", me->write_xtinput_id, sock);
666: XtRemoveInput (me->write_xtinput_id);
667: }
668:
669: me->write_xtinput_id =
670: XtAppAddInput (app_cont,
671: sock,
672: (XtPointer) XtInputWriteMask,
673: (XtInputCallbackProc) AHTCallback_bridge,
674: (XtPointer) XtInputWriteMask);
675:
676: if (THD_TRACE)
677: fprintf (stderr, "(BT) adding Xtinput %lu Socket %d W\n",
678: me->write_xtinput_id, sock);
1.4 cvs 679: }
680:
1.11 cvs 681: /*----------------------------------------------------------------------
682: RequestKillWriteXtevent
683: kills any write Xt event associated with the request pointed to
684: by "me".
685: ----------------------------------------------------------------------*/
1.4 cvs 686: #ifdef __STDC__
1.7 cvs 687: static void RequestKillWriteXtevent (AHTReqContext * me)
1.4 cvs 688: #else
1.7 cvs 689: static void RequestKillWriteXtevent (me)
690: AHTReqContext *me;
691: #endif /* __STDC__ */
1.4 cvs 692: {
1.7 cvs 693: if (me->write_xtinput_id)
694: {
695: if (THD_TRACE)
696: fprintf (stderr, "Request_kill: Clearing Write Xtinputs %lu\n", me->write_xtinput_id);
697: XtRemoveInput (me->write_xtinput_id);
698: me->write_xtinput_id = (XtInputId) NULL;
699: }
1.18 cvs 700: }
701:
702: /*----------------------------------------------------------------------
703: RequestRegisterExceptXtevent
704: Registers with Xt the except events associated with socket sock
705: ----------------------------------------------------------------------*/
706: #ifdef __STDC__
707: static void RequestRegisterExceptXtevent (AHTReqContext * me, SOCKET sock)
708: #else
709: static void RequestRegisterExceptXtevent (me, sock)
710: AHTReqContext *me;
711: SOCKET sock;
712:
713: #endif /* __STDC__ */
714: {
715: if (me->except_xtinput_id)
716: {
717: if (THD_TRACE)
718: fprintf (stderr, "Request_kill: Clearing Xtinput %lu Socket %d E\n", me->except_xtinput_id, sock);
719: XtRemoveInput (me->except_xtinput_id);
720: }
721:
722: me->except_xtinput_id =
723: XtAppAddInput (app_cont,
724: sock,
725: (XtPointer) XtInputExceptMask,
726: (XtInputCallbackProc) AHTCallback_bridge,
727: (XtPointer) XtInputExceptMask);
728:
729: if (THD_TRACE)
730: fprintf (stderr, "(BT) adding Xtinput %lu Socket %d E\n",
731: me->write_xtinput_id, sock);
732:
1.4 cvs 733: }
734:
1.11 cvs 735: /*----------------------------------------------------------------------
736: RequestKillExceptXtevent
737: kills any exception Xt event associated with the request pointed to
738: by "me".
739: ----------------------------------------------------------------------*/
1.4 cvs 740: #ifdef __STDC__
1.7 cvs 741: static void RequestKillExceptXtevent (AHTReqContext * me)
1.4 cvs 742: #else
1.7 cvs 743: static void RequestKillExceptXtevent (me)
744: AHTReqContext *me;
745: #endif /* __STDC__ */
1.4 cvs 746: {
1.7 cvs 747: if (me->except_xtinput_id)
748: {
749: if (THD_TRACE)
750: fprintf (stderr, "Request_kill: Clearing Except Xtinputs %lu\n", me->except_xtinput_id);
751: XtRemoveInput (me->except_xtinput_id);
752: me->except_xtinput_id = (XtInputId) NULL;
753: }
1.31 cvs 754: }
1.32 cvs 755: #endif /* !_WINDOWS */
1.31 cvs 756:
1.23 cvs 757: #endif /* !AMAYA_JAVA */
1.36 cvs 758:
759:
760:
761:
762:
763:
764:
1.11 cvs 765:
766:
767:
768:
Webmaster