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

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

E-mail: