Annotation of sbbs/xpdev/sockwrap.h, revision 1.1

1.1     ! root        1: /* sockwrap.h */
        !             2: 
        !             3: /* Berkley/WinSock socket API wrappers */
        !             4: 
        !             5: /* $Id: sockwrap.h,v 1.25 2004/11/03 06:05:49 rswindell Exp $ */
        !             6: 
        !             7: /****************************************************************************
        !             8:  * @format.tab-size 4          (Plain Text/Source Code File Header)                    *
        !             9:  * @format.use-tabs true       (see http://www.synchro.net/ptsc_hdr.html)              *
        !            10:  *                                                                                                                                                     *
        !            11:  * Copyright 2004 Rob Swindell - http://www.synchro.net/copyright.html         *
        !            12:  *                                                                                                                                                     *
        !            13:  * This library is free software; you can redistribute it and/or                       *
        !            14:  * modify it under the terms of the GNU Lesser General Public License          *
        !            15:  * as published by the Free Software Foundation; either version 2                      *
        !            16:  * of the License, or (at your option) any later version.                                      *
        !            17:  * See the GNU Lesser General Public License for more details: lgpl.txt or     *
        !            18:  * http://www.fsf.org/copyleft/lesser.html                                                                     *
        !            19:  *                                                                                                                                                     *
        !            20:  * Anonymous FTP access to the most recent released source is available at     *
        !            21:  * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net     *
        !            22:  *                                                                                                                                                     *
        !            23:  * Anonymous CVS access to the development source and modification history     *
        !            24:  * is available at cvs.synchro.net:/cvsroot/sbbs, example:                                     *
        !            25:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs login                       *
        !            26:  *     (just hit return, no password is necessary)                                                     *
        !            27:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src                *
        !            28:  *                                                                                                                                                     *
        !            29:  * For Synchronet coding style and modification guidelines, see                                *
        !            30:  * http://www.synchro.net/source.html                                                                          *
        !            31:  *                                                                                                                                                     *
        !            32:  * You are encouraged to submit any modifications (preferably in Unix diff     *
        !            33:  * format) via e-mail to [email protected]                                                                      *
        !            34:  *                                                                                                                                                     *
        !            35:  * Note: If this box doesn't appear square, then you need to fix your tabs.    *
        !            36:  ****************************************************************************/
        !            37: 
        !            38: #ifndef _SOCKWRAP_H
        !            39: #define _SOCKWRAP_H
        !            40: 
        !            41: #include "gen_defs.h"  /* BOOL */
        !            42: 
        !            43: /***************/
        !            44: /* OS-specific */
        !            45: /***************/
        !            46: #if defined(_WIN32)            /* Use WinSock */
        !            47: 
        !            48: #include <winsock.h>   /* socket/bind/etc. */
        !            49: 
        !            50: /* Let's agree on a standard WinSock symbol here, people */
        !            51: #ifndef _WINSOCKAPI_
        !            52: #define _WINSOCKAPI_   
        !            53: #endif
        !            54: 
        !            55: #elif defined __unix__         /* Unix-variant */
        !            56:                                                        
        !            57: #include <netdb.h>                     /* gethostbyname */
        !            58: #include <sys/types.h>         /* For u_int32_t on FreeBSD */
        !            59: #include <netinet/in.h>                /* IPPROTO_IP */
        !            60: /* define _BSD_SOCKLEN_T_ in order to define socklen_t on darwin */
        !            61: #ifdef __DARWIN__
        !            62: #define _BSD_SOCKLEN_T_        int
        !            63: #endif
        !            64: #include <sys/socket.h>                /* socket/bind/etc. */
        !            65: #include <sys/time.h>          /* struct timeval */
        !            66: #include <arpa/inet.h>         /* inet_ntoa */
        !            67: #include <netinet/tcp.h>       /* TCP_NODELAY */
        !            68: #include <unistd.h>                    /* close */
        !            69: #if defined(__solaris__)
        !            70:        #include <sys/filio.h>  /* FIONBIO */
        !            71:        #define INADDR_NONE -1L
        !            72: #else
        !            73:        #include <sys/ioctl.h>  /* FIONBIO */
        !            74: #endif
        !            75: 
        !            76: #endif
        !            77: 
        !            78: #include <errno.h>             /* errno */
        !            79: 
        !            80: /**********************************/
        !            81: /* Socket Implementation-specific */
        !            82: /**********************************/
        !            83: #if defined(_WINSOCKAPI_)
        !            84: 
        !            85: #undef  EINTR
        !            86: #define EINTR                  (WSAEINTR-WSABASEERR)
        !            87: #undef  ENOTSOCK
        !            88: #define ENOTSOCK               (WSAENOTSOCK-WSABASEERR)
        !            89: #undef  EMSGSIZE
        !            90: #define EMSGSIZE               (WSAEMSGSIZE-WSABASEERR)
        !            91: #undef  EWOULDBLOCK
        !            92: #define EWOULDBLOCK            (WSAEWOULDBLOCK-WSABASEERR)
        !            93: 
        !            94: #define EPROTOTYPE             (WSAEPROTOTYPE-WSABASEERR)
        !            95: #define ENOPROTOOPT            (WSAENOPROTOOPT-WSABASEERR)
        !            96: #define EPROTONOSUPPORT        (WSAEPROTONOSUPPORT-WSABASEERR)
        !            97: #define ESOCKTNOSUPPORT        (WSAESOCKTNOSUPPORT-WSABASEERR)
        !            98: #define EOPNOTSUPP             (WSAEOPNOTSUPP-WSABASEERR)
        !            99: #define EPFNOSUPPORT   (WSAEPFNOSUPPORT-WSABASEERR)
        !           100: #define EAFNOSUPPORT   (WSAEAFNOSUPPORT-WSABASEERR)
        !           101: 
        !           102: #undef  EADDRINUSE
        !           103: #define EADDRINUSE             (WSAEADDRINUSE-WSABASEERR)
        !           104: #undef  EADDRNOTAVAIL
        !           105: #define EADDRNOTAVAIL  (WSAEADDRNOTAVAIL-WSABASEERR)
        !           106: #undef  ECONNABORTED
        !           107: #define ECONNABORTED   (WSAECONNABORTED-WSABASEERR)
        !           108: #undef  ECONNRESET
        !           109: #define ECONNRESET             (WSAECONNRESET-WSABASEERR)
        !           110: #undef  ENOBUFS
        !           111: #define ENOBUFS                        (WSAENOBUFS-WSABASEERR)
        !           112: #undef  EISCONN
        !           113: #define EISCONN                        (WSAEISCONN-WSABASEERR)
        !           114: #undef  ENOTCONN
        !           115: #define ENOTCONN               (WSAENOTCONN-WSABASEERR)
        !           116: #undef  ESHUTDOWN
        !           117: #define ESHUTDOWN              (WSAESHUTDOWN-WSABASEERR)
        !           118: #undef  ETIMEDOUT
        !           119: #define ETIMEDOUT              (WSAETIMEDOUT-WSABASEERR)
        !           120: #undef  ECONNREFUSED
        !           121: #define ECONNREFUSED   (WSAECONNREFUSED-WSABASEERR)
        !           122: #undef EINPROGRESS
        !           123: #define EINPROGRESS            (WSAEINPROGRESS-WSABASEERR)
        !           124: 
        !           125: #define s_addr                 S_un.S_addr
        !           126: 
        !           127: #define socklen_t              int
        !           128: 
        !           129: static  wsa_error;
        !           130: #define ERROR_VALUE            ((wsa_error=WSAGetLastError())>0 ? wsa_error-WSABASEERR : wsa_error)
        !           131: #define sendsocket(s,b,l)      send(s,b,l,0)
        !           132: 
        !           133: #else  /* BSD sockets */
        !           134: 
        !           135: /* WinSock-isms */
        !           136: #define HOSTENT                        struct hostent
        !           137: #define IN_ADDR                        struct in_addr
        !           138: #define SOCKADDR               struct sockaddr
        !           139: #define SOCKADDR_IN            struct sockaddr_in
        !           140: #define LINGER                 struct linger
        !           141: #define SOCKET                 int
        !           142: #define SOCKET_ERROR   -1
        !           143: #define INVALID_SOCKET  (SOCKET)(~0)
        !           144: #define closesocket            close
        !           145: #define ioctlsocket            ioctl
        !           146: #define ERROR_VALUE            errno
        !           147: #define sendsocket             write           /* FreeBSD send() is broken */
        !           148: 
        !           149: #endif /* __unix__ */
        !           150: 
        !           151: #ifdef __cplusplus
        !           152: extern "C" {
        !           153: #endif
        !           154: 
        !           155: int            sendfilesocket(int sock, int file, long *offset, long count);
        !           156: int            recvfilesocket(int sock, int file, long *offset, long count);
        !           157: BOOL   socket_check(SOCKET sock, BOOL* rd_p, BOOL* wr_p, DWORD timeout);
        !           158: int    retry_bind(SOCKET s, const struct sockaddr *addr, socklen_t addrlen
        !           159:                                   ,uint retries, uint wait_secs, const char* prot
        !           160:                                   ,int (*lprintf)(int level, char *fmt, ...));
        !           161: 
        !           162: #ifdef __cplusplus
        !           163: }
        !           164: #endif
        !           165: 
        !           166: #ifndef SHUT_RDWR
        !           167: #define SHUT_RDWR              2       /* for shutdown() */
        !           168: #endif
        !           169: 
        !           170: #ifndef IPPORT_HTTP
        !           171: #define IPPORT_HTTP            80
        !           172: #endif
        !           173: #ifndef IPPORT_FTP
        !           174: #define IPPORT_FTP             21
        !           175: #endif
        !           176: #ifndef IPPORT_TELNET
        !           177: #define IPPORT_TELNET  23
        !           178: #endif
        !           179: #ifndef IPPORT_SMTP
        !           180: #define IPPORT_SMTP            25
        !           181: #endif
        !           182: #ifndef IPPORT_POP3
        !           183: #define IPPORT_POP3            110
        !           184: #endif
        !           185: 
        !           186: #endif /* Don't add anything after this line */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.