Commit e7834444 authored by Guido van Rossum's avatar Guido van Rossum

Intermediate version of changes after porting to MPW 3.2

parent f0171a16
/* Minimal 'stat' emulation: tells directories from files and
gives length and mtime.
Public domain by Guido van Rossum, CWI, Amsterdam (July 1987).
*/
#include "stat.h"
#include "macdefs.h"
/* Bits in ioFlAttrib: */
#define LOCKBIT (1<<0) /* File locked */
#define DIRBIT (1<<4) /* It's a directory */
int
stat(path, buf)
char *path;
struct stat *buf;
{
union {
DirInfo d;
FileParam f;
HFileInfo hf;
} pb;
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 */
if (hfsrunning())
err= PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
else
err= PBGetFInfo((ParmBlkPtr)&pb, FALSE);
if (err != noErr) {
errno = ENOENT;
return -1;
}
if (pb.d.ioFlAttrib & LOCKBIT)
buf->st_mode= 0444;
else
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;
}
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;
return 0;
}
/* Include file belonging to stat emulator.
Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). */
struct stat {
unsigned short st_mode;
unsigned long st_size;
unsigned long st_rsize; /* Resource size -- nonstandard */
unsigned long st_mtime;
};
#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
...@@ -170,6 +170,8 @@ mac_dup(self, args) ...@@ -170,6 +170,8 @@ mac_dup(self, args)
return newintobject((long)fd); return newintobject((long)fd);
} }
#endif /* MPW */
static object * static object *
mac_fdopen(self, args) mac_fdopen(self, args)
object *self; object *self;
...@@ -189,8 +191,6 @@ mac_fdopen(self, args) ...@@ -189,8 +191,6 @@ mac_fdopen(self, args)
return newopenfileobject(fp, "(fdopen)", mode, fclose); return newopenfileobject(fp, "(fdopen)", mode, fclose);
} }
#endif /* MPW */
static object * static object *
mac_getbootvol(self, args) mac_getbootvol(self, args)
object *self; object *self;
...@@ -369,7 +369,7 @@ mac_stat(self, args) ...@@ -369,7 +369,7 @@ mac_stat(self, args)
return mac_error(); return mac_error();
return mkvalue("(llllllllll)", return mkvalue("(llllllllll)",
(long)st.st_mode, (long)st.st_mode,
(long)st.st_ito, /* XXX st_ino -- typo in THINK C <stat.h>? */ (long)st.st_ino,
(long)st.st_dev, (long)st.st_dev,
(long)st.st_nlink, (long)st.st_nlink,
(long)st.st_uid, (long)st.st_uid,
...@@ -427,8 +427,8 @@ static struct methodlist mac_methods[] = { ...@@ -427,8 +427,8 @@ static struct methodlist mac_methods[] = {
{"close", mac_close}, {"close", mac_close},
#ifdef MPW #ifdef MPW
{"dup", mac_dup}, {"dup", mac_dup},
{"fdopen", mac_fdopen},
#endif #endif
{"fdopen", mac_fdopen},
{"getbootvol", mac_getbootvol}, /* non-standard */ {"getbootvol", mac_getbootvol}, /* non-standard */
{"getcwd", mac_getcwd}, {"getcwd", mac_getcwd},
{"listdir", mac_listdir}, {"listdir", mac_listdir},
......
...@@ -28,9 +28,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -28,9 +28,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "config.h" #include "config.h"
#endif #endif
/* Comment this out if you're not interested in STDWIN */
#define USE_STDWIN
#ifdef THINK_C #ifdef THINK_C
#define CONSOLE_IO #define CONSOLE_IO
#endif #endif
......
...@@ -5,10 +5,8 @@ Python can be built on the Mac using either THINK C 6.0 or MPW 3.2. ...@@ -5,10 +5,8 @@ Python can be built on the Mac using either THINK C 6.0 or MPW 3.2.
In the past it has been compiled with earlier versions of these In the past it has been compiled with earlier versions of these
compilers, but no guarantees are made that the source is still compilers, but no guarantees are made that the source is still
compatible with those versions. Likewise, new compiler versions may compatible with those versions. Likewise, new compiler versions may
effectively change the language accepted (or the library!) and thus effectively change the language accepted (or the library provided!)
cause problems. and thus cause problems.
[[MPW version and procedure must still be checked]]
1. Using Think C 6.0 1. Using Think C 6.0
...@@ -102,21 +100,14 @@ arbitrarily because of the 32000 bytes restriction. ...@@ -102,21 +100,14 @@ arbitrarily because of the 32000 bytes restriction.
macmodule.c in the Mac subdirectory, so it should already have macmodule.c in the Mac subdirectory, so it should already have
been added in a previous step.) Note that for most modules, been added in a previous step.) Note that for most modules,
the source file is called <name>module.c, but for a few long the source file is called <name>module.c, but for a few long
module names it is just <module>.c. module names it is just <module>.c. Don't add stdwinmodule.c
yet,
The following THINK C libraries must be added: from Standard The following THINK C libraries must be added: from Standard
Libraries, ANSI and unix; from Mac Libraries, MacTraps. I put each Libraries, ANSI and unix; from Mac Libraries, MacTraps. I put each
library in a separate segment. Also see my earlier remark on 4-byte library in a separate segment. Also see my earlier remark on 4-byte
ints. ints.
1.3 Living without STDWIN
-------------------------
Although STDWIN is really neat on the Mac, it's easier to begin
building Python without it, so you can concentrate on the Python
build. To this end, you have to comment out the lines defining the
symbol USE_STDWIN in macmain.c and config.c.
1.4 Adding STDWIN 1.4 Adding STDWIN
----------------- -----------------
...@@ -127,9 +118,10 @@ the same general source setup (in a sister directory of the toplevel ...@@ -127,9 +118,10 @@ the same general source setup (in a sister directory of the toplevel
Python directory). Put all sources in the same segment. To Python directory). Put all sources in the same segment. To
stdwin.pi, also add Tools/strdup.c and Gen/wtextbreak.c. stdwin.pi, also add Tools/strdup.c and Gen/wtextbreak.c.
The two projects can now be added as libraries to the Python project, The two projects can now be added as libraries to the Python project.
and the two lines commented out to live without STDWIN should be You must also add stdwinmodule.c and add "#define USE_STDWIN" to the
reinstated. Prefix in the compiler options dialog (this only affects macmain.c and
config.c).
Note that stdwinmodule.c contains an #include statement that Note that stdwinmodule.c contains an #include statement that
references "stdwin.h" by relative path name -- if the stdwin toplevel references "stdwin.h" by relative path name -- if the stdwin toplevel
...@@ -147,13 +139,21 @@ copies resources into the application file from a file ...@@ -147,13 +139,21 @@ copies resources into the application file from a file
<projectname>.rsrc. <projectname>.rsrc.
2. Using MPW 2. Using MPW 3.2
============ ================
See the subdirectory MPW. I haven't tried this recently. You're The subdirectory MPW contains a README.MPW file, a buildall script and
supposed to merge the directory tree found here with the UNIX source several Makefiles (in respective subdirectories), kindly contributed
tree. I think this is intended for use with MPW 3.2. The dynload by Richard Walker of Island Software. Move these files to the
stuff in not recommended. corresponding locations relative to the Python root directory, and run
the buildall script. The README.MPW file contains more instructions
and caveats (I've added some remarks of my own at the end). I haven't
tried building STDWIN with MPW recently (there is MPW specific code
all over the STDWIN source but it is for a much older version of the
compiler and library). The MPW and THINK C ports share all source
files, including config.c and config.h -- all differentiation is done
based on #ifdef THINK_C or #ifdef MPW (#ifdef macintosh is used for
code that should be seen by all Mac compilers).
--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl> --Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>
......
...@@ -5,10 +5,8 @@ Python can be built on the Mac using either THINK C 6.0 or MPW 3.2. ...@@ -5,10 +5,8 @@ Python can be built on the Mac using either THINK C 6.0 or MPW 3.2.
In the past it has been compiled with earlier versions of these In the past it has been compiled with earlier versions of these
compilers, but no guarantees are made that the source is still compilers, but no guarantees are made that the source is still
compatible with those versions. Likewise, new compiler versions may compatible with those versions. Likewise, new compiler versions may
effectively change the language accepted (or the library!) and thus effectively change the language accepted (or the library provided!)
cause problems. and thus cause problems.
[[MPW version and procedure must still be checked]]
1. Using Think C 6.0 1. Using Think C 6.0
...@@ -102,21 +100,14 @@ arbitrarily because of the 32000 bytes restriction. ...@@ -102,21 +100,14 @@ arbitrarily because of the 32000 bytes restriction.
macmodule.c in the Mac subdirectory, so it should already have macmodule.c in the Mac subdirectory, so it should already have
been added in a previous step.) Note that for most modules, been added in a previous step.) Note that for most modules,
the source file is called <name>module.c, but for a few long the source file is called <name>module.c, but for a few long
module names it is just <module>.c. module names it is just <module>.c. Don't add stdwinmodule.c
yet,
The following THINK C libraries must be added: from Standard The following THINK C libraries must be added: from Standard
Libraries, ANSI and unix; from Mac Libraries, MacTraps. I put each Libraries, ANSI and unix; from Mac Libraries, MacTraps. I put each
library in a separate segment. Also see my earlier remark on 4-byte library in a separate segment. Also see my earlier remark on 4-byte
ints. ints.
1.3 Living without STDWIN
-------------------------
Although STDWIN is really neat on the Mac, it's easier to begin
building Python without it, so you can concentrate on the Python
build. To this end, you have to comment out the lines defining the
symbol USE_STDWIN in macmain.c and config.c.
1.4 Adding STDWIN 1.4 Adding STDWIN
----------------- -----------------
...@@ -127,9 +118,10 @@ the same general source setup (in a sister directory of the toplevel ...@@ -127,9 +118,10 @@ the same general source setup (in a sister directory of the toplevel
Python directory). Put all sources in the same segment. To Python directory). Put all sources in the same segment. To
stdwin.pi, also add Tools/strdup.c and Gen/wtextbreak.c. stdwin.pi, also add Tools/strdup.c and Gen/wtextbreak.c.
The two projects can now be added as libraries to the Python project, The two projects can now be added as libraries to the Python project.
and the two lines commented out to live without STDWIN should be You must also add stdwinmodule.c and add "#define USE_STDWIN" to the
reinstated. Prefix in the compiler options dialog (this only affects macmain.c and
config.c).
Note that stdwinmodule.c contains an #include statement that Note that stdwinmodule.c contains an #include statement that
references "stdwin.h" by relative path name -- if the stdwin toplevel references "stdwin.h" by relative path name -- if the stdwin toplevel
...@@ -147,13 +139,21 @@ copies resources into the application file from a file ...@@ -147,13 +139,21 @@ copies resources into the application file from a file
<projectname>.rsrc. <projectname>.rsrc.
2. Using MPW 2. Using MPW 3.2
============ ================
See the subdirectory MPW. I haven't tried this recently. You're The subdirectory MPW contains a README.MPW file, a buildall script and
supposed to merge the directory tree found here with the UNIX source several Makefiles (in respective subdirectories), kindly contributed
tree. I think this is intended for use with MPW 3.2. The dynload by Richard Walker of Island Software. Move these files to the
stuff in not recommended. corresponding locations relative to the Python root directory, and run
the buildall script. The README.MPW file contains more instructions
and caveats (I've added some remarks of my own at the end). I haven't
tried building STDWIN with MPW recently (there is MPW specific code
all over the STDWIN source but it is for a much older version of the
compiler and library). The MPW and THINK C ports share all source
files, including config.c and config.h -- all differentiation is done
based on #ifdef THINK_C or #ifdef MPW (#ifdef macintosh is used for
code that should be seen by all Mac compilers).
--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl> --Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment