JunkBox_Lib++ (for Windows)
1.10.1
Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1
#ifndef __JBXL_COMMON_HEADER_
2
#define __JBXL_COMMON_HEADER_
3
12
#ifdef HAVE_CONFIG_H
13
#include "config.h"
14
#endif
15
16
17
#define _INCLUDE_POSIX_SOURCE
18
#define __EXTENSIONS__
// for Solaris
19
20
21
#ifndef _CRT_SECURE_NO_WARNINGS
22
#define _CRT_SECURE_NO_WARNINGS
// for Windows
23
#endif
24
25
26
#include <stdio.h>
27
#include <stdlib.h>
28
#include <string.h>
29
30
32
// 動作環境
33
34
#ifdef __MINGW32__
35
#define MINGW32
36
#elif defined __CYGWIN__
37
#define CYGWIN
38
#endif
39
40
42
// for Windows VC++
43
44
#ifdef WIN32
// for Windows
45
#include <io.h>
46
#include <direct.h>
47
48
#ifndef _MFC_APP_
49
#define _WINSOCKAPI_
// network.h で winsock2.h を読み込むため
50
#include <windows.h>
51
#endif
52
53
#define Intel
54
#define scanf scanf_s
55
#define unlink _unlink
56
#define snprintf _snprintf
57
#define vsnprintf _vsnprintf
58
#define strcasecmp _stricmp
59
#define strncasecmp _strnicmp
60
// #define close(p) _close(p)
61
#define mkdir(d, m) _mkdir(d)
62
#define rmdir(d) _rmdir(d)
63
#define mode_t int
64
#define bzero(p, n) ZeroMemory((p), (n))
65
#define bcopy(f, t, n) CopyMemory((t), (f), (n))
66
67
// for Unicode
68
#ifdef _UNICODE
69
#ifndef _ttof
70
#define _ttof _wtof
71
#endif
72
#else
73
#ifndef _ttof
74
#define _ttof atof
75
#endif
76
#endif
// Unicode
77
78
#define tcscmp _tcscmp
79
#define tcsncmp _tcsncmp
80
#define tcsncpy _tcsncpy
81
#define tcslen _tcslen
82
#define tunlink _tunlink
83
#define tfopen _tfopen
84
#define sntprintf _sntprintf_s
85
#define ttoi _ttoi
86
#define ttof _ttof
87
#define tprintf _tprintf
88
#define ftprintf _ftprintf
89
90
#ifdef _WINDLL
91
#define DllExport __declspec(dllexport)
92
#define DllImport __declspec(dllimport)
93
#endif
94
95
#ifdef WIN64
96
#define WIN_DD_NULL (void*)0xdddddddddddddddd
97
#else
98
#define WIN_DD_NULL (void*)0xdddddddd
99
#endif
100
101
#endif
// WIN32
102
103
104
#ifndef DllExport
105
#define DllExport
106
#define DllImport
107
#endif
108
109
111
// for Solaris
112
113
#ifndef LOG_PERROR
114
#define LOG_PERROR 0
115
#endif
116
117
119
// for not Windows
120
121
#ifndef WIN32
122
#define Sleep(t) usleep((t)*1000)
123
#endif
124
125
127
//
128
#define MAXBUFSZ 4194304
129
#define BUFSZ2M 2087152
130
#define HHHBUFSZ 2087152
131
#define BUFSZ1M 1048576
132
#define HHBUFSZ 1048576
133
#define HBUFSZ 524288
134
#define RECVBUFSZ 262144
135
#define LLLBUFSZ 131072
136
#define LLBUFSZ 65536
137
#define LBUFSZ 32768
138
#define BUFSZ 16384
139
#define MBUFSZ 8192
140
#define SBUFSZ 4096
141
142
#define L_4096 4096
143
#define L_2048 2048
144
#define LFRAME 2048
145
#define L_1024 1024
146
#define LBUF 1024
147
#define L_512 512
148
#define LMESG 512
149
#define L_256 256
150
#define LPATH 256
151
#define LDATA 256
152
#define L_128 128
153
#define LNAME 128
154
#define LMDATA 128
155
#define LPASS 128
156
#define L_64 64
157
#define LMNAME 64
158
#define LSDATA 64
159
#define LGUID 40
160
#define LUUID 36
161
#define L_32 32
162
#define LADDR 32
163
#define LADDR6 128
164
#define LSNAME 32
165
#define L_16 16
166
#define L_ID 16
167
#define L_8 8
168
#define L_OCT 8
169
170
#define LEN_REAL 32
171
#define LEN_INT 22
172
#define LEN_IPADDR 17
173
#define LEN_IPADDR6 41
174
#define LEN_PORT 7
175
#define LEN_IPPORT 23
176
177
#define STRLEN_GUID 36
178
179
#define WORK_FILENAME_LEN 16
180
181
182
#define PI 3.1415926535897932385
183
#define PI15 4.7123889803846898577
184
#define PI2 6.2831853071795864769
185
#define PI_DIV2 1.5707963267948966192
186
#define PI_DIV2_3 4.7123889803846898577
187
#define PI_DIV3 1.0471975511965977462
188
#define PI_DIV3_2 2.0943951023931954923
189
#define PI_DIV4 0.78539816339744830962
190
#define PI_DIV6 0.52359877559829887308
191
#define LN_10 2.3025850929940456840
192
#define EXP_1 2.71828182845904523536
193
194
#define DEGREE2RAD 0.0174532925199432957692
195
#define RAD2DEGREE 57.2957795130823208768
196
197
#define SQROOT_05 0.707106781186547524401
198
#define SQROOT_2 1.4142135623730950488
199
#define SQROOT_3 1.7320508075688772935
200
#define SQROOT_5 2.2360679774997896964
201
#define SQROOT_7 2.6457513110645905905
202
203
204
#define SINTMAX 2147483647
205
#define SINTMIN -2147483647
// 2147483648 of -2147483648 is over flow from INT MAX
206
#define UINTMAX 4294967295
207
#define SWORDMAX 32767
208
#define SWORDMIN -32768
209
#define UWORDMAX 65535
210
211
#ifndef RAND_MAX
212
#ifdef WIN32
// for Windows
213
#define RAND_MAX 32767
214
#else
215
#define RAND_MAX 2147483647
216
#endif
217
#endif
218
219
221
222
#ifndef FALSE
223
#define FALSE 0
224
#endif
225
#ifndef TRUE
226
#define TRUE 1
227
#endif
228
229
230
#define ON 1
231
#define OFF 0
232
#define OK 1
233
#define NG 0
234
#define YES 1
235
#define NO 0
236
237
#ifndef CRLF
238
#ifdef WIN32
239
#define CRLF "\n"
240
#else
241
#define CRLF "\r\n"
242
#endif
243
#endif
244
245
246
#ifndef Max
247
#define Max(x, y) (((x)<(y)) ? (y):(x))
248
#endif
249
#ifndef Min
250
#define Min(x, y) (((x)>(y)) ? (y):(x))
251
#endif
252
#ifndef Sign
253
#define Sign(x) (((x)>=0) ? (1):(-1))
254
#endif
255
256
#define Loop while(1)
257
#define Xabs(x) (((x)>=0) ? (x):(-(x)))
258
#define getBit(x, n) ((sByte)((*(x+(n)/8)>>(7+(n)/8*8-(n)))&0x01))
259
#define setBit(x, n, i) ((i)?(*(x+(n)/8)|=(0x80>>((n)-(n)/8*8))):(*((x)+(n)/8)&=~(0x80>>((n)-(n)/8*8))))
260
#define checkBit(dat, bit) (((dat)&(bit))==(bit))
261
#define maskBit(dat, bit) ((dat)&(0xff>>(8-(bit))))
262
263
#ifndef UNUSED
264
#define UNUSED(x) (void)((x))
265
#endif
266
267
268
#define Frand() (rand()/((double)RAND_MAX+1.0))
// 0.0〜x未満 の実数を生成
269
#define Drand(x) ((int)(rand()/((double)RAND_MAX+1.0)*((x)+1)))
// 0〜x までの整数を生成
270
#define LDrand(x) ((long int)(rand()/((double)RAND_MAX+1.0)*((x)+1)))
// 0〜x までの long int を生成
271
272
273
#ifndef WIN32
274
#ifndef Error
275
#define Error(s) {perror(s); return -1;}
276
#endif
277
#endif
278
279
280
//
281
// for conflict of other Library
282
#define JBXL_ON 1
283
#define JBXL_OFF 0
284
#define JBXL_OK 1
285
#define JBXL_NG 0
286
#define JBXL_YES 1
287
#define JBXL_NO 0
288
#define JBXL_TRUE 1
289
#define JBXL_FALSE 0
290
291
#define JBXL_Max(x, y) (((x)<(y)) ? (y):(x))
292
#define JBXL_Min(x, y) (((x)>(y)) ? (y):(x))
293
#define JBXL_Sign(x) (((x)>=0) ? (1):(-1))
294
295
#define JBXL_EPS 1.0e-6
296
297
298
// for 3D
299
#define JBXL_3D_FORMAT_NONE 0
300
#define JBXL_3D_FORMAT_DAE 1
301
#define JBXL_3D_FORMAT_OBJ 2
302
#define JBXL_3D_FORMAT_FBX 3
303
#define JBXL_3D_FORMAT_GLTF 4
304
#define JBXL_3D_FORMAT_GLB 5
305
#define JBXL_3D_FORMAT_STL 8
306
#define JBXL_3D_FORMAT_STL_A 8
307
#define JBXL_3D_FORMAT_STL_B 9
308
309
#define JBXL_3D_ENGINE_NONE 0
310
#define JBXL_3D_ENGINE_UNITY 1
311
#define JBXL_3D_ENGINE_UE 2
312
313
// Texture
314
// see gLib/gheader.h
315
#define JBXL_TEXTURE_UN_KNOWN 0
316
#define JBXL_TEXTURE_MOON 3
317
#define JBXL_TEXTURE_DICOM 4
318
#define JBXL_TEXTURE_USERSET 5
319
320
#define JBXL_TEXTURE_CT 16
321
#define JBXL_TEXTURE_JPEG 32
322
#define JBXL_TEXTURE_JPG 32
323
#define JBXL_TEXTURE_TIFF 48
324
#define JBXL_TEXTURE_PNG 64
325
#define JBXL_TEXTURE_TGA 80
326
#define JBXL_TEXTURE_JP2K 96
327
#define JBXL_TEXTURE_RAS 112
328
329
331
//
332
typedef
unsigned
char
uByte
;
333
typedef
char
sByte
;
334
typedef
unsigned
short
uWord
;
335
typedef
short
sWord
;
336
typedef
unsigned
int
uDWord
;
337
typedef
int
sDWord
;
338
339
344
typedef
struct
_parameter32 {
345
sByte
pm[32];
346
}
Parameter32
;
347
348
349
typedef
struct
_parameter64 {
350
sByte
pm[64];
351
}
Parameter64
;
352
353
354
355
#endif
// __JBXL_COMMON_HEADER_
356
sDWord
int sDWord
4Byte
Definition
common.h:337
sByte
char sByte
1Byte
Definition
common.h:333
uWord
unsigned short uWord
2Byte
Definition
common.h:334
uDWord
unsigned int uDWord
4Byte
Definition
common.h:336
sWord
short sWord
2Byte
Definition
common.h:335
uByte
unsigned char uByte
1Byte
Definition
common.h:332
Parameter32
Definition
common.h:344
Parameter64
Definition
common.h:349
BasicLib
Lib
common.h
Generated on Sat Oct 12 2024 19:42:07 for JunkBox_Lib++ (for Windows) by
1.11.0