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