Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 739267b

Browse files
committed
Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
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.
1 parent e783444 commit 739267b

8 files changed

Lines changed: 71 additions & 53 deletions

File tree

Mac/Compat/getwd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
Public domain by Guido van Rossum, CWI, Amsterdam (July 1987).
2828
*/
2929

30+
#include "macdefs.h"
3031
#ifdef MPW
3132
#include <Strings.h>
3233
#endif
33-
#include "macdefs.h"
3434

3535
#define ROOTID 2 /* Root directory ID */
3636

Mac/Compat/macstat.c

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
/* Minimal 'stat' emulation: tells directories from files and
22
gives length and mtime.
33
Public domain by Guido van Rossum, CWI, Amsterdam (July 1987).
4+
Updated to give more info, August 1994.
45
*/
56

6-
#include "stat.h"
7+
#include "macstat.h"
78
#include "macdefs.h"
89

910
/* Bits in ioFlAttrib: */
1011
#define LOCKBIT (1<<0) /* File locked */
1112
#define DIRBIT (1<<4) /* It's a directory */
1213

1314
int
14-
stat(path, buf)
15+
macstat(path, buf)
1516
char *path;
16-
struct stat *buf;
17+
struct macstat *buf;
1718
{
1819
union {
1920
DirInfo d;
@@ -23,35 +24,42 @@ stat(path, buf)
2324
char name[256];
2425
short err;
2526

26-
pb.d.ioNamePtr= (unsigned char *)c2pstr(strcpy(name, path));
27-
pb.d.ioVRefNum= 0;
28-
pb.d.ioFDirIndex= 0;
29-
pb.d.ioDrDirID= 0;
30-
pb.f.ioFVersNum= 0; /* Fix found by Timo! See Tech Note 102 */
27+
pb.d.ioNamePtr = (unsigned char *)c2pstr(strcpy(name, path));
28+
pb.d.ioVRefNum = 0;
29+
pb.d.ioFDirIndex = 0;
30+
pb.d.ioDrDirID = 0;
31+
pb.f.ioFVersNum = 0; /* Fix found by Timo! See Tech Note 102 */
3132
if (hfsrunning())
32-
err= PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
33+
err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
3334
else
34-
err= PBGetFInfo((ParmBlkPtr)&pb, FALSE);
35+
err = PBGetFInfo((ParmBlkPtr)&pb, FALSE);
3536
if (err != noErr) {
3637
errno = ENOENT;
3738
return -1;
3839
}
3940
if (pb.d.ioFlAttrib & LOCKBIT)
40-
buf->st_mode= 0444;
41+
buf->st_mode = 0444;
4142
else
42-
buf->st_mode= 0666;
43+
buf->st_mode = 0666;
4344
if (pb.d.ioFlAttrib & DIRBIT) {
4445
buf->st_mode |= 0111 | S_IFDIR;
45-
buf->st_size= pb.d.ioDrNmFls;
46-
buf->st_rsize= 0;
46+
buf->st_size = pb.d.ioDrNmFls;
47+
buf->st_rsize = 0;
4748
}
4849
else {
4950
buf->st_mode |= S_IFREG;
5051
if (pb.f.ioFlFndrInfo.fdType == 'APPL')
5152
buf->st_mode |= 0111;
52-
buf->st_size= pb.f.ioFlLgLen;
53-
buf->st_rsize= pb.f.ioFlRLgLen;
5453
}
55-
buf->st_mtime= pb.f.ioFlMdDat - TIMEDIFF;
54+
buf->st_ino = pb.hf.ioDirID;
55+
buf->st_nlink = 1;
56+
buf->st_uid = 1;
57+
buf->st_gid = 1;
58+
buf->st_size = pb.f.ioFlLgLen;
59+
buf->st_mtime = buf->st_atime = pb.f.ioFlMdDat;
60+
buf->st_ctime = pb.f.ioFlCrDat;
61+
buf->st_rsize = pb.f.ioFlRLgLen;
62+
*(unsigned long *)buf->st_type = pb.f.ioFlFndrInfo.fdType;
63+
*(unsigned long *)buf->st_creator = pb.f.ioFlFndrInfo.fdCreator;
5664
return 0;
5765
}

Mac/Compat/macstat.h

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
/* Include file belonging to stat emulator.
2-
Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). */
2+
Public domain by Guido van Rossum, CWI, Amsterdam (July 1987).
3+
Updated August 1994. */
34

4-
struct stat {
5+
struct macstat {
6+
unsigned short st_dev;
7+
unsigned long st_ino;
58
unsigned short st_mode;
9+
unsigned short st_nlink;
10+
unsigned short st_uid;
11+
unsigned short st_gid;
12+
unsigned short st_rdev;
613
unsigned long st_size;
7-
unsigned long st_rsize; /* Resource size -- nonstandard */
14+
unsigned long st_atime;
815
unsigned long st_mtime;
16+
unsigned long st_ctime;
17+
/* Non-standard additions */
18+
unsigned long st_rsize; /* Resource size */
19+
char st_type[4]; /* File type, e.g. 'APPL' or 'TEXT' */
20+
char st_creator[4]; /* File creator, e.g. 'PYTH' */
921
};
1022

11-
#ifdef UNIX_COMPAT
1223
#define S_IFMT 0170000L
1324
#define S_IFDIR 0040000L
1425
#define S_IFREG 0100000L
1526
#define S_IREAD 0400
1627
#define S_IWRITE 0200
1728
#define S_IEXEC 0100
18-
#else
19-
#define S_IFMT 0xFFFF
20-
#define S_IFDIR 0x0000
21-
#define S_IFREG 0x0003
22-
#define S_IREAD 0400
23-
#define S_IWRITE 0200
24-
#define S_IEXEC 0100
25-
#endif

Mac/Include/config.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
/* config.h for Macintosh THINK C 6.0. */
1+
/* config.h for Macintosh THINK C 6.0 and MPW 3.2. */
2+
3+
#ifdef MPW
4+
/* This must be is MPW 3.x */
5+
#define MPW_3 1
6+
#endif
27

38
/* Define if on Macintosh (THINK_C or MPW should also be defined) */
49
#define macintosh

Mac/Include/macdefs.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,13 @@
77
#include <Files.h>
88
#include <OSUtils.h>
99

10-
#ifndef MPW
10+
#ifdef THINK_C
1111
#include <pascal.h>
1212
#endif
1313

1414
#include <errno.h>
1515
#include <string.h>
1616

17-
/* Difference in origin between Mac and Unix clocks: */
18-
#define TIMEDIFF ((unsigned long) \
19-
(((1970-1904)*365 + (1970-1904)/4) * 24 * 3600))
20-
2117
/* Macro to find out whether we can do HFS-only calls: */
2218
#define FSFCBLen (* (short *) 0x3f6)
2319
#define hfsrunning() (FSFCBLen > 0)
@@ -31,8 +27,3 @@
3127
#endif
3228
#define EOS '\0'
3329
#define SEP ':'
34-
35-
#if 0 // doesn't work
36-
/* Call Macsbug: */
37-
pascal void Debugger() extern 0xA9FF;
38-
#endif

Mac/Modules/config.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3131
#ifdef macintosh
3232
/* The Macintosh main program is in macmain.c */
3333
#define NO_MAIN
34-
/* Comment this out if you're not interested in STDWIN */
35-
#define USE_STDWIN
3634
#endif
3735

3836
#include <stdio.h>

Mac/Modules/macmodule.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2323
******************************************************************/
2424

2525
/* Mac module implementation */
26-
/* Richard J. Walker April 7, 1994 Island Graphics Corp. */
27-
/* Thanks to Guido's unix emulation routines */
2826

2927
#include "allobjects.h"
3028
#include "modsupport.h"
@@ -33,7 +31,19 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3331
#include <stdio.h>
3432
#include <string.h>
3533
#include <errno.h>
36-
#include <stat.h>
34+
35+
#ifdef THINK_C
36+
#include "unix.h"
37+
#undef S_IFMT
38+
#undef S_IFDIR
39+
#undef S_IFCHR
40+
#undef S_IFBLK
41+
#undef S_IFREG
42+
#undef S_ISDIR
43+
#undef S_ISREG
44+
#endif
45+
46+
#include "macstat.h"
3747

3848
#include <fcntl.h>
3949

@@ -54,9 +64,12 @@ DIR * opendir PROTO((char *));
5464
void closedir PROTO((DIR *));
5565
struct dirent * readdir PROTO((DIR *));
5666
int rmdir PROTO((const char *path));
57-
int stat PROTO((const char *path, struct stat *buf));
5867
int sync PROTO((void));
68+
#ifdef THINK_C
69+
int unlink PROTO((char *));
70+
#else
5971
int unlink PROTO((const char *));
72+
#endif
6073

6174

6275

@@ -357,13 +370,13 @@ mac_stat(self, args)
357370
object *self;
358371
object *args;
359372
{
360-
struct stat st;
373+
struct macstat st;
361374
char *path;
362375
int res;
363376
if (!getargs(args, "s", &path))
364377
return NULL;
365378
BGN_SAVE
366-
res = stat(path, &st);
379+
res = macstat(path, &st);
367380
END_SAVE
368381
if (res != 0)
369382
return mac_error();
@@ -402,7 +415,7 @@ mac_unlink(self, args)
402415
object *self;
403416
object *args;
404417
{
405-
return mac_1str(args, unlink);
418+
return mac_1str(args, (int (*)(const char *))unlink);
406419
}
407420

408421
static object *

Mac/Python/macgetmtime.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#include <stat.h>
1+
#include "macstat.h"
22

33
/* Interfaced used by import.c */
44

55
long
66
getmtime(path)
77
char *path;
88
{
9-
struct stat st;
10-
if (stat(path, &st) != 0)
9+
struct macstat st;
10+
if (macstat(path, &st) != 0)
1111
return -1L;
1212
return st.st_mtime;
1313
}

0 commit comments

Comments
 (0)