Annotation of Amaya/amaya/AHTBridge.c, revision 1.38
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.4 cvs 102:
1.10 cvs 103: /* Libwww 5.0a does not take into account the ops parameter
1.11 cvs 104: in the invocation of for this function call */
1.38 ! cvs 105:
1.13 cvs 106: HTEventCallback *cbf;
1.7 cvs 107:
1.13 cvs 108: ops = FD_WRITE;
109: cbf = (HTEventCallback *) __RetrieveCBF (*s, 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 */
! 123: v = HASH (*s);
! 124: if (persSockets[v])
! 125: {
! 126: persSockets[v] = 0;
! 127: if (cbf)
! 128: (*cbf) (*s, 0, FD_CLOSE);
! 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.32 cvs 167: if ((status = (*cbf) (*s, 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
217: fprintf (stderr, "(BF) removing Xtinput %lu !RWE, sock %d (Request has ended)\n", *id, *s);
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.38 ! cvs 265: if ((me->output != stdout) &&
! 266: me->outputfile &&
! 267: (me->output = fopen (me->outputfile, "wb")) == NULL) {
! 268: /* the request is associated with a file */
! 269: me->outputfile[0] = EOS; /* file could not be opened */
! 270: TtaSetStatus (me->docid, 1,
! 271: TtaGetMessage (AMAYA, AM_CANNOT_CREATE_FILE),
! 272: me->outputfile);
! 273: me->reqStatus = HT_ERR;
! 274: if (me->error_html)
! 275: DocNetworkStatus[me->docid] |= AMAYA_NET_ERROR; /* so we can show the error message */
1.32 cvs 276: } else {
1.36 cvs 277: if (THD_TRACE)
278: fprintf (stderr, "WIN_Activate_Request: Activating pending %s . Open fd %d\n", me->urlName, (int) me->output);
279: HTRequest_setOutputStream (me->request, AHTFWriter_new (me->request, me->output, YES));
1.32 cvs 280: /*change the status of the request */
281: me->reqStatus = HT_WAITING;
282: }
283: }
284: else if (me->reqStatus == HT_WAITING) {
1.36 cvs 285:
286: /*change the status of the request */
287: rewind (me->output);
288: if (HTRequest_outputStream (me->request) == NULL)
289: HTRequest_setOutputStream (me->request, AHTFWriter_new (me->request, me->output, YES));
1.32 cvs 290: }
291: else {
1.36 cvs 292: me->reqStatus = HT_ERR;
1.32 cvs 293: }
294:
1.36 cvs 295: return ((me->reqStatus != HT_ERR) ? HT_OK : HT_ERROR);
1.32 cvs 296: }
297:
1.38 ! cvs 298: #else /* _WINDOWS */
1.32 cvs 299:
300: /*----------------------------------------------------------------
301: Add_NewSocket_to_Loop
302: when there are more open requests than available sockets, the
303: requests are put in a "pending state." When a socket becomes
304: available, libwww associates it with a pending request and then
305: calls this callback function. This function is responsible for
306: opening the temporary file where the GET and POST results
307: will be stored. The function is also responsible for
308: registering the socket with the Xt event loop.
309: Consult the libwww manual for more details on the signature
310: of this function.
311: ----------------------------------------------------------------*/
312: #ifdef __STDC__
313: int Add_NewSocket_to_Loop (HTRequest * request, HTAlertOpcode op, int msgnum, const char *dfault, void *input, HTAlertPar * reply)
314: #else
315: int Add_NewSocket_to_Loop (request, op, msgnum, dfault, input, reply)
316: HTRequest *request;
317: HTAlertOpcode op;
318: int msgnum;
319: const char *dfault;
320: void *input;
321: HTAlertPar *reply;
1.29 cvs 322:
1.32 cvs 323: #endif /* __STDC__ */
324: {
325: AHTReqContext *me = HTRequest_context (request);
1.38 ! cvs 326: int status = HT_OK;
1.4 cvs 327:
1.36 cvs 328: #ifdef DEBUG_LIBWWW
1.32 cvs 329: fprintf (stderr, "(Activating a request\n");
1.36 cvs 330: #endif
1.30 cvs 331:
1.36 cvs 332: if (me->reqStatus == HT_NEW) {
333: /* the request is active, open the output file */
334: if ((me->output != stdout) &&
335: !(me->output = fopen (me->outputfile, "w"))) {
336: me->outputfile[0] = EOS;
337: /* file could not be opened */
338: TtaSetStatus (me->docid, 1,
339: TtaGetMessage (AMAYA, AM_CANNOT_CREATE_FILE),
340: me->outputfile);
341: me->reqStatus = HT_ERR;
1.38 ! cvs 342: status = HT_ERROR;
1.36 cvs 343: /* should the error be shown on the Amaya doc window? */
344: if (me->error_html)
345: DocNetworkStatus[me->docid] |= AMAYA_NET_ERROR;
1.32 cvs 346: }
1.38 ! cvs 347:
1.36 cvs 348: #ifdef DEBUG_LIBWWW
349: fprintf (stderr, "ADDNEWSOCK: associated %s to FD %p\n",
350: me->urlName, me->output);
1.32 cvs 351: #endif
352: if (me->output) {
1.36 cvs 353: if (THD_TRACE)
1.32 cvs 354: fprintf (stderr, "Add_NewSocket_to_Loop: Activating pending %s . Open fd %d\n", me->urlName, (int) me->output);
1.36 cvs 355:
1.32 cvs 356: HTRequest_setOutputStream (me->request, AHTFWriter_new (me->request, me->output, YES));
357: me->reqStatus = HT_WAITING;
358: }
359: }
360: else if (me->reqStatus == HT_BUSY) {
361: /* JK: Comment: see if we can add HT_WAIT HERE */
362: /* request was aborted and now is is being reissued */
363: rewind (me->output);
364: /* verify if this is OK */
1.36 cvs 365: HTRequest_setOutputStream (me->request,
366: AHTFWriter_new (me->request, me->output, YES));
1.32 cvs 367: }
368:
1.38 ! cvs 369: return (status);
1.4 cvs 370: }
1.32 cvs 371: #endif /* _WINDOWS */
1.4 cvs 372:
1.11 cvs 373: /*----------------------------------------------------------------------
374: AHTEvent_register
375: callback called by libwww whenever a socket is open and associated
376: to a request. It sets the pertinent Xt events so that the Xt Event
377: loops gets an interruption whenever there's action of the socket.
378: In addition, it registers the request with libwww.
379: ----------------------------------------------------------------------*/
1.4 cvs 380: #ifdef __STDC__
1.7 cvs 381: int AHTEvent_register (SOCKET sock, HTRequest * rqp, SockOps ops, HTEventCallback * cbf, HTPriority p)
1.4 cvs 382: #else
1.7 cvs 383: int AHTEvent_register (sock, rqp, ops, cbf, p)
384: SOCKET sock;
385: HTRequest *rqp;
386: SockOps ops;
387: HTEventCallback *cbf;
388: HTPriority p;
389:
390: #endif /* __STDC__ */
1.4 cvs 391: {
1.11 cvs 392: AHTReqContext *me; /* current request */
393: int status; /* libwww status associated with the socket number */
1.38 ! cvs 394: #ifndef _WINDOWS
! 395: int v;
! 396: #endif /* _WINDOWS */
1.7 cvs 397:
398: if (sock == INVSOC)
1.38 ! cvs 399: return (0);
1.4 cvs 400:
1.7 cvs 401: /* get the request associated to the socket number */
402:
1.38 ! cvs 403: if (rqp == NULL)
! 404: {
1.37 cvs 405: #ifndef _WINDOWS
1.38 ! cvs 406: if (ops == FD_CLOSE)
! 407: {
1.36 cvs 408: #ifdef DEBUG_LIBWWW
1.38 ! cvs 409: fprintf(stderr, "HTEvent_register: ***** RQP is NULL @@@@@\n");
1.37 cvs 410: #endif /* DEBUG_LIBWWW */
1.38 ! cvs 411: v = HASH (sock);
! 412: if (persSockets[v] != 0)
! 413: {
! 414: XtRemoveInput (persSockets[v]);
! 415: }
! 416:
! 417: persSockets[v] = XtAppAddInput (app_cont,
! 418: sock,
! 419: (XtPointer) XtInputReadMask,
! 420: (XtInputCallbackProc) AHTCallback_bridge,
! 421: (XtPointer) XtInputReadMask);
! 422: } /* *fd_close */
! 423: }
1.37 cvs 424: #endif /* !_WINDOWS */
1.38 ! cvs 425: else /* rqp */
1.7 cvs 426: {
1.38 ! cvs 427: me = HTRequest_context (rqp);
! 428:
1.36 cvs 429: #ifndef _WINDOWS
1.38 ! cvs 430: v = HASH (sock);
! 431: if (persSockets[v] != 0) {
! 432: XtRemoveInput (persSockets[v]);
! 433: persSockets[v] = 0;
! 434: }
1.36 cvs 435: #endif /* _WINDOWS */
1.38 ! cvs 436: /* verify if we need to open the output file */
! 437: if (me->reqStatus == HT_NEW)
! 438: {
1.37 cvs 439: #ifdef _WINDOWS
1.38 ! cvs 440: /* Erase any trailing events */
! 441: HTEventrg_unregister (sock, FD_ALL);
1.37 cvs 442: #endif
1.38 ! cvs 443: /* we are opening a pending request */
! 444: #ifndef _WINDOWS
! 445: if ((me->output != stdout) &&
! 446: (me->output = fopen (me->outputfile, "w")) == NULL)
! 447: #else
1.36 cvs 448: if ((me->output != stdout) &&
1.38 ! cvs 449: (me->output = fopen (me->outputfile, "wb")) == NULL)
! 450: #endif /* !_WINDOWS */
1.7 cvs 451: {
1.36 cvs 452: me->outputfile[0] = '\0'; /* file could not be opened */
453: TtaSetStatus (me->docid, 1,
454: TtaGetMessage (AMAYA, AM_CANNOT_CREATE_FILE),
455: me->outputfile);
456: me->reqStatus = HT_ERR;
457: return (HT_ERROR);
1.7 cvs 458: }
1.36 cvs 459: #ifdef DEBUG_LIBWWW
1.38 ! cvs 460: fprintf (stderr, "ADDNEWSOCK: associated %s to FILE %p\n",
! 461: me->urlName, me->output);
! 462: #endif /* DEBUG_LIBWWW */
! 463: HTRequest_setOutputStream (me->request,
! 464: AHTFWriter_new (me->request, me->output, YES));
! 465: me->reqStatus = HT_WAITING;
! 466: }
! 467:
! 468: if (THD_TRACE)
! 469: fprintf (stderr, "AHTEvent_register: URL %s, SOCK %d, ops %lu \n",
! 470: me->urlName, sock, ops);
! 471:
1.33 cvs 472: #ifndef _WINDOWS
1.38 ! cvs 473: if (ops & ReadBits)
! 474: {
! 475: me->read_ops = ops;
! 476: RequestRegisterReadXtevent (me, sock);
! 477: }
! 478:
! 479: if (ops & WriteBits)
! 480: {
! 481: me->write_ops = ops;
! 482: RequestRegisterWriteXtevent (me, sock);
! 483: }
! 484:
! 485: if (ops & ExceptBits)
! 486: {
! 487: me->except_ops = ops;
! 488: RequestRegisterExceptXtevent (me, sock);
! 489: }
1.33 cvs 490: #endif /* !_WINDOWS */
1.38 ! cvs 491:
! 492: } /* if *rqp */
! 493:
1.37 cvs 494: status = HTEventrg_register (sock, rqp, ops,
1.38 ! cvs 495: cbf, p);
1.7 cvs 496: return (status);
1.4 cvs 497: }
1.34 cvs 498:
499: /*----------------------------------------------------------------------
500: AHTEvent_unregister
501: callback called by libwww each time a request is unregistered. This
502: function takes care of unregistering the pertinent Xt events
503: associated with the request's socket. In addition, it unregisters
504: the request from libwww.
505: ----------------------------------------------------------------------*/
506: #ifdef __STDC__
507: int AHTEvent_unregister (SOCKET sock, SockOps ops)
508: #else
509: int AHTEvent_unregister (sock, ops)
510: SOCKET sock;
511: SockOps ops;
512:
513: #endif /* __STDC__ */
514: {
515: int status;
516: HTRequest *rqp = NULL;
517: AHTReqContext *me;
1.38 ! cvs 518: #ifndef _WINDOWS
! 519: int v;
! 520: #endif /* _WINDOWS */
! 521:
1.34 cvs 522:
523: /* Libwww 5.0a does not take into account the third parameter
524: ** for this function call */
525:
1.36 cvs 526: #ifndef _WINDOWS
527: HTEventCallback *cbf = (HTEventCallback *) __RetrieveCBF (sock, (SockOps) NULL, &rqp);
1.38 ! cvs 528: #endif /* _WINDOWS */
! 529:
! 530: if (sock == INVSOC)
! 531: return HT_OK;
! 532:
! 533: #ifndef _WINDOWS
1.36 cvs 534: #ifdef DEBUG_LIBWWW
535: fprintf (stderr, "AHTEventUnregister: cbf = %d, sock = %d, rqp = %d, ops= %x", cbf, sock, rqp, ops);
1.38 ! cvs 536: #endif /* DEBUG_LIBWWW */
! 537:
! 538: v = HASH (sock);
! 539: if (persSockets[v] != 0) {
! 540: XtRemoveInput (persSockets[v]);
! 541: persSockets[v] = 0;
1.36 cvs 542: }
1.34 cvs 543:
1.7 cvs 544: if (cbf)
545: {
1.38 ! cvs 546: if (rqp && (me = HTRequest_context (rqp)) )
1.36 cvs 547: {
548: if (ops & ReadBits)
549: RequestKillReadXtevent (me);
550:
551: if (ops & WriteBits)
552: RequestKillWriteXtevent (me);
553:
554: if (ops & ExceptBits)
555: RequestKillExceptXtevent (me);
556: }
1.7 cvs 557: }
1.36 cvs 558: #endif /* !_WINDOWS */
1.35 cvs 559:
1.7 cvs 560: status = HTEventrg_unregister (sock, ops);
1.35 cvs 561:
1.7 cvs 562: return (status);
1.4 cvs 563: }
1.35 cvs 564:
565: #ifndef _WINDOWS
1.4 cvs 566:
1.11 cvs 567: /*----------------------------------------------------------------------
568: RequestKillAllXtevents
569: front-end for kill all Xt events associated with the request pointed
570: to by "me".
571: ----------------------------------------------------------------------*/
1.4 cvs 572: #ifdef __STDC__
1.7 cvs 573: void RequestKillAllXtevents (AHTReqContext * me)
1.4 cvs 574: #else
1.7 cvs 575: void RequestKillAllXtevents (me)
576: AHTReqContext *me;
577: #endif /* __STDC__ */
1.4 cvs 578: {
1.7 cvs 579: if (THD_TRACE)
580: fprintf (stderr, "Request_kill: Clearing Xtinputs\n");
1.4 cvs 581:
1.7 cvs 582: RequestKillReadXtevent (me);
583: RequestKillWriteXtevent (me);
584: RequestKillExceptXtevent (me);
1.4 cvs 585: }
586:
1.11 cvs 587: /*----------------------------------------------------------------------
1.18 cvs 588: RequestRegisterReadXtevent
589: Registers with Xt the read events associated with socket sock
590: ----------------------------------------------------------------------*/
591: #ifdef __STDC__
592: static void RequestRegisterReadXtevent (AHTReqContext * me, SOCKET sock)
593: #else
594: static void RequestRegisterReadXtevent (me, sock)
595: AHTReqContext *me;
596: SOCKET sock;
597: #endif /* __STDC__ */
598: {
599: if (me->read_xtinput_id)
600: {
601: if (THD_TRACE)
602: fprintf (stderr, "Request_kill: Clearing Xtinput %lu Socket %d R\n", me->read_xtinput_id, sock);
603: XtRemoveInput (me->read_xtinput_id);
604: }
605:
606: me->read_xtinput_id =
607: XtAppAddInput (app_cont,
608: sock,
609: (XtPointer) XtInputReadMask,
610: (XtInputCallbackProc) AHTCallback_bridge,
611: (XtPointer) XtInputReadMask);
612:
1.26 cvs 613: if (THD_TRACE)
1.18 cvs 614: fprintf (stderr, "(BT) adding Xtinput %lu Socket %d R\n",
615: me->read_xtinput_id, sock);
616:
617: }
618:
619: /*----------------------------------------------------------------------
1.11 cvs 620: RequestKillReadXtevent
621: kills any read Xt event associated with the request pointed to by "me".
622: ----------------------------------------------------------------------*/
1.4 cvs 623: #ifdef __STDC__
1.7 cvs 624: static void RequestKillReadXtevent (AHTReqContext * me)
1.4 cvs 625: #else
1.7 cvs 626: static void RequestKillReadXtevent (me)
627: AHTReqContext *me;
628: #endif /* __STDC__ */
1.4 cvs 629: {
1.7 cvs 630: if (me->read_xtinput_id)
631: {
632: if (THD_TRACE)
1.18 cvs 633: fprintf (stderr, "Request_kill: Clearing Xtinput %lu R\n", me->read_xtinput_id);
1.7 cvs 634: XtRemoveInput (me->read_xtinput_id);
635: me->read_xtinput_id = (XtInputId) NULL;
636: }
1.18 cvs 637: }
638:
639: /*----------------------------------------------------------------------
640: RequestRegisterWriteXtevent
641: Registers with Xt the write events associated with socket sock
642: ----------------------------------------------------------------------*/
643: #ifdef __STDC__
644: static void RequestRegisterWriteXtevent (AHTReqContext * me, SOCKET sock)
645: #else
646: static void RequestRegisterWriteXtevent (me, sock)
647: AHTReqContext *me;
648: SOCKET sock;
649:
650: #endif /* __STDC__ */
651: {
652: if (me->write_xtinput_id)
653: {
654: if (THD_TRACE)
655: fprintf (stderr, "Request_kill: Clearing Xtinput %lu Socket %d W\n", me->write_xtinput_id, sock);
656: XtRemoveInput (me->write_xtinput_id);
657: }
658:
659: me->write_xtinput_id =
660: XtAppAddInput (app_cont,
661: sock,
662: (XtPointer) XtInputWriteMask,
663: (XtInputCallbackProc) AHTCallback_bridge,
664: (XtPointer) XtInputWriteMask);
665:
666: if (THD_TRACE)
667: fprintf (stderr, "(BT) adding Xtinput %lu Socket %d W\n",
668: me->write_xtinput_id, sock);
1.4 cvs 669: }
670:
1.11 cvs 671: /*----------------------------------------------------------------------
672: RequestKillWriteXtevent
673: kills any write Xt event associated with the request pointed to
674: by "me".
675: ----------------------------------------------------------------------*/
1.4 cvs 676: #ifdef __STDC__
1.7 cvs 677: static void RequestKillWriteXtevent (AHTReqContext * me)
1.4 cvs 678: #else
1.7 cvs 679: static void RequestKillWriteXtevent (me)
680: AHTReqContext *me;
681: #endif /* __STDC__ */
1.4 cvs 682: {
1.7 cvs 683: if (me->write_xtinput_id)
684: {
685: if (THD_TRACE)
686: fprintf (stderr, "Request_kill: Clearing Write Xtinputs %lu\n", me->write_xtinput_id);
687: XtRemoveInput (me->write_xtinput_id);
688: me->write_xtinput_id = (XtInputId) NULL;
689: }
1.18 cvs 690: }
691:
692: /*----------------------------------------------------------------------
693: RequestRegisterExceptXtevent
694: Registers with Xt the except events associated with socket sock
695: ----------------------------------------------------------------------*/
696: #ifdef __STDC__
697: static void RequestRegisterExceptXtevent (AHTReqContext * me, SOCKET sock)
698: #else
699: static void RequestRegisterExceptXtevent (me, sock)
700: AHTReqContext *me;
701: SOCKET sock;
702:
703: #endif /* __STDC__ */
704: {
705: if (me->except_xtinput_id)
706: {
707: if (THD_TRACE)
708: fprintf (stderr, "Request_kill: Clearing Xtinput %lu Socket %d E\n", me->except_xtinput_id, sock);
709: XtRemoveInput (me->except_xtinput_id);
710: }
711:
712: me->except_xtinput_id =
713: XtAppAddInput (app_cont,
714: sock,
715: (XtPointer) XtInputExceptMask,
716: (XtInputCallbackProc) AHTCallback_bridge,
717: (XtPointer) XtInputExceptMask);
718:
719: if (THD_TRACE)
720: fprintf (stderr, "(BT) adding Xtinput %lu Socket %d E\n",
721: me->write_xtinput_id, sock);
722:
1.4 cvs 723: }
724:
1.11 cvs 725: /*----------------------------------------------------------------------
726: RequestKillExceptXtevent
727: kills any exception Xt event associated with the request pointed to
728: by "me".
729: ----------------------------------------------------------------------*/
1.4 cvs 730: #ifdef __STDC__
1.7 cvs 731: static void RequestKillExceptXtevent (AHTReqContext * me)
1.4 cvs 732: #else
1.7 cvs 733: static void RequestKillExceptXtevent (me)
734: AHTReqContext *me;
735: #endif /* __STDC__ */
1.4 cvs 736: {
1.7 cvs 737: if (me->except_xtinput_id)
738: {
739: if (THD_TRACE)
740: fprintf (stderr, "Request_kill: Clearing Except Xtinputs %lu\n", me->except_xtinput_id);
741: XtRemoveInput (me->except_xtinput_id);
742: me->except_xtinput_id = (XtInputId) NULL;
743: }
1.31 cvs 744: }
1.32 cvs 745: #endif /* !_WINDOWS */
1.31 cvs 746:
1.23 cvs 747: #endif /* !AMAYA_JAVA */
1.36 cvs 748:
749:
750:
751:
752:
753:
754:
1.11 cvs 755:
756:
757:
758:
Webmaster