monotone

monotone Mtn Source Tree

Root/netxx/osutil.h

1/*
2 * Copyright (C) 2001-2004 Peter J Jones (pjones@pmade.org)
3 * All Rights Reserved
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 * 3. Neither the name of the Author nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
23 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33/** @file
34 * This file contains definitions for OS error functions.
35**/
36
37#ifndef _netxx_osutil_h_
38#define _netxx_osutil_h_
39
40#if defined (WIN32)
41# include <winsock2.h>
42# include <winbase.h>
43# include <errno.h>
44
45# undef EINTR
46# define EINTR WSAEINTR
47
48# undef EWOULDBLOCK
49# define EWOULDBLOCK WSAEWOULDBLOCK
50
51# undef EINPROGRESS
52# define EINPROGRESS WSAEINPROGRESS
53
54# undef EAFNOSUPPORT
55# define EAFNOSUPPORT WSAEAFNOSUPPORT
56
57# undef ENOSPC
58# define ENOSPC WSAENOSPC
59
60# undef ECONNRESET
61# define ECONNRESET WSAECONNRESET
62
63# undef ECONNABORTED
64# define ECONNABORTED WSAECONNABORTED
65#else
66# include <sys/types.h>
67# include <sys/socket.h>
68# include <netinet/in.h>
69# include <arpa/inet.h>
70# include <sys/param.h>
71# include <sys/un.h>
72# include <unistd.h>
73# include <sys/stat.h>
74# include <netdb.h>
75# include <fcntl.h>
76# include <errno.h>
77
78# include <string.h>
79# include <stdlib.h>
80#endif
81
82#include <string>
83#include "config.h"
84
85namespace Netxx
86{
87#if defined (WIN32)
88 typedef DWORD error_type;
89#else
90 typedef int error_type;
91#endif
92 error_type get_last_error (void);
93 std::string str_error(error_type);
94
95
96#if defined(HAVE_SOCKLEN_T)
97 typedef socklen_t os_socklen_type;
98 typedef socklen_t* os_socklen_ptr_type;
99# define get_socklen_ptr(x) &x
100#else
101 typedef int os_socklen_type;
102 typedef int* os_socklen_ptr_type;
103# define get_socklen_ptr(x) reinterpret_cast<int*>(&x)
104#endif
105
106} // end Netxx namespace
107
108#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status