1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
// config.h
#ifndef _CONFIG_H
#define _CONFIG_H
#include <cstdio>
#include <SDL.h>
#ifndef BYTE_ORDER
#include <SDL_endian.h>
#endif
#ifndef BYTE_ORDER
#define LITTLE_ENDIAN 1234
#define BIG_ENDIAN 4321
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
#define BYTE_ORDER LITTLE_ENDIAN
#elif SDL_BYTEORDER == SDL_BIG_ENDIAN
#define BYTE_ORDER BIG_ENDIAN
#else
#error unknown byte order
#endif
#endif // BYTE_ORDER
#if defined _WIN32
#include "basetsd.h"
#ifndef filelength
#define filelength _filelength
#endif
#define strtok_r strtok_s
#define STUB_FUNCTION nprintf(( "Warning", "STUB: %s in " __FILE__ " at line %d\n", __FUNCTION__, __LINE__))
#define SOCKLEN_T int
#define NETCALL_WOULDBLOCK(err) (err == WSAEWOULDBLOCK)
#else // ! Win32
#include <unistd.h>
#include <cmath>
#include <cstdint>
// don't verbose stub funtions unless we're debugging
#define STUB_FUNCTION nprintf(( "Warning", "STUB: %s in " __FILE__ " at line %d, thread %d\n", __FUNCTION__, __LINE__, getpid() ))
#define DEBUGME(d1) nprintf(( "Warning", "DEBUGME: %s in " __FILE__ " at line %d, msg \"%s\", thread %d\n", __FUNCTION__, __LINE__, d1, getpid() ))
// networking/socket stuff
#define SOCKET int
#define SOCKADDR struct sockaddr
#define SOCKADDR_IN struct sockaddr_in
#define SOCKADDR_IN6 struct sockaddr_in6
#define SOCKADDR_STORAGE struct sockaddr_storage
#define LPSOCKADDR struct sockaddr*
#define HOSTENT struct hostent
#define SERVENT struct servent
#define closesocket(x) close(x)
#define WSAEALREADY EALREADY
#define WSAEINVAL EINVAL
#define WSAEWOULDBLOCK EINPROGRESS
#define WSAEISCONN EISCONN
#define WSAENOTSOCK ENOTSOCK
#define WSAECONNRESET ECONNRESET
#define WSAECONNABORTED ECONNABORTED
#define WSAESHUTDOWN ESHUTDOWN
#define WSAEADDRINUSE EADDRINUSE
#define SOCKET_ERROR (-1)
#define ioctlsocket(x, y, z) ioctl(x, y, z)
#define NETCALL_WOULDBLOCK(err) (err == EAGAIN || err == EINPROGRESS)
#define WSAGetLastError() (errno)
#ifndef INVALID_SOCKET
#define INVALID_SOCKET (-1)
#endif
#define SOCKLEN_T socklen_t
#define SSIZE_T ssize_t
// file related items
#define _MAX_FNAME 255
#define _MAX_PATH 255
#define MAX_PATH 255
#define _unlink(s) unlink(s)
int filelength(int fd);
int _chdir(const char *path);
int _getcwd(char *buffer, unsigned int len);
int _mkdir(const char *path);
void _splitpath(const char *path, char *drive, char *dir, char *fname, char *ext);
// other stuff
#define _hypot(x, y) hypot(x, y)
int MulDiv(int number, int numerator, int denominator);
#endif // if !defined (WINDOWS)
#endif // ifndef _CONFIG_H
|