| 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 |
#ifndef _TCLUNIXPORT |
| 26 |
#define _TCLUNIXPORT |
| 27 |
|
| 28 |
#ifndef _LANG |
| 29 |
# include "Lang.h" |
| 30 |
#endif |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
#include <errno.h> |
| 40 |
#include <fcntl.h> |
| 41 |
#ifdef HAVE_NET_ERRNO_H |
| 42 |
# include <net/errno.h> |
| 43 |
#endif |
| 44 |
#include <pwd.h> |
| 45 |
#include <signal.h> |
| 46 |
#ifdef HAVE_SYS_PARAM_H |
| 47 |
# include <sys/param.h> |
| 48 |
#endif |
| 49 |
#include <sys/types.h> |
| 50 |
#ifdef USE_DIRENT2_H |
| 51 |
# include "../compat/dirent2.h" |
| 52 |
#else |
| 53 |
#ifdef NO_DIRENT_H |
| 54 |
# include "../compat/dirent.h" |
| 55 |
#else |
| 56 |
# include <dirent.h> |
| 57 |
#endif |
| 58 |
#endif |
| 59 |
|
| 60 |
#ifdef HAVE_STRUCT_DIRENT64 |
| 61 |
typedef struct dirent64 Tcl_DirEntry; |
| 62 |
# define TclOSreaddir readdir64 |
| 63 |
# define TclOSreaddir_r readdir64_r |
| 64 |
#else |
| 65 |
typedef struct dirent Tcl_DirEntry; |
| 66 |
# define TclOSreaddir readdir |
| 67 |
# define TclOSreaddir_r readdir_r |
| 68 |
#endif |
| 69 |
|
| 70 |
#ifdef HAVE_TYPE_OFF64_T |
| 71 |
typedef off64_t Tcl_SeekOffset; |
| 72 |
# define TclOSseek lseek64 |
| 73 |
# define TclOSopen open64 |
| 74 |
#else |
| 75 |
typedef off_t Tcl_SeekOffset; |
| 76 |
# define TclOSseek lseek |
| 77 |
# define TclOSopen open |
| 78 |
#endif |
| 79 |
|
| 80 |
#ifdef HAVE_STRUCT_STAT64 |
| 81 |
# define TclOSstat stat64 |
| 82 |
# define TclOSlstat lstat64 |
| 83 |
#else |
| 84 |
# define TclOSstat stat |
| 85 |
# define TclOSlstat lstat |
| 86 |
#endif |
| 87 |
|
| 88 |
#if !HAVE_STRTOLL && defined(TCL_WIDE_INT_TYPE) && !TCL_WIDE_INT_IS_LONG |
| 89 |
EXTERN Tcl_WideInt strtoll _ANSI_ARGS_((CONST char *string, |
| 90 |
char **endPtr, int base)); |
| 91 |
EXTERN Tcl_WideUInt strtoull _ANSI_ARGS_((CONST char *string, |
| 92 |
char **endPtr, int base)); |
| 93 |
#endif |
| 94 |
|
| 95 |
#include <sys/file.h> |
| 96 |
#ifdef HAVE_SYS_SELECT_H |
| 97 |
# include <sys/select.h> |
| 98 |
#endif |
| 99 |
#include <sys/stat.h> |
| 100 |
#if TIME_WITH_SYS_TIME |
| 101 |
# include <sys/time.h> |
| 102 |
# include <time.h> |
| 103 |
#else |
| 104 |
#if HAVE_SYS_TIME_H |
| 105 |
# include <sys/time.h> |
| 106 |
#else |
| 107 |
# include <time.h> |
| 108 |
#endif |
| 109 |
#endif |
| 110 |
#ifndef NO_SYS_WAIT_H |
| 111 |
# include <sys/wait.h> |
| 112 |
#endif |
| 113 |
#ifdef HAVE_UNISTD_H |
| 114 |
# include <unistd.h> |
| 115 |
#else |
| 116 |
# include "../compat/unistd.h" |
| 117 |
#endif |
| 118 |
#ifdef USE_FIONBIO |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
# ifdef HAVE_SYS_FILIO_H |
| 125 |
# include <sys/filio.h> |
| 126 |
# endif |
| 127 |
|
| 128 |
# ifdef HAVE_SYS_IOCTL_H |
| 129 |
# include <sys/ioctl.h> |
| 130 |
# endif |
| 131 |
#endif |
| 132 |
#include <utime.h> |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
#include <sys/socket.h> |
| 140 |
#ifndef NO_UNAME |
| 141 |
# include <sys/utsname.h> |
| 142 |
#endif |
| 143 |
#include <netinet/in.h> |
| 144 |
#include <arpa/inet.h> |
| 145 |
#include <netdb.h> |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
#ifndef NO_FLOAT_H |
| 154 |
# include <float.h> |
| 155 |
#else |
| 156 |
#ifndef NO_VALUES_H |
| 157 |
# include <values.h> |
| 158 |
#endif |
| 159 |
#endif |
| 160 |
|
| 161 |
#ifndef FLT_MAX |
| 162 |
# ifdef MAXFLOAT |
| 163 |
# define FLT_MAX MAXFLOAT |
| 164 |
# else |
| 165 |
# define FLT_MAX 3.402823466E+38F |
| 166 |
# endif |
| 167 |
#endif |
| 168 |
#ifndef FLT_MIN |
| 169 |
# ifdef MINFLOAT |
| 170 |
# define FLT_MIN MINFLOAT |
| 171 |
# else |
| 172 |
# define FLT_MIN 1.175494351E-38F |
| 173 |
# endif |
| 174 |
#endif |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
#ifndef O_NONBLOCK |
| 181 |
# define O_NONBLOCK 0x80 |
| 182 |
#endif |
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
#ifdef HPUX |
| 191 |
# define NBIO_FLAG O_NONBLOCK |
| 192 |
#else |
| 193 |
# define NBIO_FLAG O_NDELAY |
| 194 |
#endif |
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
#ifdef _AIX |
| 202 |
# define WAIT_STATUS_TYPE pid_t |
| 203 |
#else |
| 204 |
#ifndef NO_UNION_WAIT |
| 205 |
# define WAIT_STATUS_TYPE union wait |
| 206 |
#else |
| 207 |
# define WAIT_STATUS_TYPE int |
| 208 |
#endif |
| 209 |
#endif |
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
#ifndef WIFEXITED |
| 217 |
# define WIFEXITED(stat) (((*((int *) &(stat))) & 0xff) == 0) |
| 218 |
#endif |
| 219 |
|
| 220 |
#ifndef WEXITSTATUS |
| 221 |
# define WEXITSTATUS(stat) (((*((int *) &(stat))) >> 8) & 0xff) |
| 222 |
#endif |
| 223 |
|
| 224 |
#ifndef WIFSIGNALED |
| 225 |
# define WIFSIGNALED(stat) (((*((int *) &(stat)))) && ((*((int *) &(stat))) == ((*((int *) &(stat))) & 0x00ff))) |
| 226 |
#endif |
| 227 |
|
| 228 |
#ifndef WTERMSIG |
| 229 |
# define WTERMSIG(stat) ((*((int *) &(stat))) & 0x7f) |
| 230 |
#endif |
| 231 |
|
| 232 |
#ifndef WIFSTOPPED |
| 233 |
# define WIFSTOPPED(stat) (((*((int *) &(stat))) & 0xff) == 0177) |
| 234 |
#endif |
| 235 |
|
| 236 |
#ifndef WSTOPSIG |
| 237 |
# define WSTOPSIG(stat) (((*((int *) &(stat))) >> 8) & 0xff) |
| 238 |
#endif |
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
#ifndef WNOHANG |
| 246 |
# define WNOHANG 1 |
| 247 |
#endif |
| 248 |
#ifndef WUNTRACED |
| 249 |
# define WUNTRACED 2 |
| 250 |
#endif |
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
#ifndef SEEK_SET |
| 258 |
# define SEEK_SET 0 |
| 259 |
#endif |
| 260 |
#ifndef SEEK_CUR |
| 261 |
# define SEEK_CUR 1 |
| 262 |
#endif |
| 263 |
#ifndef SEEK_END |
| 264 |
# define SEEK_END 2 |
| 265 |
#endif |
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
#ifdef NO_GETTOD |
| 275 |
# include <sys/times.h> |
| 276 |
# include <sys/param.h> |
| 277 |
# ifndef CLK_TCK |
| 278 |
# ifdef HZ |
| 279 |
# define CLK_TCK HZ |
| 280 |
# else |
| 281 |
# define CLK_TCK 60 |
| 282 |
# endif |
| 283 |
# endif |
| 284 |
#else |
| 285 |
# ifdef HAVE_BSDGETTIMEOFDAY |
| 286 |
# define gettimeofday BSDgettimeofday |
| 287 |
# endif |
| 288 |
#endif |
| 289 |
|
| 290 |
#ifdef GETTOD_NOT_DECLARED |
| 291 |
EXTERN int gettimeofday _ANSI_ARGS_((struct timeval *tp, |
| 292 |
struct timezone *tzp)); |
| 293 |
#endif |
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
#ifndef F_OK |
| 300 |
# define F_OK 00 |
| 301 |
#endif |
| 302 |
#ifndef X_OK |
| 303 |
# define X_OK 01 |
| 304 |
#endif |
| 305 |
#ifndef W_OK |
| 306 |
# define W_OK 02 |
| 307 |
#endif |
| 308 |
#ifndef R_OK |
| 309 |
# define R_OK 04 |
| 310 |
#endif |
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
#ifndef FD_CLOEXEC |
| 318 |
# define FD_CLOEXEC 1 |
| 319 |
#endif |
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
#ifndef S_IFLNK |
| 327 |
# undef TclOSlstat |
| 328 |
# define lstat stat |
| 329 |
# define lstat64 stat64 |
| 330 |
# define TclOSlstat TclOSstat |
| 331 |
#endif |
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
#ifndef S_ISREG |
| 339 |
# ifdef S_IFREG |
| 340 |
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) |
| 341 |
# else |
| 342 |
# define S_ISREG(m) 0 |
| 343 |
# endif |
| 344 |
#endif |
| 345 |
#ifndef S_ISDIR |
| 346 |
# ifdef S_IFDIR |
| 347 |
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) |
| 348 |
# else |
| 349 |
# define S_ISDIR(m) 0 |
| 350 |
# endif |
| 351 |
#endif |
| 352 |
#ifndef S_ISCHR |
| 353 |
# ifdef S_IFCHR |
| 354 |
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) |
| 355 |
# else |
| 356 |
# define S_ISCHR(m) 0 |
| 357 |
# endif |
| 358 |
#endif |
| 359 |
#ifndef S_ISBLK |
| 360 |
# ifdef S_IFBLK |
| 361 |
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) |
| 362 |
# else |
| 363 |
# define S_ISBLK(m) 0 |
| 364 |
# endif |
| 365 |
#endif |
| 366 |
#ifndef S_ISFIFO |
| 367 |
# ifdef S_IFIFO |
| 368 |
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) |
| 369 |
# else |
| 370 |
# define S_ISFIFO(m) 0 |
| 371 |
# endif |
| 372 |
#endif |
| 373 |
#ifndef S_ISLNK |
| 374 |
# ifdef S_IFLNK |
| 375 |
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) |
| 376 |
# else |
| 377 |
# define S_ISLNK(m) 0 |
| 378 |
# endif |
| 379 |
#endif |
| 380 |
#ifndef S_ISSOCK |
| 381 |
# ifdef S_IFSOCK |
| 382 |
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) |
| 383 |
# else |
| 384 |
# define S_ISSOCK(m) 0 |
| 385 |
# endif |
| 386 |
#endif |
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
#ifndef MAXPATHLEN |
| 393 |
# ifdef PATH_MAX |
| 394 |
# define MAXPATHLEN PATH_MAX |
| 395 |
# else |
| 396 |
# define MAXPATHLEN 2048 |
| 397 |
# endif |
| 398 |
#endif |
| 399 |
|
| 400 |
#ifndef MAXNAMLEN |
| 401 |
# ifdef NAME_MAX |
| 402 |
# define MAXNAMLEN NAME_MAX |
| 403 |
# else |
| 404 |
# define MAXNAMLEN 255 |
| 405 |
# endif |
| 406 |
#endif |
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
#ifndef L_tmpnam |
| 413 |
# define L_tmpnam 100 |
| 414 |
#endif |
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
#ifndef NO_FD_SET |
| 422 |
# define SELECT_MASK fd_set |
| 423 |
#else |
| 424 |
# ifndef _AIX |
| 425 |
typedef long fd_mask; |
| 426 |
# endif |
| 427 |
# if defined(_IBMR2) |
| 428 |
# define SELECT_MASK void |
| 429 |
# else |
| 430 |
# define SELECT_MASK int |
| 431 |
# endif |
| 432 |
#endif |
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
#ifndef NBBY |
| 439 |
# define NBBY 8 |
| 440 |
#endif |
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
#ifndef FD_SETSIZE |
| 447 |
# ifdef OPEN_MAX |
| 448 |
# define FD_SETSIZE OPEN_MAX |
| 449 |
# else |
| 450 |
# define FD_SETSIZE 256 |
| 451 |
# endif |
| 452 |
#endif |
| 453 |
#if !defined(howmany) |
| 454 |
# define howmany(x, y) (((x)+((y)-1))/(y)) |
| 455 |
#endif |
| 456 |
#ifndef NFDBITS |
| 457 |
# define NFDBITS NBBY*sizeof(fd_mask) |
| 458 |
#endif |
| 459 |
#define MASK_SIZE howmany(FD_SETSIZE, NFDBITS) |
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
extern int errno; |
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
#ifndef EOVERFLOW |
| 475 |
# ifdef EFBIG |
| 476 |
# define EOVERFLOW EFBIG |
| 477 |
# else |
| 478 |
# define EOVERFLOW EINVAL |
| 479 |
# endif |
| 480 |
#endif |
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
#if defined(_sgi) || defined(__sgi) || (defined(__APPLE__) && defined(__DYNAMIC__)) |
| 487 |
# define environ _environ |
| 488 |
#endif |
| 489 |
extern char **environ; |
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
extern double strtod(); |
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
#define TclpPanic ((Tcl_PanicProc *) NULL) |
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
#ifdef DJGPP |
| 520 |
#define TCL_PLATFORM_TRANSLATION TCL_TRANSLATE_CRLF |
| 521 |
#else |
| 522 |
#define TCL_PLATFORM_TRANSLATION TCL_TRANSLATE_LF |
| 523 |
#endif |
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
#define TclpGetPid(pid) ((unsigned long) (pid)) |
| 531 |
#define TclpReleaseFile(file) |
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
#if USE_TCLALLOC |
| 539 |
# define TclpSysAlloc(size, isBin) malloc((size_t)size) |
| 540 |
# define TclpSysFree(ptr) free((char*)ptr) |
| 541 |
# define TclpSysRealloc(ptr, size) realloc((char*)ptr, (size_t)size) |
| 542 |
#endif |
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
#define TclpExit exit |
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
#ifdef TCL_THREADS |
| 559 |
#include <pthread.h> |
| 560 |
typedef pthread_mutex_t TclpMutex; |
| 561 |
EXTERN void TclpMutexInit _ANSI_ARGS_((TclpMutex *mPtr)); |
| 562 |
EXTERN void TclpMutexLock _ANSI_ARGS_((TclpMutex *mPtr)); |
| 563 |
EXTERN void TclpMutexUnlock _ANSI_ARGS_((TclpMutex *mPtr)); |
| 564 |
EXTERN Tcl_DirEntry * TclpReaddir(DIR *); |
| 565 |
EXTERN struct tm * TclpLocaltime(time_t *); |
| 566 |
EXTERN struct tm * TclpGmtime(time_t *); |
| 567 |
EXTERN char * TclpInetNtoa(struct in_addr); |
| 568 |
#define readdir(x) TclpReaddir(x) |
| 569 |
#define localtime(x) TclpLocaltime(x) |
| 570 |
#define gmtime(x) TclpGmtime(x) |
| 571 |
#define inet_ntoa(x) TclpInetNtoa(x) |
| 572 |
#undef TclOSreaddir |
| 573 |
#define TclOSreaddir(x) TclpReaddir(x) |
| 574 |
#ifdef MAC_OSX_TCL |
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
#define NO_REALPATH |
| 580 |
#endif |
| 581 |
#else |
| 582 |
typedef int TclpMutex; |
| 583 |
#define TclpMutexInit(a) |
| 584 |
#define TclpMutexLock(a) |
| 585 |
#define TclpMutexUnlock(a) |
| 586 |
#endif |
| 587 |
|
| 588 |
#include "tclPlatDecls.h" |
| 589 |
#include "tclIntPlatDecls.h" |
| 590 |
|
| 591 |
#endif |