Annotation of Amaya/amaya/AHTBridge.c, revision 1.51
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.50 cvs 15: * J. K./R. G. 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.47 cvs 107:
1.13 cvs 108: ops = FD_WRITE;
1.40 cvs 109: cbf = (HTEventCallback *) __RetrieveCBF (socket, ops, &rqp);
1.47 cvs 110:
111: v = HASH (socket);
112: if (persSockets[v])
113: {
114: persSockets[v] = 0;
115: /* we're not sure what can be the value of rqp */
116: rqp = NULL;
117: }
118:
1.38 cvs 119: /* if rqp is NULL, we are dealing with a persistent socket shutdown */
120: if (!(cbf) || !(rqp) || rqp->priority == HT_PRIORITY_OFF)
121: {
1.43 cvs 122: if (cbf)
1.47 cvs 123: (*cbf) (socket, 0, FD_READ);
1.43 cvs 124:
1.47 cvs 125: /* remove the Xt input which caused this callback */
126: # ifdef WWW_XWINDOWS
127: XtRemoveInput (*id);
128: # endif
1.38 cvs 129: return (0);
130: }
131:
1.7 cvs 132: me = HTRequest_context (rqp);
1.38 cvs 133:
1.36 cvs 134: #ifdef DEBUG_LIBWWW
1.38 cvs 135: fprintf (stderr, "AHTBridge: Processing url %s \n", me->urlName);
1.36 cvs 136: #endif
1.38 cvs 137:
1.32 cvs 138: switch ((XtInputId) cd) {
1.38 cvs 139: case XtInputReadMask:
1.19 cvs 140: ops = me->read_ops;
141: ops = FD_READ;
142: break;
1.32 cvs 143: case XtInputWriteMask:
1.7 cvs 144: ops = me->write_ops;
145: ops = FD_WRITE;
146: break;
1.32 cvs 147: case XtInputExceptMask:
1.7 cvs 148: ops = me->except_ops;
149: ops = FD_OOB;
150: break;
1.32 cvs 151: default:
152: break;
153: } /* switch */
1.17 cvs 154:
1.32 cvs 155: /* Invokes the callback associated to the requests */
156:
157: /* first we change the status of the request, to say it
158: has entered a critical section */
1.38 cvs 159:
1.43 cvs 160: /* JK: An early warning of problems */
1.32 cvs 161: if ((HTRequest_outputStream(me->request) == (HTStream *) NULL))
1.38 cvs 162: fprintf(stderr,"\n **ERROR** opening %s\n\n", me->urlName);
1.32 cvs 163:
164: me->reqStatus = HT_BUSY;
1.38 cvs 165:
1.40 cvs 166: if ((status = (*cbf) (socket, rqp, ops)) != HT_OK)
1.36 cvs 167: #ifdef DEBUG_LIBWWW
168: HTTrace ("Callback.... returned a value != HT_OK");
169: #endif
1.7 cvs 170: /* Several states can happen after this callback. They
171: * are indicated by the me->reqStatus structure member and
172: * the fds external variables. The following lines examine
173: * the states and correspondly update the Xt event register
174: *
175: * Regarding the me->reqStatus member, we have the following
176: * possible states:
177: *
178: * HT_BUSY: Request has blocked
179: * HT_WAITING: Request has been reissued
180: * HT_ABORT: Request has been stopped
181: * HT_END: Request has ended
182: */
183:
1.32 cvs 184: if (me->reqStatus == HT_ABORT) {
1.11 cvs 185: /* Has the user stopped the request? */
1.38 cvs 186: me->reqStatus = HT_WAITING;
1.49 cvs 187: me->mode &= ~AMAYA_ASYNC_SAFE_STOP;
1.38 cvs 188: StopRequest (me->docid);
189: return (0);
1.32 cvs 190: }
1.7 cvs 191:
1.42 cvs 192: if (me->reqStatus == HT_WAITING ||
193: me->reqStatus == HT_NEW) {
1.38 cvs 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: */
204:
1.36 cvs 205: #ifdef DEBUG_LIBWWW
1.38 cvs 206: fprintf (stderr, "*** detected a reissue of request \n");
1.36 cvs 207: #endif
1.38 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: if ((me->reqStatus == HT_END) ||
215: (me->reqStatus == HT_ERR)) {
216: /* request has ended */
217: #ifdef DEBUG_LIBWWW
1.40 cvs 218: fprintf (stderr, "(BF) removing Xtinput %lu !RWE, sock %d (Request has ended)\n", *id, socket);
1.36 cvs 219: #endif
1.41 cvs 220:
221: if ((me->mode & AMAYA_ASYNC) || (me->mode & AMAYA_IASYNC))
222: {
223: AHTPrintPendingRequestStatus (me->docid, YES);
224: /* free the memory allocated for async requests */
225: AHTReqContext_delete (me);
226: }
1.43 cvs 227:
1.41 cvs 228: else if (me->reqStatus == HT_END &&
229: HTError_hasSeverity (HTRequest_error (me->request),
230: ERR_NON_FATAL))
231:
1.38 cvs 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);
1.32 cvs 235: }
1.38 cvs 236:
1.36 cvs 237: /* The request is still alive, so change it's status to indicate
238: it's out of the critical section */
1.7 cvs 239: me->reqStatus = HT_WAITING;
240: return (0);
1.4 cvs 241: }
1.37 cvs 242: #endif /* !_WINDOWS */
1.41 cvs 243:
244: /*--------------------------------------------------------------------
245: ProcessTerminateRequest
246: This function is called whenever a request has ended. If the requested
247: ended normally, the function will call any callback associated to the
248: request. Otherwise, it will just mark the request as over.
249: -------------------------------------------------------------------*/
250: #ifdef __STDC__
251: void ProcessTerminateRequest (AHTReqContext *me)
252: #else
253: void ProcessTerminateRequest (me)
254: AHTReqContext *me;
255: #endif
256: {
257: /* Second Step: choose a correct treatment in function of the request's
258: being associated with an error, with an interruption, or with a
259: succesful completion */
260:
261: if (me->reqStatus == HT_END)
262: {
263: if (me->terminate_cbf)
1.49 cvs 264: (*me->terminate_cbf) (me->docid, 0, me->urlName, me->outputfile,
265: me->content_type, me->context_tcbf);
1.41 cvs 266: }
1.42 cvs 267: else if (me->reqStatus == HT_ABORT)
1.41 cvs 268: /* either the application ended or the user pressed the stop
269: button. We erase the incoming file, if it exists */
270: {
271: if (me->outputfile && me->outputfile[0] != EOS)
272: {
273: TtaFileUnlink (me->outputfile);
274: me->outputfile[0] = EOS;
275: }
276: }
277: else if (me->reqStatus == HT_ERR)
278: {
279: /* there was an error */
280: if (me->terminate_cbf)
1.49 cvs 281: (*me->terminate_cbf) (me->docid, -1, me->urlName, me->outputfile,
282: me->content_type, me->context_tcbf);
1.41 cvs 283:
284: if (me->outputfile && me->outputfile[0] != EOS)
285: {
286: TtaFileUnlink (me->outputfile);
287: me->outputfile[0] = EOS;
288: }
289: }
1.49 cvs 290: else if (me->reqStatus == HT_ABORT)
291: {
292: if (me->outputfile && me->outputfile[0] != EOS)
293: {
294: TtaFileUnlink (me->outputfile);
295: me->outputfile[0] = EOS;
296: }
297: }
298:
1.41 cvs 299: #ifdef _WINDOWS
300: /* we erase the context if we're dealing with an asynchronous request */
301: if ((me->mode & AMAYA_ASYNC) ||
302: (me->mode & AMAYA_IASYNC)) {
303: me->reqStatus = HT_END;
1.48 cvs 304: AHTReqContext_delete (me);
1.41 cvs 305: }
306: #endif /* _WINDOWS */
307:
308: }
1.4 cvs 309:
1.32 cvs 310: #ifdef _WINDOWS
1.29 cvs 311: /*----------------------------------------------------------------
1.32 cvs 312: WIN_Activate_Request
1.29 cvs 313: when there are more open requests than available sockets, the
314: requests are put in a "pending state." When a socket becomes
315: available, libwww associates it with a pending request and then
316: calls this callback function. This function is responsible for
317: opening the temporary file where the GET and POST results
318: will be stored. The function is also responsible for
319: registering the socket with the Xt event loop.
320: Consult the libwww manual for more details on the signature
321: of this function.
322: ----------------------------------------------------------------*/
323: #ifdef __STDC__
1.32 cvs 324: int WIN_Activate_Request (HTRequest * request, HTAlertOpcode op, int msgnum, const char *dfault, void *input, HTAlertPar * reply)
1.29 cvs 325: #else
1.32 cvs 326: int WIN_Activate_Request (request, op, msgnum, dfault, input, reply)
1.29 cvs 327: HTRequest *request;
328: HTAlertOpcode op;
329: int msgnum;
330: const char *dfault;
331: void *input;
332: HTAlertPar *reply;
333:
334: #endif /* __STDC__ */
335: {
336: AHTReqContext *me = HTRequest_context (request);
337:
1.32 cvs 338: if (me->reqStatus == HT_NEW) {
1.40 cvs 339: if (!(me->output) &&
340: (me->output != stdout) &&
1.38 cvs 341: me->outputfile &&
342: (me->output = fopen (me->outputfile, "wb")) == NULL) {
343: /* the request is associated with a file */
344: me->outputfile[0] = EOS; /* file could not be opened */
345: TtaSetStatus (me->docid, 1,
346: TtaGetMessage (AMAYA, AM_CANNOT_CREATE_FILE),
347: me->outputfile);
348: me->reqStatus = HT_ERR;
349: if (me->error_html)
350: DocNetworkStatus[me->docid] |= AMAYA_NET_ERROR; /* so we can show the error message */
1.32 cvs 351: } else {
1.36 cvs 352: if (THD_TRACE)
353: fprintf (stderr, "WIN_Activate_Request: Activating pending %s . Open fd %d\n", me->urlName, (int) me->output);
354: HTRequest_setOutputStream (me->request, AHTFWriter_new (me->request, me->output, YES));
1.32 cvs 355: /*change the status of the request */
356: me->reqStatus = HT_WAITING;
357: }
358: }
359: else if (me->reqStatus == HT_WAITING) {
1.36 cvs 360:
361: /*change the status of the request */
362: rewind (me->output);
363: if (HTRequest_outputStream (me->request) == NULL)
364: HTRequest_setOutputStream (me->request, AHTFWriter_new (me->request, me->output, YES));
1.32 cvs 365: }
366: else {
1.36 cvs 367: me->reqStatus = HT_ERR;
1.32 cvs 368: }
369:
1.36 cvs 370: return ((me->reqStatus != HT_ERR) ? HT_OK : HT_ERROR);
1.32 cvs 371: }
372:
1.38 cvs 373: #else /* _WINDOWS */
1.32 cvs 374:
375: /*----------------------------------------------------------------
376: Add_NewSocket_to_Loop
377: when there are more open requests than available sockets, the
378: requests are put in a "pending state." When a socket becomes
379: available, libwww associates it with a pending request and then
380: calls this callback function. This function is responsible for
381: opening the temporary file where the GET and POST results
382: will be stored. The function is also responsible for
383: registering the socket with the Xt event loop.
384: Consult the libwww manual for more details on the signature
385: of this function.
386: ----------------------------------------------------------------*/
387: #ifdef __STDC__
388: int Add_NewSocket_to_Loop (HTRequest * request, HTAlertOpcode op, int msgnum, const char *dfault, void *input, HTAlertPar * reply)
389: #else
390: int Add_NewSocket_to_Loop (request, op, msgnum, dfault, input, reply)
391: HTRequest *request;
392: HTAlertOpcode op;
393: int msgnum;
394: const char *dfault;
395: void *input;
396: HTAlertPar *reply;
1.29 cvs 397:
1.32 cvs 398: #endif /* __STDC__ */
399: {
400: AHTReqContext *me = HTRequest_context (request);
1.38 cvs 401: int status = HT_OK;
1.4 cvs 402:
1.36 cvs 403: #ifdef DEBUG_LIBWWW
1.32 cvs 404: fprintf (stderr, "(Activating a request\n");
1.36 cvs 405: #endif
1.30 cvs 406:
1.40 cvs 407: /* request was aborted (redirection, authentication) and now is is
408: being automatically reissued */
409:
410: if (me->reqStatus == HT_BUSY && me->output) {
411: fclose (me->output);
412: me->output = NULL;
413: }
414:
415: /* the request is active, open the output file */
416: if (!(me->output) &&
417: (me->output != stdout) &&
418: me->outputfile &&
419: !(me->output = fopen (me->outputfile, "w"))) {
420: me->outputfile[0] = EOS;
421: /* file could not be opened */
422: TtaSetStatus (me->docid, 1,
423: TtaGetMessage (AMAYA, AM_CANNOT_CREATE_FILE),
424: me->outputfile);
425: me->reqStatus = HT_ERR;
426: status = HT_ERROR;
427: /* should the error be shown on the Amaya doc window? */
428: if (me->error_html)
429: DocNetworkStatus[me->docid] |= AMAYA_NET_ERROR;
430: }
1.38 cvs 431:
1.40 cvs 432: if (me->output) {
433:
434: HTRequest_setOutputStream (me->request,
435: AHTFWriter_new (me->request,
436: me->output,
437: YES));
438: me->reqStatus = HT_WAITING;
1.43 cvs 439: #ifdef DEBUG_LIBWWW
440: fprintf (stderr, "Add_NewSocket_to_Loop: Activating "
441: "pending %s . Open fd %p, stream %p\n",
442: me->urlName, (int) me->output, HTRequest_outputStream(me->request));
443: #endif
444:
1.40 cvs 445: }
1.43 cvs 446: #ifdef DEBUG_LIBWWW
447: else {
448: fprintf (stderr, "Add_NewSocket_to_Loop: Error, me->output == NULL\n"
449: "for URL %s . Open fd %p, stream %p\n",
450: me->urlName, (int) me->output, HTRequest_outputStream(me->request));
451: }
452: #endif
1.40 cvs 453:
1.32 cvs 454:
1.40 cvs 455: return (status);
1.4 cvs 456: }
1.32 cvs 457: #endif /* _WINDOWS */
1.4 cvs 458:
1.11 cvs 459: /*----------------------------------------------------------------------
460: AHTEvent_register
461: callback called by libwww whenever a socket is open and associated
462: to a request. It sets the pertinent Xt events so that the Xt Event
463: loops gets an interruption whenever there's action of the socket.
464: In addition, it registers the request with libwww.
465: ----------------------------------------------------------------------*/
1.4 cvs 466: #ifdef __STDC__
1.7 cvs 467: int AHTEvent_register (SOCKET sock, HTRequest * rqp, SockOps ops, HTEventCallback * cbf, HTPriority p)
1.4 cvs 468: #else
1.7 cvs 469: int AHTEvent_register (sock, rqp, ops, cbf, p)
470: SOCKET sock;
471: HTRequest *rqp;
472: SockOps ops;
473: HTEventCallback *cbf;
474: HTPriority p;
475:
476: #endif /* __STDC__ */
1.4 cvs 477: {
1.40 cvs 478: AHTReqContext *me; /* current request */
479: int status; /* libwww status associated with
480: the socket number */
481: int v;
1.7 cvs 482:
1.43 cvs 483: #ifdef DEBUG_LIBWWW
484: fprintf(stderr, "HTEvent_register\n");
485: #endif /* DEBUG_LIBWWW */
1.40 cvs 486: if (sock == INVSOC)
487: return (0);
1.4 cvs 488:
1.47 cvs 489: /* get the request associated to the socket number */
1.43 cvs 490:
1.47 cvs 491: #ifndef _WINDOWS
492: v = HASH (sock);
493: if (persSockets[v] != 0)
494: {
495: XtRemoveInput (persSockets[v]);
496: persSockets[v] = 0;
497: }
498: #endif
1.7 cvs 499:
1.40 cvs 500: if (rqp == NULL)
501: {
1.37 cvs 502: #ifndef _WINDOWS
1.40 cvs 503: if (ops == FD_CLOSE)
504: {
1.36 cvs 505: #ifdef DEBUG_LIBWWW
1.40 cvs 506: fprintf(stderr, "HTEvent_register: ***** RQP is NULL @@@@@\n");
1.37 cvs 507: #endif /* DEBUG_LIBWWW */
1.43 cvs 508:
1.40 cvs 509: persSockets[v] = XtAppAddInput (app_cont,
510: sock,
511: (XtPointer) XtInputReadMask,
512: (XtInputCallbackProc) AHTCallback_bridge,
513: (XtPointer) XtInputReadMask);
514: } /* *fd_close */
1.43 cvs 515:
1.39 cvs 516: #endif /* !_WINDOWS */
1.40 cvs 517: }
518: else /* rqp */
519: {
520: me = HTRequest_context (rqp);
1.47 cvs 521:
522: /* Erase any trailing events */
1.43 cvs 523: /* HTEventrg_unregister (sock, FD_ALL); */
1.47 cvs 524:
1.33 cvs 525: #ifndef _WINDOWS
1.38 cvs 526: if (ops & ReadBits)
527: {
528: me->read_ops = ops;
529: RequestRegisterReadXtevent (me, sock);
530: }
531:
532: if (ops & WriteBits)
533: {
534: me->write_ops = ops;
535: RequestRegisterWriteXtevent (me, sock);
536: }
537:
538: if (ops & ExceptBits)
539: {
540: me->except_ops = ops;
541: RequestRegisterExceptXtevent (me, sock);
542: }
1.33 cvs 543: #endif /* !_WINDOWS */
1.38 cvs 544:
1.43 cvs 545: #ifdef DEBUG_LIBWWW
546: fprintf (stderr, "AHTEvent_register: URL %s, SOCK %d,
547: ops %lu, fd %p \n",
548: me->urlName, sock, ops, me->output);
549: #endif /* DEBUG_LIBWWW */
1.38 cvs 550: } /* if *rqp */
1.50 cvs 551:
1.51 ! cvs 552: #ifdef _WINDOWS
1.50 cvs 553: /* under windows, libwww requires an explicit FD_CLOSE registration
554: to detect HTTP responses not having a Content-Length header */
555: status = HTEventrg_register (sock, rqp, ops | FD_CLOSE,
556: cbf, p);
557: #else
1.37 cvs 558: status = HTEventrg_register (sock, rqp, ops,
1.38 cvs 559: cbf, p);
1.51 ! cvs 560: #endif /* _WINDOWS */
1.50 cvs 561:
1.7 cvs 562: return (status);
1.4 cvs 563: }
1.34 cvs 564:
565: /*----------------------------------------------------------------------
566: AHTEvent_unregister
567: callback called by libwww each time a request is unregistered. This
568: function takes care of unregistering the pertinent Xt events
569: associated with the request's socket. In addition, it unregisters
570: the request from libwww.
571: ----------------------------------------------------------------------*/
572: #ifdef __STDC__
573: int AHTEvent_unregister (SOCKET sock, SockOps ops)
574: #else
575: int AHTEvent_unregister (sock, ops)
576: SOCKET sock;
577: SockOps ops;
578:
579: #endif /* __STDC__ */
580: {
581: int status;
582: HTRequest *rqp = NULL;
1.39 cvs 583: #ifndef _WINDOWS
1.34 cvs 584: AHTReqContext *me;
1.44 cvs 585: #endif /* _WINDOWS */
586:
1.38 cvs 587: int v;
1.34 cvs 588:
589: /* Libwww 5.0a does not take into account the third parameter
590: ** for this function call */
591:
1.36 cvs 592: #ifndef _WINDOWS
593: HTEventCallback *cbf = (HTEventCallback *) __RetrieveCBF (sock, (SockOps) NULL, &rqp);
1.38 cvs 594: #endif /* _WINDOWS */
595:
596: if (sock == INVSOC)
597: return HT_OK;
598:
599: #ifndef _WINDOWS
1.36 cvs 600: #ifdef DEBUG_LIBWWW
601: fprintf (stderr, "AHTEventUnregister: cbf = %d, sock = %d, rqp = %d, ops= %x", cbf, sock, rqp, ops);
1.38 cvs 602: #endif /* DEBUG_LIBWWW */
603:
604: v = HASH (sock);
1.47 cvs 605: if (persSockets[v] != 0)
606: {
607: XtRemoveInput (persSockets[v]);
608: persSockets[v] = 0;
609: }
1.43 cvs 610:
1.7 cvs 611: if (cbf)
612: {
1.38 cvs 613: if (rqp && (me = HTRequest_context (rqp)) )
1.36 cvs 614: {
615: if (ops & ReadBits)
616: RequestKillReadXtevent (me);
617:
618: if (ops & WriteBits)
619: RequestKillWriteXtevent (me);
620:
621: if (ops & ExceptBits)
622: RequestKillExceptXtevent (me);
623: }
1.7 cvs 624: }
1.36 cvs 625: #endif /* !_WINDOWS */
1.35 cvs 626:
1.7 cvs 627: status = HTEventrg_unregister (sock, ops);
1.35 cvs 628:
1.7 cvs 629: return (status);
1.4 cvs 630: }
1.35 cvs 631:
632: #ifndef _WINDOWS
1.4 cvs 633:
1.11 cvs 634: /*----------------------------------------------------------------------
635: RequestKillAllXtevents
636: front-end for kill all Xt events associated with the request pointed
637: to by "me".
638: ----------------------------------------------------------------------*/
1.4 cvs 639: #ifdef __STDC__
1.7 cvs 640: void RequestKillAllXtevents (AHTReqContext * me)
1.4 cvs 641: #else
1.7 cvs 642: void RequestKillAllXtevents (me)
643: AHTReqContext *me;
644: #endif /* __STDC__ */
1.4 cvs 645: {
1.7 cvs 646: if (THD_TRACE)
647: fprintf (stderr, "Request_kill: Clearing Xtinputs\n");
1.4 cvs 648:
1.7 cvs 649: RequestKillReadXtevent (me);
650: RequestKillWriteXtevent (me);
651: RequestKillExceptXtevent (me);
1.4 cvs 652: }
653:
1.11 cvs 654: /*----------------------------------------------------------------------
1.18 cvs 655: RequestRegisterReadXtevent
656: Registers with Xt the read events associated with socket sock
657: ----------------------------------------------------------------------*/
658: #ifdef __STDC__
659: static void RequestRegisterReadXtevent (AHTReqContext * me, SOCKET sock)
660: #else
661: static void RequestRegisterReadXtevent (me, sock)
662: AHTReqContext *me;
663: SOCKET sock;
664: #endif /* __STDC__ */
665: {
666: if (me->read_xtinput_id)
667: {
668: if (THD_TRACE)
669: fprintf (stderr, "Request_kill: Clearing Xtinput %lu Socket %d R\n", me->read_xtinput_id, sock);
670: XtRemoveInput (me->read_xtinput_id);
671: }
672:
673: me->read_xtinput_id =
674: XtAppAddInput (app_cont,
675: sock,
676: (XtPointer) XtInputReadMask,
677: (XtInputCallbackProc) AHTCallback_bridge,
678: (XtPointer) XtInputReadMask);
679:
1.26 cvs 680: if (THD_TRACE)
1.18 cvs 681: fprintf (stderr, "(BT) adding Xtinput %lu Socket %d R\n",
682: me->read_xtinput_id, sock);
683:
684: }
685:
686: /*----------------------------------------------------------------------
1.11 cvs 687: RequestKillReadXtevent
688: kills any read Xt event associated with the request pointed to by "me".
689: ----------------------------------------------------------------------*/
1.4 cvs 690: #ifdef __STDC__
1.7 cvs 691: static void RequestKillReadXtevent (AHTReqContext * me)
1.4 cvs 692: #else
1.7 cvs 693: static void RequestKillReadXtevent (me)
694: AHTReqContext *me;
695: #endif /* __STDC__ */
1.4 cvs 696: {
1.7 cvs 697: if (me->read_xtinput_id)
698: {
699: if (THD_TRACE)
1.18 cvs 700: fprintf (stderr, "Request_kill: Clearing Xtinput %lu R\n", me->read_xtinput_id);
1.7 cvs 701: XtRemoveInput (me->read_xtinput_id);
702: me->read_xtinput_id = (XtInputId) NULL;
703: }
1.18 cvs 704: }
705:
706: /*----------------------------------------------------------------------
707: RequestRegisterWriteXtevent
708: Registers with Xt the write events associated with socket sock
709: ----------------------------------------------------------------------*/
710: #ifdef __STDC__
711: static void RequestRegisterWriteXtevent (AHTReqContext * me, SOCKET sock)
712: #else
713: static void RequestRegisterWriteXtevent (me, sock)
714: AHTReqContext *me;
715: SOCKET sock;
716:
717: #endif /* __STDC__ */
718: {
719: if (me->write_xtinput_id)
720: {
721: if (THD_TRACE)
722: fprintf (stderr, "Request_kill: Clearing Xtinput %lu Socket %d W\n", me->write_xtinput_id, sock);
723: XtRemoveInput (me->write_xtinput_id);
724: }
725:
726: me->write_xtinput_id =
727: XtAppAddInput (app_cont,
728: sock,
729: (XtPointer) XtInputWriteMask,
730: (XtInputCallbackProc) AHTCallback_bridge,
731: (XtPointer) XtInputWriteMask);
732:
733: if (THD_TRACE)
734: fprintf (stderr, "(BT) adding Xtinput %lu Socket %d W\n",
735: me->write_xtinput_id, sock);
1.4 cvs 736: }
737:
1.11 cvs 738: /*----------------------------------------------------------------------
739: RequestKillWriteXtevent
740: kills any write Xt event associated with the request pointed to
741: by "me".
742: ----------------------------------------------------------------------*/
1.4 cvs 743: #ifdef __STDC__
1.7 cvs 744: static void RequestKillWriteXtevent (AHTReqContext * me)
1.4 cvs 745: #else
1.7 cvs 746: static void RequestKillWriteXtevent (me)
747: AHTReqContext *me;
748: #endif /* __STDC__ */
1.4 cvs 749: {
1.7 cvs 750: if (me->write_xtinput_id)
751: {
752: if (THD_TRACE)
753: fprintf (stderr, "Request_kill: Clearing Write Xtinputs %lu\n", me->write_xtinput_id);
754: XtRemoveInput (me->write_xtinput_id);
755: me->write_xtinput_id = (XtInputId) NULL;
756: }
1.18 cvs 757: }
758:
759: /*----------------------------------------------------------------------
760: RequestRegisterExceptXtevent
761: Registers with Xt the except events associated with socket sock
762: ----------------------------------------------------------------------*/
763: #ifdef __STDC__
764: static void RequestRegisterExceptXtevent (AHTReqContext * me, SOCKET sock)
765: #else
766: static void RequestRegisterExceptXtevent (me, sock)
767: AHTReqContext *me;
768: SOCKET sock;
769:
770: #endif /* __STDC__ */
771: {
772: if (me->except_xtinput_id)
773: {
774: if (THD_TRACE)
775: fprintf (stderr, "Request_kill: Clearing Xtinput %lu Socket %d E\n", me->except_xtinput_id, sock);
776: XtRemoveInput (me->except_xtinput_id);
777: }
778:
779: me->except_xtinput_id =
780: XtAppAddInput (app_cont,
781: sock,
782: (XtPointer) XtInputExceptMask,
783: (XtInputCallbackProc) AHTCallback_bridge,
784: (XtPointer) XtInputExceptMask);
785:
786: if (THD_TRACE)
787: fprintf (stderr, "(BT) adding Xtinput %lu Socket %d E\n",
788: me->write_xtinput_id, sock);
789:
1.4 cvs 790: }
791:
1.11 cvs 792: /*----------------------------------------------------------------------
793: RequestKillExceptXtevent
794: kills any exception Xt event associated with the request pointed to
795: by "me".
796: ----------------------------------------------------------------------*/
1.4 cvs 797: #ifdef __STDC__
1.7 cvs 798: static void RequestKillExceptXtevent (AHTReqContext * me)
1.4 cvs 799: #else
1.7 cvs 800: static void RequestKillExceptXtevent (me)
801: AHTReqContext *me;
802: #endif /* __STDC__ */
1.4 cvs 803: {
1.7 cvs 804: if (me->except_xtinput_id)
805: {
806: if (THD_TRACE)
807: fprintf (stderr, "Request_kill: Clearing Except Xtinputs %lu\n", me->except_xtinput_id);
808: XtRemoveInput (me->except_xtinput_id);
809: me->except_xtinput_id = (XtInputId) NULL;
810: }
1.31 cvs 811: }
1.32 cvs 812: #endif /* !_WINDOWS */
1.31 cvs 813:
1.23 cvs 814: #endif /* !AMAYA_JAVA */
1.11 cvs 815:
Webmaster