-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathcommon.h
More file actions
283 lines (253 loc) · 7.02 KB
/
Copy pathcommon.h
File metadata and controls
283 lines (253 loc) · 7.02 KB
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#ifndef _MAXH_
#define _MAXH_
#ifdef INFORMATION
Copyright (C)2011-2024 by Bruce Wilcox
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#endif
#ifdef WIN32
#pragma warning( disable : 4206 4456 4457 4459 4505 4611)
#pragma warning( disable : 26481 26462 26446 26494 0260 26485)
#endif
// These can be used to shed components of the system to save space
//#define DISCARDSERVER 1
//#define DISCARDSCRIPTCOMPILER 1
//#define DISCARDPARSER 1
//#define DISCARDTESTING 1
//#define DISCARDTCPOPEN 1
//#define DISCARDMYSQL 1
//#define DISCARDPOSTGRES 1
//#define DISCARDMONGO 1
//#define DISCARDMICROSOFTSQL 1
//#define DISCARDJSONOPEN 1
//#define DISCARDJAVASCRIPT 1
//#define DISCARD_TEXT_COMPRESSION 1
//#define DISCARDWEBSOCKET 1
//#define DISCARD_JAPANESE 1
#define DISCARD_PYTHON 1
// these can add components
//#define TREETAGGER 1
//#define HARDCRASH 1 - dont trap interrupt (for debugging)
#ifdef DLL
#define NOMAIN 1
#define DISCARD_TEXT_COMPRESSION 1
#ifndef JA
#define DISCARDMICROSOFTSQL 1
#endif
#endif
#ifdef WIN32
//#define USERPATHPREFIX 1
#elif IOS
#define DISCARDCOUNTER 1
#define DISCARDMYSQL 1
#define DISCARDMICROSOFTSQL 1
#define DISCARD_TEXT_COMPRESSION 1
#define DISCARDPOSTGRES 1
#define DISCARDMONGO 1
#define DISCARDCOUNTER 1
#define DISCARDCLIENT 1
#define DISCARDJSONOPEN 1
#define DISCARDWEBSOCKET 1
#define DISCARD_JAPANESE 1
#elif ANDROID
#define DISCARDCOUNTER 1
#define DISCARDMYSQL 1
#define DISCARDMICROSOFTSQL 1
#define DISCARD_TEXT_COMPRESSION 1
#define DISCARDPOSTGRES 1
#define DISCARDMONGO 1
#define DISCARDCOUNTER 1
#define DISCARDCLIENT 1
#define DISCARDJSONOPEN 1
#define DISCARDWEBSOCKET 1
#define DISCARD_JAPANESE 1
#elif __MACH__
#define DISCARDPOSTGRES 1
#define DISCARDMICROSOFTSQL 1
#define DISCARDMYSQL 1
#define DISCARDWEBSOCKET 1
#define DISCARDMONGO 1
#define DISCARD_TEXT_COMPRESSION 1
#else // GENERIC LINUX
#ifndef EVSERVER
#define SAFETIME 1 // protect server from time concurrency issues in C++ library.
#endif
#endif
// These can be used to include LINUX EVSERVER component - this is automatically done by the makefile in src - EV Server does not work under windows
// #define EVSERVER 1
// These can be used to embed chatscript within another application (then you must call InitSystem on startup yourself)
// #define NOMAIN 1
#ifndef WIN32
typedef long long long_t;
typedef unsigned long long ulong_t;
#include <sys/time.h>
#include <termios.h>
#include <unistd.h>
#define stricmp strcasecmp
#define strnicmp strncasecmp
#else
typedef long long_t;
typedef unsigned long ulong_t;
#endif
#ifdef WIN32
#pragma comment(lib, "ws2_32.lib")
#pragma warning( disable : 4100 )
#pragma warning( disable : 4189 )
#pragma warning( disable : 4290 )
#pragma warning( disable : 4706 )
#pragma warning( disable : 4996 )
#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_WARNINGS 1
#define _CRT_NONSTDC_NO_DEPRECATE
#define _CRT_NONSTDC_NO_WARNINGS 1
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h> // needs to compile before any refs to winsock.h
#include <ws2tcpip.h>
#include <iphlpapi.h>
#pragma comment(lib, "Ws2_32.lib")
#pragma comment (lib, "Mswsock.lib")
#pragma comment (lib, "AdvApi32.lib")
#elif IOS
#include <dirent.h>
#include <mach/clock.h>
#include <mach/mach.h>
#elif __MACH__
#include <dirent.h>
#include <mach/clock.h>
#include <mach/mach.h>
#ifndef HARDCRASH
#define USESIGNALHANDLER 1
#endif
#else // LINUX
#include <dirent.h>
#ifndef LINUX
#define LINUX 1
#endif
#ifndef HARDCRASH
#define USESIGNALHANDLER 1
#endif
#endif
#ifdef IOS
#elif __MACH__
#include <sys/malloc.h>
#elif FREEBSD
// avoid requesting malloc.h
#else
#include <malloc.h>
#endif
#ifndef DISCARD_PYTHON
#define PY_SSIZE_T_CLEAN
#include "Python/include/Python.h"
#endif
#include <algorithm>
#include <assert.h>
#include <atomic>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <ctype.h>
#include <errno.h>
#include <exception>
#include <fcntl.h>
#include <iostream>
#include <math.h>
#include <memory.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <sys/stat.h>
#include <sys/timeb.h>
#include <sys/types.h>
#include <time.h>
#include <utility>
#include <vector>
#ifndef DISCARDMONGO
#include "bson.h"
#endif
using namespace std;
#ifdef EVSERVER
#define EV_STANDALONE 1
#define EV_CHILD_ENABLE 1
#ifdef DISCARDMONGO
#ifdef DISCARDPOSTGRES
#define LOCKUSERFILE 1 // protect from multiple servers hitting same file
//#define USERPATHPREFIX 1 // do binary tree of log file - for high speed servers recommend userlog, no server log and this (large server logs are a pain to handle)
#endif
#endif
#endif
#ifndef DISCARDJSONOPEN
#ifdef WIN32
#include "curl.h"
#ifdef DEBUG
#pragma comment(lib, "../SRC/curl/libcurld.lib")
#else
#pragma comment(lib, "../SRC/curl/libcurl.lib")
#endif
#else
#include <curl/curl.h>
#endif
#endif
#include "common1.h"
#include "os.h"
#include "dictionarySystem.h"
#include "mainSystem.h"
#include "factSystem.h"
#include "functionExecute.h"
#include "cs_jp.h"
#include "cs_es.h"
#include "cs_german.h"
#include "csocket.h"
#include "constructCode.h"
#include "english.h"
#include "infer.h"
#include "json.h"
#include "markSystem.h"
#include "mongodb.h"
#include "my_sql.h"
#include "ms_sql.h"
#include "outputSystem.h"
#include "patternSystem.h"
#include "postgres.h"
#include "scriptCompile.h"
#include "spellcheck.h"
#include "systemVariables.h"
#include "tagger.h"
#include "testing.h"
#include "textUtilities.h"
#include "tokenSystem.h"
#include "topicSystem.h"
#include "userCache.h"
#include "userSystem.h"
#include "variableSystem.h"
#ifndef DISCARDWEBSOCKET
#include "easywclient/easywsclient.hpp"
#endif
#ifdef PRIVATE_CODE
#include "../privatecode/privatesrc.h"
#endif
#ifdef WIN32
#include <direct.h>
#define GetCurrentDir _getcwd
#else
#include <unistd.h>
#include <fcntl.h>
#define GetCurrentDir getcwd
#endif
#endif
#ifdef USESIGNALHANDLER
// headers for error handling
#include <signal.h>
#include <execinfo.h>
#endif