]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
authorGuido van Rossum <guido@python.org>
Mon, 29 Aug 1994 08:42:37 +0000 (08:42 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 29 Aug 1994 08:42:37 +0000 (08:42 +0000)
versions -- they now share config.c and config.h, and statting is
always done through macstat.[ch] (THINK's <stat.h> defines funny
constants).  Also the configuration of stdwin is done differently: you
have to define USE_STDWIN to the compiler prefix.

Mac/Compat/getwd.c
Mac/Compat/macstat.c
Mac/Compat/macstat.h
Mac/Include/config.h
Mac/Include/macdefs.h
Mac/Modules/config.c
Mac/Modules/macmodule.c
Mac/Python/macgetmtime.c

index 3a093ed0572091b7a3bf13f8f71ecd318ae50ed2..a783ff606a578138258d305a1dc75455daaeaa62 100644 (file)
    Public domain by Guido van Rossum, CWI, Amsterdam (July 1987).
 */
 
+#include "macdefs.h"
 #ifdef MPW
 #include <Strings.h>
 #endif
-#include "macdefs.h"
 
 #define ROOTID 2 /* Root directory ID */
 
index e64505086bd116841a7d3ea24d1cbd2332b3e1b9..564da1030f8da949b329df6d3766584f6d41ccab 100644 (file)
@@ -1,9 +1,10 @@
 /* Minimal 'stat' emulation: tells directories from files and
    gives length and mtime.
    Public domain by Guido van Rossum, CWI, Amsterdam (July 1987).
+   Updated to give more info, August 1994.
 */
 
-#include "stat.h"
+#include "macstat.h"
 #include "macdefs.h"
 
 /* Bits in ioFlAttrib: */
@@ -11,9 +12,9 @@
 #define DIRBIT (1<<4)          /* It's a directory */
 
 int
-stat(path, buf)
+macstat(path, buf)
        char *path;
-       struct stat *buf;
+       struct macstat *buf;
 {
        union {
                DirInfo d;
@@ -23,35 +24,42 @@ stat(path, buf)
        char name[256];
        short err;
        
-       pb.d.ioNamePtr= (unsigned char *)c2pstr(strcpy(name, path));
-       pb.d.ioVRefNum= 0;
-       pb.d.ioFDirIndex= 0;
-       pb.d.ioDrDirID= 0;
-       pb.f.ioFVersNum= 0; /* Fix found by Timo! See Tech Note 102 */
+       pb.d.ioNamePtr = (unsigned char *)c2pstr(strcpy(name, path));
+       pb.d.ioVRefNum = 0;
+       pb.d.ioFDirIndex = 0;
+       pb.d.ioDrDirID = 0;
+       pb.f.ioFVersNum = 0; /* Fix found by Timo! See Tech Note 102 */
        if (hfsrunning())
-               err= PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
+               err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
        else
-               err= PBGetFInfo((ParmBlkPtr)&pb, FALSE);
+               err = PBGetFInfo((ParmBlkPtr)&pb, FALSE);
        if (err != noErr) {
                errno = ENOENT;
                return -1;
        }
        if (pb.d.ioFlAttrib & LOCKBIT)
-               buf->st_mode= 0444;
+               buf->st_mode = 0444;
        else
-               buf->st_mode= 0666;
+               buf->st_mode = 0666;
        if (pb.d.ioFlAttrib & DIRBIT) {
                buf->st_mode |= 0111 | S_IFDIR;
-               buf->st_size= pb.d.ioDrNmFls;
-               buf->st_rsize= 0;
+               buf->st_size = pb.d.ioDrNmFls;
+               buf->st_rsize = 0;
        }
        else {
                buf->st_mode |= S_IFREG;
                if (pb.f.ioFlFndrInfo.fdType == 'APPL')
                        buf->st_mode |= 0111;
-               buf->st_size= pb.f.ioFlLgLen;
-               buf->st_rsize= pb.f.ioFlRLgLen;
        }
-       buf->st_mtime= pb.f.ioFlMdDat - TIMEDIFF;
+       buf->st_ino = pb.hf.ioDirID;
+       buf->st_nlink = 1;
+       buf->st_uid = 1;
+       buf->st_gid = 1;
+       buf->st_size = pb.f.ioFlLgLen;
+       buf->st_mtime = buf->st_atime = pb.f.ioFlMdDat;
+       buf->st_ctime = pb.f.ioFlCrDat;
+       buf->st_rsize = pb.f.ioFlRLgLen;
+       *(unsigned long *)buf->st_type = pb.f.ioFlFndrInfo.fdType;
+       *(unsigned long *)buf->st_creator = pb.f.ioFlFndrInfo.fdCreator;
        return 0;
 }
index c14116a309ab73aa4dafa0af034ad81e5d9978bd..4c2421998c185fc0d036279b0ab4be87922b9c33 100644 (file)
@@ -1,25 +1,28 @@
 /* Include file belonging to stat emulator.
-   Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). */
+   Public domain by Guido van Rossum, CWI, Amsterdam (July 1987).
+   Updated August 1994. */
 
-struct stat {
+struct macstat {
+       unsigned short st_dev;
+       unsigned long st_ino;
        unsigned short st_mode;
+       unsigned short st_nlink;
+       unsigned short st_uid;
+       unsigned short st_gid;
+       unsigned short st_rdev;
        unsigned long st_size;
-       unsigned long st_rsize; /* Resource size -- nonstandard */
+       unsigned long st_atime;
        unsigned long st_mtime;
+       unsigned long st_ctime;
+       /* Non-standard additions */
+       unsigned long st_rsize; /* Resource size */
+       char st_type[4]; /* File type, e.g. 'APPL' or 'TEXT' */
+       char st_creator[4]; /* File creator, e.g. 'PYTH' */
 };
 
-#ifdef UNIX_COMPAT
 #define S_IFMT 0170000L
 #define S_IFDIR        0040000L
 #define S_IFREG 0100000L
 #define S_IREAD    0400
 #define S_IWRITE   0200
 #define S_IEXEC    0100
-#else
-#define S_IFMT 0xFFFF
-#define S_IFDIR        0x0000
-#define S_IFREG 0x0003
-#define S_IREAD    0400
-#define S_IWRITE   0200
-#define S_IEXEC    0100
-#endif
index 7b98e958c4bff7f436dc98fbb5b47024b44c63e9..e04fde6c4c0f24ccb46fcd13827a9dee306b0ebb 100644 (file)
@@ -1,4 +1,9 @@
-/* config.h for Macintosh THINK C 6.0.  */
+/* config.h for Macintosh THINK C 6.0 and MPW 3.2.  */
+
+#ifdef MPW
+/* This must be is MPW 3.x */
+#define MPW_3 1
+#endif
 
 /* Define if on Macintosh (THINK_C or MPW should also be defined) */
 #define macintosh
index dcdedb14743da8f0e28a613f697b0e9cc40422e5..c1e8a6e275389940a59fd77952f487db116987cd 100644 (file)
@@ -7,17 +7,13 @@
 #include <Files.h>
 #include <OSUtils.h>
 
-#ifndef MPW
+#ifdef THINK_C
 #include <pascal.h>
 #endif
 
 #include <errno.h>
 #include <string.h>
 
-/* Difference in origin between Mac and Unix clocks: */
-#define TIMEDIFF ((unsigned long) \
-       (((1970-1904)*365 + (1970-1904)/4) * 24 * 3600))
-
 /* Macro to find out whether we can do HFS-only calls: */
 #define FSFCBLen (* (short *) 0x3f6)
 #define hfsrunning() (FSFCBLen > 0)
@@ -31,8 +27,3 @@
 #endif
 #define EOS '\0'
 #define SEP ':'
-
-#if 0 // doesn't work
-/* Call Macsbug: */
-pascal void Debugger() extern 0xA9FF;
-#endif
index 54fed7430dec532036602e86cc9256330ce936e7..3595a9ea81bc3408b8d5d6bc5379ae9a71102373 100644 (file)
@@ -31,8 +31,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #ifdef macintosh
 /* The Macintosh main program is in macmain.c */
 #define NO_MAIN
-/* Comment this out if you're not interested in STDWIN */
-#define USE_STDWIN
 #endif
 
 #include <stdio.h>
index ff06acded971cc1cdda56b5c6917e609b382b359..d8d0dd873e8f8ce2c158ef0d5de60f51b75751f8 100644 (file)
@@ -23,8 +23,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 ******************************************************************/
 
 /* Mac module implementation */
-/* Richard J. Walker April 7, 1994 Island Graphics Corp. */
-/* Thanks to Guido's unix emulation routines */
 
 #include "allobjects.h"
 #include "modsupport.h"
@@ -33,7 +31,19 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
-#include <stat.h>
+
+#ifdef THINK_C
+#include "unix.h"
+#undef S_IFMT
+#undef S_IFDIR
+#undef S_IFCHR
+#undef S_IFBLK
+#undef S_IFREG
+#undef S_ISDIR
+#undef S_ISREG
+#endif
+
+#include "macstat.h"
 
 #include <fcntl.h>
 
@@ -54,9 +64,12 @@ DIR * opendir PROTO((char *));
 void closedir PROTO((DIR *));
 struct dirent * readdir PROTO((DIR *));
 int rmdir PROTO((const char *path));
-int stat PROTO((const char *path, struct stat *buf));
 int sync PROTO((void));
+#ifdef THINK_C
+int unlink PROTO((char *));
+#else
 int unlink PROTO((const char *));
+#endif
 
 
 
@@ -357,13 +370,13 @@ mac_stat(self, args)
        object *self;
        object *args;
 {
-       struct stat st;
+       struct macstat st;
        char *path;
        int res;
        if (!getargs(args, "s", &path))
                return NULL;
        BGN_SAVE
-       res = stat(path, &st);
+       res = macstat(path, &st);
        END_SAVE
        if (res != 0)
                return mac_error();
@@ -402,7 +415,7 @@ mac_unlink(self, args)
        object *self;
        object *args;
 {
-       return mac_1str(args, unlink);
+       return mac_1str(args, (int (*)(const char *))unlink);
 }
 
 static object *
index 9ba813659b9bf3d61f5a763eb3646b1c8b0c05b1..d4d15be9d94af36dde17bf2578d32262d0c4037b 100644 (file)
@@ -1,4 +1,4 @@
-#include <stat.h>
+#include "macstat.h"
 
 /* Interfaced used by import.c */
 
@@ -6,8 +6,8 @@ long
 getmtime(path)
        char *path;
 {
-       struct stat st;
-       if (stat(path, &st) != 0)
+       struct macstat st;
+       if (macstat(path, &st) != 0)
                return -1L;
        return st.st_mtime;
 }