annotate Mac/Modules/macmodule.c @ 4566:6403c94de50d legacy-trunk

Added safeguard against failure in __del__.
author Guido van Rossum <guido@python.org>
date Wed, 27 Nov 1996 19:39:58 +0000
parents 600f5b8a16cb
children 44bdf0b56c0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 /***********************************************************
2091
b4d982c648bb 1995 copyright
Guido van Rossum <guido@python.org>
parents: 2032
diff changeset
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
b4d982c648bb 1995 copyright
Guido van Rossum <guido@python.org>
parents: 2032
diff changeset
3 The Netherlands.
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 All Rights Reserved
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 Permission to use, copy, modify, and distribute this software and its
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 documentation for any purpose and without fee is hereby granted,
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 provided that the above copyright notice appear in all copies and that
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 both that copyright notice and this permission notice appear in
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 supporting documentation, and that the names of Stichting Mathematisch
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 Centrum or CWI not be used in advertising or publicity pertaining to
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 distribution of the software without specific, written prior permission.
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
14
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
22
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 ******************************************************************/
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
24
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
25 /* Mac module implementation */
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
26
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 #include "allobjects.h"
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
28 #include "modsupport.h"
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
29 #include "ceval.h"
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
30
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
31 #include <stdio.h>
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
32 #include <string.h>
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
33 #include <errno.h>
1822
76d0f2b3b9ee Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1821
diff changeset
34
76d0f2b3b9ee Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1821
diff changeset
35 #ifdef THINK_C
76d0f2b3b9ee Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1821
diff changeset
36 #include "unix.h"
76d0f2b3b9ee Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1821
diff changeset
37 #undef S_IFMT
76d0f2b3b9ee Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1821
diff changeset
38 #undef S_IFDIR
76d0f2b3b9ee Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1821
diff changeset
39 #undef S_IFCHR
76d0f2b3b9ee Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1821
diff changeset
40 #undef S_IFBLK
76d0f2b3b9ee Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1821
diff changeset
41 #undef S_IFREG
76d0f2b3b9ee Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1821
diff changeset
42 #undef S_ISDIR
76d0f2b3b9ee Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1821
diff changeset
43 #undef S_ISREG
76d0f2b3b9ee Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1821
diff changeset
44 #endif
76d0f2b3b9ee Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1821
diff changeset
45
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
46 #include "macstat.h"
3394
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
47 #ifdef USE_GUSI
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
48 /* Remove defines from macstat.h */
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
49 #undef S_IFMT
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
50 #undef S_IFDIR
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
51 #undef S_IFREG
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
52 #undef S_IREAD
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
53 #undef S_IWRITE
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
54 #undef S_IEXEC
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
55
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
56 #include <GUSI.h>
3394
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
57 #include <sys/types.h>
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
58 #include <stat.h>
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
59 #else
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
60 #define stat macstat
3394
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
61 #endif
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
62
2250
3bef1aff871b CodeWarrior 5 has more unixisms (open/close/read/write)
Jack Jansen <jack.jansen@cwi.nl>
parents: 2222
diff changeset
63 #ifdef __MWERKS__
3bef1aff871b CodeWarrior 5 has more unixisms (open/close/read/write)
Jack Jansen <jack.jansen@cwi.nl>
parents: 2222
diff changeset
64 #include <unix.h>
3bef1aff871b CodeWarrior 5 has more unixisms (open/close/read/write)
Jack Jansen <jack.jansen@cwi.nl>
parents: 2222
diff changeset
65 #else
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
66 #include <fcntl.h>
2032
609bfb8ae7f5 Ported to MetroWerks, which misses file-descriptor like functionality.
Jack Jansen <jack.jansen@cwi.nl>
parents: 1822
diff changeset
67 #endif
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
68
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
69 /* Optional routines, for some compiler/runtime combinations */
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
70 #if defined(USE_GUSI) || !defined(__MWERKS__)
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
71 #define WEHAVE_FDOPEN
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
72 #endif
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
73 #if defined(MPW) || defined(USE_GUSI)
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
74 #define WEHAVE_DUP
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
75 #endif
2222
bbb56dc3b526 Make malloc stats routine available under MetroWerks
Jack Jansen <jack.jansen@cwi.nl>
parents: 2179
diff changeset
76
1795
fa8bbd09f2e6 Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents: 1692
diff changeset
77 #include "macdefs.h"
3394
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
78 #ifdef USE_GUSI
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
79 #include <dirent.h>
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
80 #else
1795
fa8bbd09f2e6 Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents: 1692
diff changeset
81 #include "dirent.h"
3394
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
82 #endif
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
83
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
84 #ifndef MAXPATHLEN
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
85 #define MAXPATHLEN 1024
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
86 #endif
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
87
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
88 /* Prototypes for Unix simulation on Mac */
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
89
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
90 #ifndef USE_GUSI
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
91
1622
812d0811fcf3 Walker's changes fixed so they work in THINK C 5
Guido van Rossum <guido@python.org>
parents: 1620
diff changeset
92 int chdir PROTO((const char *path));
812d0811fcf3 Walker's changes fixed so they work in THINK C 5
Guido van Rossum <guido@python.org>
parents: 1620
diff changeset
93 int mkdir PROTO((const char *path, int mode));
812d0811fcf3 Walker's changes fixed so they work in THINK C 5
Guido van Rossum <guido@python.org>
parents: 1620
diff changeset
94 DIR * opendir PROTO((char *));
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
95 void closedir PROTO((DIR *));
1795
fa8bbd09f2e6 Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents: 1692
diff changeset
96 struct dirent * readdir PROTO((DIR *));
1622
812d0811fcf3 Walker's changes fixed so they work in THINK C 5
Guido van Rossum <guido@python.org>
parents: 1620
diff changeset
97 int rmdir PROTO((const char *path));
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
98 int sync PROTO((void));
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
99
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
100 #if defined(THINK_C) || defined(__SC__)
1822
76d0f2b3b9ee Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1821
diff changeset
101 int unlink PROTO((char *));
76d0f2b3b9ee Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1821
diff changeset
102 #else
1622
812d0811fcf3 Walker's changes fixed so they work in THINK C 5
Guido van Rossum <guido@python.org>
parents: 1620
diff changeset
103 int unlink PROTO((const char *));
1822
76d0f2b3b9ee Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1821
diff changeset
104 #endif
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
105
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
106 #endif /* USE_GUSI */
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
107
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
108 char *getwd PROTO((char *));
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
109 char *getbootvol PROTO((void));
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
110
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
111
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
112 static object *MacError; /* Exception mac.error */
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
113
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
114 /* Set a MAC-specific error from errno, and return NULL */
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
115
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
116 static object *
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
117 mac_error()
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
118 {
1622
812d0811fcf3 Walker's changes fixed so they work in THINK C 5
Guido van Rossum <guido@python.org>
parents: 1620
diff changeset
119 return err_errno(MacError);
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
120 }
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
121
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
122 /* MAC generic methods */
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
123
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
124 static object *
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
125 mac_1str(args, func)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
126 object *args;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
127 int (*func) FPROTO((const char *));
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
128 {
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
129 char *path1;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
130 int res;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
131 if (!getargs(args, "s", &path1))
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
132 return NULL;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
133 BGN_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
134 res = (*func)(path1);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
135 END_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
136 if (res < 0)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
137 return mac_error();
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
138 INCREF(None);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
139 return None;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
140 }
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
141
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
142 static object *
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
143 mac_2str(args, func)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
144 object *args;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
145 int (*func) FPROTO((const char *, const char *));
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
146 {
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
147 char *path1, *path2;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
148 int res;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
149 if (!getargs(args, "(ss)", &path1, &path2))
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
150 return NULL;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
151 BGN_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
152 res = (*func)(path1, path2);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
153 END_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
154 if (res < 0)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
155 return mac_error();
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
156 INCREF(None);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
157 return None;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
158 }
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
159
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
160 static object *
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
161 mac_strint(args, func)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
162 object *args;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
163 int (*func) FPROTO((const char *, int));
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
164 {
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
165 char *path;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
166 int i;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
167 int res;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
168 if (!getargs(args, "(si)", &path, &i))
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
169 return NULL;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
170 BGN_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
171 res = (*func)(path, i);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
172 END_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
173 if (res < 0)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
174 return mac_error();
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
175 INCREF(None);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
176 return None;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
177 }
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
178
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
179 static object *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
180 mac_chdir(self, args)
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
181 object *self;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
182 object *args;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
183 {
3433
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3405
diff changeset
184 #ifdef USE_GUSI
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3405
diff changeset
185 object *rv;
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3405
diff changeset
186
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3405
diff changeset
187 /* Change MacOS's idea of wd too */
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3405
diff changeset
188 rv = mac_1str(args, chdir);
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3405
diff changeset
189 PyMac_FixGUSIcd();
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3405
diff changeset
190 return rv;
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3405
diff changeset
191 #else
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
192 return mac_1str(args, chdir);
3433
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3405
diff changeset
193 #endif
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3405
diff changeset
194
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
195 }
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
196
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
197 static object *
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
198 mac_close(self, args)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
199 object *self;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
200 object *args;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
201 {
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
202 int fd, res;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
203 if (!getargs(args, "i", &fd))
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
204 return NULL;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
205 BGN_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
206 res = close(fd);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
207 END_SAVE
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
208 #ifndef USE_GUSI
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
209 /* GUSI gives surious errors here? */
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
210 if (res < 0)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
211 return mac_error();
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
212 #endif
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
213 INCREF(None);
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
214 return None;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
215 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
216
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
217 #ifdef WEHAVE_DUP
1622
812d0811fcf3 Walker's changes fixed so they work in THINK C 5
Guido van Rossum <guido@python.org>
parents: 1620
diff changeset
218
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
219 static object *
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
220 mac_dup(self, args)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
221 object *self;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
222 object *args;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
223 {
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
224 int fd;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
225 if (!getargs(args, "i", &fd))
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
226 return NULL;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
227 BGN_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
228 fd = dup(fd);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
229 END_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
230 if (fd < 0)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
231 return mac_error();
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
232 return newintobject((long)fd);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
233 }
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
234
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
235 #endif
1821
40594f80ab3c Intermediate version of changes after porting to MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1808
diff changeset
236
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
237 #ifdef WEHAVE_FDOPEN
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
238 static object *
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
239 mac_fdopen(self, args)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
240 object *self;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
241 object *args;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
242 {
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
243 extern int fclose PROTO((FILE *));
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
244 int fd;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
245 char *mode;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
246 FILE *fp;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
247 if (!getargs(args, "(is)", &fd, &mode))
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
248 return NULL;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
249 BGN_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
250 fp = fdopen(fd, mode);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
251 END_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
252 if (fp == NULL)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
253 return mac_error();
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
254 return newopenfileobject(fp, "(fdopen)", mode, fclose);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
255 }
2032
609bfb8ae7f5 Ported to MetroWerks, which misses file-descriptor like functionality.
Jack Jansen <jack.jansen@cwi.nl>
parents: 1822
diff changeset
256 #endif
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
257
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
258 static object *
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
259 mac_getbootvol(self, args)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
260 object *self;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
261 object *args;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
262 {
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
263 char *res;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
264 if (!getnoarg(args))
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
265 return NULL;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
266 BGN_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
267 res = getbootvol();
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
268 END_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
269 if (res == NULL)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
270 return mac_error();
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
271 return newstringobject(res);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
272 }
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
273
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
274 static object *
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
275 mac_getcwd(self, args)
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
276 object *self;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
277 object *args;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
278 {
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
279 char path[MAXPATHLEN];
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
280 char *res;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
281 if (!getnoarg(args))
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
282 return NULL;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
283 BGN_SAVE
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
284 #ifdef USE_GUSI
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
285 res = getcwd(path, sizeof path);
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
286 #else
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
287 res = getwd(path);
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
288 #endif
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
289 END_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
290 if (res == NULL) {
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
291 err_setstr(MacError, path);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
292 return NULL;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
293 }
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
294 return newstringobject(res);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
295 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
296
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
297 static object *
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
298 mac_listdir(self, args)
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
299 object *self;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
300 object *args;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
301 {
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
302 char *name;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
303 object *d, *v;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
304 DIR *dirp;
1795
fa8bbd09f2e6 Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents: 1692
diff changeset
305 struct dirent *ep;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
306 if (!getargs(args, "s", &name))
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
307 return NULL;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
308 BGN_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
309 if ((dirp = opendir(name)) == NULL) {
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
310 RET_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
311 return mac_error();
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
312 }
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
313 if ((d = newlistobject(0)) == NULL) {
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
314 closedir(dirp);
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
315 RET_SAVE
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
316 return NULL;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
317 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
318 while ((ep = readdir(dirp)) != NULL) {
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
319 v = newstringobject(ep->d_name);
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
320 if (v == NULL) {
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
321 DECREF(d);
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
322 d = NULL;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
323 break;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
324 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
325 if (addlistitem(d, v) != 0) {
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
326 DECREF(v);
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
327 DECREF(d);
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
328 d = NULL;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
329 break;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
330 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
331 DECREF(v);
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
332 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
333 closedir(dirp);
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
334 END_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
335
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
336 return d;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
337 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
338
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
339 static object *
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
340 mac_lseek(self, args)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
341 object *self;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
342 object *args;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
343 {
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
344 int fd;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
345 int where;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
346 int how;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
347 long res;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
348 if (!getargs(args, "(iii)", &fd, &where, &how))
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
349 return NULL;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
350 BGN_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
351 res = lseek(fd, (long)where, how);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
352 END_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
353 if (res < 0)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
354 return mac_error();
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
355 return newintobject(res);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
356 }
3394
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
357
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
358 static object *
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
359 mac_mkdir(self, args)
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
360 object *self;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
361 object *args;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
362 {
3405
c283447b985f Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3400
diff changeset
363 int res;
c283447b985f Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3400
diff changeset
364 char *path;
c283447b985f Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3400
diff changeset
365 int mode = 0777; /* Unused */
c283447b985f Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3400
diff changeset
366 if (!newgetargs(args, "s|i", &path, &mode))
c283447b985f Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3400
diff changeset
367 return NULL;
c283447b985f Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3400
diff changeset
368 BGN_SAVE
3942
38684852376f GUSI mkdir() lost its dummy second arg
Jack Jansen <jack.jansen@cwi.nl>
parents: 3433
diff changeset
369 #ifdef USE_GUSI
38684852376f GUSI mkdir() lost its dummy second arg
Jack Jansen <jack.jansen@cwi.nl>
parents: 3433
diff changeset
370 res = mkdir(path);
38684852376f GUSI mkdir() lost its dummy second arg
Jack Jansen <jack.jansen@cwi.nl>
parents: 3433
diff changeset
371 #else
3405
c283447b985f Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3400
diff changeset
372 res = mkdir(path, mode);
3942
38684852376f GUSI mkdir() lost its dummy second arg
Jack Jansen <jack.jansen@cwi.nl>
parents: 3433
diff changeset
373 #endif
3405
c283447b985f Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3400
diff changeset
374 END_SAVE
c283447b985f Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3400
diff changeset
375 if (res < 0)
c283447b985f Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3400
diff changeset
376 return mac_error();
c283447b985f Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3400
diff changeset
377 INCREF(None);
c283447b985f Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3400
diff changeset
378 return None;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
379 }
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
380
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
381 static object *
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
382 mac_open(self, args)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
383 object *self;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
384 object *args;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
385 {
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
386 char *path;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
387 int mode;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
388 int fd;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
389 if (!getargs(args, "(si)", &path, &mode))
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
390 return NULL;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
391 BGN_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
392 fd = open(path, mode);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
393 END_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
394 if (fd < 0)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
395 return mac_error();
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
396 return newintobject((long)fd);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
397 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
398
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
399 static object *
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
400 mac_read(self, args)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
401 object *self;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
402 object *args;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
403 {
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
404 int fd, size;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
405 object *buffer;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
406 if (!getargs(args, "(ii)", &fd, &size))
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
407 return NULL;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
408 buffer = newsizedstringobject((char *)NULL, size);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
409 if (buffer == NULL)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
410 return NULL;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
411 BGN_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
412 size = read(fd, getstringvalue(buffer), size);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
413 END_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
414 if (size < 0) {
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
415 DECREF(buffer);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
416 return mac_error();
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
417 }
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
418 resizestring(&buffer, size);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
419 return buffer;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
420 }
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
421
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
422 static object *
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
423 mac_rename(self, args)
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
424 object *self;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
425 object *args;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
426 {
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
427 return mac_2str(args, rename);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
428 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
429
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
430 static object *
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
431 mac_rmdir(self, args)
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
432 object *self;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
433 object *args;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
434 {
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
435 return mac_1str(args, rmdir);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
436 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
437
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
438 static object *
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
439 mac_stat(self, args)
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
440 object *self;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
441 object *args;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
442 {
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
443 struct stat st;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
444 char *path;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
445 int res;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
446 if (!getargs(args, "s", &path))
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
447 return NULL;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
448 BGN_SAVE
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
449 res = stat(path, &st);
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
450 END_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
451 if (res != 0)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
452 return mac_error();
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
453 #if 1
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
454 return mkvalue("(lllllllddd)",
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
455 (long)st.st_mode,
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
456 (long)st.st_ino,
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
457 (long)st.st_dev,
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
458 (long)st.st_nlink,
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
459 (long)st.st_uid,
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
460 (long)st.st_gid,
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
461 (long)st.st_size,
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
462 (double)st.st_atime,
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
463 (double)st.st_mtime,
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
464 (double)st.st_ctime);
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
465 #else
1795
fa8bbd09f2e6 Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents: 1692
diff changeset
466 return mkvalue("(llllllllll)",
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
467 (long)st.st_mode,
1821
40594f80ab3c Intermediate version of changes after porting to MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1808
diff changeset
468 (long)st.st_ino,
1795
fa8bbd09f2e6 Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents: 1692
diff changeset
469 (long)st.st_dev,
fa8bbd09f2e6 Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents: 1692
diff changeset
470 (long)st.st_nlink,
fa8bbd09f2e6 Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents: 1692
diff changeset
471 (long)st.st_uid,
fa8bbd09f2e6 Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents: 1692
diff changeset
472 (long)st.st_gid,
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
473 (long)st.st_size,
1795
fa8bbd09f2e6 Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents: 1692
diff changeset
474 (long)st.st_atime,
fa8bbd09f2e6 Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents: 1692
diff changeset
475 (long)st.st_mtime,
fa8bbd09f2e6 Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents: 1692
diff changeset
476 (long)st.st_ctime);
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
477 #endif
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
478 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
479
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
480 static object *
2929
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
481 mac_xstat(self, args)
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
482 object *self;
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
483 object *args;
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
484 {
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
485 struct macstat mst;
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
486 struct stat st;
2929
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
487 char *path;
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
488 int res;
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
489 if (!getargs(args, "s", &path))
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
490 return NULL;
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
491 /*
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
492 ** Convoluted: we want stat() and xstat() to agree, so we call both
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
493 ** stat and macstat, and use the latter only for values not provided by
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
494 ** the former.
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
495 */
2929
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
496 BGN_SAVE
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
497 res = macstat(path, &mst);
2929
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
498 END_SAVE
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
499 if (res != 0)
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
500 return mac_error();
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
501 BGN_SAVE
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
502 res = stat(path, &st);
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
503 END_SAVE
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
504 if (res != 0)
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
505 return mac_error();
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
506 #if 1
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
507 return mkvalue("(llllllldddls#s#)",
3394
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
508 (long)st.st_mode,
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
509 (long)st.st_ino,
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
510 (long)st.st_dev,
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
511 (long)st.st_nlink,
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
512 (long)st.st_uid,
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
513 (long)st.st_gid,
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
514 (long)st.st_size,
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
515 (double)st.st_atime,
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
516 (double)st.st_mtime,
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
517 (double)st.st_ctime,
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
518 (long)mst.st_rsize,
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
519 mst.st_creator, 4,
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
520 mst.st_type, 4);
3394
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
521 #else
2929
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
522 return mkvalue("(llllllllllls#s#)",
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
523 (long)st.st_mode,
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
524 (long)st.st_ino,
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
525 (long)st.st_dev,
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
526 (long)st.st_nlink,
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
527 (long)st.st_uid,
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
528 (long)st.st_gid,
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
529 (long)st.st_size,
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
530 (long)st.st_atime,
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
531 (long)st.st_mtime,
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
532 (long)st.st_ctime,
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
533 (long)mst.st_rsize,
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
534 mst.st_creator, 4,
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
535 mst.st_type, 4);
3394
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
536 #endif
2929
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
537 }
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
538
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
539 static object *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
540 mac_sync(self, args)
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
541 object *self;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
542 object *args;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
543 {
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
544 int res;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
545 if (!getnoarg(args))
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
546 return NULL;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
547 BGN_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
548 res = sync();
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
549 END_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
550 if (res != 0)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
551 return mac_error();
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
552 INCREF(None);
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
553 return None;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
554 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
555
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
556 static object *
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
557 mac_unlink(self, args)
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
558 object *self;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
559 object *args;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
560 {
1822
76d0f2b3b9ee Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1821
diff changeset
561 return mac_1str(args, (int (*)(const char *))unlink);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
562 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
563
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
564 static object *
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
565 mac_write(self, args)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
566 object *self;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
567 object *args;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
568 {
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
569 int fd, size;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
570 char *buffer;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
571 if (!getargs(args, "(is#)", &fd, &buffer, &size))
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
572 return NULL;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
573 BGN_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
574 size = write(fd, buffer, size);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
575 END_SAVE
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
576 if (size < 0)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
577 return mac_error();
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
578 return newintobject((long)size);
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
579 }
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
580
4468
600f5b8a16cb Malloc debugging now flagged with USE_MALLOC_DEBUG
Jack Jansen <jack.jansen@cwi.nl>
parents: 4414
diff changeset
581 #ifdef USE_MALLOC_DEBUG
2179
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
582 static object *
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
583 mac_mstats(self, args)
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
584 object*self;
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
585 object *args;
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
586 {
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
587 mstats("python");
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
588 INCREF(None);
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
589 return None;
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
590 }
4468
600f5b8a16cb Malloc debugging now flagged with USE_MALLOC_DEBUG
Jack Jansen <jack.jansen@cwi.nl>
parents: 4414
diff changeset
591 #endif USE_MALLOC_DEBUG
2179
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
592
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
593 static struct methodlist mac_methods[] = {
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
594 {"chdir", mac_chdir},
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
595 {"close", mac_close},
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
596 #ifdef WEHAVE_DUP
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
597 {"dup", mac_dup},
1821
40594f80ab3c Intermediate version of changes after porting to MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1808
diff changeset
598 #endif
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
599 #ifdef WEHAVE_FDOPEN
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
600 {"fdopen", mac_fdopen},
2032
609bfb8ae7f5 Ported to MetroWerks, which misses file-descriptor like functionality.
Jack Jansen <jack.jansen@cwi.nl>
parents: 1822
diff changeset
601 #endif
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
602 {"getbootvol", mac_getbootvol}, /* non-standard */
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
603 {"getcwd", mac_getcwd},
2391
ecbbaa584f3c explicitly init flags in methodlist
Guido van Rossum <guido@python.org>
parents: 2359
diff changeset
604 {"listdir", mac_listdir, 0},
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
605 {"lseek", mac_lseek},
3405
c283447b985f Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3400
diff changeset
606 {"mkdir", mac_mkdir, 1},
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
607 {"open", mac_open},
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
608 {"read", mac_read},
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
609 {"rename", mac_rename},
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
610 {"rmdir", mac_rmdir},
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
611 {"stat", mac_stat},
2929
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
612 {"xstat", mac_xstat},
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
613 {"sync", mac_sync},
3405
c283447b985f Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3400
diff changeset
614 {"remove", mac_unlink},
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
615 {"unlink", mac_unlink},
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
616 {"write", mac_write},
4468
600f5b8a16cb Malloc debugging now flagged with USE_MALLOC_DEBUG
Jack Jansen <jack.jansen@cwi.nl>
parents: 4414
diff changeset
617 #ifdef USE_MALLOC_DEBUG
2179
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
618 {"mstats", mac_mstats},
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
619 #endif
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
620
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
621 {NULL, NULL} /* Sentinel */
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
622 };
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
623
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
624
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
625 void
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
626 initmac()
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
627 {
2179
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
628 object *m, *d;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
629
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
630 m = initmodule("mac", mac_methods);
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
631 d = getmoduledict(m);
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
632
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
633 /* Initialize mac.error exception */
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
634 MacError = newstringobject("mac.error");
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
635 if (MacError == NULL || dictinsert(d, "error", MacError) != 0)
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
636 fatal("can't define mac.error");
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
637 }