Back to index

lightning-sunbird  0.9+nobinonly
Defines | Typedefs | Enumerations | Functions | Variables
mozock.c File Reference
#include <windows.h>
#include <winsock.h>
#include <string.h>

Go to the source code of this file.

Defines

#define SZWINSOCK   "winsock.dll"
#define NON_BLOCKING(command, condition, index, type)

Typedefs

typedef unsigned int
typedef unsigned long
typedef fd_set FAR *typedef SOCKET (PASCAL FAR *sp_SOCKET_SOCKET_sockaddrFARp_intFARp)(SOCKET
typedef struct hostent *PASCAL
FAR
sp_hostentFARp_ccharFARp (const char FAR *)
typedef struct hostent *PASCAL
FAR
sp_hostentFARp_ccharFARp_int_int (const char FAR *, int, int)
typedef struct sockaddr int
FAR *typedef char FAR int FAR
*typedef 
u_long (PASCAL FAR *sp_ulong_ulong)(u_long)
typedef char FAR *PASCAL FARsp_charFARp_in_addr (struct in_addr in)
typedef struct protoent
*PASCAL FAR
sp_protoentFARcchar (const char FAR *)

Enumerations

enum  SockProc {
  sp_WSAAsyncGetHostByName = 0, sp_WSAAsyncSelect, sp_WSACleanup, sp_WSAGetLastError,
  sp_WSASetLastError, sp_WSAStartup, sp___WSAFDIsSet, sp_accept,
  sp_bind, sp_closesocket, sp_connect, sp_gethostbyname,
  sp_gethostbyaddr, sp_gethostname, sp_getpeername, sp_getsockname,
  sp_getsockopt, sp_getprotobyname, sp_htonl, sp_htons,
  sp_inet_addr, sp_ioctlsocket, sp_listen, sp_ntohl,
  sp_ntohs, sp_recv, sp_select, sp_send,
  sp_setsockopt, sp_shutdown, sp_socket, sp_inet_ntoa,
  sp_MaxProcs, sp_WSAAsyncGetHostByName = 0, sp_WSAAsyncSelect, sp_WSACleanup,
  sp_WSAGetLastError, sp_WSASetLastError, sp_WSAStartup, sp___WSAFDIsSet,
  sp_accept, sp_bind, sp_closesocket, sp_connect,
  sp_gethostbyname, sp_gethostbyaddr, sp_gethostname, sp_getpeername,
  sp_getsockname, sp_getsockopt, sp_getprotobyname, sp_htonl,
  sp_htons, sp_inet_addr, sp_ioctlsocket, sp_listen,
  sp_ntohl, sp_ntohs, sp_recv, sp_select,
  sp_send, sp_setsockopt, sp_shutdown, sp_socket,
  sp_inet_ntoa, sp_MaxProcs
}

Functions

typedef int (PASCAL FAR *sp_int_WORD_LPWSADATA)(WORD
typedef HANDLE (PASCAL FAR *sp_HANDLE_HWND_uint_ccharFARp_charFARp_int)(HWND
typedef void (PASCAL FAR *sp_void_int)(int)
typedef u_short (PASCAL FAR *sp_ushort_ushort)(u_short)
typedef SOCKET (PASCAL FAR *sp_SOCKET_int_int_int)(int
BOOL IsWinsockLoaded (int sp)
int PASCAL FAR WSAStartup (WORD wVersionRequested, LPWSADATA lpWSAData)
int PASCAL FAR WSACleanup (void)
HANDLE PASCAL FAR WSAAsyncGetHostByName (HWND hWnd, unsigned int wMsg, const char FAR *name, char FAR *buf, int buflen)
int PASCAL FAR WSAAsyncSelect (SOCKET s, HWND hWnd, unsigned int wMsg, long lEvent)
int PASCAL FAR WSAGetLastError (void)
void PASCAL FAR WSASetLastError (int iError)
int PASCAL FAR __WSAFDIsSet (SOCKET fd, fd_set FAR *set)
SOCKET PASCAL FAR accept (SOCKET s, struct sockaddr FAR *addr, int FAR *addrlen)
int PASCAL FAR bind (SOCKET s, const struct sockaddr FAR *name, int namelen)
int PASCAL FAR closesocket (SOCKET s)
int PASCAL FAR connect (SOCKET s, const struct sockaddr FAR *name, int namelen)
struct hostent *PASCAL FAR gethostbyname (const char FAR *name)
struct hostent *PASCAL FAR gethostbyaddr (const char FAR *addr, int len, int type)
int PASCAL FAR gethostname (char FAR *name, int namelen)
int PASCAL FAR getpeername (SOCKET s, struct sockaddr FAR *name, int FAR *namelen)
int PASCAL FAR getsockname (SOCKET s, struct sockaddr FAR *name, int FAR *namelen)
int PASCAL FAR getsockopt (SOCKET s, int level, int optname, char FAR *optval, int FAR *optlen)
struct protoent *PASCAL getprotobyname (const char FAR *name)
u_long PASCAL FAR htonl (u_long hostlong)
u_short PASCAL FAR htons (u_short hostshort)
u_long PASCAL FAR ntohl (u_long hostlong)
u_short PASCAL FAR ntohs (u_short hostshort)
unsigned long PASCAL FAR inet_addr (const char FAR *cp)
int PASCAL FAR ioctlsocket (SOCKET s, long cmd, u_long FAR *argp)
int PASCAL FAR listen (SOCKET s, int backlog)
int PASCAL FAR recv (SOCKET s, char FAR *buf, int len, int flags)
int PASCAL FAR select (int nfds, fd_set FAR *readfds, fd_set FAR *writefds, fd_set FAR *exceptfds, const struct timeval FAR *timeout)
int PASCAL FAR send (SOCKET s, const char FAR *buf, int len, int flags)
int PASCAL FAR setsockopt (SOCKET s, int level, int optname, const char FAR *optval, int optlen)
int PASCAL FAR shutdown (SOCKET s, int how)
SOCKET PASCAL FAR socket (int af, int type, int protocol)
char FAR *PASCAL FAR inet_ntoa (struct in_addr in)

Variables

char * spName [(int) sp_MaxProcs]
FARPROC spArray [(int) sp_MaxProcs]
typedef LPWSADATA
typedef HWND
HINSTANCE hWinsock = NULL
int ispError = 0

Define Documentation

#define NON_BLOCKING (   command,
  condition,
  index,
  type 
)
Value:
if(IsWinsockLoaded(index)) {                                         \
       return command;                                               \
    }

Definition at line 235 of file mozock.c.

#define SZWINSOCK   "winsock.dll"

Definition at line 52 of file mozock.c.


Typedef Documentation

typedef int [read, abstract]

Definition at line 149 of file mozock.c.

typedef long

Definition at line 150 of file mozock.c.

typedef fd_set FAR* typedef SOCKET(PASCAL FAR *sp_SOCKET_SOCKET_sockaddrFARp_intFARp)(SOCKET

Definition at line 153 of file mozock.c.

typedef char FAR* PASCAL FAR* sp_charFARp_in_addr(struct in_addr in)

Definition at line 171 of file mozock.c.

typedef struct hostent* PASCAL FAR* sp_hostentFARp_ccharFARp(const char FAR *)

Definition at line 156 of file mozock.c.

Definition at line 157 of file mozock.c.

typedef struct protoent* PASCAL FAR* sp_protoentFARcchar(const char FAR *)

Definition at line 172 of file mozock.c.

typedef struct sockaddr int FAR* typedef char FAR int FAR* typedef u_long(PASCAL FAR *sp_ulong_ulong)(u_long)

Definition at line 161 of file mozock.c.


Enumeration Type Documentation

enum SockProc
Enumerator:
sp_WSAAsyncGetHostByName 
sp_WSAAsyncSelect 
sp_WSACleanup 
sp_WSAGetLastError 
sp_WSASetLastError 
sp_WSAStartup 
sp___WSAFDIsSet 
sp_accept 
sp_bind 
sp_closesocket 
sp_connect 
sp_gethostbyname 
sp_gethostbyaddr 
sp_gethostname 
sp_getpeername 
sp_getsockname 
sp_getsockopt 
sp_getprotobyname 
sp_htonl 
sp_htons 
sp_inet_addr 
sp_ioctlsocket 
sp_listen 
sp_ntohl 
sp_ntohs 
sp_recv 
sp_select 
sp_send 
sp_setsockopt 
sp_shutdown 
sp_socket 
sp_inet_ntoa 
sp_MaxProcs 
sp_WSAAsyncGetHostByName 
sp_WSAAsyncSelect 
sp_WSACleanup 
sp_WSAGetLastError 
sp_WSASetLastError 
sp_WSAStartup 
sp___WSAFDIsSet 
sp_accept 
sp_bind 
sp_closesocket 
sp_connect 
sp_gethostbyname 
sp_gethostbyaddr 
sp_gethostname 
sp_getpeername 
sp_getsockname 
sp_getsockopt 
sp_getprotobyname 
sp_htonl 
sp_htons 
sp_inet_addr 
sp_ioctlsocket 
sp_listen 
sp_ntohl 
sp_ntohs 
sp_recv 
sp_select 
sp_send 
sp_setsockopt 
sp_shutdown 
sp_socket 
sp_inet_ntoa 
sp_MaxProcs 

Definition at line 61 of file mozock.c.


Function Documentation

int PASCAL FAR __WSAFDIsSet ( SOCKET  fd,
fd_set FAR set 
)

Definition at line 401 of file mozock.c.

                                                        {
       int i;

       //     See if someone else will handle.
       if(IsWinsockLoaded(sp___WSAFDIsSet))      {
              return(((sp_int_SOCKET_fdsetFARp)spArray[sp___WSAFDIsSet])(fd, set));
       }

       //     Default implementation.
       i = set->fd_count;
       while (i--)   {
              if (set->fd_array[i] == fd) {
                     return 1;
              }
       }
       return 0;
}

Here is the call graph for this function:

SOCKET PASCAL FAR accept ( SOCKET  s,
struct sockaddr FAR addr,
int FAR addrlen 
)

Definition at line 419 of file mozock.c.

                                                                                {
       //     Internally or shim
       NON_BLOCKING(
           (((sp_SOCKET_SOCKET_sockaddrFARp_intFARp)spArray[sp_accept])(s, addr, addrlen)),
           FD_ACCEPT, sp_accept, SOCKET);

       //     Fail.
       WSASetLastError(WSAENETDOWN);
       return(INVALID_SOCKET);
}

Here is the call graph for this function:

int PASCAL FAR bind ( SOCKET  s,
const struct sockaddr FAR name,
int  namelen 
)

Definition at line 430 of file mozock.c.

                                                                             {
       //     Internally or shim
       if(IsWinsockLoaded(sp_bind))       {
              return(((sp_int_SOCKET_csockaddrFARp_int)spArray[sp_bind])(s, name, namelen));
       }

       //     Fail.
       WSASetLastError(WSAENETDOWN);
       return(SOCKET_ERROR);
}

Here is the call graph for this function:

Definition at line 441 of file mozock.c.

                                          {
       //     Internally or shim.
       NON_BLOCKING(
           (((sp_int_SOCKET)spArray[sp_closesocket])(s)),
           FD_CLOSE, sp_closesocket, int);

       //     Error.
       WSASetLastError(WSAENETDOWN);
       return(SOCKET_ERROR);
}

Here is the call graph for this function:

int PASCAL FAR connect ( SOCKET  s,
const struct sockaddr FAR name,
int  namelen 
)

Definition at line 452 of file mozock.c.

                                                                                    {
       //     Internally or shim.
       if(IsWinsockLoaded(sp_connect)) {
              /* This could block and so it would seem that the NON_BLOCK
               * macro should be used here.  However it was causing a crash
               * and so it was decided to allow blocking here instead
               */
              return (((sp_int_SOCKET_csockaddrFARp_int)spArray[sp_connect])(s, name, namelen));
       }

       //     Err.
       WSASetLastError(WSAENETDOWN);
       return(SOCKET_ERROR);
}

Here is the call graph for this function:

struct hostent* PASCAL FAR gethostbyaddr ( const char FAR addr,
int  len,
int  type 
) [read, abstract]

Definition at line 476 of file mozock.c.

Here is the call graph for this function:

struct hostent* PASCAL FAR gethostbyname ( const char FAR name) [read, abstract]

Definition at line 467 of file mozock.c.

Here is the call graph for this function:

int PASCAL FAR gethostname ( char FAR name,
int  namelen 
)

Definition at line 485 of file mozock.c.

                                                        {
       if(IsWinsockLoaded(sp_gethostname))       {
              return(((sp_int_charFARp_int)spArray[sp_gethostname])(name, namelen));
       }

       WSASetLastError(WSAENETDOWN);
       return(SOCKET_ERROR);
}

Here is the call graph for this function:

int PASCAL FAR getpeername ( SOCKET  s,
struct sockaddr FAR name,
int FAR namelen 
)

Definition at line 494 of file mozock.c.

                                                                                    {
       if(IsWinsockLoaded(sp_getpeername))       {
              return(((sp_int_SOCKET_sockaddrFARp_intFARp)spArray[sp_getpeername])(s, name, namelen));
       }

       WSASetLastError(WSAENETDOWN);
       return(SOCKET_ERROR);
}

Here is the call graph for this function:

struct protoent* PASCAL getprotobyname ( const char FAR name) [read, abstract]

Definition at line 521 of file mozock.c.

Here is the call graph for this function:

int PASCAL FAR getsockname ( SOCKET  s,
struct sockaddr FAR name,
int FAR namelen 
)

Definition at line 503 of file mozock.c.

                                                                                    {
       if(IsWinsockLoaded(sp_getsockname))       {
              return(((sp_int_SOCKET_sockaddrFARp_intFARp)spArray[sp_getsockname])(s, name, namelen));
       }

       WSASetLastError(WSAENETDOWN);
       return(SOCKET_ERROR);
}

Here is the call graph for this function:

int PASCAL FAR getsockopt ( SOCKET  s,
int  level,
int  optname,
char FAR optval,
int FAR optlen 
)

Definition at line 512 of file mozock.c.

                                                                                                  {
       if(IsWinsockLoaded(sp_getsockopt)) {
              return(((sp_int_SOCKET_int_int_charFARp_intFARp)spArray[sp_getsockopt])(s, level, optname, optval, optlen));
       }

       WSASetLastError(WSAENETDOWN);
       return(SOCKET_ERROR);
}

Here is the call graph for this function:

typedef HANDLE ( PASCAL FAR sp_HANDLE_HWND_uint_ccharFARp_charFARp_int)
u_long PASCAL FAR htonl ( u_long  hostlong)

Definition at line 530 of file mozock.c.

                                          {
       if(IsWinsockLoaded(sp_htonl))      {
              return(((sp_ulong_ulong)spArray[sp_htonl])(hostlong));
       }

#ifndef _WIN32
       return
           (((hostlong&0xff)<<24) + ((hostlong&0xff00)<<8) +
            ((hostlong&0xff0000)>>8) + ((hostlong&0xff000000)>>24));

#else
       //     Just return what was passed in.
       return(hostlong);
#endif
}

Here is the call graph for this function:

u_short PASCAL FAR htons ( u_short  hostshort)

Definition at line 546 of file mozock.c.

                                                 {
       if(IsWinsockLoaded(sp_htons))      {
              return(((sp_ushort_ushort)spArray[sp_htons])(hostshort));
       }

#ifndef _WIN32
       return (((hostshort&0xff)<<8) + ((hostshort&0xff00)>>8));

#else
       //     Just return what was passed in.
       return(hostshort);
#endif
}

Here is the call graph for this function:

unsigned long PASCAL FAR inet_addr ( const char FAR cp)

Definition at line 590 of file mozock.c.

                                                        {
       if(IsWinsockLoaded(sp_inet_addr))  {
              return(((sp_ulong_ccharFARp)spArray[sp_inet_addr])(cp));
       }

       return(INADDR_NONE);
}

Here is the call graph for this function:

char FAR* PASCAL FAR inet_ntoa ( struct in_addr  in)

Definition at line 678 of file mozock.c.

Here is the call graph for this function:

typedef int ( PASCAL FAR sp_int_WORD_LPWSADATA)
int PASCAL FAR ioctlsocket ( SOCKET  s,
long  cmd,
u_long FAR argp 
)

Definition at line 598 of file mozock.c.

                                                                      {
       if(IsWinsockLoaded(sp_ioctlsocket))       {
              return(((sp_int_SOCKET_long_ulongFARp)spArray[sp_ioctlsocket])(s, cmd, argp));
       }

       WSASetLastError(WSAENETDOWN);
       return(SOCKET_ERROR);
}

Here is the call graph for this function:

Definition at line 183 of file mozock.c.

{
       if (hWinsock == NULL)
       {
              WSADATA wsaData;
              WSAStartup(0x0101, &wsaData);
       }
//     Quick macro to tell if the winsock has actually loaded for a particular
//            function.
//  Debug version is a little more strict to make sure you get the names right.
#ifdef DEBUG
       return hWinsock != NULL && spArray[(int)(sp)] != NULL;
#else //  A little faster
       return hWinsock != NULL;
#endif
}

Here is the call graph for this function:

int PASCAL FAR listen ( SOCKET  s,
int  backlog 
)

Definition at line 607 of file mozock.c.

                                                 {
       if(IsWinsockLoaded(sp_listen))     {
              return(((sp_int_SOCKET_int)spArray[sp_listen])(s, backlog));
       }

       WSASetLastError(WSAENETDOWN);
       return(SOCKET_ERROR);
}

Here is the call graph for this function:

u_long PASCAL FAR ntohl ( u_long  hostlong)

Definition at line 560 of file mozock.c.

                                          {
       if(IsWinsockLoaded(sp_ntohl))      {
              return(((sp_ulong_ulong)spArray[sp_ntohl])(hostlong));
       }

#ifndef _WIN32
       return
           (((hostlong&0xff)<<24) + ((hostlong&0xff00)<<8) +
            ((hostlong&0xff0000)>>8) + ((hostlong&0xff000000)>>24));

#else
       //     Just return what was passed in.
       return(hostlong);
#endif
}

Here is the call graph for this function:

u_short PASCAL FAR ntohs ( u_short  hostshort)

Definition at line 576 of file mozock.c.

                                                 {
       if(IsWinsockLoaded(sp_ntohs))      {
              return(((sp_ushort_ushort)spArray[sp_ntohs])(hostshort));
       }

#ifndef _WIN32
       return (((hostshort&0xff)<<8) + ((hostshort&0xff00)>>8));

#else
       //     Just return what was passed in.
       return(hostshort);
#endif
}

Here is the call graph for this function:

int PASCAL FAR recv ( SOCKET  s,
char FAR buf,
int  len,
int  flags 
)

Definition at line 616 of file mozock.c.

                                                                      {
       NON_BLOCKING(
           (((sp_int_SOCKET_charFARp_int_int)spArray[sp_recv])(s, buf, len, flags)),
           FD_READ, sp_recv, int);

       WSASetLastError(WSAENETDOWN);
       return(SOCKET_ERROR);
}

Here is the call graph for this function:

int PASCAL FAR select ( int  nfds,
fd_set FAR readfds,
fd_set FAR writefds,
fd_set FAR exceptfds,
const struct timeval FAR timeout 
)

Definition at line 625 of file mozock.c.

                                                                                                                                     {
    //  If there's nothing to do, stop now before we go off into dll land.
    // Optimization, boyz.
    if((readfds && readfds->fd_count) || (writefds && writefds->fd_count) || (exceptfds && exceptfds->fd_count))    {
           if(IsWinsockLoaded(sp_select)) {
                     return(((sp_int_int_fdsetFARp_fdsetFARp_fdsetFARp_ctimevalFARp)spArray[sp_select])(nfds,readfds,writefds,exceptfds,timeout));
           }

           WSASetLastError(WSAENETDOWN);
           return(SOCKET_ERROR);
    }

    // No need to go to the DLL, there is nothing to do.
    return(0);
}

Here is the call graph for this function:

int PASCAL FAR send ( SOCKET  s,
const char FAR buf,
int  len,
int  flags 
)

Definition at line 641 of file mozock.c.

                                                                             {
       NON_BLOCKING(

           (((sp_int_SOCKET_ccharFARp_int_int)spArray[sp_send])(s, buf, len, flags)),
           FD_WRITE, sp_send, int);

       WSASetLastError(WSAENETDOWN);
       return(SOCKET_ERROR);
}

Here is the call graph for this function:

int PASCAL FAR setsockopt ( SOCKET  s,
int  level,
int  optname,
const char FAR optval,
int  optlen 
)

Definition at line 651 of file mozock.c.

                                                                                                {
       if(IsWinsockLoaded(sp_setsockopt)) {
              return(((sp_int_SOCKET_int_int_ccharFARp_int)spArray[sp_setsockopt])(s, level, optname, optval, optlen));
       }

       WSASetLastError(WSAENETDOWN);
       return(SOCKET_ERROR);
}

Here is the call graph for this function:

int PASCAL FAR shutdown ( SOCKET  s,
int  how 
)

Definition at line 660 of file mozock.c.

                                                 {
       if(IsWinsockLoaded(sp_shutdown))   {
              return(((sp_int_SOCKET_int)spArray[sp_shutdown])(s, how));
       }

       WSASetLastError(WSAENETDOWN);
       return(SOCKET_ERROR);
}

Here is the call graph for this function:

typedef SOCKET ( PASCAL FAR sp_SOCKET_int_int_int)
SOCKET PASCAL FAR socket ( int  af,
int  type,
int  protocol 
)

Definition at line 669 of file mozock.c.

                                                               {
       if(IsWinsockLoaded(sp_socket))     {
              return(((sp_SOCKET_int_int_int)spArray[sp_socket])(af, type, protocol));
       }

       WSASetLastError(WSAENETDOWN);
       return(INVALID_SOCKET);
}

Here is the call graph for this function:

typedef u_short ( PASCAL FAR sp_ushort_ushort)
typedef void ( PASCAL FAR sp_void_int)
HANDLE PASCAL FAR WSAAsyncGetHostByName ( HWND  hWnd,
unsigned int  wMsg,
const char FAR name,
char FAR buf,
int  buflen 
)

Definition at line 341 of file mozock.c.

                                                                                                                       {
       // Normal or shim.
       if(IsWinsockLoaded(sp_WSAAsyncGetHostByName))    {
              return(((sp_HANDLE_HWND_uint_ccharFARp_charFARp_int)spArray[sp_WSAAsyncGetHostByName])(hWnd, wMsg, name, buf, buflen));
       }

       //     Must return error here.
       //     Set our last error value to be that the net is down.
       WSASetLastError(WSAENETDOWN);
       return(NULL);
}

Here is the call graph for this function:

int PASCAL FAR WSAAsyncSelect ( SOCKET  s,
HWND  hWnd,
unsigned int  wMsg,
long  lEvent 
)

Definition at line 353 of file mozock.c.

                                                                                    {
       //     Normal or shim.
       if(IsWinsockLoaded(sp_WSAAsyncSelect))    {
              return(((sp_int_SOCKET_HWND_uint_long)spArray[sp_WSAAsyncSelect])(s, hWnd, wMsg, lEvent));
       }

       //     Must return error here.
       WSASetLastError(WSAENETDOWN);
       return(SOCKET_ERROR);
}

Here is the call graph for this function:

Definition at line 315 of file mozock.c.

                                {
       int iRetval = 0;

       //     Handling normally or internally.
       // When IsWinsockLoaded() is called and hWinsock is NULL, it winds up calling WSAStartup
       // which wedges rpcrt4.dll on win95 with some winsock implementations. Bug: 81359.
       if(hWinsock && IsWinsockLoaded(sp_WSACleanup))   {
              //     Call their cleanup routine.
              //     We could set the return value here, but it is meaning less.
              //     We always return success.
              iRetval = ((sp_int_void)spArray[sp_WSACleanup])();
              //ASSERT(iRetval == 0);
              iRetval = 0;
       }

       //     Wether or not it succeeded, we free off the library here.
       //     Clear out our proc table too.
       memset(spArray, 0, sizeof(spArray));
       if(hWinsock != NULL) {
              FreeLibrary(hWinsock);
              hWinsock = NULL;
       }

       return(iRetval);
}

Here is the call graph for this function:

Definition at line 364 of file mozock.c.

                                          {
       //     See if someone else can handle.
       if(IsWinsockLoaded(sp_WSAGetLastError)) {
              return(((sp_int_void)spArray[sp_WSAGetLastError])());
       }

#ifndef _WIN32
       {
              //     Fake it.
              int iRetval = ispError;
              ispError = 0;
              return(iRetval);
       }
#else
       //     Use default OS handler.
       return(GetLastError());
#endif
}

Here is the call graph for this function:

Definition at line 383 of file mozock.c.

                                                 {
       //     See if someone else can handle.
       if(IsWinsockLoaded(sp_WSASetLastError)) {
              ((sp_void_int)spArray[sp_WSASetLastError])(iError);
              return;
       }

#ifndef _WIN32
       //     Fake it.
       ispError = iError;
       return;
#else
       //     Use default OS handler.
       SetLastError(iError);
       return;
#endif
}

Here is the call graph for this function:

int PASCAL FAR WSAStartup ( WORD  wVersionRequested,
LPWSADATA  lpWSAData 
)

Definition at line 241 of file mozock.c.

                                                                             {
       //     Our default return value is failure, though we change this regardless.
       int iRetval = WSAVERNOTSUPPORTED;

       //     Before doing anything, clear out our proc array.
       memset(spArray, 0, sizeof(spArray));

       //     attempt to load the real winsock.
       hWinsock = LoadLibrary(SZWINSOCK);
#ifdef _WIN32
       if(hWinsock != NULL) {
#else
       if(hWinsock > HINSTANCE_ERROR)     {
#endif
              //     Winsock was loaded.
              //     Get the proc addresses for each needed function next.
              int spTraverse;
              for(spTraverse = 0; spTraverse < (int)sp_MaxProcs; spTraverse++)      {
                     spArray[spTraverse] = GetProcAddress(hWinsock, spName[spTraverse]);
                     if ( NULL == spArray[spTraverse] )
                            return iRetval;//    Bad winsock?  Bad function name?
              }

              //     AllRight, attempt to make our first proxied call.
              if(IsWinsockLoaded(sp_WSAStartup)) {
                     iRetval = ((sp_int_WORD_LPWSADATA)spArray[sp_WSAStartup])(wVersionRequested, lpWSAData);
              }

              //     If the return value is still an error at this point, we unload the DLL,
              //            so that we can act as though nothing happened and the user
              //            gets no network access.
              if(iRetval != 0)     {
                     //     Clear out our proc array.
                     memset(spArray, 0, sizeof(spArray));

                     //     Free up the winsock.
                     FreeLibrary(hWinsock);
                     hWinsock = NULL;
              }
       }
#ifndef _WIN32
       else   {
              //     Failed to load.
              //     Set this to NULL so it is clear.
              hWinsock = NULL;
       }
#endif

        //      Check our return value, if it isn't success, then we need to fake
       //            our own winsock implementation.
       if(iRetval != 0)     {
              //     We always return success.
              iRetval = 0;

              //     Fill in the structure.
              //     Return the version requested as the version supported.
              lpWSAData->wVersion = wVersionRequested;
              lpWSAData->wHighVersion = wVersionRequested;

              //     Fill in a discription.
                strcpy(lpWSAData->szDescription, "Mozock DLL internal implementation.");
                strcpy(lpWSAData->szSystemStatus, "Winsock running, allowing no network access.");

              //     Report a nice round number for sockets and datagram sizes.
              lpWSAData->iMaxSockets = 4096;
              lpWSAData->iMaxUdpDg = 4096;

              //     No vendor information.
              lpWSAData->lpVendorInfo = NULL;
       }

       return(iRetval);
}

Here is the call graph for this function:


Variable Documentation

Definition at line 175 of file mozock.c.

typedef HWND

Definition at line 150 of file mozock.c.

Definition at line 179 of file mozock.c.

typedef LPWSADATA

Definition at line 147 of file mozock.c.

Definition at line 140 of file mozock.c.

Definition at line 101 of file mozock.c.