File indexing completed on 2024-05-18 08:30:22
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #ifndef _TCLUNIXPORT
0023 #define _TCLUNIXPORT
0024
0025
0026
0027
0028
0029
0030
0031
0032 #include <errno.h>
0033 #include <fcntl.h>
0034 #ifdef HAVE_NET_ERRNO_H
0035 # include <net/errno.h>
0036 #endif
0037 #include <pwd.h>
0038 #include <signal.h>
0039 #ifdef HAVE_SYS_PARAM_H
0040 # include <sys/param.h>
0041 #endif
0042 #include <sys/types.h>
0043 #ifdef USE_DIRENT2_H
0044 # include "../compat/dirent2.h"
0045 #else
0046 #ifdef NO_DIRENT_H
0047 # include "../compat/dirent.h"
0048 #else
0049 # include <dirent.h>
0050 #endif
0051 #endif
0052
0053
0054
0055
0056
0057
0058
0059 #ifdef HAVE_STRUCT_DIRENT64
0060 typedef struct dirent64 Tcl_DirEntry;
0061 # define TclOSreaddir readdir64
0062 #else
0063 typedef struct dirent Tcl_DirEntry;
0064 # define TclOSreaddir readdir
0065 #endif
0066 #ifdef HAVE_DIR64
0067 typedef DIR64 TclDIR;
0068 # define TclOSopendir opendir64
0069 # define TclOSrewinddir rewinddir64
0070 # define TclOSclosedir closedir64
0071 #else
0072 typedef DIR TclDIR;
0073 # define TclOSopendir opendir
0074 # define TclOSrewinddir rewinddir
0075 # define TclOSclosedir closedir
0076 #endif
0077
0078 #ifdef HAVE_TYPE_OFF64_T
0079 typedef off64_t Tcl_SeekOffset;
0080 # define TclOSseek lseek64
0081 # define TclOSopen open64
0082 #else
0083 typedef off_t Tcl_SeekOffset;
0084 # define TclOSseek lseek
0085 # define TclOSopen open
0086 #endif
0087
0088 #ifdef __CYGWIN__
0089 #ifdef __cplusplus
0090 extern "C" {
0091 #endif
0092
0093 # define DWORD unsigned int
0094 # define CP_UTF8 65001
0095 # define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 0x00000004
0096 # define HANDLE void *
0097 # define HINSTANCE void *
0098 # define SOCKET unsigned int
0099 # define WSAEWOULDBLOCK 10035
0100 typedef unsigned short WCHAR;
0101 #ifdef __clang__
0102 #pragma clang diagnostic push
0103 #pragma clang diagnostic ignored "-Wignored-attributes"
0104 #endif
0105 __declspec(dllimport) extern __stdcall int GetModuleHandleExW(unsigned int, const void *, void *);
0106 __declspec(dllimport) extern __stdcall int GetModuleFileNameW(void *, const void *, int);
0107 __declspec(dllimport) extern __stdcall int WideCharToMultiByte(int, int, const void *, int,
0108 char *, int, const char *, void *);
0109 __declspec(dllimport) extern __stdcall int MultiByteToWideChar(int, int, const char *, int,
0110 WCHAR *, int);
0111 __declspec(dllimport) extern __stdcall void OutputDebugStringW(const WCHAR *);
0112 __declspec(dllimport) extern __stdcall int IsDebuggerPresent(void);
0113 __declspec(dllimport) extern __stdcall int GetLastError(void);
0114 __declspec(dllimport) extern __stdcall int GetFileAttributesW(const WCHAR *);
0115 __declspec(dllimport) extern __stdcall int SetFileAttributesW(const WCHAR *, int);
0116 __declspec(dllimport) extern int cygwin_conv_path(int, const void *, void *, int);
0117 #ifdef __clang__
0118 #pragma clang diagnostic pop
0119 #endif
0120 # define timezone _timezone
0121 extern int TclOSstat(const char *name, void *statBuf);
0122 extern int TclOSlstat(const char *name, void *statBuf);
0123 #ifdef __cplusplus
0124 }
0125 #endif
0126 #elif defined(HAVE_STRUCT_STAT64) && !defined(__APPLE__)
0127 # define TclOSstat(name, buf) stat64(name, (struct stat64 *)buf)
0128 # define TclOSlstat(name,buf) lstat64(name, (struct stat64 *)buf)
0129 #else
0130 # define TclOSstat(name, buf) stat(name, (struct stat *)buf)
0131 # define TclOSlstat(name, buf) lstat(name, (struct stat *)buf)
0132 #endif
0133
0134
0135
0136
0137
0138
0139
0140 #include <sys/file.h>
0141 #ifdef HAVE_SYS_SELECT_H
0142 # include <sys/select.h>
0143 #endif
0144 #include <sys/stat.h>
0145 #ifdef TIME_WITH_SYS_TIME
0146 # include <sys/time.h>
0147 # include <time.h>
0148 #else
0149 #ifdef HAVE_SYS_TIME_H
0150 # include <sys/time.h>
0151 #else
0152 # include <time.h>
0153 #endif
0154 #endif
0155 #ifndef NO_SYS_WAIT_H
0156 # include <sys/wait.h>
0157 #endif
0158 #ifdef HAVE_INTTYPES_H
0159 # include <inttypes.h>
0160 #endif
0161 #include <limits.h>
0162 #ifdef HAVE_STDINT_H
0163 # include <stdint.h>
0164 #endif
0165 #ifdef HAVE_UNISTD_H
0166 # include <unistd.h>
0167 #else
0168 # include "../compat/unistd.h"
0169 #endif
0170
0171 extern int TclUnixSetBlockingMode(int fd, int mode);
0172
0173 #include <utime.h>
0174
0175
0176
0177
0178
0179
0180
0181
0182 #include <sys/socket.h> /* struct sockaddr, SOCK_STREAM, ... */
0183 #ifndef NO_UNAME
0184 # include <sys/utsname.h> /* uname system call. */
0185 #endif
0186 #include <netinet/in.h> /* struct in_addr, struct sockaddr_in */
0187 #include <arpa/inet.h> /* inet_ntoa() */
0188 #include <netdb.h> /* getaddrinfo() */
0189 #ifdef NEED_FAKE_RFC2553
0190 # include "../compat/fake-rfc2553.h"
0191 #endif
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201 #ifndef NO_FLOAT_H
0202 # include <float.h>
0203 #else
0204 #ifndef NO_VALUES_H
0205 # include <values.h>
0206 #endif
0207 #endif
0208
0209 #ifndef FLT_MAX
0210 # ifdef MAXFLOAT
0211 # define FLT_MAX MAXFLOAT
0212 # else
0213 # define FLT_MAX 3.402823466E+38F
0214 # endif
0215 #endif
0216 #ifndef FLT_MIN
0217 # ifdef MINFLOAT
0218 # define FLT_MIN MINFLOAT
0219 # else
0220 # define FLT_MIN 1.175494351E-38F
0221 # endif
0222 #endif
0223
0224
0225
0226
0227
0228
0229
0230 #ifndef O_NONBLOCK
0231 # define O_NONBLOCK 0x80
0232 #endif
0233
0234
0235
0236
0237
0238
0239
0240
0241 #ifdef _AIX
0242 # define WAIT_STATUS_TYPE pid_t
0243 #else
0244 #ifndef NO_UNION_WAIT
0245 # define WAIT_STATUS_TYPE union wait
0246 #else
0247 # define WAIT_STATUS_TYPE int
0248 #endif
0249 #endif
0250
0251
0252
0253
0254
0255
0256
0257
0258 #ifndef WIFEXITED
0259 # define WIFEXITED(stat) (((*((int *) &(stat))) & 0xFF) == 0)
0260 #endif
0261
0262 #ifndef WEXITSTATUS
0263 # define WEXITSTATUS(stat) (((*((int *) &(stat))) >> 8) & 0xFF)
0264 #endif
0265
0266 #ifndef WIFSIGNALED
0267 # define WIFSIGNALED(stat) \
0268 (((*((int *) &(stat)))) && ((*((int *) &(stat))) \
0269 == ((*((int *) &(stat))) & 0x00FF)))
0270 #endif
0271
0272 #ifndef WTERMSIG
0273 # define WTERMSIG(stat) ((*((int *) &(stat))) & 0x7F)
0274 #endif
0275
0276 #ifndef WIFSTOPPED
0277 # define WIFSTOPPED(stat) (((*((int *) &(stat))) & 0xFF) == 0177)
0278 #endif
0279
0280 #ifndef WSTOPSIG
0281 # define WSTOPSIG(stat) (((*((int *) &(stat))) >> 8) & 0xFF)
0282 #endif
0283
0284
0285
0286
0287
0288
0289
0290
0291 #ifndef WNOHANG
0292 # define WNOHANG 1
0293 #endif
0294 #ifndef WUNTRACED
0295 # define WUNTRACED 2
0296 #endif
0297
0298
0299
0300
0301
0302
0303
0304
0305 #ifndef SEEK_SET
0306 # define SEEK_SET 0
0307 #endif
0308 #ifndef SEEK_CUR
0309 # define SEEK_CUR 1
0310 #endif
0311 #ifndef SEEK_END
0312 # define SEEK_END 2
0313 #endif
0314
0315
0316
0317
0318
0319
0320
0321
0322 #ifdef NO_GETTOD
0323 # include <sys/times.h>
0324 #else
0325 # ifdef HAVE_BSDGETTIMEOFDAY
0326 # define gettimeofday BSDgettimeofday
0327 # endif
0328 #endif
0329
0330 #ifdef GETTOD_NOT_DECLARED
0331 extern int gettimeofday(struct timeval *tp,
0332 struct timezone *tzp);
0333 #endif
0334
0335
0336
0337
0338
0339
0340
0341 #ifndef F_OK
0342 # define F_OK 00
0343 #endif
0344 #ifndef X_OK
0345 # define X_OK 01
0346 #endif
0347 #ifndef W_OK
0348 # define W_OK 02
0349 #endif
0350 #ifndef R_OK
0351 # define R_OK 04
0352 #endif
0353
0354
0355
0356
0357
0358
0359
0360
0361 #ifndef FD_CLOEXEC
0362 # define FD_CLOEXEC 1
0363 #endif
0364
0365
0366
0367
0368
0369
0370
0371
0372 #ifndef S_IFLNK
0373 # undef TclOSlstat
0374 # define lstat stat
0375 # define lstat64 stat64
0376 # define TclOSlstat TclOSstat
0377 #endif
0378
0379
0380
0381
0382
0383
0384
0385 #ifndef S_ISREG
0386 # ifdef S_IFREG
0387 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
0388 # else
0389 # define S_ISREG(m) 0
0390 # endif
0391 #endif
0392 #ifndef S_ISDIR
0393 # ifdef S_IFDIR
0394 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
0395 # else
0396 # define S_ISDIR(m) 0
0397 # endif
0398 #endif
0399 #ifndef S_ISCHR
0400 # ifdef S_IFCHR
0401 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
0402 # else
0403 # define S_ISCHR(m) 0
0404 # endif
0405 #endif
0406
0407 #ifndef S_ISBLK
0408 # ifdef S_IFBLK
0409 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
0410 # else
0411 # define S_ISBLK(m) 0
0412 # endif
0413 #endif
0414
0415 #ifndef S_ISFIFO
0416 # ifdef S_IFIFO
0417 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
0418 # else
0419 # define S_ISFIFO(m) 0
0420 # endif
0421 #endif
0422
0423 #ifndef S_ISLNK
0424 # ifdef S_IFLNK
0425 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
0426 # else
0427 # define S_ISLNK(m) 0
0428 # endif
0429 #endif
0430
0431 #ifndef S_ISSOCK
0432 # ifdef S_IFSOCK
0433 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
0434 # else
0435 # define S_ISSOCK(m) 0
0436 # endif
0437 #endif
0438
0439
0440
0441
0442
0443
0444
0445 #ifndef MAXPATHLEN
0446 # ifdef PATH_MAX
0447 # define MAXPATHLEN PATH_MAX
0448 # else
0449 # define MAXPATHLEN 2048
0450 # endif
0451 #endif
0452
0453 #ifndef MAXNAMLEN
0454 # ifdef NAME_MAX
0455 # define MAXNAMLEN NAME_MAX
0456 # else
0457 # define MAXNAMLEN 255
0458 # endif
0459 #endif
0460
0461
0462
0463
0464
0465
0466
0467 #ifndef NO_FD_SET
0468 # define SELECT_MASK fd_set
0469 #else
0470 # ifndef _AIX
0471 typedef long fd_mask;
0472 # endif
0473 # if defined(_IBMR2)
0474 # define SELECT_MASK void
0475 # else
0476 # define SELECT_MASK int
0477 # endif
0478 #endif
0479
0480
0481
0482
0483
0484
0485
0486 #ifndef NBBY
0487 # define NBBY 8
0488 #endif
0489
0490
0491
0492
0493
0494
0495
0496 #ifndef FD_SETSIZE
0497 # ifdef OPEN_MAX
0498 # define FD_SETSIZE OPEN_MAX
0499 # else
0500 # define FD_SETSIZE 256
0501 # endif
0502 #endif
0503
0504 #ifndef howmany
0505 # define howmany(x, y) (((x)+((y)-1))/(y))
0506 #endif
0507
0508 #ifndef NFDBITS
0509 # define NFDBITS NBBY*sizeof(fd_mask)
0510 #endif
0511
0512 #define MASK_SIZE howmany(FD_SETSIZE, NFDBITS)
0513
0514
0515
0516
0517
0518
0519
0520
0521
0522 #ifdef NO_ERRNO
0523 extern int errno;
0524 #endif
0525
0526
0527
0528
0529
0530
0531
0532
0533 #ifndef EOVERFLOW
0534 # ifdef EFBIG
0535 # define EOVERFLOW EFBIG
0536 # else
0537 # define EOVERFLOW EINVAL
0538 # endif
0539 #endif
0540
0541
0542
0543
0544
0545
0546
0547 #if defined(__APPLE__) && defined(__DYNAMIC__)
0548 # include <crt_externs.h>
0549 # define environ (*_NSGetEnviron())
0550 # define USE_PUTENV 1
0551 #else
0552 # if defined(_sgi) || defined(__sgi)
0553 # define environ _environ
0554 # endif
0555 extern char ** environ;
0556 #endif
0557
0558
0559
0560
0561
0562
0563
0564 #ifdef __APPLE__
0565
0566
0567
0568
0569
0570
0571
0572 # if defined(__LP64__) && defined (NO_COREFOUNDATION_64)
0573 # undef HAVE_COREFOUNDATION
0574 # endif
0575 # include <sys/cdefs.h>
0576 # ifdef __DARWIN_UNIX03
0577 # if __DARWIN_UNIX03
0578 # undef HAVE_PUTENV_THAT_COPIES
0579 # else
0580 # define HAVE_PUTENV_THAT_COPIES 1
0581 # endif
0582 # endif
0583
0584
0585
0586
0587
0588
0589
0590
0591 # ifdef HAVE_AVAILABILITYMACROS_H
0592 # include <AvailabilityMacros.h>
0593 # endif
0594
0595
0596
0597
0598
0599
0600
0601 # ifdef HAVE_WEAK_IMPORT
0602 # if !defined(HAVE_AVAILABILITYMACROS_H) || !defined(MAC_OS_X_VERSION_MIN_REQUIRED)
0603 # undef HAVE_WEAK_IMPORT
0604 # else
0605 # ifndef WEAK_IMPORT_ATTRIBUTE
0606 # define WEAK_IMPORT_ATTRIBUTE __attribute__((weak_import))
0607 # endif
0608 # endif
0609 # endif
0610
0611
0612
0613
0614
0615
0616
0617
0618 # ifdef MAC_OS_X_VERSION_MAX_ALLOWED
0619 # if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 && defined(__LP64__)
0620 # undef HAVE_COREFOUNDATION
0621 # endif
0622 # if MAC_OS_X_VERSION_MAX_ALLOWED < 1040
0623 # undef HAVE_OSSPINLOCKLOCK
0624 # undef HAVE_PTHREAD_ATFORK
0625 # undef HAVE_COPYFILE
0626 # endif
0627 # if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
0628 # ifdef TCL_THREADS
0629
0630 # define NO_REALPATH 1
0631 # endif
0632 # undef HAVE_LANGINFO
0633 # endif
0634 # endif
0635 # if defined(HAVE_COREFOUNDATION) && defined(__LP64__) && \
0636 defined(HAVE_WEAK_IMPORT) && MAC_OS_X_VERSION_MIN_REQUIRED < 1050
0637 # warning "Weak import of 64-bit CoreFoundation is not supported, will not run on Mac OS X < 10.5."
0638 # endif
0639
0640
0641
0642
0643
0644
0645
0646
0647 # if defined(__x86_64__) && !defined(FIXED_RDAR_4685553)
0648 # undef USE_VFORK
0649 # endif
0650
0651 # if defined (__llvm__) && \
0652 (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 2 || \
0653 (__GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ > 0))))
0654 # undef USE_VFORK
0655 # endif
0656 #endif
0657
0658
0659
0660
0661
0662
0663
0664
0665
0666
0667
0668
0669
0670 #ifdef DJGPP
0671 #define TCL_PLATFORM_TRANSLATION TCL_TRANSLATE_CRLF
0672 typedef int socklen_t;
0673 #else
0674 #define TCL_PLATFORM_TRANSLATION TCL_TRANSLATE_LF
0675 #endif
0676
0677
0678
0679
0680
0681
0682
0683
0684 #define TclpReleaseFile(file)
0685
0686
0687
0688
0689
0690
0691
0692 #define TclpSysAlloc(size, isBin) malloc((size_t)(size))
0693 #define TclpSysFree(ptr) free((char *)(ptr))
0694 #define TclpSysRealloc(ptr, size) realloc((char *)(ptr), (size_t)(size))
0695
0696
0697
0698
0699
0700
0701
0702 #define TclpExit exit
0703
0704 #ifdef TCL_THREADS
0705 # include <pthread.h>
0706 #endif
0707
0708
0709 #ifndef AF_INET6
0710 # define AF_INET6 10
0711 #endif
0712
0713
0714
0715
0716
0717
0718
0719
0720
0721 #include <pwd.h>
0722 #include <grp.h>
0723
0724 extern struct passwd * TclpGetPwNam(const char *name);
0725 extern struct group * TclpGetGrNam(const char *name);
0726 extern struct passwd * TclpGetPwUid(uid_t uid);
0727 extern struct group * TclpGetGrGid(gid_t gid);
0728 extern struct hostent * TclpGetHostByName(const char *name);
0729 extern struct hostent * TclpGetHostByAddr(const char *addr,
0730 int length, int type);
0731 extern void *TclpMakeTcpClientChannelMode(
0732 void *tcpSocket, int mode);
0733
0734 #endif
0735
0736
0737
0738
0739
0740
0741
0742