00001 #ifndef DEFINITIONS_GROUP
00002 #define 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
00054 #ifdef BUILD_OPERATING_SYSTEM
00056
00063 #define BASIS_EXTERN HOOPLE_DLL_EXPORT_FUNCTION
00064 #elif defined(USE_HOOPLE_DLLS)
00065 #define BASIS_EXTERN HOOPLE_DLL_IMPORT_FUNCTION
00066 #else
00067 #define BASIS_EXTERN
00068 #endif
00069
00071
00073 const char *software_product_name();
00074
00075 #ifndef NIL
00077 #define NIL 0
00078 #endif
00079
00080 #ifndef NULL
00082 #define NULL 0
00083 #endif
00084
00085 #ifndef BITS_PER_BYTE
00087 #define BITS_PER_BYTE 8
00088 #endif
00089
00090 #ifndef PI_APPROX
00092 #define PI_APPROX 3.14159265358
00093 #endif
00094
00096
00097 #ifndef formal
00099 #define formal(parameter)
00100 #endif
00101
00102 #ifndef byte
00104 typedef unsigned char byte;
00105 #endif
00106
00107 #if defined(UNICODE) && defined(__WIN32__)
00109 typedef wchar_t flexichar;
00110 #else
00111
00112 typedef char flexichar;
00113 #endif
00114
00115 #ifndef u_int
00117 typedef unsigned int u_int;
00118 #endif
00119 #ifndef u_short
00121 typedef unsigned short u_short;
00122 #endif
00123 #ifndef u_long
00125 typedef unsigned long u_long;
00126 #endif
00127
00128
00129
00130
00131 #ifndef MAXINT
00133 #define MAXINT 0x7fffffff
00134 #endif
00135 #ifndef MININT
00137 #define MININT 0x80000000
00138 #endif
00139 #ifndef MAXLONG
00141 #define MAXLONG 0x7fffffff
00142 #endif
00143 #ifndef MINLONG
00145 #define MINLONG 0x80000000
00146 #endif
00147 #ifndef MAXCHAR
00149 #define MAXCHAR 0x7f
00150 #endif
00151 #ifndef MINCHAR
00153 #define MINCHAR 0x80
00154 #endif
00155 #ifndef MAXSHORT
00157 #define MAXSHORT 0x7fff
00158 #endif
00159 #ifndef MINSHORT
00161 #define MINSHORT 0x8000
00162 #endif
00163 #ifndef MAXBYTE
00165 #define MAXBYTE 0xff
00166 #endif
00167 #ifndef MINBYTE
00169 #define MINBYTE 0x00
00170 #endif
00171
00172
00173
00174 typedef char int8;
00175 typedef unsigned char uint8;
00176 typedef signed short int16;
00177 typedef unsigned short uint16;
00178 typedef signed long int32;
00179 typedef unsigned long uint32;
00180
00182
00183
00184
00185
00186 const int SECOND_ms = 1000;
00187 const int MINUTE_ms = 60 * SECOND_ms;
00188 const int HOUR_ms = 60 * MINUTE_ms;
00189 const int DAY_ms = 24 * HOUR_ms;
00190
00191
00192 const int MINUTE_s = 60;
00193 const int HOUR_s = 60 * MINUTE_s;
00194 const int DAY_s = 24 * HOUR_s;
00195
00196
00197
00198 const int KILOBYTE = 1024;
00199 const int MEGABYTE = KILOBYTE * KILOBYTE;
00200 const int GIGABYTE = MEGABYTE * KILOBYTE;
00201 inline double TERABYTE() { return double(GIGABYTE) * double(KILOBYTE); }
00203
00206
00207
00208
00209
00210
00211 class byte_array;
00212 class byte_sequence;
00213 class chaos;
00214 class int_array;
00215 class int_set;
00216 class istring;
00217 class istring_object;
00218 class mutex;
00219 class string_array;
00220 class unichar_sequence;
00221
00223
00225
00229 #define DEFINE_FILTER(NAME, CURRENT_VALUE, INFO_STRING) \
00230 NAME = CURRENT_VALUE
00231
00233
00235
00241 #define DEFINE_EVENT(NAME, CURRENT_VALUE, INFO_STRING) \
00242 NAME = CURRENT_VALUE
00243
00245
00247
00248 struct common {
00249
00251
00253 enum outcomes {
00254 DEFINE_API_OUTCOME(OKAY, 0, "Everything is just fine"),
00255 DEFINE_API_OUTCOME(NOT_IMPLEMENTED, -1, "The invoked method is "
00256 "unimplemented"),
00257 DEFINE_API_OUTCOME(OUT_OF_RANGE, -2, "The value specified was out "
00258 "of bounds"),
00259 DEFINE_API_OUTCOME(NOT_FOUND, -3, "The item sought is not present"),
00260 DEFINE_API_OUTCOME(BAD_INPUT, -4, "Precondition failure--the parameters "
00261 "were inappropriate"),
00262 DEFINE_API_OUTCOME(BAD_TYPE, -5, "The objects are of incompatible types"),
00263 DEFINE_API_OUTCOME(IS_FULL, -6, "There is no room in the storage facility"),
00264 DEFINE_API_OUTCOME(IS_EMPTY, -7, "The container is empty currently"),
00265 DEFINE_API_OUTCOME(IS_NEW, -8, "The item is new"),
00266 DEFINE_API_OUTCOME(EXISTING, -9, "The item was already present"),
00267 DEFINE_API_OUTCOME(FAILURE, -10, "A failure has occurred"),
00268 DEFINE_API_OUTCOME(OUT_OF_MEMORY, -11, "There is not enough memory for the "
00269 "request according to the operating system"),
00270 DEFINE_API_OUTCOME(ACCESS_DENIED, -12, "The request was denied, possibly "
00271 "by the operating system"),
00272 DEFINE_API_OUTCOME(IN_USE, -13, "The object is already in exclusive use"),
00273 DEFINE_API_OUTCOME(UNINITIALIZED, -14, "The object has not been "
00274 "constructed properly"),
00275 DEFINE_API_OUTCOME(TIMED_OUT, -15, "The allowed time has now elapsed"),
00276 DEFINE_API_OUTCOME(GARBAGE, -16, "The request or response has been "
00277 "corrupted"),
00278 DEFINE_API_OUTCOME(NO_SPACE, -17, "A programmatic limit on storage space "
00279 "has been reached"),
00280 DEFINE_API_OUTCOME(DISALLOWED, -18, "The method denied the request"),
00281 DEFINE_API_OUTCOME(INCOMPLETE, -19, "The operation did not finish or the "
00282 "object is not completed"),
00283 DEFINE_API_OUTCOME(NO_HANDLER, -20, "The object type passed in was not "
00284 "understood by the invoked method"),
00285 DEFINE_API_OUTCOME(NONE_READY, -21, "There were no objects available"),
00286 DEFINE_API_OUTCOME(INVALID, -22, "That request or object was invalid"),
00287 DEFINE_API_OUTCOME(PARTIAL, -23, "The request was only partially finished"),
00288 DEFINE_API_OUTCOME(NO_LICENSE, -24, "The software license does not permit"
00289 "this request"),
00290 DEFINE_API_OUTCOME(UNEXPECTED, -25, "This item was unexpected, although "
00291 "not necessarily erroneous"),
00292 DEFINE_API_OUTCOME(ENCRYPTION_MISMATCH, -26, "The request failed due to a "
00293 "mismatch between encryption expected and encryption provided")
00294 };
00295
00296 static const char *outcome_name(const outcome &to_name);
00298
00303 enum list_positions {
00304 HEAD = -298,
00305 TAIL,
00306 MIDDLE
00307 };
00308
00309 enum how_to_copy { NEW_AT_END, NEW_AT_BEGINNING, DONT_COPY };
00311
00321
00322 enum filters {
00323 DEFINE_FILTER(NEVER_PRINT, -1, "Indicates that the diagnostic entry "
00324 "should be dropped"),
00325 DEFINE_FILTER(ALWAYS_PRINT, 0, "Indicates that the diagnostic entry "
00326 "should always be recorded"),
00327 DEFINE_FILTER(NETWORK_LOGGING, 1, "Extra logging of network events "
00328 "will be performed"),
00329 DEFINE_FILTER(UNUSUAL_LOGGING, 2, "Logging of unusual but not "
00330 "necessarily erroneous events"),
00331
00332
00333 FIRST_LOW_LEVEL_FILTER = NETWORK_LOGGING,
00334 LAST_LOW_LEVEL_FILTER = UNUSUAL_LOGGING
00335 };
00336
00337 static int_set low_level_filters();
00339 };
00340
00342
00343
00344
00345
00346
00347
00348
00349
00350 #ifdef __UNIX__
00351 extern int __argc;
00352 extern char **__argv;
00354 #define DEFINE_ARGC_AND_ARGV int __argc = 0; char **__argv = NIL
00355 #elif defined(__WIN32__)
00356 #include <stdlib.h>
00357
00358 #define DEFINE_ARGC_AND_ARGV
00359
00360 #else
00361
00362 extern int __argc;
00363 extern char **__argv;
00364 #define DEFINE_ARGC_AND_ARGV int __argc = 0; char **__argv = NIL
00365 #endif
00366
00368
00369 #ifdef ENABLE_MEMORY_HOOK
00370
00371
00372
00373
00374
00375 #define _AFX_NO_DEBUG_CRT
00376
00377
00378 #ifndef __WIN32__
00380 void *operator new(size_t size, char *file, int line) throw (std::bad_alloc);
00381
00383 inline void* operator new [] (size_t size, char *file, int line)
00384 throw (std::bad_alloc) { return ::operator new(size, file, line); }
00385
00387 void operator delete (void *ptr) throw ();
00388
00390 inline void operator delete [] (void *ptr) throw ()
00391 { ::operator delete(ptr); }
00392 #else
00393
00394 void *operator new(size_t size, char *file, int line);
00395 inline void* operator new [] (size_t size, char *file, int line)
00396 { return ::operator new(size, file, line); }
00397 void operator delete (void *ptr);
00398 inline void operator delete [] (void *ptr) { ::operator delete(ptr); }
00399 inline void operator delete (void *ptr, char *file, int line)
00400 { ::operator delete(ptr); }
00401 inline void operator delete [] (void *ptr, char *file, int line)
00402 { ::operator delete(ptr); }
00403 #endif
00404
00406 #define HOOPLE_NEW new(__FILE__, __LINE__)
00407
00409 #define new HOOPLE_NEW
00410
00411 #endif // ENABLE_MEMORY_HOOK
00412
00414
00415
00416
00417 #if defined(__WIN32__) || defined(_MSC_VER)
00418
00419
00420
00421 #ifndef WIN32
00422 #define WIN32
00423 #endif
00424 #ifndef __WIN32__
00425 #define __WIN32__
00426 #endif
00427 #ifndef _WIN32
00428 #define _WIN32
00429 #endif
00430 #ifndef _Windows
00431 #define _Windows
00432 #endif
00433 #ifndef _WINDOWS
00434 #define _WINDOWS
00435 #endif
00436
00437 #ifdef _MSC_VER
00438
00439
00440
00441 #ifdef _AFXDLL
00442 #ifdef _DEBUG
00443 #ifndef ENABLE_MEMORY_HOOK
00444
00445 #include <afx.h>
00446 #define new DEBUG_NEW
00447
00448 #endif
00449 #endif
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461 #ifdef _M_IX86
00462 #pragma comment(linker,"/manifestdependency:\"type='win32' " \
00463 "name='Microsoft.Windows.Common-Controls' " \
00464 "version='6.0.0.0' " \
00465 "processorArchitecture='x86' " \
00466 "publicKeyToken='6595b64144ccf1df' " \
00467 "language='*'\"")
00468 #endif
00469
00470 #ifdef _M_AMD64
00471 #pragma comment(linker,"/manifestdependency:\"type='win32' " \
00472 "name='Microsoft.Windows.Common-Controls' " \
00473 "version='6.0.0.0' " \
00474 "processorArchitecture='amd64' " \
00475 "publicKeyToken='6595b64144ccf1df' " \
00476 "language='*'\"")
00477 #endif
00478
00479 #ifdef _M_IA64
00480 #pragma comment(linker,"/manifestdependency:\"type='win32' " \
00481 "name='Microsoft.Windows.Common-Controls' " \
00482 "version='6.0.0.0' " \
00483 "processorArchitecture='ia64' " \
00484 "publicKeyToken='6595b64144ccf1df' " \
00485 "language='*'\"")
00486 #endif
00487
00488 #endif
00489
00490
00491 #pragma warning(disable : 4251 4275 4003 4800 4355 4786 4290 4996 4407)
00492 #pragma warning(error : 4172)
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507 #endif // visual c++.
00508
00509 #elif defined(__UNIX__)
00510 #define LOBYTE(to_chop) (byte(to_chop))
00512 #define HIBYTE(to_chop) (byte(0xff & (u_short(to_chop) >> 8)))
00514 #else
00515
00516
00517 typedef int bool;
00518 enum _boolean_enumeration_ { false, true };
00519 #endif
00520
00521 #endif // outer guard.
00522