version 1.25, 1997/05/30 15:20:02
|
version 1.26, 1997/06/02 10:19:26
|
Line 12
|
Line 12
|
* requests. |
* requests. |
* |
* |
* Author: J Kahan |
* Author: J Kahan |
|
* R. Guetari Windows NT/95 routines |
* |
* |
*/ |
*/ |
#ifndef AMAYA_JAVA |
#ifndef AMAYA_JAVA |
Line 28
|
Line 29
|
extern ThotAppContext app_cont; |
extern ThotAppContext app_cont; |
#endif |
#endif |
|
|
|
#if 0 |
#ifdef _WINDOWS |
#ifdef _WINDOWS |
static HWND HTSocketWin; |
static HWND HTSocketWin; |
static unsigned long HTwinMsg; |
static unsigned long HTwinMsg; |
Line 51 typedef struct WSAData {
|
Line 53 typedef struct WSAData {
|
typedef WSADATA FAR *LPWSADATA; |
typedef WSADATA FAR *LPWSADATA; |
#endif /* __GNUC__ */ |
#endif /* __GNUC__ */ |
#endif /* _WINDOWS */ |
#endif /* _WINDOWS */ |
|
#endif /* 0 */ |
|
|
/* |
/* |
* Private functions |
* Private functions |
Line 76 static void RequestKillExceptXte
|
Line 79 static void RequestKillExceptXte
|
#ifdef _WINDOWS |
#ifdef _WINDOWS |
static void WIN_ResetMaxSock (void); |
static void WIN_ResetMaxSock (void); |
static int WIN_ProcessFds (fd_set * fdsp, SockOps ops); |
static int WIN_ProcessFds (fd_set * fdsp, SockOps ops); |
|
#if 0 |
static int VerifySocketState (AHTReqContext *me, SOCKET sock); |
static int VerifySocketState (AHTReqContext *me, SOCKET sock); |
PUBLIC LRESULT CALLBACK ASYNCWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
PUBLIC LRESULT CALLBACK ASYNCWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
|
#endif /* 0 */ |
#endif /* _WINDOWS */ |
#endif /* _WINDOWS */ |
|
|
/* |
/* |
Line 98 static const SockOps ExceptBits = FD_OOB
|
Line 103 static const SockOps ExceptBits = FD_OOB
|
|
|
#ifdef _WINDOWS |
#ifdef _WINDOWS |
static fd_set read_fds, write_fds, except_fds, all_fds; |
static fd_set read_fds, write_fds, except_fds, all_fds; |
static int maxfds; |
static int maxfds = 0; |
#endif /* _WINDOWS */ |
#endif /* _WINDOWS */ |
|
|
/* |
/* |
Line 122 static int maxfds;
|
Line 127 static int maxfds;
|
the memory allocated to it. |
the memory allocated to it. |
-------------------------------------------------------------------*/ |
-------------------------------------------------------------------*/ |
#ifdef _WINDOWS |
#ifdef _WINDOWS |
static void *WIN_AHTCallback_bridge (SockOps _ops, int *s) |
#ifdef __STDC__ |
#else |
static void* WIN_AHTCallback_bridge (SockOps _ops, int *s) |
|
#else /* __STDC__ */ |
|
static void* WIN_AHTCallback_bridge (_ops, s) |
|
SockOps _ops; |
|
int* s; |
|
#endif /* __STDC__ */ |
|
#else /* _WINDOWS */ |
#ifdef __STDC__ |
#ifdef __STDC__ |
void *AHTCallback_bridge (caddr_t cd, int *s, XtInputId * id) |
void *AHTCallback_bridge (caddr_t cd, int *s, XtInputId * id) |
#else |
#else /* __STDC__ */ |
void *AHTCallback_bridge (cd, s, id) |
void *AHTCallback_bridge (cd, s, id) |
caddr_t cd; |
caddr_t cd; |
int *s; |
int *s; |
Line 170 XtInputId *id;
|
Line 181 XtInputId *id;
|
return (0); |
return (0); |
} |
} |
|
|
#ifdef _WINDOWS |
# ifdef _WINDOWS |
ops = _ops; |
ops = _ops; |
#else |
# else |
switch ((XtInputId) cd) |
switch ((XtInputId) cd) |
{ |
{ |
case XtInputReadMask: |
case XtInputReadMask: |
Line 190 XtInputId *id;
|
Line 201 XtInputId *id;
|
default: |
default: |
break; |
break; |
} /* switch */ |
} /* switch */ |
#endif /* _WINDOWS */ |
# endif /* _WINDOWS */ |
|
|
/* Invokes the callback associated to the requests */ |
/* Invokes the callback associated to the requests */ |
|
|
Line 250 XtInputId *id;
|
Line 261 XtInputId *id;
|
if ((me->request->net == (HTNet *) NULL) || (me->reqStatus == HT_END || me->reqStatus == HT_ERR)) |
if ((me->request->net == (HTNet *) NULL) || (me->reqStatus == HT_END || me->reqStatus == HT_ERR)) |
/* request has ended */ |
/* request has ended */ |
{ |
{ |
#ifndef _WINDOWS |
# ifndef _WINDOWS |
if (THD_TRACE) |
if (THD_TRACE) |
fprintf (stderr, "(BF) removing Xtinput %lu !RWE, sock %d (Request has ended)\n", *id, *s); |
fprintf (stderr, "(BF) removing Xtinput %lu !RWE, sock %d (Request has ended)\n", *id, *s); |
#endif |
# endif |
if ((me->mode & AMAYA_ASYNC) || (me->mode & AMAYA_IASYNC)) |
if ((me->mode & AMAYA_ASYNC) || (me->mode & AMAYA_IASYNC)) |
/* free the memory allocated for async requests */ |
/* free the memory allocated for async requests */ |
{ |
{ |
Line 501 SOCKET sock;
|
Line 512 SOCKET sock;
|
|
|
#endif /* __STDC__ */ |
#endif /* __STDC__ */ |
{ |
{ |
#ifdef _WINDOWS |
# ifdef _WINDOWS |
/* |
FD_SET (sock, &read_fds); |
FD_SET (sock, &read_fds); |
FD_SET (sock, &all_fds); |
FD_SET (sock, &all_fds); |
me->read_sock = sock; |
*/ |
if (sock > maxfds) |
|
|
me->read_sock = sock; |
|
me->read_fd_state |= FD_READ; |
|
|
|
WSAAsyncSelect (sock, HTSocketWin, HTwinMsg, me->read_fd_state); |
|
|
|
/* |
|
if (sock > maxfds) |
|
maxfds = sock; |
maxfds = sock; |
*/ |
|
#else |
/* |
|
me->read_sock = sock; |
|
me->read_fd_state |= FD_READ; |
|
WSAAsyncSelect (sock, HTSocketWin, HTwinMsg, me->read_fd_state); |
|
*/ |
|
# else |
if (me->read_xtinput_id) |
if (me->read_xtinput_id) |
{ |
{ |
if (THD_TRACE) |
if (THD_TRACE) |
Line 531 SOCKET sock;
|
Line 539 SOCKET sock;
|
(XtInputCallbackProc) AHTCallback_bridge, |
(XtInputCallbackProc) AHTCallback_bridge, |
(XtPointer) XtInputReadMask); |
(XtPointer) XtInputReadMask); |
|
|
if (THD_TRACE) |
if (THD_TRACE) |
fprintf (stderr, "(BT) adding Xtinput %lu Socket %d R\n", |
fprintf (stderr, "(BT) adding Xtinput %lu Socket %d R\n", |
me->read_xtinput_id, sock); |
me->read_xtinput_id, sock); |
#endif /* !_WINDOWS */ |
# endif /* !_WINDOWS */ |
|
|
} |
} |
|
|
Line 550 AHTReqContext *me;
|
Line 558 AHTReqContext *me;
|
|
|
#endif /* __STDC__ */ |
#endif /* __STDC__ */ |
{ |
{ |
#ifdef _WINDOWS |
# ifdef _WINDOWS |
int new_fd; |
int new_fd; |
|
|
if(me->read_sock != INVSOC) |
if (me->read_sock != INVSOC) { |
{ |
FD_CLR (me->read_sock, &read_fds); |
/* |
FD_CLR (me->read_sock, &all_fds); |
FD_CLR (me->read_sock, &read_fds); |
me->read_sock = INVSOC; |
FD_CLR (me->read_sock, &all_fds); |
WIN_ResetMaxSock(); |
*/ |
/* |
me->read_fd_state &= ~FD_READ; |
me->read_fd_state &= ~FD_READ; |
|
new_fd = VerifySocketState (me, me->read_sock); |
new_fd = VerifySocketState (me, me->read_sock); |
if (new_fd) |
|
WSAAsyncSelect (me->read_sock, HTSocketWin, HTwinMsg, new_fd); |
if (new_fd) |
else |
WSAAsyncSelect (me->read_sock, HTSocketWin, HTwinMsg, new_fd); |
WSAAsyncSelect (me->read_sock, HTSocketWin, 0, 0); |
else |
me->read_sock = INVSOC; |
WSAAsyncSelect (me->read_sock, HTSocketWin, 0, 0); |
*/ |
me->read_sock = INVSOC; |
} |
/* WIN_ResetMaxSock(); |
# else |
*/ |
|
} |
|
#else |
|
if (me->read_xtinput_id) |
if (me->read_xtinput_id) |
{ |
{ |
if (THD_TRACE) |
if (THD_TRACE) |
Line 579 int new_fd;
|
Line 584 int new_fd;
|
XtRemoveInput (me->read_xtinput_id); |
XtRemoveInput (me->read_xtinput_id); |
me->read_xtinput_id = (XtInputId) NULL; |
me->read_xtinput_id = (XtInputId) NULL; |
} |
} |
#endif /* !_WINDOWS */ |
# endif /* !_WINDOWS */ |
} |
} |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
Line 595 SOCKET sock;
|
Line 600 SOCKET sock;
|
|
|
#endif /* __STDC__ */ |
#endif /* __STDC__ */ |
{ |
{ |
#ifdef _WINDOWS |
# ifdef _WINDOWS |
/* |
FD_SET (sock, &write_fds); |
FD_SET (sock, &write_fds); |
FD_SET (sock, &all_fds); |
FD_SET (sock, &all_fds); |
me->write_sock = sock; |
me->write_sock = sock; |
|
|
if (sock > maxfds) |
if (sock > maxfds) |
maxfds = sock ; |
maxfds = sock ; |
/* |
*/ |
me->write_sock = sock; |
me->write_sock = sock; |
me->write_fd_state |= FD_WRITE; |
me->write_fd_state |= FD_WRITE; |
WSAAsyncSelect (sock, HTSocketWin, HTwinMsg, me->write_fd_state); |
|
*/ |
WSAAsyncSelect (sock, HTSocketWin, HTwinMsg, me->write_fd_state); |
# else |
#else |
|
if (me->write_xtinput_id) |
if (me->write_xtinput_id) |
{ |
{ |
if (THD_TRACE) |
if (THD_TRACE) |
Line 626 SOCKET sock;
|
Line 630 SOCKET sock;
|
if (THD_TRACE) |
if (THD_TRACE) |
fprintf (stderr, "(BT) adding Xtinput %lu Socket %d W\n", |
fprintf (stderr, "(BT) adding Xtinput %lu Socket %d W\n", |
me->write_xtinput_id, sock); |
me->write_xtinput_id, sock); |
#endif /* !_WINDOWS */ |
# endif /* !_WINDOWS */ |
} |
} |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
Line 642 AHTReqContext *me;
|
Line 646 AHTReqContext *me;
|
|
|
#endif /* __STDC__ */ |
#endif /* __STDC__ */ |
{ |
{ |
#ifdef _WINDOWS |
# ifdef _WINDOWS |
int new_fd; |
int new_fd; |
|
|
if(me->write_sock != INVSOC) |
if (me->write_sock != INVSOC) { |
{ |
FD_CLR (me->write_sock, &write_fds); |
/* |
FD_CLR (me->write_sock, &all_fds); |
FD_CLR (me->write_sock, &write_fds); |
me->write_sock = INVSOC; |
FD_CLR (me->write_sock, &all_fds); |
WIN_ResetMaxSock(); |
*/ |
/* |
me->write_fd_state &= ~FD_WRITE; |
me->write_fd_state &= ~FD_WRITE; |
|
new_fd = VerifySocketState (me, me->write_sock); |
new_fd = VerifySocketState (me, me->write_sock); |
if (new_fd) |
|
WSAAsyncSelect (me->write_sock, HTSocketWin, HTwinMsg, new_fd); |
if (new_fd) |
else |
WSAAsyncSelect (me->write_sock, HTSocketWin, HTwinMsg, new_fd); |
WSAAsyncSelect (me->write_sock, HTSocketWin, 0, 0); |
else |
me->write_sock = INVSOC; |
WSAAsyncSelect (me->write_sock, HTSocketWin, 0, 0); |
*/ |
me->write_sock = INVSOC; |
} |
/* WIN_ResetMaxSock(); */ |
# else |
} |
|
#else |
|
if (me->write_xtinput_id) |
if (me->write_xtinput_id) |
{ |
{ |
if (THD_TRACE) |
if (THD_TRACE) |
Line 670 int new_fd;
|
Line 672 int new_fd;
|
XtRemoveInput (me->write_xtinput_id); |
XtRemoveInput (me->write_xtinput_id); |
me->write_xtinput_id = (XtInputId) NULL; |
me->write_xtinput_id = (XtInputId) NULL; |
} |
} |
#endif /* !_WINDOWS */ |
# endif /* !_WINDOWS */ |
} |
} |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
Line 686 SOCKET sock;
|
Line 688 SOCKET sock;
|
|
|
#endif /* __STDC__ */ |
#endif /* __STDC__ */ |
{ |
{ |
#ifdef _WINDOWS |
# ifdef _WINDOWS |
/* |
FD_SET (sock, &except_fds); |
FD_SET (sock, &except_fds); |
FD_SET (sock, &all_fds); |
FD_SET (sock, &all_fds); |
me->except_sock = sock; |
me->except_sock = sock; |
if (sock > maxfds) |
|
maxfds = sock ; |
if (sock > maxfds) |
/* |
maxfds = sock ; |
me->except_sock = sock; |
*/ |
me->except_fd_state |= FD_OOB; |
me->except_sock = sock; |
WSAAsyncSelect (sock, HTSocketWin, HTwinMsg, me->except_fd_state); |
me->except_fd_state |= FD_OOB; |
*/ |
|
# else |
WSAAsyncSelect (sock, HTSocketWin, HTwinMsg, me->except_fd_state); |
|
|
|
#else |
|
if (me->except_xtinput_id) |
if (me->except_xtinput_id) |
{ |
{ |
if (THD_TRACE) |
if (THD_TRACE) |
Line 719 SOCKET sock;
|
Line 718 SOCKET sock;
|
fprintf (stderr, "(BT) adding Xtinput %lu Socket %d E\n", |
fprintf (stderr, "(BT) adding Xtinput %lu Socket %d E\n", |
me->write_xtinput_id, sock); |
me->write_xtinput_id, sock); |
|
|
#endif /* !_WINDOWS */ |
# endif /* !_WINDOWS */ |
} |
} |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
Line 735 AHTReqContext *me;
|
Line 734 AHTReqContext *me;
|
|
|
#endif /* __STDC__ */ |
#endif /* __STDC__ */ |
{ |
{ |
#ifdef _WINDOWS |
# ifdef _WINDOWS |
int new_fd; |
int new_fd; |
if(me->except_sock != INVSOC) |
if (me->except_sock != INVSOC) { |
{ |
FD_CLR (me->except_sock, &except_fds); |
/* |
FD_CLR (me->except_sock, &all_fds); |
FD_CLR (me->except_sock, &except_fds); |
me->except_sock = INVSOC; |
FD_CLR (me->except_sock, &all_fds); |
WIN_ResetMaxSock(); |
*/ |
/* |
|
me->except_fd_state &= ~FD_WRITE; |
me->except_fd_state &= ~FD_WRITE; |
new_fd = VerifySocketState (me, me->except_sock); |
|
if (new_fd) |
new_fd = VerifySocketState (me, me->except_sock); |
WSAAsyncSelect (me->except_sock, HTSocketWin, HTwinMsg, new_fd); |
|
else |
if (new_fd) |
WSAAsyncSelect (me->except_sock, HTSocketWin, 0, 0); |
WSAAsyncSelect (me->except_sock, HTSocketWin, HTwinMsg, new_fd); |
me->except_sock = INVSOC; |
else |
*/ |
WSAAsyncSelect (me->except_sock, HTSocketWin, 0, 0); |
} |
me->except_sock = INVSOC; |
# else |
/* WIN_ResetMaxSock(); */ |
|
} |
|
#else |
|
if (me->except_xtinput_id) |
if (me->except_xtinput_id) |
{ |
{ |
if (THD_TRACE) |
if (THD_TRACE) |
Line 763 int new_fd;
|
Line 759 int new_fd;
|
XtRemoveInput (me->except_xtinput_id); |
XtRemoveInput (me->except_xtinput_id); |
me->except_xtinput_id = (XtInputId) NULL; |
me->except_xtinput_id = (XtInputId) NULL; |
} |
} |
#endif /* !_WINDOWS */ |
# endif /* !_WINDOWS */ |
} |
} |
|
|
#ifdef _WINDOWS |
#ifdef _WINDOWS |
|
#ifdef __STDC__ |
static void WIN_ResetMaxSock(void) |
static void WIN_ResetMaxSock (void) |
|
#else /* __STDC__ */ |
|
static void WIN_ResetMaxSock () |
|
#endif /* __STDC__ */ |
{ |
{ |
SOCKET s ; |
SOCKET s ; |
SOCKET t_max = 0; |
SOCKET t_max = 0; |
|
|
for (s = 0 ; s <= maxfds; s++) { |
for (s = 0 ; s <= maxfds; s++) { |
if (FD_ISSET(s, &all_fds)) |
if (FD_ISSET(s, &all_fds)) { |
{ |
if (s > t_max) |
if (s > t_max) |
t_max = s ; |
t_max = s ; |
} /* scope */ |
} /* scope */ |
|
} /* for */ |
} /* for */ |
|
|
maxfds = t_max ; |
maxfds = t_max ; |
} |
} |
|
|
void WIN_ProcessSocketActivity (void) |
#ifdef __STDC__ |
|
void WIN_ProcessSocketActivity (void) |
|
#else /* __STDC__ */ |
|
void WIN_ProcessSocketActivity () |
|
#endif /* __STDC__ */ |
{ |
{ |
int active_sockets; |
int active_sockets; |
SOCKET s; |
SOCKET s; |
Line 801 void WIN_ProcessSocketActivity (
|
Line 803 void WIN_ProcessSocketActivity (
|
tv.tv_usec = 0; |
tv.tv_usec = 0; |
|
|
if (maxfds == 0) |
if (maxfds == 0) |
return; /* there are no active connections */ |
return; /* there are no active connections */ |
|
|
active_sockets = select(maxfds+1, &treadset, &twriteset, &texceptset, |
|
(struct timeval *) &tv); |
|
|
|
switch(active_sockets) { |
active_sockets = select(maxfds+1, &treadset, &twriteset, &texceptset, (struct timeval *) &tv); |
case 0: /* no activity - timeout - allowed */ |
|
return; |
|
break; |
|
|
|
case -1: /* error has occurred */ |
|
return; |
|
break; |
|
|
|
default: |
switch (active_sockets) { |
break; |
case 0: /* no activity - timeout - allowed */ |
|
case -1: /* error has occurred */ |
|
return; |
|
default: |
|
break; |
} /* switch */ |
} /* switch */ |
|
|
exceptions = 0; |
exceptions = 0; |
readings = 0; |
readings = 0; |
writings = 0; |
writings = 0; |
|
|
for (s = 0 ; s <= maxfds ; s++) |
for (s = 0 ; s <= maxfds ; s++) { |
{ |
if (FD_ISSET(s, &texceptset)) |
if (FD_ISSET(s, &texceptset)) |
exceptions++; |
exceptions++; |
if (FD_ISSET(s, &treadset)) |
if (FD_ISSET(s, &treadset)) |
readings++; |
readings++; |
if (FD_ISSET(s, &twriteset)) |
if (FD_ISSET(s, &twriteset)) |
writings++; |
writings++; |
} /* for */ |
} /* for */ |
|
|
if (exceptions) |
if (exceptions) { |
WIN_ProcessFds (&texceptset, FD_OOB); |
WIN_ProcessFds (&texceptset, FD_OOB); |
|
} |
|
|
|
if (readings) { |
|
WIN_ProcessFds (&treadset, FD_READ); |
|
} |
|
|
|
if (writings) { |
if (readings) |
WIN_ProcessFds (&twriteset, FD_WRITE); |
WIN_ProcessFds (&treadset, FD_READ); |
} |
|
|
if (writings) |
|
WIN_ProcessFds (&twriteset, FD_WRITE); |
} |
} |
|
|
void WIN_InitializeSockets (void) |
#ifdef __STDC__ |
|
void WIN_InitializeSockets (void) |
|
#else /* __STDC__ */ |
|
void WIN_InitializeSockets () |
|
#endif /* __STDC__ */ |
{ |
{ |
maxfds = 0 ; |
maxfds = 0 ; |
|
|
Line 854 void WIN_InitializeSockets (void
|
Line 850 void WIN_InitializeSockets (void
|
FD_ZERO(&write_fds); |
FD_ZERO(&write_fds); |
FD_ZERO(&except_fds) ; |
FD_ZERO(&except_fds) ; |
FD_ZERO(&all_fds); |
FD_ZERO(&all_fds); |
|
/* |
AHTEventInit (); |
AHTEventInit (); |
|
*/ |
} |
} |
|
|
|
#if 0 |
|
#ifdef __STDC__ |
static BOOL AHTEventInit (void) |
static BOOL AHTEventInit (void) |
|
#else /* __STDC__ */ |
|
static BOOL AHTEventInit () |
|
#endif /* __STDC__ */ |
{ |
{ |
/* |
/* |
** We are here starting a hidden window to take care of events from |
** We are here starting a hidden window to take care of events from |
** the async select() call in the async version of the event loop in |
** the async select() call in the async version of the event loop in |
** the Internal event manager (HTEvntrg.c) |
** the Internal event manager (HTEvntrg.c) |
*/ |
*/ |
static char className[] = "AsyncWindowClass"; |
static char className[] = "AsyncWindowClass"; |
WNDCLASS wc; |
WNDCLASS wc; |
OSVERSIONINFO osInfo; |
OSVERSIONINFO osInfo; |
WSADATA wsadata; |
WSADATA wsadata; |
|
|
wc.style=0; |
wc.style = 0; |
wc.lpfnWndProc=(WNDPROC)ASYNCWindowProc; |
wc.lpfnWndProc = (WNDPROC) ASYNCWindowProc; |
wc.cbClsExtra=0; |
wc.cbClsExtra = 0; |
wc.cbWndExtra=0; |
wc.cbWndExtra = 0; |
wc.hIcon=0; |
wc.hIcon = 0; |
wc.hCursor=0; |
wc.hCursor = 0; |
wc.hbrBackground=0; |
wc.hbrBackground = 0; |
wc.lpszMenuName=(LPSTR)0; |
wc.lpszMenuName = (LPSTR) 0; |
wc.lpszClassName=className; |
wc.lpszClassName = className; |
|
|
osInfo.dwOSVersionInfoSize = sizeof(osInfo); |
osInfo.dwOSVersionInfoSize = sizeof (osInfo); |
GetVersionEx(&osInfo); |
GetVersionEx (&osInfo); |
if (osInfo.dwPlatformId == VER_PLATFORM_WIN32s /*|| osInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS*/) |
if (osInfo.dwPlatformId == VER_PLATFORM_WIN32s || osInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) |
wc.hInstance=GetModuleHandle(NULL); /* 95 and non threaded platforms */ |
wc.hInstance = GetModuleHandle (NULL); /* 95 and non threaded platforms */ |
else |
else |
wc.hInstance=GetCurrentProcess(); /* NT and hopefully everything following */ |
wc.hInstance = GetCurrentProcess (); /* NT and hopefully everything following */ |
|
|
RegisterClass(&wc); |
RegisterClass (&wc); |
if (!(HTSocketWin = CreateWindow(className, "WWW_WIN_ASYNC", WS_POPUP, CW_USEDEFAULT, CW_USEDEFAULT, |
if (!(HTSocketWin = CreateWindow (className, "WWW_WIN_ASYNC", WS_POPUP, CW_USEDEFAULT, CW_USEDEFAULT, |
CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, wc.hInstance,0))) { |
CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, wc.hInstance,0))) { |
return NO; |
return NO; |
} |
} |
HTwinMsg = WM_USER; /* use first available message since app uses none */ |
HTwinMsg = WM_USER; /* use first available message since app uses none */ |
Line 896 static BOOL AHTEventInit (void)
|
Line 899 static BOOL AHTEventInit (void)
|
/* |
/* |
** Initialise WinSock DLL. This must also be shut down! PMH |
** Initialise WinSock DLL. This must also be shut down! PMH |
*/ |
*/ |
if (WSAStartup(DESIRED_WINSOCK_VERSION, &wsadata)) { |
if (WSAStartup (DESIRED_WINSOCK_VERSION, &wsadata)) { |
WSACleanup(); |
WSACleanup (); |
return NO; |
return NO; |
} |
} |
|
|
if (wsadata.wVersion < MINIMUM_WINSOCK_VERSION) { |
if (wsadata.wVersion < MINIMUM_WINSOCK_VERSION) { |
WSACleanup(); |
WSACleanup (); |
return NO; |
return NO; |
} |
} |
|
|
return YES; |
return YES; |
} |
} |
|
|
PUBLIC LRESULT CALLBACK ASYNCWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
#ifdef __STDC__ |
|
PUBLIC LRESULT CALLBACK ASYNCWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
|
#else /* __STDC__ */ |
|
PUBLIC LRESULT CALLBACK ASYNCWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
|
HWND hwnd; |
|
UINT uMsg; |
|
WPARAM wParam; |
|
LPARAM lParam; |
|
#endif /* __STDC__ */ |
{ |
{ |
WORD event; |
WORD event; |
SOCKET sock; |
SOCKET sock; |
|
|
if (uMsg != HTwinMsg) /* not our async message */ |
if (uMsg != HTwinMsg) /* not our async message */ |
return (DefWindowProc(hwnd, uMsg, wParam, lParam)); |
return (DefWindowProc (hwnd, uMsg, wParam, lParam)); |
|
|
event = LOWORD(lParam); |
event = LOWORD (lParam); |
sock = (SOCKET)wParam; |
sock = (SOCKET) wParam; |
|
|
if (event & (FD_READ | FD_ACCEPT | FD_CLOSE)) |
if (event & (FD_READ | FD_ACCEPT | FD_CLOSE)) |
WIN_AHTCallback_bridge (FD_READ, &sock); |
WIN_AHTCallback_bridge (FD_READ, &sock); |
|
|
if (event & (FD_WRITE | FD_CONNECT)) |
if (event & (FD_WRITE | FD_CONNECT)) |
WIN_AHTCallback_bridge (FD_WRITE, &sock); |
WIN_AHTCallback_bridge (FD_WRITE, &sock); |
|
|
if (event & FD_OOB) |
if (event & FD_OOB) |
WIN_AHTCallback_bridge (FD_OOB, &sock); |
WIN_AHTCallback_bridge (FD_OOB, &sock); |
|
|
return (0); |
return (0); |
} |
} |
|
|
static int WIN_ProcessFds( fd_set * fdsp, SockOps ops) |
#ifdef __STDC__ |
{ |
|
SOCKET s ; |
|
|
|
for (s = 0 ; s <= maxfds; s++) { |
|
if (FD_ISSET( s, fdsp)) |
|
{ |
|
WIN_AHTCallback_bridge (ops, &s); |
|
return; |
|
} |
|
} |
|
return HT_OK; |
|
} |
|
|
|
static int VerifySocketState (AHTReqContext *me, SOCKET sock) |
static int VerifySocketState (AHTReqContext *me, SOCKET sock) |
|
#else /* __STDC__ */ |
|
static int VerifySocketState (me, sock) |
|
AHTReqContext* me; |
|
SOCKET sock; |
|
#endif /* __STDC__ */ |
{ |
{ |
int fd_state = 0; |
int fd_state = 0; |
|
|
if (sock == me->read_sock) |
if (sock == me->read_sock) |
fd_state |= me->read_fd_state; |
fd_state |= me->read_fd_state; |
|
|
if (sock == me->write_sock) |
if (sock == me->write_sock) |
fd_state |= me->write_fd_state; |
fd_state |= me->write_fd_state; |
|
|
if (sock == me->except_sock) |
if (sock == me->except_sock) |
fd_state |= me->except_fd_state; |
fd_state |= me->except_fd_state; |
|
|
return (fd_state); |
return (fd_state); |
} |
} |
|
#endif /* 0 */ |
|
|
|
#ifdef __STDC__ |
|
static int WIN_ProcessFds (fd_set* fdsp, SockOps ops) |
|
#else /* __STDC__ */ |
|
static int WIN_ProcessFds (fdsp, ops) |
|
fd_set* fdsp; |
|
SockOps ops; |
|
#endif /* __STDC__ */ |
|
{ |
|
SOCKET s ; |
|
|
|
for (s = 0 ; s <= maxfds; s++) { |
|
if (FD_ISSET( s, fdsp)) { |
|
WIN_AHTCallback_bridge (ops, &s); |
|
return; |
|
} |
|
} |
|
return HT_OK; |
|
} |
#endif /* _WINDOWS */ |
#endif /* _WINDOWS */ |
/* |
|
End of Module AHTBridge.c |
|
*/ |
|
|
|
#endif /* !AMAYA_JAVA */ |
#endif /* !AMAYA_JAVA */ |
|
|
|
|