00001 #ifndef BASIS_DEFINITIONS_GROUP
00002 #define BASIS_DEFINITIONS_GROUP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00019
00025
00026 #include <ctype.h>
00027 #ifndef EMBEDDED_BUILD
00028 #include <new>
00029 #else
00030 #include <string.h>
00031 #endif
00032
00033 #ifdef __WIN32__
00034 #ifndef CLAM_BUILT
00035 #include <__build_configuration.h>
00036 #endif
00037 #endif
00038
00040
00042
00045 #ifndef HOOPLE_CODEBASE
00046 #define HOOPLE_CODEBASE
00047 #endif
00048
00049
00050 #include "outcome.h"
00051
00053
00055 const char *software_product_name();
00056
00057 #ifndef NIL
00059 #define NIL 0
00060 #endif
00061
00062 #ifndef NULL
00064 #define NULL 0
00065 #endif
00066
00067 #ifndef BITS_PER_BYTE
00069 #define BITS_PER_BYTE 8
00070 #endif
00071
00072 #ifndef PI_APPROX
00074 #define PI_APPROX 3.14159265358
00075 #endif
00076
00078
00079 #ifndef formal
00081 #define formal(parameter)
00082 #endif
00083
00084 #ifndef byte
00086 typedef unsigned char byte;
00087 #endif
00088
00089 #if defined(UNICODE) && defined(__WIN32__)
00091 typedef wchar_t flexichar;
00092 #else
00093
00094 typedef char flexichar;
00095 #endif
00096
00097 #ifndef u_int
00099 typedef unsigned int u_int;
00100 #endif
00101 #ifndef u_short
00103 typedef unsigned short u_short;
00104 #endif
00105 #ifndef u_long
00107 typedef unsigned long u_long;
00108 #endif
00109
00110
00111
00112
00113 #ifndef MAXINT
00115 #define MAXINT 0x7fffffff
00116 #endif
00117 #ifndef MININT
00119 #define MININT 0x80000000
00120 #endif
00121 #ifndef MAXLONG
00123 #define MAXLONG 0x7fffffff
00124 #endif
00125 #ifndef MINLONG
00127 #define MINLONG 0x80000000
00128 #endif
00129 #ifndef MAXCHAR
00131 #define MAXCHAR 0x7f
00132 #endif
00133 #ifndef MINCHAR
00135 #define MINCHAR 0x80
00136 #endif
00137 #ifndef MAXSHORT
00139 #define MAXSHORT 0x7fff
00140 #endif
00141 #ifndef MINSHORT
00143 #define MINSHORT 0x8000
00144 #endif
00145 #ifndef MAXBYTE
00147 #define MAXBYTE 0xff
00148 #endif
00149 #ifndef MINBYTE
00151 #define MINBYTE 0x00
00152 #endif
00153
00154
00155
00156 typedef char int8;
00157 typedef unsigned char uint8;
00158 typedef signed short int16;
00159 typedef unsigned short uint16;
00160 typedef signed long int32;
00161 typedef unsigned long uint32;
00162
00164
00165
00166
00167
00168 const int SECOND_ms = 1000;
00169 const int MINUTE_ms = 60 * SECOND_ms;
00170 const int HOUR_ms = 60 * MINUTE_ms;
00171 const int DAY_ms = 24 * HOUR_ms;
00172
00173
00174 const int MINUTE_s = 60;
00175 const int HOUR_s = 60 * MINUTE_s;
00176 const int DAY_s = 24 * HOUR_s;
00177
00178
00179
00180 const int KILOBYTE = 1024;
00181 const int MEGABYTE = KILOBYTE * KILOBYTE;
00182 const int GIGABYTE = MEGABYTE * KILOBYTE;
00183 inline double TERABYTE() { return double(GIGABYTE) * double(KILOBYTE); }
00185
00188
00189
00190
00191
00192
00193 class byte_array;
00194 class byte_sequence;
00195 class chaos;
00196 class int_array;
00197 class int_set;
00198 class istring;
00199 class istring_object;
00200 class mutex;
00201 class string_array;
00202 class unichar_sequence;
00203
00205
00207
00211 #define DEFINE_FILTER(NAME, CURRENT_VALUE, INFO_STRING) \
00212 NAME = CURRENT_VALUE
00213
00215
00217
00223 #define DEFINE_EVENT(NAME, CURRENT_VALUE, INFO_STRING) \
00224 NAME = CURRENT_VALUE
00225
00227
00229
00230 struct common {
00231
00233
00235 enum outcomes {
00236 DEFINE_API_OUTCOME(OKAY, 0, "Everything is just fine"),
00237 DEFINE_API_OUTCOME(NOT_IMPLEMENTED, -1, "The invoked method is "
00238 "unimplemented"),
00239 DEFINE_API_OUTCOME(OUT_OF_RANGE, -2, "The value specified was out "
00240 "of bounds"),
00241 DEFINE_API_OUTCOME(NOT_FOUND, -3, "The item sought is not present"),
00242 DEFINE_API_OUTCOME(BAD_INPUT, -4, "Precondition failure--the parameters "
00243 "were inappropriate"),
00244 DEFINE_API_OUTCOME(BAD_TYPE, -5, "The objects are of incompatible types"),
00245 DEFINE_API_OUTCOME(IS_FULL, -6, "There is no room in the storage facility"),
00246 DEFINE_API_OUTCOME(IS_EMPTY, -7, "The container is empty currently"),
00247 DEFINE_API_OUTCOME(IS_NEW, -8, "The item is new"),
00248 DEFINE_API_OUTCOME(EXISTING, -9, "The item was already present"),
00249 DEFINE_API_OUTCOME(FAILURE, -10, "A failure has occurred"),
00250 DEFINE_API_OUTCOME(OUT_OF_MEMORY, -11, "There is not enough memory for the "
00251 "request according to the operating system"),
00252 DEFINE_API_OUTCOME(ACCESS_DENIED, -12, "The request was denied, possibly "
00253 "by the operating system"),
00254 DEFINE_API_OUTCOME(IN_USE, -13, "The object is already in exclusive use"),
00255 DEFINE_API_OUTCOME(UNINITIALIZED, -14, "The object has not been "
00256 "constructed properly"),
00257 DEFINE_API_OUTCOME(TIMED_OUT, -15, "The allowed time has now elapsed"),
00258 DEFINE_API_OUTCOME(GARBAGE, -16, "The request or response has been "
00259 "corrupted"),
00260 DEFINE_API_OUTCOME(NO_SPACE, -17, "A programmatic limit on storage space "
00261 "has been reached"),
00262 DEFINE_API_OUTCOME(DISALLOWED, -18, "The method denied the request"),
00263 DEFINE_API_OUTCOME(INCOMPLETE, -19, "The operation did not finish or the "
00264 "object is not completed"),
00265 DEFINE_API_OUTCOME(NO_HANDLER, -20, "The object type passed in was not "
00266 "understood by the invoked method"),
00267 DEFINE_API_OUTCOME(NONE_READY, -21, "There were no objects available"),
00268 DEFINE_API_OUTCOME(INVALID, -22, "That request or object was invalid"),
00269 DEFINE_API_OUTCOME(PARTIAL, -23, "The request was only partially finished"),
00270 DEFINE_API_OUTCOME(NO_LICENSE, -24, "The software license does not permit"
00271 "this request"),
00272 DEFINE_API_OUTCOME(UNEXPECTED, -25, "This item was unexpected, although "
00273 "not necessarily erroneous"),
00274 DEFINE_API_OUTCOME(ENCRYPTION_MISMATCH, -26, "The request failed due to a "
00275 "mismatch between encryption expected and encryption provided")
00276 };
00277
00278 static const char *outcome_name(const outcome &to_name);
00280
00285 enum list_positions {
00286 HEAD = -298,
00287 TAIL,
00288 MIDDLE
00289 };
00290
00291 enum how_to_copy { NEW_AT_END, NEW_AT_BEGINNING, DONT_COPY };
00293
00303
00304 enum filters {
00305 DEFINE_FILTER(NEVER_PRINT, -1, "Indicates that the diagnostic entry "
00306 "should be dropped"),
00307 DEFINE_FILTER(ALWAYS_PRINT, 0, "Indicates that the diagnostic entry "
00308 "should always be recorded"),
00309 DEFINE_FILTER(NETWORK_LOGGING, 1, "Extra logging of network events "
00310 "will be performed"),
00311 DEFINE_FILTER(UNUSUAL_LOGGING, 2, "Logging of unusual but not "
00312 "necessarily erroneous events"),
00313
00314
00315 FIRST_LOW_LEVEL_FILTER = NETWORK_LOGGING,
00316 LAST_LOW_LEVEL_FILTER = UNUSUAL_LOGGING
00317 };
00318
00319 static int_set low_level_filters();
00321 };
00322
00324
00325
00326
00327
00328
00329
00330
00331
00332 #ifdef __UNIX__
00333 extern int __argc;
00334 extern char **__argv;
00336 #define DEFINE_ARGC_AND_ARGV int __argc = 0; char **__argv = NIL
00337 #elif defined(__WIN32__)
00338 #include <stdlib.h>
00339
00340 #define DEFINE_ARGC_AND_ARGV
00341
00342 #else
00343
00344 extern int __argc;
00345 extern char **__argv;
00346 #define DEFINE_ARGC_AND_ARGV int __argc = 0; char **__argv = NIL
00347 #endif
00348
00350
00351 #ifdef ENABLE_MEMORY_HOOK
00352
00353
00354
00355
00356
00357 #define _AFX_NO_DEBUG_CRT
00358
00359
00360 #ifndef __WIN32__
00362 void *operator new(size_t size, char *file, int line) throw (std::bad_alloc);
00363
00365 inline void* operator new [] (size_t size, char *file, int line)
00366 throw (std::bad_alloc) { return ::operator new(size, file, line); }
00367
00369 void operator delete (void *ptr) throw ();
00370
00372 inline void operator delete [] (void *ptr) throw ()
00373 { ::operator delete(ptr); }
00374 #else
00375
00376 void *operator new(size_t size, char *file, int line);
00377 inline void* operator new [] (size_t size, char *file, int line)
00378 { return ::operator new(size, file, line); }
00379 void operator delete (void *ptr);
00380 inline void operator delete [] (void *ptr) { ::operator delete(ptr); }
00381 inline void operator delete (void *ptr, char *file, int line)
00382 { ::operator delete(ptr); }
00383 inline void operator delete [] (void *ptr, char *file, int line)
00384 { ::operator delete(ptr); }
00385 #endif
00386
00388 #define HOOPLE_NEW new(__FILE__, __LINE__)
00389
00391 #define new HOOPLE_NEW
00392
00393 #endif // ENABLE_MEMORY_HOOK
00394
00396
00397
00398
00399 #if defined(__WIN32__) || defined(_MSC_VER)
00400
00401
00402
00403 #ifndef WIN32
00404 #define WIN32
00405 #endif
00406 #ifndef __WIN32__
00407 #define __WIN32__
00408 #endif
00409 #ifndef _WIN32
00410 #define _WIN32
00411 #endif
00412 #ifndef _Windows
00413 #define _Windows
00414 #endif
00415 #ifndef _WINDOWS
00416 #define _WINDOWS
00417 #endif
00418
00419 #ifdef _MSC_VER
00420
00421
00422
00423 #ifdef _AFXDLL
00424 #ifdef _DEBUG
00425 #ifndef ENABLE_MEMORY_HOOK
00426
00427 #include <afx.h>
00428 #define new DEBUG_NEW
00429
00430 #endif
00431 #endif
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443 #ifdef _M_IX86
00444 #pragma comment(linker,"/manifestdependency:\"type='win32' " \
00445 "name='Microsoft.Windows.Common-Controls' " \
00446 "version='6.0.0.0' " \
00447 "processorArchitecture='x86' " \
00448 "publicKeyToken='6595b64144ccf1df' " \
00449 "language='*'\"")
00450 #endif
00451
00452 #ifdef _M_AMD64
00453 #pragma comment(linker,"/manifestdependency:\"type='win32' " \
00454 "name='Microsoft.Windows.Common-Controls' " \
00455 "version='6.0.0.0' " \
00456 "processorArchitecture='amd64' " \
00457 "publicKeyToken='6595b64144ccf1df' " \
00458 "language='*'\"")
00459 #endif
00460
00461 #ifdef _M_IA64
00462 #pragma comment(linker,"/manifestdependency:\"type='win32' " \
00463 "name='Microsoft.Windows.Common-Controls' " \
00464 "version='6.0.0.0' " \
00465 "processorArchitecture='ia64' " \
00466 "publicKeyToken='6595b64144ccf1df' " \
00467 "language='*'\"")
00468 #endif
00469
00470 #endif
00471
00472
00473 #pragma warning(disable : 4251 4275 4003 4800 4355 4786 4290 4996 4407)
00474 #pragma warning(error : 4172)
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489 #endif // visual c++.
00490
00491 #elif defined(__UNIX__)
00492 #define LOBYTE(to_chop) (byte(to_chop))
00494 #define HIBYTE(to_chop) (byte(0xff & (u_short(to_chop) >> 8)))
00496 #else
00497
00498
00499 typedef int bool;
00500 enum _boolean_enumeration_ { false, true };
00501 #endif
00502
00503 #endif // outer guard.
00504