ObjFW
 All Classes Functions Variables
common.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012
3  * Jonathan Schleifer <js@webkeks.org>
4  *
5  * All rights reserved.
6  *
7  * This file is part of ObjFW. It may be distributed under the terms of the
8  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
9  * the packaging of this file.
10  *
11  * Alternatively, it may be distributed under the terms of the GNU General
12  * Public License, either version 2 or 3, which can be found in the file
13  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
14  * file.
15  */
16 
17 #include <string.h>
18 
19 #import "macros.h"
20 
21 #ifndef _WIN32
22 #if !defined(HAVE_THREADSAFE_GETADDRINFO) && !defined(_PSP)
23 # include <netdb.h>
24 #endif
25 # include <errno.h>
26 # define GET_ERRNO errno
27 # ifndef HAVE_THREADSAFE_GETADDRINFO
28 # define GET_AT_ERRNO h_errno
29 # else
30 # define GET_AT_ERRNO errno
31 # endif
32 # define GET_SOCK_ERRNO errno
33 # define ERRFMT "Error string was: %s"
34 # define ERRPARAM strerror(errNo)
35 # if !defined(HAVE_THREADSAFE_GETADDRINFO) && !defined(_PSP)
36 # define AT_ERRPARAM hstrerror(errNo)
37 # else
38 # define AT_ERRPARAM strerror(errNo)
39 # endif
40 #else
41 # include <windows.h>
42 # define GET_ERRNO GetLastError()
43 # define GET_AT_ERRNO WSAGetLastError()
44 # define GET_SOCK_ERRNO WSAGetLastError()
45 # define ERRFMT "Error code was: %d"
46 # define ERRPARAM errNo
47 # define AT_ERRPARAM errNo
48 #endif