home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tcl8.0 / mac / tclMacPort.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-15  |  6.9 KB  |  264 lines  |  [TEXT/CWIE]

  1. /*
  2.  * tclMacPort.h --
  3.  *
  4.  *    This header file handles porting issues that occur because of
  5.  *    differences between the Mac and Unix. It should be the only
  6.  *    file that contains #ifdefs to handle different flavors of OS.
  7.  *
  8.  * Copyright (c) 1995-1997 Sun Microsystems, Inc.
  9.  *
  10.  * See the file "license.terms" for information on usage and redistribution
  11.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12.  *
  13.  * SCCS: @(#) tclMacPort.h 1.75 97/08/11 10:18:07
  14.  */
  15.  
  16. #ifndef _MACPORT
  17. #define _MACPORT
  18.  
  19. #ifndef _TCL
  20. #include "tcl.h"
  21. #endif
  22.  
  23. #include "tclErrno.h"
  24. #include <float.h>
  25.  
  26. /* Includes */
  27. #ifdef THINK_C
  28.     /*
  29.      * The Symantic C code has not been tested
  30.      * and probably will not work.
  31.      */
  32. #   include <pascal.h>
  33. #   include <posix.h>
  34. #   include <string.h>
  35. #   include <fcntl.h>
  36. #   include <pwd.h>
  37. #   include <sys/param.h>
  38. #   include <sys/types.h>
  39. #   include <sys/stat.h>
  40. #   include <unistd.h>
  41. #elif defined(__MWERKS__)
  42. #   include <time.h>
  43. #   include <unistd.h>
  44. /*
  45.  * The following definitions are usually found if fcntl.h.
  46.  * However, MetroWerks has screwed that file up a couple of times
  47.  * and all we need are the defines.
  48.  */
  49. #define O_RDWR      0x0        /* open the file in read/write mode */
  50. #define O_RDONLY  0x1        /* open the file in read only mode */
  51. #define O_WRONLY  0x2        /* open the file in write only mode */
  52. #define O_APPEND  0x0100    /* open the file in append mode */
  53. #define O_CREAT      0x0200    /* create the file if it doesn't exist */
  54. #define O_EXCL      0x0400    /* if the file exists don't create it again */
  55. #define O_TRUNC      0x0800    /* truncate the file after opening it */
  56.  
  57. /*
  58.  * MetroWerks stat.h file is rather weak.  The defines
  59.  * after the include are needed to fill in the missing
  60.  * defines.
  61.  */
  62. #   include <stat.h>
  63. #   ifndef S_IFIFO
  64. #    define   S_IFIFO    0x0100
  65. #   endif
  66. #   ifndef S_IFBLK
  67. #    define   S_IFBLK    0x0600
  68. #   endif
  69. #   ifndef S_ISLNK
  70. #    define   S_ISLNK(m)    (((m)&(S_IFMT)) == (S_IFLNK))
  71. #   endif
  72. #   ifndef S_ISSOCK
  73. #    define   S_ISSOCK(m)    (((m)&(S_IFMT)) == (S_IFSOCK))
  74. #   endif
  75. #   ifndef S_IRWXU
  76. #    define    S_IRWXU    00007        /* read, write, execute: owner */
  77. #       define    S_IRUSR    00004        /* read permission: owner */
  78. #       define    S_IWUSR    00002        /* write permission: owner */
  79. #       define    S_IXUSR    00001        /* execute permission: owner */
  80. #       define    S_IRWXG    00007        /* read, write, execute: group */
  81. #       define    S_IRGRP    00004        /* read permission: group */
  82. #       define    S_IWGRP    00002        /* write permission: group */
  83. #       define    S_IXGRP    00001        /* execute permission: group */
  84. #       define    S_IRWXO    00007        /* read, write, execute: other */
  85. #       define    S_IROTH    00004        /* read permission: other */
  86. #       define    S_IWOTH    00002        /* write permission: other */
  87. #       define    S_IXOTH    00001        /* execute permission: other */
  88. #   endif
  89.  
  90. #   define isatty(arg) 1
  91.  
  92. /* 
  93.  * Defines used by access function.  This function is provided
  94.  * by Mac Tcl as the function TclMacAccess.
  95.  */
  96.  
  97. #   define    F_OK        0    /* test for existence of file */
  98. #   define    X_OK        0x01    /* test for execute or search permission */
  99. #   define    W_OK        0x02    /* test for write permission */
  100. #   define    R_OK        0x04    /* test for read permission */
  101.  
  102. #endif
  103.  
  104. /*
  105.  * waitpid doesn't work on a Mac - the following makes
  106.  * Tcl compile without errors.  These would normally
  107.  * be defined in sys/wait.h on UNIX systems.
  108.  */
  109.  
  110. #define WNOHANG 1
  111. #define WIFSTOPPED(stat) (1)
  112. #define WIFSIGNALED(stat) (1)
  113. #define WIFEXITED(stat) (1)
  114. #define WIFSTOPSIG(stat) (1)
  115. #define WIFTERMSIG(stat) (1)
  116. #define WIFEXITSTATUS(stat) (1)
  117. #define WEXITSTATUS(stat) (1)
  118. #define WTERMSIG(status) (1)
  119. #define WSTOPSIG(status) (1)
  120.  
  121. /*
  122.  * Define "NBBY" (number of bits per byte) if it's not already defined.
  123.  */
  124.  
  125. #ifndef NBBY
  126. #   define NBBY 8
  127. #endif
  128.  
  129. /*
  130.  * These functions always return dummy values on Mac.
  131.  */
  132. #ifndef geteuid
  133. #   define geteuid() 1
  134. #endif
  135. #ifndef getpid
  136. #   define getpid() -1
  137. #endif
  138.  
  139. #define NO_SYS_ERRLIST
  140. #define WAIT_STATUS_TYPE int
  141.  
  142. /*
  143.  * Make sure that MAXPATHLEN is defined.
  144.  */
  145.  
  146. #ifndef MAXPATHLEN
  147. #   ifdef PATH_MAX
  148. #       define MAXPATHLEN PATH_MAX
  149. #   else
  150. #       define MAXPATHLEN 2048
  151. #   endif
  152. #endif
  153.  
  154. /*
  155.  * The following functions are declared in tclInt.h but don't do anything
  156.  * on Macintosh systems.
  157.  */
  158.  
  159. #define TclSetSystemEnv(a,b)
  160.  
  161. /*
  162.  * Many signals are not supported on the Mac and are thus not defined in
  163.  * <signal.h>.  They are defined here so that Tcl will compile with less
  164.  * modification.
  165.   */
  166.  
  167. #ifndef SIGQUIT
  168. #define SIGQUIT 300
  169. #endif
  170.  
  171. #ifndef SIGPIPE
  172. #define SIGPIPE 13
  173. #endif
  174.  
  175. #ifndef SIGHUP
  176. #define SIGHUP  100
  177. #endif
  178.  
  179. extern char **environ;
  180.  
  181. /*
  182.  * Prototypes needed for compatability
  183.  */
  184.  
  185. EXTERN int     TclMacCreateEnv _ANSI_ARGS_((void));
  186. EXTERN int    strncasecmp _ANSI_ARGS_((CONST char *s1,
  187.                 CONST char *s2, size_t n));
  188.  
  189. /*
  190.  * The following declarations belong in tclInt.h, but depend on platform
  191.  * specific types (e.g. struct tm).
  192.  */
  193.  
  194. EXTERN struct tm *    TclpGetDate _ANSI_ARGS_((const time_t *tp,
  195.                 int useGMT));
  196. EXTERN size_t        TclStrftime _ANSI_ARGS_((char *s, size_t maxsize,
  197.                 const char *format, const struct tm *t));
  198.  
  199. #define tzset()
  200. #define TclpGetPid(pid)        ((unsigned long) (pid))
  201.  
  202. /*
  203.  * The following prototypes and defines replace the Macintosh version
  204.  * of the POSIX functions "stat" and "access".  The various compilier 
  205.  * vendors don't implement this function well nor consistantly.
  206.  */
  207. EXTERN int TclMacStat _ANSI_ARGS_((char *path, struct stat *buf));
  208. #define stat(path, bufPtr) TclMacStat(path, bufPtr)
  209. #define lstat(path, bufPtr) TclMacStat(path, bufPtr)
  210. EXTERN int TclMacAccess _ANSI_ARGS_((const char *filename, int mode));
  211. #define access(path, mode) TclMacAccess(path, mode)
  212. EXTERN FILE * TclMacFOpenHack _ANSI_ARGS_((const char *path,
  213.     const char *mode));
  214. #define fopen(path, mode) TclMacFOpenHack(path, mode)
  215. EXTERN int TclMacReadlink _ANSI_ARGS_((char *path, char *buf, int size));
  216. #define readlink(fileName, buffer, size) TclMacReadlink(fileName, buffer, size)
  217. #ifdef TCL_TEST
  218. #define chmod(path, mode) TclMacChmod(path, mode)
  219. EXTERN int    TclMacChmod(char *path, int mode);
  220. #endif
  221.  
  222. /*
  223.  * Defines for Tcl internal commands that aren't really needed on
  224.  * the Macintosh.  They all act as no-ops.
  225.  */
  226. #define TclCreateCommandChannel(out, in, err, num, pidPtr)    NULL
  227. #define TclClosePipeFile(x)
  228.  
  229. /*
  230.  * These definitions force putenv & company to use the version
  231.  * supplied with Tcl.
  232.  */
  233. #ifndef putenv
  234. #   define unsetenv    TclUnsetEnv
  235. #   define putenv    Tcl_PutEnv
  236. #   define setenv    TclSetEnv
  237. void    TclSetEnv(CONST char *name, CONST char *value);
  238. int    Tcl_PutEnv(CONST char *string);
  239. void    TclUnsetEnv(CONST char *name);
  240. #endif
  241.  
  242. /*
  243.  * The default platform eol translation on Mac is TCL_TRANSLATE_CR:
  244.  */
  245.  
  246. #define    TCL_PLATFORM_TRANSLATION    TCL_TRANSLATE_CR
  247.  
  248. /*
  249.  * Declare dynamic loading extension macro.
  250.  */
  251.  
  252. #define TCL_SHLIB_EXT ".shlb"
  253.  
  254. /*
  255.  * The following define should really be in tclInt.h, but tclInt.h does
  256.  * not include tclPort.h, which includes the "struct stat" definition.
  257.  */
  258.  
  259. EXTERN int              TclpSameFile _ANSI_ARGS_((char *file1, char *file2,
  260.                 struct stat *sourceStatBufPtr, 
  261.                     struct stat *destStatBufPtr)) ;
  262.  
  263. #endif /* _MACPORT */
  264.