lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #ifndef _h_UEMF |
| 2 | #define _h_UEMF 1 |
| 3 | |
| 4 | #ifdef WIN |
| 5 | #include <direct.h> |
| 6 | #include <io.h> |
| 7 | #include <sys/stat.h> |
| 8 | #include <limits.h> |
| 9 | #include <tchar.h> |
| 10 | #include <windows.h> |
| 11 | #include <winnls.h> |
| 12 | #include <time.h> |
| 13 | #include <sys/types.h> |
| 14 | #include <stdio.h> |
| 15 | #include <stdlib.h> |
| 16 | #include <fcntl.h> |
| 17 | #include <errno.h> |
| 18 | #endif /* WIN */ |
| 19 | |
| 20 | #ifdef CE |
| 21 | /*#include <errno.h>*/ |
| 22 | #include <limits.h> |
| 23 | #include <tchar.h> |
| 24 | #include <windows.h> |
| 25 | #include <winsock.h> |
| 26 | #include <winnls.h> |
| 27 | #include "CE/wincompat.h" |
| 28 | #include <winsock.h> |
| 29 | #endif /* CE */ |
| 30 | |
| 31 | #ifdef NW |
| 32 | #include <direct.h> |
| 33 | #include <io.h> |
| 34 | #include <sys/stat.h> |
| 35 | #include <time.h> |
| 36 | #include <sys/types.h> |
| 37 | #include <stdio.h> |
| 38 | #include <stdlib.h> |
| 39 | #include <fcntl.h> |
| 40 | #include <errno.h> |
| 41 | #include <niterror.h> |
| 42 | #define EINTR EINUSE |
| 43 | #define WEBS 1 |
| 44 | #include <limits.h> |
| 45 | #include <netdb.h> |
| 46 | #include <process.h> |
| 47 | #include <tiuser.h> |
| 48 | #include <sys/time.h> |
| 49 | #include <arpa/inet.h> |
| 50 | #include <sys/types.h> |
| 51 | #include <sys/socket.h> |
| 52 | #include <sys/filio.h> |
| 53 | #include <netinet/in.h> |
| 54 | #endif /* NW */ |
| 55 | |
| 56 | #ifdef SCOV5 |
| 57 | #include <sys/types.h> |
| 58 | #include <stdio.h> |
| 59 | #include "sys/socket.h" |
| 60 | #include "sys/select.h" |
| 61 | #include "netinet/in.h" |
| 62 | #include "arpa/inet.h" |
| 63 | #include "netdb.h" |
| 64 | #endif /* SCOV5 */ |
| 65 | |
| 66 | #ifdef UNIX |
| 67 | #include <stdio.h> |
| 68 | #endif /* UNIX */ |
| 69 | |
| 70 | #ifdef LINUX |
| 71 | #include <sys/types.h> |
| 72 | #include <sys/stat.h> |
| 73 | #include <sys/param.h> |
| 74 | #include <limits.h> |
| 75 | #include <stdio.h> |
| 76 | #include <stdlib.h> |
| 77 | #include <unistd.h> |
| 78 | #include <sys/socket.h> |
| 79 | #include <sys/select.h> |
| 80 | #include <netinet/in.h> |
| 81 | #include <arpa/inet.h> |
| 82 | #include <netdb.h> |
| 83 | #include <time.h> |
| 84 | #include <fcntl.h> |
| 85 | #include <errno.h> |
| 86 | #endif /* LINUX */ |
| 87 | |
| 88 | #ifdef LYNX |
| 89 | #include <limits.h> |
| 90 | #include <stdarg.h> |
| 91 | #include <stdio.h> |
| 92 | #include <stdlib.h> |
| 93 | #include <unistd.h> |
| 94 | #include <socket.h> |
| 95 | #include <netinet/in.h> |
| 96 | #include <arpa/inet.h> |
| 97 | #include <netdb.h> |
| 98 | #include <time.h> |
| 99 | #include <fcntl.h> |
| 100 | #include <errno.h> |
| 101 | #endif /* LYNX */ |
| 102 | |
| 103 | #ifdef MACOSX |
| 104 | #include <sys/stat.h> |
| 105 | #include <stdio.h> |
| 106 | #include <stdlib.h> |
| 107 | #include <unistd.h> |
| 108 | #include <sys/socket.h> |
| 109 | #include <netinet/in.h> |
| 110 | #include <arpa/inet.h> |
| 111 | #include <netdb.h> |
| 112 | #include <fcntl.h> |
| 113 | #include <errno.h> |
| 114 | #endif /* MACOSX */ |
| 115 | |
| 116 | #ifdef UW |
| 117 | #include <stdio.h> |
| 118 | #endif /* UW */ |
| 119 | |
| 120 | #ifdef VXWORKS |
| 121 | #include <vxWorks.h> |
| 122 | #include <sockLib.h> |
| 123 | #include <selectLib.h> |
| 124 | #include <inetLib.h> |
| 125 | #include <ioLib.h> |
| 126 | #include <stdio.h> |
| 127 | #include <stat.h> |
| 128 | #include <time.h> |
| 129 | #include <usrLib.h> |
| 130 | #include <fcntl.h> |
| 131 | #include <errno.h> |
| 132 | #endif /* VXWORKS */ |
| 133 | |
| 134 | #ifdef sparc |
| 135 | # define __NO_PACK |
| 136 | #endif /* sparc */ |
| 137 | |
| 138 | #ifdef SOLARIS |
| 139 | #include <sys/types.h> |
| 140 | #include <limits.h> |
| 141 | #include <stdio.h> |
| 142 | #include <stdlib.h> |
| 143 | #include <unistd.h> |
| 144 | #include <socket.h> |
| 145 | #include <sys/select.h> |
| 146 | #include <netinet/in.h> |
| 147 | #include <arpa/inet.h> |
| 148 | #include <netdb.h> |
| 149 | #include <time.h> |
| 150 | #include <fcntl.h> |
| 151 | #include <errno.h> |
| 152 | #endif /* SOLARIS */ |
| 153 | |
| 154 | #ifdef QNX4 |
| 155 | #include <sys/types.h> |
| 156 | #include <stdio.h> |
| 157 | #include <sys/socket.h> |
| 158 | #include <sys/select.h> |
| 159 | #include <netinet/in.h> |
| 160 | #include <arpa/inet.h> |
| 161 | #include <netdb.h> |
| 162 | #include <stdlib.h> |
| 163 | #include <unistd.h> |
| 164 | #include <sys/uio.h> |
| 165 | #include <sys/wait.h> |
| 166 | #endif /* QNX4 */ |
| 167 | |
| 168 | #ifdef ECOS |
| 169 | #include <limits.h> |
| 170 | #include <cyg/infra/cyg_type.h> |
| 171 | #include <cyg/kernel/kapi.h> |
| 172 | #include <time.h> |
| 173 | #include <network.h> |
| 174 | #include <errno.h> |
| 175 | #endif /* ECOS */ |
| 176 | |
| 177 | #include <ctype.h> |
| 178 | #include <stdarg.h> |
| 179 | #include <string.h> |
| 180 | |
| 181 | #ifndef WEBS |
| 182 | #include "messages.h" |
| 183 | #endif /* ! WEBS */ |
| 184 | |
| 185 | #ifdef UW |
| 186 | #define __NO_PACK 1 |
| 187 | #endif /* UW */ |
| 188 | |
| 189 | #if (defined (SCOV5) || defined (VXWORKS) || defined (LINUX) || defined (LYNX) || defined (MACOSX)) |
| 190 | #ifndef O_BINARY |
| 191 | #define O_BINARY 0 |
| 192 | #endif /* O_BINARY */ |
| 193 | #define SOCKET_ERROR -1 |
| 194 | #endif /* SCOV5 || VXWORKS || LINUX || LYNX || MACOSX */ |
| 195 | |
| 196 | #if (defined (WIN) || defined (CE)) |
| 197 | |
| 198 | #define __NO_FCNTL 1 |
| 199 | |
| 200 | #undef R_OK |
| 201 | #define R_OK 4 |
| 202 | #undef W_OK |
| 203 | #define W_OK 2 |
| 204 | #undef X_OK |
| 205 | #define X_OK 1 |
| 206 | #undef F_OK |
| 207 | #define F_OK 0 |
| 208 | #endif /* WIN || CE */ |
| 209 | |
| 210 | #if (defined (LINUX) && !defined (_STRUCT_TIMEVAL)) |
| 211 | struct timeval |
| 212 | { |
| 213 | time_t tv_sec; |
| 214 | time_t tv_usec; |
| 215 | }; |
| 216 | #define _STRUCT_TIMEVAL 1 |
| 217 | #endif /* LINUX && ! _STRUCT_TIMEVAL */ |
| 218 | |
| 219 | #ifdef ECOS |
| 220 | #define O_RDONLY 1 |
| 221 | #define O_BINARY 2 |
| 222 | |
| 223 | #define __NO_PACK 1 |
| 224 | #define __NO_EJ_FILE 1 |
| 225 | #define __NO_CGI_BIN 1 |
| 226 | #define __NO_FCNTL 1 |
| 227 | |
| 228 | #define LIBKERN_INLINE |
| 229 | |
| 230 | #endif /* ECOS */ |
| 231 | |
| 232 | #ifdef QNX4 |
| 233 | typedef long fd_mask; |
| 234 | #define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */ |
| 235 | #endif /* QNX4 */ |
| 236 | |
| 237 | #ifdef NW |
| 238 | #define fd_mask fd_set |
| 239 | #define INADDR_NONE -1l |
| 240 | #define Sleep delay |
| 241 | |
| 242 | #define __NO_FCNTL 1 |
| 243 | |
| 244 | #undef R_OK |
| 245 | #define R_OK 4 |
| 246 | #undef W_OK |
| 247 | #define W_OK 2 |
| 248 | #undef X_OK |
| 249 | #define X_OK 1 |
| 250 | #undef F_OK |
| 251 | #define F_OK 0 |
| 252 | #endif /* NW */ |
| 253 | |
| 254 | #define TRACE_MAX (4096 - 48) |
| 255 | #define VALUE_MAX_STRING (4096 - 48) |
| 256 | #define SYM_MAX (512) |
| 257 | #define XML_MAX 4096 |
| 258 | #define BUF_MAX 4096 |
| 259 | #define FMT_STATIC_MAX 256 |
| 260 | |
| 261 | #if (defined (LITTLEFOOT) || defined (WEBS)) |
| 262 | #define LF_BUF_MAX (510) |
| 263 | #define LF_PATHSIZE LF_BUF_MAX |
| 264 | #else |
| 265 | #define LF_BUF_MAX BUF_MAX |
| 266 | #define LF_PATHSIZE PATHSIZE |
| 267 | #define UPPATHSIZE PATHSIZE |
| 268 | #endif /* LITTLEFOOT || WEBS */ |
| 269 | |
| 270 | #ifndef CHAR_T_DEFINED |
| 271 | #define CHAR_T_DEFINED 1 |
| 272 | #ifdef UNICODE |
| 273 | |
| 274 | #define T(x) __TXT(x) |
| 275 | #define __TXT(s) L ## s |
| 276 | typedef unsigned short char_t; |
| 277 | typedef unsigned short uchar_t; |
| 278 | |
| 279 | #define TSZ(x) (sizeof(x) / sizeof(char_t)) |
| 280 | |
| 281 | #define TASTRL(x) ((wcslen(x) + 1) * sizeof(char_t)) |
| 282 | |
| 283 | #else |
| 284 | #define T(s) s |
| 285 | typedef char char_t; |
| 286 | #define TSZ(x) (sizeof(x)) |
| 287 | #define TASTRL(x) (strlen(x) + 1) |
| 288 | #ifdef WIN |
| 289 | typedef unsigned char uchar_t; |
| 290 | #endif /* WIN */ |
| 291 | |
| 292 | #endif /* UNICODE */ |
| 293 | |
| 294 | #endif /* ! CHAR_T_DEFINED */ |
| 295 | |
| 296 | #ifndef TRUE |
| 297 | #define TRUE 1 |
| 298 | #endif |
| 299 | |
| 300 | #ifndef FALSE |
| 301 | #define FALSE 0 |
| 302 | #endif |
| 303 | |
| 304 | #define GOAHEAD_COPYRIGHT \ |
| 305 | T("Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.") |
| 306 | |
| 307 | #if (defined (LITTLEFOOT) && defined (INMEM)) |
| 308 | #include "lf/inmem.h" |
| 309 | #endif /* LITTLEFOOT && INMEM */ |
| 310 | |
| 311 | #ifdef UNICODE |
| 312 | |
| 313 | #define gmain wmain |
| 314 | |
| 315 | #define gasctime _wasctime |
| 316 | #define gsprintf swprintf |
| 317 | #define gprintf wprintf |
| 318 | #define gfprintf fwprintf |
| 319 | #define gsscanf swscanf |
| 320 | #define gvsprintf vswprintf |
| 321 | |
| 322 | #define gstrcpy wcscpy |
| 323 | #define gstrncpy wcsncpy |
| 324 | #define gstrncat wcsncat |
| 325 | #define gstrlen wcslen |
| 326 | #define gstrcat wcscat |
| 327 | #define gstrcmp wcscmp |
| 328 | #define gstrncmp wcsncmp |
| 329 | #define gstricmp wcsicmp |
| 330 | #define gstrchr wcschr |
| 331 | #define gstrrchr wcsrchr |
| 332 | #define gstrtok wcstok |
| 333 | #define gstrnset wcsnset |
| 334 | #define gstrrchr wcsrchr |
| 335 | #define gstrspn wcsspn |
| 336 | #define gstrcspn wcscspn |
| 337 | #define gstrstr wcsstr |
| 338 | #define gstrtol wcstol |
| 339 | |
| 340 | #define gfopen _wfopen |
| 341 | #define gopen _wopen |
| 342 | #define gclose close |
| 343 | #define gcreat _wcreat |
| 344 | #define gfgets fgetws |
| 345 | #define gfputs fputws |
| 346 | #define gfscanf fwscanf |
| 347 | #define ggets _getws |
| 348 | #define glseek lseek |
| 349 | #define gunlink _wunlink |
| 350 | #define gread read |
| 351 | #define grename _wrename |
| 352 | #define gwrite write |
| 353 | #define gtmpnam _wtmpnam |
| 354 | #define gtempnam _wtempnam |
| 355 | #define gfindfirst _wfindfirst |
| 356 | #define gfinddata_t _wfinddata_t |
| 357 | #define gfindnext _wfindnext |
| 358 | #define gfindclose _findclose |
| 359 | #define gstat _wstat |
| 360 | #define gaccess _waccess |
| 361 | #define gchmod _wchmod |
| 362 | |
| 363 | typedef struct _stat gstat_t; |
| 364 | |
| 365 | #define gmkdir _wmkdir |
| 366 | #define gchdir _wchdir |
| 367 | #define grmdir _wrmdir |
| 368 | #define ggetcwd _wgetcwd |
| 369 | |
| 370 | #define gtolower towlower |
| 371 | #define gtoupper towupper |
| 372 | #ifdef CE |
| 373 | #define gisspace isspace |
| 374 | #define gisdigit isdigit |
| 375 | #define gisxdigit isxdigit |
| 376 | #define gisupper isupper |
| 377 | #define gislower islower |
| 378 | #define gisprint isprint |
| 379 | #else |
| 380 | #define gremove _wremove |
| 381 | #define gisspace iswspace |
| 382 | #define gisdigit iswdigit |
| 383 | #define gisxdigit iswxdigit |
| 384 | #define gisupper iswupper |
| 385 | #define gislower iswlower |
| 386 | #endif /* if CE */ |
| 387 | #define gisalnum iswalnum |
| 388 | #define gisalpha iswalpha |
| 389 | #define gatoi(s) wcstol(s, NULL, 10) |
| 390 | |
| 391 | #define gctime _wctime |
| 392 | #define ggetenv _wgetenv |
| 393 | #define gexecvp _wexecvp |
| 394 | |
| 395 | #else /* ! UNICODE */ |
| 396 | |
| 397 | #ifdef VXWORKS |
| 398 | #define gchdir vxchdir |
| 399 | #define gmkdir vxmkdir |
| 400 | #define grmdir vxrmdir |
| 401 | #elif (defined (LYNX) || defined (LINUX) || defined (MACOSX) || defined (SOLARIS)) |
| 402 | #define gchdir chdir |
| 403 | #define gmkdir(s) mkdir(s,0755) |
| 404 | #define grmdir rmdir |
| 405 | #else |
| 406 | #define gchdir chdir |
| 407 | #define gmkdir mkdir |
| 408 | #define grmdir rmdir |
| 409 | #endif /* VXWORKS #elif LYNX || LINUX || MACOSX || SOLARIS*/ |
| 410 | |
| 411 | #define gclose close |
| 412 | #define gclosedir closedir |
| 413 | #define gchmod chmod |
| 414 | #define ggetcwd getcwd |
| 415 | #define glseek lseek |
| 416 | #define gloadModule loadModule |
| 417 | #define gopen open |
| 418 | #define gopendir opendir |
| 419 | #define gread read |
| 420 | #define greaddir readdir |
| 421 | #define grename rename |
| 422 | #define gstat stat |
| 423 | #define gunlink unlink |
| 424 | #define gwrite write |
| 425 | |
| 426 | #define gasctime asctime |
| 427 | #define gsprintf sprintf |
| 428 | #define gprintf printf |
| 429 | #define gfprintf fprintf |
| 430 | #define gsscanf sscanf |
| 431 | #define gvsprintf vsprintf |
| 432 | |
| 433 | #define gstrcpy strcpy |
| 434 | #define gstrncpy strncpy |
| 435 | #define gstrncat strncat |
| 436 | #define gstrlen strlen |
| 437 | #define gstrcat strcat |
| 438 | #define gstrcmp strcmp |
| 439 | #define gstrncmp strncmp |
| 440 | #define gstricmp strcmpci |
| 441 | #define gstrchr strchr |
| 442 | #define gstrrchr strrchr |
| 443 | #define gstrtok strtok |
| 444 | #define gstrnset strnset |
| 445 | #define gstrrchr strrchr |
| 446 | #define gstrspn strspn |
| 447 | #define gstrcspn strcspn |
| 448 | #define gstrstr strstr |
| 449 | #define gstrtol strtol |
| 450 | |
| 451 | #define gfopen fopen |
| 452 | #define gcreat creat |
| 453 | #define gfgets fgets |
| 454 | #define gfputs fputs |
| 455 | #define gfscanf fscanf |
| 456 | #define ggets gets |
| 457 | #define gtmpnam tmpnam |
| 458 | #define gtempnam tempnam |
| 459 | #define gfindfirst _findfirst |
| 460 | #define gfinddata_t _finddata_t |
| 461 | #define gfindnext _findnext |
| 462 | #define gfindclose _findclose |
| 463 | #define gaccess access |
| 464 | |
| 465 | typedef struct stat gstat_t; |
| 466 | |
| 467 | #define gremove remove |
| 468 | |
| 469 | #define gtolower tolower |
| 470 | #define gtoupper toupper |
| 471 | #define gisspace isspace |
| 472 | #define gisdigit isdigit |
| 473 | #define gisxdigit isxdigit |
| 474 | #define gisalnum isalnum |
| 475 | #define gisalpha isalpha |
| 476 | #define gisupper isupper |
| 477 | #define gislower islower |
| 478 | #define gatoi atoi |
| 479 | |
| 480 | #define gctime ctime |
| 481 | #define ggetenv getenv |
| 482 | #define gexecvp execvp |
| 483 | #ifndef VXWORKS |
| 484 | #define gmain main |
| 485 | #endif /* ! VXWORKS */ |
| 486 | #ifdef VXWORKS |
| 487 | #define fcntl(a, b, c) |
| 488 | #endif /* VXWORKS */ |
| 489 | #endif /* ! UNICODE */ |
| 490 | |
| 491 | #ifdef INMEM |
| 492 | #include "lf/inmem.h" |
| 493 | #endif |
| 494 | |
| 495 | #ifndef FNAMESIZE |
| 496 | #define FNAMESIZE 254 |
| 497 | #endif /* FNAMESIZE */ |
| 498 | |
| 499 | #define E_MAX_ERROR 4096 |
| 500 | #define URL_MAX 4096 |
| 501 | |
| 502 | #define E_ASSERT 0x1 |
| 503 | #define E_LOG 0x2 |
| 504 | #define E_USER 0x3 |
| 505 | |
| 506 | #define E_L T(__FILE__), __LINE__ |
| 507 | #define E_ARGS_DEC char_t *file, int line |
| 508 | #define E_ARGS file, line |
| 509 | |
| 510 | #if (defined (ASSERT) || defined (ASSERT_CE)) |
| 511 | #define a_assert(C) if (C) ; else error(E_L, E_ASSERT, T("%s"), T(#C)) |
| 512 | #else |
| 513 | #define a_assert(C) if (1) ; else |
| 514 | #endif /* ASSERT || ASSERT_CE */ |
| 515 | |
| 516 | typedef enum { |
| 517 | undefined = 0, |
| 518 | byteint = 1, |
| 519 | shortint = 2, |
| 520 | integer = 3, |
| 521 | hex = 4, |
| 522 | percent = 5, |
| 523 | octal = 6, |
| 524 | big = 7, |
| 525 | flag = 8, |
| 526 | floating = 9, |
| 527 | string = 10, |
| 528 | bytes = 11, |
| 529 | symbol = 12, |
| 530 | errmsg = 13 |
| 531 | } vtype_t; |
| 532 | |
| 533 | #ifndef __NO_PACK |
| 534 | #pragma pack(2) |
| 535 | #endif /* _NO_PACK */ |
| 536 | |
| 537 | typedef struct { |
| 538 | |
| 539 | union { |
| 540 | char flag; |
| 541 | char byteint; |
| 542 | short shortint; |
| 543 | char percent; |
| 544 | long integer; |
| 545 | long hex; |
| 546 | long octal; |
| 547 | long big[2]; |
| 548 | #ifdef FLOATING_POINT_SUPPORT |
| 549 | double floating; |
| 550 | #endif /* FLOATING_POINT_SUPPORT */ |
| 551 | char_t *string; |
| 552 | char *bytes; |
| 553 | char_t *errmsg; |
| 554 | void *symbol; |
| 555 | } value; |
| 556 | |
| 557 | vtype_t type; |
| 558 | unsigned int valid : 8; |
| 559 | unsigned int allocated : 8; |
| 560 | } value_t; |
| 561 | |
| 562 | #ifndef __NO_PACK |
| 563 | #pragma pack() |
| 564 | #endif /* __NO_PACK */ |
| 565 | |
| 566 | #define VALUE_ALLOCATE 0x1 |
| 567 | |
| 568 | #define value_numeric(t) (t >= byteint && t <= big) |
| 569 | #define value_str(t) (t >= string && t <= bytes) |
| 570 | #define value_ok(t) (t > undefined && t <= symbol) |
| 571 | |
| 572 | #define VALUE_VALID { {0}, integer, 1 } |
| 573 | #define VALUE_INVALID { {0}, undefined, 0 } |
| 574 | |
| 575 | typedef struct { |
| 576 | unsigned char *buf; |
| 577 | unsigned char *servp; |
| 578 | unsigned char *endp; |
| 579 | unsigned char *endbuf; |
| 580 | int buflen; |
| 581 | int maxsize; |
| 582 | int increment; |
| 583 | } ringq_t; |
| 584 | |
| 585 | #ifdef B_STATS |
| 586 | #ifndef B_L |
| 587 | #define B_L T(__FILE__), __LINE__ |
| 588 | #define B_ARGS_DEC char_t *file, int line |
| 589 | #define B_ARGS file, line |
| 590 | #endif /* B_L */ |
| 591 | #endif /* B_STATS */ |
| 592 | |
| 593 | typedef struct { |
| 594 | union { |
| 595 | void *next; |
| 596 | int size; |
| 597 | } u; |
| 598 | int flags; |
| 599 | } bType; |
| 600 | |
| 601 | #define B_SHIFT 4 |
| 602 | #define B_ROUND ((1 << (B_SHIFT)) - 1) |
| 603 | #define B_MAX_CLASS 13 |
| 604 | #define B_MALLOCED 0x80000000 |
| 605 | #define B_DEFAULT_MEM (64 * 1024) |
| 606 | #define B_MAX_FILES (512) |
| 607 | #define B_FILL_CHAR (0x77) |
| 608 | #define B_FILL_WORD (0x77777777) |
| 609 | #define B_MAX_BLOCKS (64 * 1024) |
| 610 | |
| 611 | |
| 612 | #define B_INTEGRITY 0x8124000 |
| 613 | #define B_INTEGRITY_MASK 0xFFFF000 |
| 614 | #define B_USE_MALLOC 0x1 |
| 615 | #define B_USER_BUF 0x2 |
| 616 | |
| 617 | |
| 618 | typedef struct sym_t { |
| 619 | struct sym_t *forw; |
| 620 | value_t name; |
| 621 | value_t content; |
| 622 | int arg; |
| 623 | } sym_t; |
| 624 | |
| 625 | typedef int sym_fd_t; |
| 626 | |
| 627 | #define EMF_SCRIPT_JSCRIPT 0 |
| 628 | #define EMF_SCRIPT_TCL 1 |
| 629 | #define EMF_SCRIPT_EJSCRIPT 2 |
| 630 | #define EMF_SCRIPT_MAX 3 |
| 631 | |
| 632 | #define MAXINT INT_MAX |
| 633 | #define BITSPERBYTE 8 |
| 634 | #define BITS(type) (BITSPERBYTE * (int) sizeof(type)) |
| 635 | #define STRSPACE T("\t \n\r\t") |
| 636 | |
| 637 | #ifndef max |
| 638 | #define max(a,b) (((a) > (b)) ? (a) : (b)) |
| 639 | #endif /* max */ |
| 640 | |
| 641 | #ifndef min |
| 642 | #define min(a,b) (((a) < (b)) ? (a) : (b)) |
| 643 | #endif /* min */ |
| 644 | |
| 645 | typedef struct { |
| 646 | char_t *minute; |
| 647 | char_t *hour; |
| 648 | char_t *day; |
| 649 | char_t *month; |
| 650 | char_t *dayofweek; |
| 651 | } cron_t; |
| 652 | |
| 653 | extern long cronUntil(cron_t *cp, int period, time_t testTime); |
| 654 | extern int cronAlloc(cron_t *cp, char_t *str); |
| 655 | extern int cronFree(cron_t *cp); |
| 656 | |
| 657 | |
| 658 | #if ((defined (WIN) || defined (CE)) && defined (WEBS)) |
| 659 | #define EWOULDBLOCK WSAEWOULDBLOCK |
| 660 | #define ENETDOWN WSAENETDOWN |
| 661 | #define ECONNRESET WSAECONNRESET |
| 662 | #endif /* (WIN || CE) && WEBS) */ |
| 663 | |
| 664 | #define SOCKET_EOF 0x1 |
| 665 | #define SOCKET_CONNECTING 0x2 |
| 666 | #define SOCKET_BROADCAST 0x4 |
| 667 | #define SOCKET_PENDING 0x8 |
| 668 | #define SOCKET_FLUSHING 0x10 |
| 669 | #define SOCKET_DATAGRAM 0x20 |
| 670 | #define SOCKET_ASYNC 0x40 |
| 671 | #define SOCKET_BLOCK 0x80 |
| 672 | #define SOCKET_LISTENING 0x100 |
| 673 | #define SOCKET_CLOSING 0x200 |
| 674 | #define SOCKET_CONNRESET 0x400 |
| 675 | |
| 676 | #define SOCKET_PORT_MAX 0xffff |
| 677 | |
| 678 | |
| 679 | #define SOCKET_WOULDBLOCK 1 |
| 680 | #define SOCKET_RESET 2 |
| 681 | #define SOCKET_NETDOWN 3 |
| 682 | #define SOCKET_AGAIN 4 |
| 683 | #define SOCKET_INTR 5 |
| 684 | #define SOCKET_INVAL 6 |
| 685 | |
| 686 | #define SOCKET_READABLE 0x2 |
| 687 | #define SOCKET_WRITABLE 0x4 |
| 688 | #define SOCKET_EXCEPTION 0x8 |
| 689 | #define EMF_SOCKET_MESSAGE (WM_USER+13) |
| 690 | |
| 691 | #ifdef LITTLEFOOT |
| 692 | #define SOCKET_BUFSIZ 510 |
| 693 | #else |
| 694 | #define SOCKET_BUFSIZ 1024 |
| 695 | #endif /* LITTLEFOOT */ |
| 696 | |
| 697 | typedef void (*socketHandler_t)(int sid, int mask, int data); |
| 698 | typedef int (*socketAccept_t)(int sid, char *ipaddr, int port, |
| 699 | int listenSid); |
| 700 | typedef struct { |
| 701 | char host[64]; |
| 702 | ringq_t inBuf; |
| 703 | ringq_t outBuf; |
| 704 | ringq_t lineBuf; |
| 705 | socketAccept_t accept; |
| 706 | socketHandler_t handler; |
| 707 | int handler_data; |
| 708 | int handlerMask; |
| 709 | int sid; |
| 710 | int port; |
| 711 | int flags; |
| 712 | int sock; |
| 713 | int fileHandle; |
| 714 | int interestEvents; |
| 715 | int currentEvents; |
| 716 | int selectEvents; |
| 717 | int saveMask; |
| 718 | int error; |
| 719 | } socket_t; |
| 720 | |
| 721 | |
| 722 | extern void bclose(); |
| 723 | extern int bopen(void *buf, int bufsize, int flags); |
| 724 | |
| 725 | |
| 726 | #ifdef NO_BALLOC |
| 727 | #define balloc(B_ARGS, num) malloc(num) |
| 728 | #define bfree(B_ARGS, p) free(p) |
| 729 | #define bfreeSafe(B_ARGS, p) \ |
| 730 | if (p) { free(p); } else |
| 731 | #define brealloc(B_ARGS, p, num) realloc(p, num) |
| 732 | extern char_t *bstrdupNoBalloc(char_t *s); |
| 733 | extern char *bstrdupANoBalloc(char *s); |
| 734 | #define bstrdup(B_ARGS, s) bstrdupNoBalloc(s) |
| 735 | #define bstrdupA(B_ARGS, s) bstrdupANoBalloc(s) |
| 736 | #define gstrdup(B_ARGS, s) bstrdupNoBalloc(s) |
| 737 | |
| 738 | #else /* BALLOC */ |
| 739 | |
| 740 | #ifndef B_STATS |
| 741 | #define balloc(B_ARGS, num) balloc(num) |
| 742 | #define bfree(B_ARGS, p) bfree(p) |
| 743 | #define bfreeSafe(B_ARGS, p) bfreeSafe(p) |
| 744 | #define brealloc(B_ARGS, p, size) brealloc(p, size) |
| 745 | #define bstrdup(B_ARGS, p) bstrdup(p) |
| 746 | |
| 747 | #ifdef UNICODE |
| 748 | #define bstrdupA(B_ARGS, p) bstrdupA(p) |
| 749 | #else /* UNICODE */ |
| 750 | #define bstrdupA bstrdup |
| 751 | #endif /* UNICODE */ |
| 752 | |
| 753 | #endif /* B_STATS */ |
| 754 | |
| 755 | #define gstrdup bstrdup |
| 756 | extern void *balloc(B_ARGS_DEC, int size); |
| 757 | extern void bfree(B_ARGS_DEC, void *mp); |
| 758 | extern void bfreeSafe(B_ARGS_DEC, void *mp); |
| 759 | extern void *brealloc(B_ARGS_DEC, void *buf, int newsize); |
| 760 | extern char_t *bstrdup(B_ARGS_DEC, char_t *s); |
| 761 | |
| 762 | #ifdef UNICODE |
| 763 | extern char *bstrdupA(B_ARGS_DEC, char *s); |
| 764 | #else /* UNICODE */ |
| 765 | #define bstrdupA bstrdup |
| 766 | #endif /* UNICODE */ |
| 767 | #endif /* BALLOC */ |
| 768 | |
| 769 | extern void bstats(int handle, void (*writefn)(int handle, char_t *fmt, ...)); |
| 770 | |
| 771 | #define B_USE_MALLOC 0x1 /* Okay to use malloc if required */ |
| 772 | #define B_USER_BUF 0x2 /* User supplied buffer for mem */ |
| 773 | |
| 774 | |
| 775 | #ifndef LINUX |
| 776 | extern char_t *basename(char_t *name); |
| 777 | #endif /* !LINUX */ |
| 778 | |
| 779 | #if (defined (UEMF) && defined (WEBS)) |
| 780 | |
| 781 | #define emfSchedCallback websSchedCallBack |
| 782 | #define emfUnschedCallback websUnschedCallBack |
| 783 | #define emfReschedCallback websReschedCallBack |
| 784 | #endif /* UEMF && WEBS */ |
| 785 | |
| 786 | typedef void (emfSchedProc)(void *data, int id); |
| 787 | extern int emfSchedCallback(int delay, emfSchedProc *proc, void *arg); |
| 788 | extern void emfUnschedCallback(int id); |
| 789 | extern void emfReschedCallback(int id, int delay); |
| 790 | extern void emfSchedProcess(); |
| 791 | extern int emfInstGet(); |
| 792 | extern void emfInstSet(int inst); |
| 793 | extern void error(E_ARGS_DEC, int flags, char_t *fmt, ...); |
| 794 | extern void (*errorSetHandler(void (*function)(int etype, char_t *msg))) \ |
| 795 | (int etype, char_t *msg); |
| 796 | |
| 797 | #ifdef B_STATS |
| 798 | #define hAlloc(x) HALLOC(B_L, x) |
| 799 | #define hAllocEntry(x, y, z) HALLOCENTRY(B_L, x, y, z) |
| 800 | extern int HALLOC(B_ARGS_DEC, void ***map); |
| 801 | extern int HALLOCENTRY(B_ARGS_DEC, void ***list, int *max, int size); |
| 802 | #else |
| 803 | extern int hAlloc(void ***map); |
| 804 | extern int hAllocEntry(void ***list, int *max, int size); |
| 805 | #endif /* B_STATS */ |
| 806 | |
| 807 | extern int hFree(void ***map, int handle); |
| 808 | |
| 809 | extern int ringqOpen(ringq_t *rq, int increment, int maxsize); |
| 810 | extern void ringqClose(ringq_t *rq); |
| 811 | extern int ringqLen(ringq_t *rq); |
| 812 | |
| 813 | extern int ringqPutc(ringq_t *rq, char_t c); |
| 814 | extern int ringqInsertc(ringq_t *rq, char_t c); |
| 815 | extern int ringqPutStr(ringq_t *rq, char_t *str); |
| 816 | extern int ringqGetc(ringq_t *rq); |
| 817 | |
| 818 | extern int fmtValloc(char_t **s, int n, char_t *fmt, va_list arg); |
| 819 | extern int fmtAlloc(char_t **s, int n, char_t *fmt, ...); |
| 820 | extern int fmtStatic(char_t *s, int n, char_t *fmt, ...); |
| 821 | |
| 822 | #ifdef UNICODE |
| 823 | extern int ringqPutcA(ringq_t *rq, char c); |
| 824 | extern int ringqInsertcA(ringq_t *rq, char c); |
| 825 | extern int ringqPutStrA(ringq_t *rq, char *str); |
| 826 | extern int ringqGetcA(ringq_t *rq); |
| 827 | #else |
| 828 | #define ringqPutcA ringqPutc |
| 829 | #define ringqInsertcA ringqInsertc |
| 830 | #define ringqPutStrA ringqPutStr |
| 831 | #define ringqGetcA ringqGetc |
| 832 | #endif /* UNICODE */ |
| 833 | |
| 834 | extern int ringqPutBlk(ringq_t *rq, unsigned char *buf, int len); |
| 835 | extern int ringqPutBlkMax(ringq_t *rq); |
| 836 | extern void ringqPutBlkAdj(ringq_t *rq, int size); |
| 837 | extern int ringqGetBlk(ringq_t *rq, unsigned char *buf, int len); |
| 838 | extern int ringqGetBlkMax(ringq_t *rq); |
| 839 | extern void ringqGetBlkAdj(ringq_t *rq, int size); |
| 840 | extern void ringqFlush(ringq_t *rq); |
| 841 | extern void ringqAddNull(ringq_t *rq); |
| 842 | |
| 843 | extern int scriptSetVar(int engine, char_t *var, char_t *value); |
| 844 | extern int scriptEval(int engine, char_t *cmd, char_t **rslt, int chan); |
| 845 | |
| 846 | extern void socketClose(); |
| 847 | extern void socketCloseConnection(int sid); |
| 848 | extern void socketCreateHandler(int sid, int mask, socketHandler_t |
| 849 | handler, int arg); |
| 850 | extern void socketDeleteHandler(int sid); |
| 851 | extern int socketEof(int sid); |
| 852 | extern int socketCanWrite(int sid); |
| 853 | extern void socketSetBufferSize(int sid, int in, int line, int out); |
| 854 | extern int socketFlush(int sid); |
| 855 | extern int socketGets(int sid, char_t **buf); |
| 856 | extern int socketGetPort(int sid); |
| 857 | extern int socketInputBuffered(int sid); |
| 858 | extern int socketOpen(); |
| 859 | extern int socketOpenConnection(char *host, int port, |
| 860 | socketAccept_t accept, int flags); |
| 861 | extern void socketProcess(int hid); |
| 862 | extern int socketRead(int sid, char *buf, int len); |
| 863 | extern int socketReady(int hid); |
| 864 | extern int socketWrite(int sid, char *buf, int len); |
| 865 | extern int socketWriteString(int sid, char_t *buf); |
| 866 | extern int socketSelect(int hid, int timeout); |
| 867 | extern int socketGetHandle(int sid); |
| 868 | extern int socketSetBlock(int sid, int flags); |
| 869 | extern int socketGetBlock(int sid); |
| 870 | extern int socketAlloc(char *host, int port, socketAccept_t accept, |
| 871 | int flags); |
| 872 | extern void socketFree(int sid); |
| 873 | extern int socketGetError(); |
| 874 | extern socket_t *socketPtr(int sid); |
| 875 | extern int socketWaitForEvent(socket_t *sp, int events, int *errCode); |
| 876 | extern void socketRegisterInterest(socket_t *sp, int handlerMask); |
| 877 | extern int socketGetInput(int sid, char *buf, int toRead, int *errCode); |
| 878 | |
| 879 | extern char_t *strlower(char_t *string); |
| 880 | extern char_t *strupper(char_t *string); |
| 881 | |
| 882 | extern char_t *stritoa(int n, char_t *string, int width); |
| 883 | |
| 884 | extern sym_fd_t symOpen(int hash_size); |
| 885 | extern void symClose(sym_fd_t sd); |
| 886 | extern sym_t *symLookup(sym_fd_t sd, char_t *name); |
| 887 | extern sym_t *symEnter(sym_fd_t sd, char_t *name, value_t v, int arg); |
| 888 | extern int symDelete(sym_fd_t sd, char_t *name); |
| 889 | extern void symWalk(sym_fd_t sd, void (*fn)(sym_t *symp)); |
| 890 | extern sym_t *symFirst(sym_fd_t sd); |
| 891 | extern sym_t *symNext(sym_fd_t sd); |
| 892 | extern int symSubOpen(); |
| 893 | extern void symSubClose(); |
| 894 | |
| 895 | extern void trace(int lev, char_t *fmt, ...); |
| 896 | extern void traceRaw(char_t *buf); |
| 897 | extern void (*traceSetHandler(void (*function)(int level, char_t *buf))) |
| 898 | (int level, char_t *buf); |
| 899 | |
| 900 | extern value_t valueInteger(long value); |
| 901 | extern value_t valueString(char_t *value, int flags); |
| 902 | extern value_t valueErrmsg(char_t *value); |
| 903 | extern void valueFree(value_t *v); |
| 904 | extern int vxchdir(char *dirname); |
| 905 | |
| 906 | extern unsigned int hextoi(char_t *hexstring); |
| 907 | extern unsigned int gstrtoi(char_t *s); |
| 908 | extern time_t timeMsec(); |
| 909 | |
| 910 | extern char_t *ascToUni(char_t *ubuf, char *str, int nBytes); |
| 911 | extern char *uniToAsc(char *buf, char_t *ustr, int nBytes); |
| 912 | extern char_t *ballocAscToUni(char *cp, int alen); |
| 913 | extern char *ballocUniToAsc(char_t *unip, int ulen); |
| 914 | |
| 915 | extern char_t *basicGetHost(); |
| 916 | extern char_t *basicGetAddress(); |
| 917 | extern char_t *basicGetProduct(); |
| 918 | extern void basicSetHost(char_t *host); |
| 919 | extern void basicSetAddress(char_t *addr); |
| 920 | |
| 921 | extern int harnessOpen(char_t **argv); |
| 922 | extern void harnessClose(int status); |
| 923 | extern void harnessTesting(char_t *msg, ...); |
| 924 | extern void harnessPassed(); |
| 925 | extern void harnessFailed(int line); |
| 926 | extern int harnessLevel(); |
| 927 | |
| 928 | #endif /* _h_UEMF */ |
| 929 | |