Annotation of parser3/src/main/pa_socks.C, revision 1.18.2.4

1.3       paf         1: /**    @file
1.1       paf         2:        Parser: socks initialization/finalization.
                      3: 
1.18.2.3  paf         4:        Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com)
1.13      paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.15      paf         6: */
1.1       paf         7: 
1.18.2.4! paf         8: static const char* IDENT_SOCKS_C="$Date: 2003/01/31 12:34:37 $";
1.2       paf         9: 
                     10: #define NO_UNISTD_H
                     11: #include "pa_config_includes.h"
1.1       paf        12: 
1.17      paf        13: #ifdef HAVE_WINSOCK_H
1.9       paf        14: #include "pa_exception.h"
                     15: #include "pa_socks.h"
1.18.2.2  paf        16: #include "pa_string.h"
1.11      paf        17: 
1.18.2.4! paf        18: #ifdef CYGWIN
        !            19: // for PASCAL
        !            20: #include <windows.h>
        !            21: // WSADATA
        !            22: #define WSADESCRIPTION_LEN     256
        !            23: #define WSASYS_STATUS_LEN      128
        !            24: typedef struct WSAData {
        !            25:        WORD    wVersion;
        !            26:        WORD    wHighVersion;
        !            27:        char    szDescription[WSADESCRIPTION_LEN+1];
        !            28:        char    szSystemStatus[WSASYS_STATUS_LEN+1];
        !            29:        unsigned short  iMaxSockets;
        !            30:        unsigned short  iMaxUdpDg;
        !            31:        char *  lpVendorInfo;
        !            32: } WSADATA;
        !            33: typedef WSADATA *LPWSADATA;
        !            34: 
        !            35: int PASCAL WSAStartup(WORD,LPWSADATA);
        !            36: int PASCAL WSACleanup(void);
        !            37: #endif
1.9       paf        38: 
1.1       paf        39: WSADATA wsaData;
                     40: 
1.18.2.1  paf        41: void pa_init_socks() {
1.1       paf        42:        WORD wVersionRequested;
                     43:        int err; 
                     44:        wVersionRequested = MAKEWORD( 1, 1 ); 
                     45:        //wVersionRequested = MAKEWORD( 2, 2 ); 
                     46:        err = WSAStartup( wVersionRequested, &wsaData );
                     47:        if ( err != 0 ) {
                     48:            /* Tell the user that we could not find a usable */
                     49:                /* WinSock DLL.                                  */    
1.14      paf        50:                throw Exception(0,
1.18.2.1  paf        51:                        Exception::undefined_source,
1.1       paf        52:                        "can not WSAStartup, err=%d", 
                     53:                                err);
                     54:        } 
                     55: }
                     56: 
1.18.2.1  paf        57: void pa_done_socks() {
1.1       paf        58:        /* Confirm that the WinSock DLL supports 2.2.*/
                     59:        /* Note that if the DLL supports versions greater    */
                     60:        /* than 2.2 in addition to 2.2, it will still return */
                     61:        /* 2.2 in wVersion since that is the version we      */
                     62:        /* requested.                                        */ 
                     63:        if ( LOBYTE( wsaData.wVersion ) == 2 ||
                     64:         HIBYTE( wsaData.wVersion ) == 2 ) {
                     65:                WSACleanup( );
                     66:                return; 
                     67:        } 
                     68: }
                     69: 
                     70: #else
1.10      paf        71: 
1.18.2.1  paf        72: void pa_init_socks() {}
                     73: void pa_done_socks() {}
1.1       paf        74: 
                     75: #endif

E-mail: