This repository has been archived by the owner on Mar 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
definitions.h
106 lines (87 loc) · 2.36 KB
/
definitions.h
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
//////////////////////////////////////////////////////////////////////
// OTAdmin - OpenTibia
//////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//////////////////////////////////////////////////////////////////////
#ifndef __OTADMIN_DEFINITIONS_H__
#define __OTADMIN_DEFINITIONS_H__
#if defined __WINDOWS__ || defined WIN32
#include <sys/timeb.h>
#else
#include "stdint.h"
#endif
#define NETWORKMESSAGE_MAXSIZE 16768
#if defined WIN32 || defined __WINDOWS__
#include "windows.h"
#define EWOULDBLOCK WSAEWOULDBLOCK
#ifndef __GNUC__
#pragma comment( lib, "Ws2_32.lib" )
typedef unsigned long uint32_t;
typedef signed long int32_t;
typedef unsigned short uint16_t;
typedef unsigned char uint8_t;
#endif
inline void OTSYS_SLEEP(uint32_t t)
{
Sleep(t);
}
inline long long OTSYS_TIME()
{
_timeb t;
_ftime(&t);
return ((long long)t.millitm) + ((long long)t.time) * 1000;
}
#else
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <sys/timeb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdint.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#ifndef SOCKET
#define SOCKET int
#endif
#ifndef closesocket
#define closesocket close
#endif
#ifndef SOCKADDR
#define SOCKADDR sockaddr
#endif
#ifndef SOCKET_ERROR
#define SOCKET_ERROR -1
#endif
inline void OTSYS_SLEEP(int t)
{
timespec tv;
tv.tv_sec = t / 1000;
tv.tv_nsec = (t % 1000)*1000000;
nanosleep(&tv, NULL);
}
inline long long OTSYS_TIME()
{
timeb t;
ftime(&t);
return ((long long)t.millitm) + ((long long)t.time) * 1000;
}
#endif
#endif