version 1.84, 2003/01/06 15:42:05
|
version 1.85, 2003/10/21 16:22:57
|
Line 17
|
Line 17
|
* |
* |
*/ |
*/ |
#ifdef _GTK |
#ifdef _GTK |
#include <glib.h> |
#include <glib.h> |
#endif /* _GTK */ |
#endif /* _GTK */ |
|
|
#define THOT_EXPORT extern |
#define THOT_EXPORT extern |
Line 33
|
Line 33
|
#define THD_TRACE 1 |
#define THD_TRACE 1 |
#endif |
#endif |
|
|
#ifndef _WINDOWS |
#ifdef _MOTIF |
#ifndef _GTK |
/* Amaya's X appcontext */ |
/* Amaya's X appcontext */ |
extern ThotAppContext app_cont; |
extern ThotAppContext app_cont; |
#endif /* #ifdef _MOTIF */ |
#endif /* !_GTK */ |
|
|
#if defined(_MOTIF) || defined(_GTK) |
/* Private functions */ |
/* Private functions */ |
static void RequestRegisterReadXtevent (SOCKET); |
static void RequestRegisterReadXtevent (SOCKET); |
static void RequestKillReadXtevent (SOCKET); |
static void RequestKillReadXtevent (SOCKET); |
static void RequestRegisterWriteXtevent ( SOCKET); |
static void RequestRegisterWriteXtevent ( SOCKET); |
static void RequestKillWriteXtevent (SOCKET); |
static void RequestKillWriteXtevent (SOCKET); |
static void RequestRegisterExceptXtevent ( SOCKET); |
static void RequestRegisterExceptXtevent ( SOCKET); |
static void RequestKillExceptXtevent (SOCKET); |
static void RequestKillExceptXtevent (SOCKET); |
#endif /* !_WINDOWS */ |
#endif /* #if defined(_MOTIF) || defined(_GTK) */ |
|
|
/* Private variables */ |
/* Private variables */ |
|
|
Line 63 static const HTEventType ReadBits = HTEv
|
Line 63 static const HTEventType ReadBits = HTEv
|
static const HTEventType WriteBits = HTEvent_WRITE | HTEvent_CONNECT; |
static const HTEventType WriteBits = HTEvent_WRITE | HTEvent_CONNECT; |
static const HTEventType ExceptBits = HTEvent_OOB; |
static const HTEventType ExceptBits = HTEvent_OOB; |
|
|
#ifndef _GTK |
#ifdef _MOTIF |
typedef struct sStatus { |
typedef struct sStatus { |
XtInputId read; /* the different Xt Id's */ |
XtInputId read; /* the different Xt Id's */ |
XtInputId write; |
XtInputId write; |
XtInputId except; |
XtInputId except; |
} SocketStatus; |
} SocketStatus; |
#endif /*! _GTK */ |
#endif /*! #ifdef _MOTIF */ |
|
|
#ifdef _GTK |
#ifdef _GTK |
typedef struct sStatus { |
typedef struct sStatus { |
gint read; /* the different GTK Id's */ |
gint read; /* the different GTK Id's */ |
gint write; |
gint write; |
gint except; |
gint except; |
} SocketStatus; |
} SocketStatus; |
#endif /* _GTK */ |
#endif /* _GTK */ |
|
|
|
#ifdef _NOGUI |
|
typedef struct sStatus { |
|
int read; |
|
int write; |
|
int except; |
|
} SocketStatus; |
|
#endif /* #ifdef _NOGUI */ |
|
|
#define SOCK_TABLE_SIZE 67 |
#define SOCK_TABLE_SIZE 67 |
#define HASH(s) ((s) % SOCK_TABLE_SIZE) |
#define HASH(s) ((s) % SOCK_TABLE_SIZE) |
static SocketStatus persSockets[SOCK_TABLE_SIZE]; |
static SocketStatus persSockets[SOCK_TABLE_SIZE]; |
Line 99 static SocketStatus persSockets[SOCK_TAB
|
Line 107 static SocketStatus persSockets[SOCK_TAB
|
the state of the request and, if it's an asynchronous request, deletes |
the state of the request and, if it's an asynchronous request, deletes |
the memory allocated to it. |
the memory allocated to it. |
-------------------------------------------------------------------*/ |
-------------------------------------------------------------------*/ |
#ifndef _WINDOWS |
#ifdef _MOTIF |
#ifndef _GTK |
|
void *AHTCallback_bridge (caddr_t cd, int *s, XtInputId * id) |
void *AHTCallback_bridge (caddr_t cd, int *s, XtInputId * id) |
{ |
{ |
int status; /* the status result of the libwwww call */ |
int status; /* the status result of the libwwww call */ |
Line 145 void *AHTCallback_bridge (caddr_t cd, in
|
Line 152 void *AHTCallback_bridge (caddr_t cd, in
|
|
|
return (0); |
return (0); |
} |
} |
#else /* _GTK */ |
#endif /* _MOTIF */ |
|
|
|
#ifdef _GTK |
static void AHTCallback_bridgeGTK (gpointer data, gint source, GdkInputCondition condition) |
static void AHTCallback_bridgeGTK (gpointer data, gint source, GdkInputCondition condition) |
{ |
{ |
int status; /* the status result of the libwwww call */ |
int status; /* the status result of the libwwww call */ |
Line 188 static void AHTCallback_bridgeGTK (gpoin
|
Line 197 static void AHTCallback_bridgeGTK (gpoin
|
} |
} |
/*** CanDoStop_set (TRUE); **/ |
/*** CanDoStop_set (TRUE); **/ |
} |
} |
#endif /* !_GTK */ |
#endif /* _GTK */ |
#endif /* !_WINDOWS */ |
|
|
|
/*-------------------------------------------------------------------- |
/*-------------------------------------------------------------------- |
ProcessTerminateRequest |
ProcessTerminateRequest |
Line 315 int WIN_Activate_Request (HTRequest * re
|
Line 323 int WIN_Activate_Request (HTRequest * re
|
return ((me->reqStatus != HT_ERR) ? HT_OK : HT_ERROR); |
return ((me->reqStatus != HT_ERR) ? HT_OK : HT_ERROR); |
} |
} |
|
|
#endif /* WINDOWS but should be an else */ |
#endif /* _WINDOWS */ |
/* #else */ /* _WINDOWS */ |
|
|
|
#ifndef _WINDOWS |
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
AHTEvent_register |
AHTEvent_register |
callback called by libwww whenever a socket is open and associated |
callback called by libwww whenever a socket is open and associated |
Line 328 int WIN_Activate_Request (HTRequest * re
|
Line 334 int WIN_Activate_Request (HTRequest * re
|
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
int AHTEvent_register (SOCKET sock, HTEventType type, HTEvent *event) |
int AHTEvent_register (SOCKET sock, HTEventType type, HTEvent *event) |
{ |
{ |
int status; |
int status = 0; |
|
|
if (sock == INVSOC) |
if (sock == INVSOC) |
{ |
{ |
Line 338 int AHTEvent_register (SOCKET sock, HTEv
|
Line 344 int AHTEvent_register (SOCKET sock, HTEv
|
return (0); |
return (0); |
} |
} |
|
|
#ifndef _WINDOWS |
#if defined(_MOTIF) || defined(_GTK) |
/* need something special for HTEvent_CLOSE */ |
/* need something special for HTEvent_CLOSE */ |
if (type & ReadBits) |
if (type & ReadBits) |
RequestRegisterReadXtevent (sock); |
RequestRegisterReadXtevent (sock); |
Line 348 int AHTEvent_register (SOCKET sock, HTEv
|
Line 354 int AHTEvent_register (SOCKET sock, HTEv
|
|
|
if (type & ExceptBits) |
if (type & ExceptBits) |
RequestRegisterExceptXtevent (sock); |
RequestRegisterExceptXtevent (sock); |
#endif /* !_WINDOWS */ |
#endif /* #if defined(_MOTIF) || defined(_GTK) */ |
|
|
#ifdef _WINDOWS |
#ifdef _WINDOWS |
/* under windows, libwww requires an explicit FD_CLOSE registration |
/* under windows, libwww requires an explicit FD_CLOSE registration |
to detect HTTP responses not having a Content-Length header */ |
to detect HTTP responses not having a Content-Length header */ |
status = HTEventList_register (sock, type | HTEvent_CLOSE , event); |
status = HTEventList_register (sock, type | HTEvent_CLOSE , event); |
#else |
|
status = HTEventList_register (sock, type, event); |
|
#endif /* _WINDOWS */ |
#endif /* _WINDOWS */ |
|
|
|
#if defined(_MOTIF) || defined(_GTK) |
|
status = HTEventList_register (sock, type, event); |
|
#endif /* #if defined(_MOTIF) || defined(_GTK) */ |
|
|
return (status); |
return (status); |
} |
} |
#endif /* _WINDOWS */ |
|
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
AHTEvent_unregister |
AHTEvent_unregister |
Line 376 int AHTEvent_unregister (SOCKET sock, HT
|
Line 383 int AHTEvent_unregister (SOCKET sock, HT
|
if (sock == INVSOC) |
if (sock == INVSOC) |
return HT_OK; |
return HT_OK; |
|
|
#ifndef _WINDOWS |
#if defined(_MOTIF) || defined(_GTK) |
/* remove the Xt event hooks */ |
/* remove the Xt event hooks */ |
if (type & ReadBits) |
if (type & ReadBits) |
RequestKillReadXtevent (sock); |
RequestKillReadXtevent (sock); |
Line 386 int AHTEvent_unregister (SOCKET sock, HT
|
Line 393 int AHTEvent_unregister (SOCKET sock, HT
|
|
|
if (type & ExceptBits) |
if (type & ExceptBits) |
RequestKillExceptXtevent (sock); |
RequestKillExceptXtevent (sock); |
#endif /* !_WINDOWS */ |
#endif /* #if defined(_MOTIF) || defined(_GTK) */ |
|
|
/* @@@ if this is the default for windows, no need to have AHTEvent_.. |
/* @@@ if this is the default for windows, no need to have AHTEvent_.. |
in windows!! */ |
in windows!! */ |
Line 397 int AHTEvent_unregister (SOCKET sock, HT
|
Line 404 int AHTEvent_unregister (SOCKET sock, HT
|
return (status); |
return (status); |
} |
} |
|
|
#ifndef _WINDOWS |
#if defined(_MOTIF) || defined(_GTK) || defined(_NOGUI) |
/* Private functions */ |
/* Private functions */ |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
Line 444 static void RequestRegisterReadXtevent (
|
Line 451 static void RequestRegisterReadXtevent (
|
|
|
if (!persSockets[v].read) |
if (!persSockets[v].read) |
{ |
{ |
#ifndef _GTK |
|
|
#ifdef _MOTIF |
persSockets[v].read = |
persSockets[v].read = |
XtAppAddInput (app_cont, |
XtAppAddInput (app_cont, |
sock, |
sock, |
(XtPointer) XtInputReadMask, |
(XtPointer) XtInputReadMask, |
(XtInputCallbackProc) AHTCallback_bridge, |
(XtInputCallbackProc) AHTCallback_bridge, |
(XtPointer) XtInputReadMask); |
(XtPointer) XtInputReadMask); |
#else /* _GTK */ |
#endif /* _MOTIF */ |
|
|
|
#ifdef _GTK |
persSockets[v].read = |
persSockets[v].read = |
gdk_input_add ((gint) sock, |
gdk_input_add ((gint) sock, |
GDK_INPUT_READ, |
GDK_INPUT_READ, |
Line 485 static void RequestKillReadXtevent (SOCK
|
Line 495 static void RequestKillReadXtevent (SOCK
|
fprintf (stderr, "UnregisterReadXtEvent: Clearing XtInput %lu\n", |
fprintf (stderr, "UnregisterReadXtEvent: Clearing XtInput %lu\n", |
persSockets[v].read); |
persSockets[v].read); |
#endif /* DEBUG_LIBWWW */ |
#endif /* DEBUG_LIBWWW */ |
#ifndef _GTK |
|
|
#ifdef _MOTIF |
XtRemoveInput (persSockets[v].read); |
XtRemoveInput (persSockets[v].read); |
persSockets[v].read = (XtInputId) NULL; |
persSockets[v].read = (XtInputId) NULL; |
#else /* _GTK */ |
#endif /* _MOTIF */ |
|
|
|
#ifdef _GTK |
gdk_input_remove (persSockets[v].read); |
gdk_input_remove (persSockets[v].read); |
persSockets[v].read = (gint) 0; |
persSockets[v].read = (gint) 0; |
#endif /* !_GTK */ |
#endif /* !_GTK */ |
|
|
} |
} |
} |
} |
|
|
Line 506 static void RequestRegisterWriteXtevent
|
Line 520 static void RequestRegisterWriteXtevent
|
|
|
if (!persSockets[v].write) |
if (!persSockets[v].write) |
{ |
{ |
#ifndef _GTK |
#ifdef _MOTIF |
persSockets[v].write = |
persSockets[v].write = |
XtAppAddInput (app_cont, |
XtAppAddInput (app_cont, |
sock, |
sock, |
(XtPointer) XtInputWriteMask, |
(XtPointer) XtInputWriteMask, |
(XtInputCallbackProc) AHTCallback_bridge, |
(XtInputCallbackProc) AHTCallback_bridge, |
(XtPointer) XtInputWriteMask); |
(XtPointer) XtInputWriteMask); |
#else /* _GTK */ |
#endif /* _MOTIF */ |
|
|
|
#ifdef _GTK |
persSockets[v].write = |
persSockets[v].write = |
gdk_input_add ((gint) sock, |
gdk_input_add ((gint) sock, |
GDK_INPUT_WRITE, |
GDK_INPUT_WRITE, |
AHTCallback_bridgeGTK, |
AHTCallback_bridgeGTK, |
(gpointer) sock); |
(gpointer) sock); |
#endif /* !_GTK */ |
#endif /* _GTK */ |
|
|
#ifdef DEBUG_LIBWWW |
#ifdef DEBUG_LIBWWW |
if (THD_TRACE) |
if (THD_TRACE) |
Line 549 static void RequestKillWriteXtevent (SOC
|
Line 565 static void RequestKillWriteXtevent (SOC
|
"%lu\n", |
"%lu\n", |
persSockets[v].write); |
persSockets[v].write); |
#endif /* DEBUG_LIBWWW */ |
#endif /* DEBUG_LIBWWW */ |
#ifndef _GTK |
|
|
#ifdef _MOTIF |
XtRemoveInput (persSockets[v].write); |
XtRemoveInput (persSockets[v].write); |
persSockets[v].write = (XtInputId) NULL; |
persSockets[v].write = (XtInputId) NULL; |
#else /* _GTK */ |
#endif /* _MOTIF */ |
|
|
|
#ifdef _GTK |
gdk_input_remove (persSockets[v].write); |
gdk_input_remove (persSockets[v].write); |
persSockets[v].write = (gint) 0; |
persSockets[v].write = (gint) 0; |
#endif /* !_GTK */ |
#endif /* _GTK */ |
|
|
} |
} |
} |
} |
|
|
Line 571 static void RequestRegisterExceptXtevent
|
Line 591 static void RequestRegisterExceptXtevent
|
|
|
if (!persSockets[v].except) |
if (!persSockets[v].except) |
{ |
{ |
#ifndef _GTK |
#ifdef _MOTIF |
persSockets[v].except = |
persSockets[v].except = |
XtAppAddInput (app_cont, |
XtAppAddInput (app_cont, |
sock, |
sock, |
(XtPointer) XtInputExceptMask, |
(XtPointer) XtInputExceptMask, |
(XtInputCallbackProc) AHTCallback_bridge, |
(XtInputCallbackProc) AHTCallback_bridge, |
(XtPointer) XtInputExceptMask); |
(XtPointer) XtInputExceptMask); |
#else /* _GTK */ |
#endif /* _MOTIF */ |
|
|
|
#ifdef _GTK |
persSockets[v].except = |
persSockets[v].except = |
gdk_input_add ((gint) sock, |
gdk_input_add ((gint) sock, |
GDK_INPUT_EXCEPTION, |
GDK_INPUT_EXCEPTION, |
AHTCallback_bridgeGTK, |
AHTCallback_bridgeGTK, |
(gpointer) sock); |
(gpointer) sock); |
#endif /* !_GTK */ |
#endif /* _GTK */ |
|
|
#ifdef DEBUG_LIBWWW |
#ifdef DEBUG_LIBWWW |
if (THD_TRACE) |
if (THD_TRACE) |
fprintf (stderr, "RegisterExceptXtEvent: adding XtInput %lu Socket %d\n", |
fprintf (stderr, "RegisterExceptXtEvent: adding XtInput %lu Socket %d\n", |
Line 610 static void RequestKillExceptXtevent (SO
|
Line 633 static void RequestKillExceptXtevent (SO
|
fprintf (stderr, "UnregisterExceptXtEvent: Clearing Except XtInputs " |
fprintf (stderr, "UnregisterExceptXtEvent: Clearing Except XtInputs " |
"%lu\n", persSockets[v].except); |
"%lu\n", persSockets[v].except); |
#endif /* DEBUG_LIBWWW */ |
#endif /* DEBUG_LIBWWW */ |
#ifndef _GTK |
|
|
#ifdef _MOTIF |
XtRemoveInput (persSockets[v].except); |
XtRemoveInput (persSockets[v].except); |
persSockets[v].except = (XtInputId) NULL; |
persSockets[v].except = (XtInputId) NULL; |
#else /* _GTK */ |
#endif /* _MOTIF */ |
|
|
|
#ifdef _GTK |
gdk_input_remove (persSockets[v].except); |
gdk_input_remove (persSockets[v].except); |
persSockets[v].except = (gint) 0; |
persSockets[v].except = (gint) 0; |
#endif /* !_GTK */ |
#endif /* _GTK */ |
|
|
} |
} |
} |
} |
|
|
Line 635 struct _HTTimer {
|
Line 662 struct _HTTimer {
|
|
|
struct _AmayaTimer { |
struct _AmayaTimer { |
HTTimer *libwww_timer; |
HTTimer *libwww_timer; |
#ifndef _GTK |
|
|
#ifdef _MOTIF |
XtIntervalId xt_timer; |
XtIntervalId xt_timer; |
#else /* _GTK */ |
#endif /* _MOTIF */ |
|
|
|
#ifdef _GTK |
guint xt_timer; |
guint xt_timer; |
#endif /* !_GTK */ |
#endif /* _GTK */ |
|
|
|
#ifdef _NOGUI |
|
unsigned int xt_timer; |
|
#endif /* #ifdef _NOGUI */ |
|
|
}; |
}; |
|
|
typedef struct _AmayaTimer AmayaTimer; |
typedef struct _AmayaTimer AmayaTimer; |
Line 651 static HTList *Timers = NULL;
|
Line 686 static HTList *Timers = NULL;
|
called by the system event loop. Timers shouldn't be restarted |
called by the system event loop. Timers shouldn't be restarted |
on exiting. |
on exiting. |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
#ifndef _GTK |
#ifdef _MOTIF |
void *TimerCallback (XtPointer cdata, XtIntervalId *id) |
void *TimerCallback (XtPointer cdata, XtIntervalId *id) |
{ |
{ |
HTList *cur, *last; |
HTList *cur, *last; |
Line 682 void *TimerCallback (XtPointer cdata, Xt
|
Line 717 void *TimerCallback (XtPointer cdata, Xt
|
|
|
return (0); |
return (0); |
} |
} |
|
#endif /* _MOTIF */ |
|
|
#else /* _GTK */ |
#ifdef _GTK |
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
TimerCallbackGTK |
TimerCallbackGTK |
The callback returns FALSE to destroy the timer that called it. |
The callback returns FALSE to destroy the timer that called it. |
Line 721 gboolean TimerCallbackGTK (gpointer id)
|
Line 757 gboolean TimerCallbackGTK (gpointer id)
|
|
|
return (FALSE); |
return (FALSE); |
} |
} |
#endif /* !_GTK */ |
#endif /* _GTK */ |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
KillAllTimers |
KillAllTimers |
Line 764 void AMAYA_SetTimer (HTTimer *libwww_tim
|
Line 800 void AMAYA_SetTimer (HTTimer *libwww_tim
|
/* remove the old timer */ |
/* remove the old timer */ |
if (me->xt_timer) |
if (me->xt_timer) |
{ |
{ |
#ifndef _GTK |
|
|
#ifdef _MOTIF |
XtRemoveTimeOut (me->xt_timer); |
XtRemoveTimeOut (me->xt_timer); |
me->xt_timer = (XtIntervalId) NULL; |
me->xt_timer = (XtIntervalId) NULL; |
#else /* _GTK */ |
#endif /* _MOTIF */ |
|
|
|
#ifdef _GTK |
gtk_timeout_remove (me->xt_timer); |
gtk_timeout_remove (me->xt_timer); |
me->xt_timer = (guint) 0; |
me->xt_timer = (guint) 0; |
#endif /* !_GTK */ |
#endif /* !_GTK */ |
} |
|
|
} |
} |
} |
else |
else |
{ |
{ |
Line 783 void AMAYA_SetTimer (HTTimer *libwww_tim
|
Line 823 void AMAYA_SetTimer (HTTimer *libwww_tim
|
} |
} |
|
|
/* add a new time out */ |
/* add a new time out */ |
#ifndef _GTK |
#ifdef _MOTIF |
me->xt_timer = XtAppAddTimeOut (app_cont, |
me->xt_timer = XtAppAddTimeOut (app_cont, |
me->libwww_timer->millis, |
me->libwww_timer->millis, |
(XtTimerCallbackProc) TimerCallback, |
(XtTimerCallbackProc) TimerCallback, |
(XtPointer *) (void *) me); |
(XtPointer *) (void *) me); |
#else /* _GTK */ |
#endif /* _MOTIF */ |
|
|
|
#ifdef _GTK |
me->xt_timer = gtk_timeout_add ((guint32) me->libwww_timer->millis, |
me->xt_timer = gtk_timeout_add ((guint32) me->libwww_timer->millis, |
(GtkFunction) TimerCallbackGTK, |
(GtkFunction) TimerCallbackGTK, |
(gpointer) me); |
(gpointer) me); |
#endif /* !_GTK */ |
#endif /* _GTK */ |
|
|
} |
} |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
Line 818 void AMAYA_DeleteTimer (HTTimer *libwww_
|
Line 861 void AMAYA_DeleteTimer (HTTimer *libwww_
|
if (me) |
if (me) |
{ |
{ |
/* remove the Xt timer */ |
/* remove the Xt timer */ |
#ifndef _GTK |
#ifdef _MOTIF |
XtRemoveTimeOut (me->xt_timer); |
XtRemoveTimeOut (me->xt_timer); |
#else /* _GTK */ |
#endif /* _MOTIF */ |
|
|
|
#ifdef _GTK |
gtk_timeout_remove (me->xt_timer); |
gtk_timeout_remove (me->xt_timer); |
#endif /* !_GTK */ |
#endif /* _GTK */ |
|
|
/* and the element from the list */ |
/* and the element from the list */ |
HTList_removeObject (Timers, me); |
HTList_removeObject (Timers, me); |
TtaFreeMemory (me); |
TtaFreeMemory (me); |
} |
} |
} |
} |
#endif /* !_WINDOWS */ |
#endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_NOGUI) */ |