Planeshift
sockuni.h
Go to the documentation of this file.
1 /*
2  * sockuni.h
3  *
4  * Copyright (C) 2001 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  * Socket definitions for UNIX
19  *
20  * Author: Matthias Braun <MatzeBraun@gmx.de>
21  */
22 
23 #ifndef __SOCKUNI_H__
24 #define __SOCKUNI_H__
25 
26 /* Include various files needed for sockets */
27 #include <sys/socket.h>
28 #include <sys/types.h>
29 #include <sys/ioctl.h>
30 #include <netinet/in.h>
31 #include <arpa/inet.h>
32 #include <netdb.h>
33 #include <unistd.h>
34 
39 //#define INCLUDE_IPV6_SUPPORT true
40 
41 /* define some types */
42 #ifndef SOCKET
43 #define SOCKET int
44 #endif
45 
46 #ifndef IN_ADDR
47 #ifdef INCLUDE_IPV6_SUPPORT
48 #define IN_ADDR struct in6_addr
49 #else
50 #define IN_ADDR struct in_addr
51 #endif
52 #endif
53 
54 #ifndef SOCKADDR_IN
55 #ifdef INCLUDE_IPV6_SUPPORT
56 #define SOCKADDR_IN struct sockaddr_in6
57 #else
58 #define SOCKADDR_IN struct sockaddr_in
59 #endif
60 #endif
61 
62 #ifndef LPSOCKADDR
63 #define LPSOCKADDR struct sockaddr *
64 #endif
65 
66 #ifndef LPSOCKADDR_IN
67 #ifdef INCLUDE_IPV6_SUPPORT
68 #define LPSOCKADDR_IN struct sockaddr_in6 *
69 #else
70 #define LPSOCKADDR_IN struct sockaddr_in *
71 #endif
72 #endif
73 
74 #define SOCK_SENDTO(a,b,c,d,e,f) sendto(a,(const void *) b,c,d,e,f)
75 #define SOCK_RECVFROM(a,b,c,d,e,f) recvfrom(a,(void *) b,c,d,e,f)
76 #define SOCK_IOCTL(a,b,c) ioctl(a,b,c)
77 #define SOCK_CLOSE(a) close(a)
78 #define SOCK_SELECT(max,read,write,except,timeout) select(max,read,write,except,timeout)
79 
80 #define INVALID_SOCKET -1
81 
82 static inline int initSocket()
83 {
84  /* we don't need to init sockets in unix... */
85  return 0;
86 }
87 
88 static inline void exitSocket()
89 {
90  return;
91 }
92 
95 #endif
static int initSocket()
Definition: sockuni.h:82
static void exitSocket()
Definition: sockuni.h:88