-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobal.h
220 lines (186 loc) · 4.68 KB
/
Global.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#ifndef _GLOBAL_H
#define _GLOBAL_H
////////////////////////////////////////////////////////////////////////////////
//
// OS Type Definition
//
// Definition of the operation system type.
//
// These directives are for the portable program.
// I suppose this program would run on Microsoft Windows, Linux, FreeBSD, Solaris etc.
// For this purpose, I must mainly write in ANSI C.
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// Microsoft Windows : _MICROSOFT_WINDOWS
// RedHat Linux : _REDHAT_LINUX
// SUN Solaris : _SUN_SOLARIS
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// General including files
//
// Including the files for the system.
//
// These including files are generally used in different operation system.
//
////////////////////////////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <assert.h>
#ifdef _MICROSOFT_WINDOWS
#include <conio.h>
#endif
////////////////////////////////////////////////////////////////////////////////
//
// General requirements
//
// Including the requirements for general using.
//
// These requirements are generally used in different operation system.
//
////////////////////////////////////////////////////////////////////////////////
//Debug
#ifndef _DEBUG
#define _DEBUG
#endif
////////////////////////////////////////////////////////////////////////////////
//
// General definitions
//
// Including the definitions for general using.
//
// These definitions are generally used in different operation system.
//
////////////////////////////////////////////////////////////////////////////////
//INT8
typedef char _INT8;
//Unsigned INT8
typedef unsigned char _UINT8;
//INT16
typedef short _INT16;
//Unsigned INT16
typedef unsigned short _UINT16;
//INT32
typedef int _INT32;
//Unsigned INT32
typedef unsigned int _UINT32;
//BOOL
typedef _UINT32 _BOOL;
//TRUE
#define _TRUE (_BOOL)1
//FALSE
#define _FALSE (_BOOL)0
//SUCCESS
#define _SUCCESS 0
//FAILURE
#define _FAILURE -1
//Byte
typedef _INT8 _BYTE;
//Char
typedef _INT8 _CHAR;
//Wide Char
typedef _INT16 _WIDECHAR;
//Short
typedef _INT16 _SHORT;
//Integer
typedef _INT32 _INTEGER;
//Object
typedef void* _OBJECT;
//String
typedef _CHAR* _STRING;
//Wide String
typedef _WIDECHAR* _WIDESTRING;
//Buffer
typedef _BYTE* _BUFFER;
//Pascal String Length
#define PASCAL_STRING_LENGTH 256
//Pascal String
typedef _CHAR _PASCALSTRING[PASCAL_STRING_LENGTH];
//Block Size
#define BLOCK_SIZE 4096 * sizeof(_UINT8)
//Block
typedef _UINT8 _BLOCK[BLOCK_SIZE];
////////////////////////////////////////////////////////////////////////////////
//
// General including files
//
// Including the files for the system.
//
// These including files are generally used in different operation system.
//
////////////////////////////////////////////////////////////////////////////////
//Print
#include "Print.h"
//Hex
#include "Hex.h"
//Digital
#include "Digital.h"
//Characater
#include "Characater.h"
//Simple Time
#include "SimpleTime.h"
//Timestamp
#include "Timestamp.h"
//Timeout
#include "Timeout.h"
//Watch
#include "Watch.h"
//Chain
#include "Chain.h"
//Directory
#include "Directory.h"
//Socket
#include "Socket.h"
//Server Socket
#include "ServerSocket.h"
//Client Socket
#include "ClientSocket.h"
//Lock
#include "Lock.h"
//Sleep
#include "Sleep.h"
//Thread
#include "Thread.h"
//Buffer
#include "Buffer.h"
//Recorder
#include "Recorder.h"
//Log
#include "Log.h"
//Checksum
#include "Checksum.h"
//Ethernet
#include "Ethernet.h"
//Registration
#include "Registration.h"
//Tunnel
#include "Tunnel.h"
//IPHelper
#include "IPHelper.h"
////////////////////////////////////////////////////////////////////////////////
//
// General functions
//
////////////////////////////////////////////////////////////////////////////////
//Odd
#define IsOdd(value) \
(((value) & 0x01) == 1)
//Even
#define IsEven(value) \
(((value) & 0x01) == 0)
//Maximum
#define Maximum(a,b) \
(((a) > (b)) ? (a) : (b))
//Minimum
#define Minimum(a,b) \
(((a) < (b)) ? (a) : (b))
////////////////////////////////////////////////////////////////////////////////
#endif //End of the head file !