EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
eve-compat.h
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: Aim, Captnoord, Zhur, Bloody.Rabbit
24 */
25 
26 #ifndef __EVE_COMPAT_H__INCL__
27 #define __EVE_COMPAT_H__INCL__
28 
29 /*************************************************************************/
30 /* inttypes.h */
31 /*************************************************************************/
32 /*
33  * u?int(8|16|32|64)
34  */
35 #ifdef HAVE_INTTYPES_H
36 typedef int8_t int8;
37 typedef uint8_t uint8;
38 typedef int16_t int16;
39 typedef uint16_t uint16;
40 typedef int32_t int32;
41 typedef uint32_t uint32;
42 typedef int64_t int64;
43 //typedef uint64_t uint64;
44 #else /* !HAVE_INTTYPES_H */
45 typedef signed __int8 int8;
46 typedef unsigned __int8 uint8;
47 typedef signed __int16 int16;
48 typedef unsigned __int16 uint16;
49 typedef signed __int32 int32;
50 typedef unsigned __int32 uint32;
51 typedef signed __int64 int64;
52 //typedef unsigned __int64 uint64;
53 #endif /* !HAVE_INTTYPES_H */
54 
55 /*
56  * PRI[diouxX](8|16|32|64)
57  * SCN[diouxX](8|16|32|64)
58  */
59 // do we really need these?
60 #ifndef HAVE_INTTYPES_H
61 # define PRId8 "hhd"
62 # define PRIi8 "hhi"
63 # define PRIo8 "hho"
64 # define PRIu8 "hhu"
65 # define PRIx8 "hhx"
66 # define PRIX8 "hhX"
67 
68 # define PRId16 "hd"
69 # define PRIi16 "hi"
70 # define PRIo16 "ho"
71 # define PRIu16 "hu"
72 # define PRIx16 "hx"
73 # define PRIX16 "hX"
74 
75 # define PRId32 "I32d"
76 # define PRIi32 "I32i"
77 # define PRIo32 "I32o"
78 # define PRIu32 "I32u"
79 # define PRIx32 "I32x"
80 # define PRIX32 "I32X"
81 
82 # define PRId64 "I64d"
83 # define PRIi64 "I64i"
84 # define PRIo64 "I64o"
85 # define PRIu64 "I64u"
86 # define PRIx64 "I64x"
87 # define PRIX64 "I64X"
88 
89 # define SCNd8 "hhd"
90 # define SCNi8 "hhi"
91 # define SCNo8 "hho"
92 # define SCNu8 "hhu"
93 # define SCNx8 "hhx"
94 
95 # define SCNd16 "hd"
96 # define SCNi16 "hi"
97 # define SCNo16 "ho"
98 # define SCNu16 "hu"
99 # define SCNx16 "hx"
100 
101 # define SCNd32 "I32d"
102 # define SCNi32 "I32i"
103 # define SCNo32 "I32o"
104 # define SCNu32 "I32u"
105 # define SCNx32 "I32x"
106 
107 # define SCNd64 "I64d"
108 # define SCNi64 "I64i"
109 # define SCNo64 "I64o"
110 # define SCNu64 "I64u"
111 # define SCNx64 "I64x"
112 #endif /* !HAVE_INTTYPES_H */
113 
114 /*************************************************************************/
115 /* windows.h */
116 /*************************************************************************/
117 #ifndef HAVE_WINDOWS_H
118 void Sleep( uint32 x );
120 int CreateDirectory( const char* name, void* );
121 #endif /* !HAVE_WINDOWS_H */
122 
123 /*************************************************************************/
124 /* winsock2.h */
125 /*************************************************************************/
126 #ifndef HAVE_WINSOCK2_H
127 typedef int SOCKET;
128 
129 # define INVALID_SOCKET -1
130 # define SOCKET_ERROR -1
131 #endif /* !HAVE_WINSOCK2_H */
132 
133 #ifndef MSG_NOSIGNAL
134 # ifdef SO_NOSIGPIPE
135 # define MSG_NOSIGNAL SO_NOSIGPIPE
136 # else /* !SO_NOSIGPIPE */
137 # define MSG_NOSIGNAL 0
138 # endif /* !SO_NOSIGPIPE */
139 #endif /* !MSG_NOSIGNAL */
140 
141 /*************************************************************************/
142 /* cfloat, cmath */
143 /*************************************************************************/
144 #ifndef HAVE_ASINH
145 # define asinh boost::math::asinh
146 #endif /* !HAVE_ASINH */
147 
148 #ifndef HAVE_FINITE
149 # if defined( HAVE_ISFINITE )
150 # define finite isfinite
151 # elif defined( HAVE_STD_FINITE )
152 # define finite std::finite
153 # elif defined( HAVE_STD_ISFINITE )
154 # define finite std::isfinite
155 # elif defined( HAVE__FINITE )
156 # define finite _finite
157 # elif defined( HAVE___FINITE )
158 # define finite __finite
159 # endif /* HAVE___FINITE */
160 #endif /* !HAVE_FINITE */
161 
162 #ifndef HAVE_ISNAN
163 //# if defined( HAVE_STD_ISNAN )
164 //# define isnan std::isnan
165 # if defined( HAVE__ISNAN )
166 # define isnan _isnan
167 //# elif defined( HAVE___ISNAN )
168 //# define isnan __isnan
169 # endif
170 #endif /* !HAVE_ISNAN */
171 
172 /*************************************************************************/
173 /* cstdarg */
174 /*************************************************************************/
175 #ifndef HAVE_VA_COPY
176  // Use memcpy() because of possible array implementation.
177 # define va_copy( a, b ) ::memcpy( &( a ), &( b ), sizeof( va_list ) )
178 #endif /* !HAVE_VA_COPY */
179 
180 /*************************************************************************/
181 /* cstdio */
182 /*************************************************************************/
183 #ifndef HAVE_SNPRINTF
184 # define snprintf _snprintf
185 #endif /* !HAVE_SNPRINTF */
186 
187 #ifndef HAVE_VSNPRINTF
188 # define vsnprintf _vsnprintf
189 #endif /* !HAVE_VSNPRINTF */
190 
191 #ifndef HAVE_ASPRINTF
192 int asprintf( char** strp, const char* fmt, ... );
193 #endif /* !HAVE_ASPRINTF */
194 
195 #ifndef HAVE_VASPRINTF
196 int vasprintf( char** strp, const char* fmt, va_list ap );
197 #endif /* !HAVE_VASPRINTF */
198 
207 std::string sprintf( const char* fmt, ... );
216 std::string vsprintf( const char* fmt, va_list ap );
217 
227 int sprintf( std::string& str, const char* fmt, ... );
237 int vsprintf( std::string& str, const char* fmt, va_list ap );
238 
239 /*************************************************************************/
240 /* cstdlib */
241 /*************************************************************************/
242 #ifndef HAVE_STRTOLL
243 # define strtoll _strtoi64
244 #endif /* !HAVE_STRTOLL */
245 
246 #ifndef HAVE_STRTOULL
247 # define strtoull _strtoui64
248 #endif /* !HAVE_STRTOULL */
249 
250 #ifndef HAVE_STRTOF
251 float strtof( const char* nptr, char** endptr );
252 #endif /* !HAVE_STRTOF */
253 
254 /*************************************************************************/
255 /* cstring */
256 /*************************************************************************/
257 #ifndef HAVE_STRDUP
258 # define strdup _strdup
259 #endif /* !HAVE_STRDUP */
260 
261 #ifndef HAVE_STRCASECMP
262 # define strcasecmp _stricmp
263 #endif /* !HAVE_STRCASECMP */
264 
265 #ifndef HAVE_STRNCASECMP
266 # define strncasecmp _strnicmp
267 #endif /* !HAVE_STRNCASECMP */
268 
269 /*************************************************************************/
270 /* ctime */
271 /*************************************************************************/
272 #ifndef HAVE_LOCALTIME_R
273 tm* localtime_r( const time_t* timep, tm* result );
274 #endif /* !HAVE_LOCALTIME_R */
275 
276 #endif /* !__EVE_COMPAT_H__INCL__ */
unsigned __int8 uint8
Definition: eve-compat.h:46
tm * localtime_r(const time_t *timep, tm *result)
Definition: eve-compat.cpp:184
int vasprintf(char **strp, const char *fmt, va_list ap)
Definition: eve-compat.cpp:70
std::string sprintf(const char *fmt,...)
sprintf for std::string.
Definition: eve-compat.cpp:106
signed __int8 int8
Definition: eve-compat.h:45
signed __int32 int32
Definition: eve-compat.h:49
void Sleep(uint32 x)
Definition: eve-compat.cpp:32
int asprintf(char **strp, const char *fmt,...)
Definition: eve-compat.cpp:57
std::string vsprintf(const char *fmt, va_list ap)
vsprintf for std::string.
Definition: eve-compat.cpp:122
uint32 GetTickCount()
Definition: eve-compat.cpp:39
unsigned __int32 uint32
Definition: eve-compat.h:50
int SOCKET
Definition: eve-compat.h:127
signed __int64 int64
Definition: eve-compat.h:51
signed __int16 int16
Definition: eve-compat.h:47
unsigned __int16 uint16
Definition: eve-compat.h:48
float strtof(const char *nptr, char **endptr)
Definition: eve-compat.cpp:176
int CreateDirectory(const char *name, void *)
Definition: eve-compat.cpp:46