annotate Mac/Modules/macmodule.c @ 25838:8540887bcec6 2.2

Backport of 2.183: Fix memory leak in add_subclass() found by NealN with valgrind.
author Guido van Rossum <guido@python.org>
date Fri, 18 Oct 2002 13:42:21 +0000
parents 457bf184e7ba
children 4f9d5ea4f37d
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 /***********************************************************
5079
d6b292a33cfe Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents: 5071
diff changeset
2 Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam,
2091
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
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
27 #include "Python.h"
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
28 #include "structseq.h"
1620
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
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15835
diff changeset
35 #if TARGET_API_MAC_OS8
15835
b1b0a703ec4e xstat() will never be implemented under Carbon. Fortunately it also doesn't appear to be used anywhere.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14205
diff changeset
36 /* Skip for Carbon */
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
37 #include "macstat.h"
12836
3fe304050434 Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12686
diff changeset
38 #endif
3fe304050434 Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12686
diff changeset
39
3394
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
40 #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
41 /* 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
42 #undef S_IFMT
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
43 #undef S_IFDIR
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
44 #undef S_IFREG
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
45 #undef S_IREAD
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
46 #undef S_IWRITE
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
47 #undef S_IEXEC
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
48
12284
9c96e5d437a8 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 7434
diff changeset
49 #ifdef USE_GUSI1
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
50 #include <GUSI.h>
12284
9c96e5d437a8 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 7434
diff changeset
51 #endif /* USE_GUSI1 */
3394
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
52 #include <sys/types.h>
12284
9c96e5d437a8 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 7434
diff changeset
53 #include <sys/stat.h>
9c96e5d437a8 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 7434
diff changeset
54 #else /* USE_GUSI */
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15835
diff changeset
55 #if TARGET_API_MAC_OS8
12284
9c96e5d437a8 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 7434
diff changeset
56 #define stat macstat
12836
3fe304050434 Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12686
diff changeset
57 #endif
12284
9c96e5d437a8 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 7434
diff changeset
58 #endif /* USE_GUSI */
9c96e5d437a8 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 7434
diff changeset
59
9c96e5d437a8 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 7434
diff changeset
60 #ifdef USE_GUSI2
9c96e5d437a8 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 7434
diff changeset
61 #include <unistd.h>
9c96e5d437a8 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 7434
diff changeset
62 #include <fcntl.h>
3394
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
63 #else
12686
bc96c912dce8 Fixed to work again without USE_GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 12284
diff changeset
64 #define mode_t int
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
65 #include <fcntl.h>
12836
3fe304050434 Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12686
diff changeset
66 #ifdef _POSIX
3fe304050434 Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12686
diff changeset
67 #include <unistd.h>
3fe304050434 Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12686
diff changeset
68 #include <stat.h>
3fe304050434 Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12686
diff changeset
69 #endif
2032
609bfb8ae7f5 Ported to MetroWerks, which misses file-descriptor like functionality.
Jack Jansen <jack.jansen@cwi.nl>
parents: 1822
diff changeset
70 #endif
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
71
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
72 /* Optional routines, for some compiler/runtime combinations */
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
73 #if defined(USE_GUSI) || !defined(__MWERKS__)
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
74 #define WEHAVE_FDOPEN
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
75 #endif
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
76 #if defined(MPW) || defined(USE_GUSI)
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
77 #define WEHAVE_DUP
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
78 #endif
7434
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
79 #if defined(USE_GUSI)
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
80 #define WEHAVE_FSTAT
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
81 #endif
2222
bbb56dc3b526 Make malloc stats routine available under MetroWerks
Jack Jansen <jack.jansen@cwi.nl>
parents: 2179
diff changeset
82
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
83 #include "macdefs.h"
3394
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
84 #ifdef USE_GUSI
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
85 #include <dirent.h>
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
86 #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
87 #include "dirent.h"
3394
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
88 #endif
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
89
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
90 #ifndef MAXPATHLEN
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
91 #define MAXPATHLEN 1024
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
92 #endif
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
93
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
94 /* 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
95
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
96 #ifndef USE_GUSI
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
97
13542
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12856
diff changeset
98 int chdir(const char *path);
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12856
diff changeset
99 int mkdir(const char *path, int mode);
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12856
diff changeset
100 DIR * opendir(char *);
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12856
diff changeset
101 void closedir(DIR *);
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12856
diff changeset
102 struct dirent * readdir(DIR *);
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12856
diff changeset
103 int rmdir(const char *path);
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12856
diff changeset
104 int sync(void);
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
105
13542
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12856
diff changeset
106 int unlink(const char *);
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
107
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
108 #endif /* USE_GUSI */
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
109
13542
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12856
diff changeset
110 char *getwd(char *);
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12856
diff changeset
111 char *getbootvol(void);
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
112
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
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
116 static PyObject *
1620
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 {
21113
ed3dce17fc79 Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
Jack Jansen <jack.jansen@cwi.nl>
parents: 20896
diff changeset
119 return PyErr_SetFromErrno(PyExc_OSError);
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
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
124 static PyObject *
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
125 mac_1str(args, func)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
126 PyObject *args;
13542
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12856
diff changeset
127 int (*func)(const char *);
1620
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;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
131 if (!PyArg_ParseTuple(args, "s", &path1))
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
132 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
133 Py_BEGIN_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
134 res = (*func)(path1);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
135 Py_END_ALLOW_THREADS
1620
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();
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
138 Py_INCREF(Py_None);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
139 return Py_None;
1620
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
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
142 static PyObject *
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
143 mac_2str(args, func)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
144 PyObject *args;
13542
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12856
diff changeset
145 int (*func)(const char *, const char *);
1620
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;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
149 if (!PyArg_ParseTuple(args, "ss", &path1, &path2))
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
150 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
151 Py_BEGIN_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
152 res = (*func)(path1, path2);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
153 Py_END_ALLOW_THREADS
1620
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();
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
156 Py_INCREF(Py_None);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
157 return Py_None;
1620
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
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
160 static PyObject *
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
161 mac_strint(args, func)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
162 PyObject *args;
13542
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12856
diff changeset
163 int (*func)(const char *, int);
1620
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;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
168 if (!PyArg_ParseTuple(args, "si", &path, &i))
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
169 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
170 Py_BEGIN_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
171 res = (*func)(path, i);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
172 Py_END_ALLOW_THREADS
1620
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();
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
175 Py_INCREF(Py_None);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
176 return Py_None;
1620
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
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
179 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
180 mac_chdir(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
181 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
182 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
183 {
12284
9c96e5d437a8 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 7434
diff changeset
184 #ifdef USE_GUSI1
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
185 PyObject *rv;
3433
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
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
197 static PyObject *
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
198 mac_close(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
199 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
200 PyObject *args;
1620
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;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
203 if (!PyArg_ParseTuple(args, "i", &fd))
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
204 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
205 Py_BEGIN_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
206 res = close(fd);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
207 Py_END_ALLOW_THREADS
12284
9c96e5d437a8 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 7434
diff changeset
208 #ifndef USE_GUSI1
3400
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
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
213 Py_INCREF(Py_None);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
214 return Py_None;
1495
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
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
219 static PyObject *
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
220 mac_dup(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
221 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
222 PyObject *args;
1620
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;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
225 if (!PyArg_ParseTuple(args, "i", &fd))
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
226 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
227 Py_BEGIN_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
228 fd = dup(fd);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
229 Py_END_ALLOW_THREADS
1620
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();
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
232 return PyInt_FromLong((long)fd);
1620
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
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
238 static PyObject *
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
239 mac_fdopen(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
240 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
241 PyObject *args;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
242 {
13542
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12856
diff changeset
243 extern int fclose(FILE *);
1620
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;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
247 if (!PyArg_ParseTuple(args, "is", &fd, &mode))
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
248 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
249 Py_BEGIN_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
250 fp = fdopen(fd, mode);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
251 Py_END_ALLOW_THREADS
1620
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();
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
254 return PyFile_FromFile(fp, "(fdopen)", mode, fclose);
1620
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
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15835
diff changeset
258 #if TARGET_API_MAC_OS8
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
259 static PyObject *
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
260 mac_getbootvol(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
261 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
262 PyObject *args;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
263 {
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
264 char *res;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
265 if (!PyArg_ParseTuple(args, ""))
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
266 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
267 Py_BEGIN_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
268 res = getbootvol();
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
269 Py_END_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
270 if (res == NULL)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
271 return mac_error();
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
272 return PyString_FromString(res);
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
273 }
12836
3fe304050434 Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12686
diff changeset
274 #endif
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
275
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
276 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
277 mac_getcwd(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
278 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
279 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
280 {
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
281 char path[MAXPATHLEN];
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
282 char *res;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
283 if (!PyArg_ParseTuple(args, ""))
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
284 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
285 Py_BEGIN_ALLOW_THREADS
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
286 #ifdef USE_GUSI
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
287 res = getcwd(path, sizeof path);
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
288 #else
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
289 res = getwd(path);
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
290 #endif
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
291 Py_END_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
292 if (res == NULL) {
21113
ed3dce17fc79 Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
Jack Jansen <jack.jansen@cwi.nl>
parents: 20896
diff changeset
293 return mac_error();
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
294 }
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
295 return PyString_FromString(res);
1495
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
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
298 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
299 mac_listdir(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
300 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
301 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
302 {
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
303 char *name;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
304 PyObject *d, *v;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
305 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
306 struct dirent *ep;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
307 if (!PyArg_ParseTuple(args, "s", &name))
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
308 return NULL;
19181
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
309 #ifdef USE_GUSI
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
310 /* Work around a bug in GUSI: if you opendir() a file it will
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
311 ** actually opendir() the parent directory.
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
312 */
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
313 {
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
314 struct stat stb;
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
315 int res;
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
316
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
317 res = stat(name, &stb);
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
318 if ( res < 0 )
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
319 return mac_error();
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
320 if (!S_ISDIR(stb.st_mode) ) {
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
321 errno = ENOTDIR;
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
322 return mac_error();
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
323 }
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
324 }
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
325 #endif
1d462b737810 test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18960
diff changeset
326
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
327 Py_BEGIN_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
328 if ((dirp = opendir(name)) == NULL) {
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
329 Py_BLOCK_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
330 return mac_error();
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
331 }
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
332 if ((d = PyList_New(0)) == NULL) {
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
333 closedir(dirp);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
334 Py_BLOCK_THREADS
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
335 return NULL;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
336 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
337 while ((ep = readdir(dirp)) != NULL) {
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
338 v = PyString_FromString(ep->d_name);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
339 if (v == NULL) {
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
340 Py_DECREF(d);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
341 d = NULL;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
342 break;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
343 }
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
344 if (PyList_Append(d, v) != 0) {
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
345 Py_DECREF(v);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
346 Py_DECREF(d);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
347 d = NULL;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
348 break;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
349 }
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
350 Py_DECREF(v);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
351 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
352 closedir(dirp);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
353 Py_END_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
354
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
355 return d;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
356 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
357
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
358 static PyObject *
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
359 mac_lseek(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
360 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
361 PyObject *args;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
362 {
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
363 int fd;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
364 int where;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
365 int how;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
366 long res;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
367 if (!PyArg_ParseTuple(args, "iii", &fd, &where, &how))
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
368 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
369 Py_BEGIN_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
370 res = lseek(fd, (long)where, how);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
371 Py_END_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
372 if (res < 0)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
373 return mac_error();
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
374 return PyInt_FromLong(res);
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
375 }
3394
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
376
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
377 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
378 mac_mkdir(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
379 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
380 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
381 {
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
382 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
383 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
384 int mode = 0777; /* Unused */
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
385 if (!PyArg_ParseTuple(args, "s|i", &path, &mode))
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
386 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
387 Py_BEGIN_ALLOW_THREADS
12284
9c96e5d437a8 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 7434
diff changeset
388 #ifdef USE_GUSI1
3942
38684852376f GUSI mkdir() lost its dummy second arg
Jack Jansen <jack.jansen@cwi.nl>
parents: 3433
diff changeset
389 res = mkdir(path);
38684852376f GUSI mkdir() lost its dummy second arg
Jack Jansen <jack.jansen@cwi.nl>
parents: 3433
diff changeset
390 #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
391 res = mkdir(path, mode);
3942
38684852376f GUSI mkdir() lost its dummy second arg
Jack Jansen <jack.jansen@cwi.nl>
parents: 3433
diff changeset
392 #endif
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
393 Py_END_ALLOW_THREADS
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
394 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
395 return mac_error();
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
396 Py_INCREF(Py_None);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
397 return Py_None;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
398 }
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
399
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
400 static PyObject *
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
401 mac_open(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
402 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
403 PyObject *args;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
404 {
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
405 char *path;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
406 int mode;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
407 int perm; /* Accepted but ignored */
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
408 int fd;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
409 if (!PyArg_ParseTuple(args, "si|i", &path, &mode, &perm))
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
410 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
411 Py_BEGIN_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
412 fd = open(path, mode);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
413 Py_END_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
414 if (fd < 0)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
415 return mac_error();
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
416 return PyInt_FromLong((long)fd);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
417 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
418
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
419 static PyObject *
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
420 mac_read(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
421 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
422 PyObject *args;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
423 {
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
424 int fd, size;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
425 PyObject *buffer;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
426 if (!PyArg_ParseTuple(args, "ii", &fd, &size))
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
427 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
428 buffer = PyString_FromStringAndSize((char *)NULL, size);
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
429 if (buffer == NULL)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
430 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
431 Py_BEGIN_ALLOW_THREADS
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
432 size = read(fd, PyString_AsString(buffer), size);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
433 Py_END_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
434 if (size < 0) {
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
435 Py_DECREF(buffer);
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
436 return mac_error();
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
437 }
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
438 _PyString_Resize(&buffer, size);
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
439 return buffer;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
440 }
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
441
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
442 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
443 mac_rename(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
444 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
445 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
446 {
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
447 return mac_2str(args, rename);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
448 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
449
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
450 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
451 mac_rmdir(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
452 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
453 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
454 {
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
455 return mac_1str(args, rmdir);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
456 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
457
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
458 static char stat_result__doc__[] =
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
459 "stat_result: Result from stat or lstat.\n\n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
460 This object may be accessed either as a tuple of\n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
461 (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)\n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
462 or via the attributes st_mode, st_ino, st_dev, st_nlink, st_uid, and so on.\n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
463 \n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
464 See os.stat for more information.\n";
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
465
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
466 #define COMMON_STAT_RESULT_FIELDS \
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
467 { "st_mode", "protection bits" }, \
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
468 { "st_ino", "inode" }, \
20643
ef78ec602a40 Some escaped newlines had spaces between the backslash and the newline. Also slightly changed the comment on xstat().
Jack Jansen <jack.jansen@cwi.nl>
parents: 20539
diff changeset
469 { "st_dev", "device" }, \
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
470 { "st_nlink", "number of hard links" }, \
20643
ef78ec602a40 Some escaped newlines had spaces between the backslash and the newline. Also slightly changed the comment on xstat().
Jack Jansen <jack.jansen@cwi.nl>
parents: 20539
diff changeset
471 { "st_uid", "user ID of owner" }, \
ef78ec602a40 Some escaped newlines had spaces between the backslash and the newline. Also slightly changed the comment on xstat().
Jack Jansen <jack.jansen@cwi.nl>
parents: 20539
diff changeset
472 { "st_gid", "group ID of owner" }, \
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
473 { "st_size", "total size, in bytes" }, \
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
474 { "st_atime", "time of last access" }, \
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
475 { "st_mtime", "time of last modification" }, \
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
476 { "st_ctime", "time of last change" },
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
477
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
478
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
479
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
480 static PyStructSequence_Field stat_result_fields[] = {
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
481 COMMON_STAT_RESULT_FIELDS
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
482 {0}
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
483 };
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
484
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
485 static PyStructSequence_Desc stat_result_desc = {
21313
91dd223829c6 Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents: 21113
diff changeset
486 "mac.stat_result",
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
487 stat_result__doc__,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
488 stat_result_fields,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
489 10
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
490 };
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
491
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
492 static PyTypeObject StatResultType;
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
493
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
494 #ifdef TARGET_API_MAC_OS8
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
495 static PyStructSequence_Field xstat_result_fields[] = {
20643
ef78ec602a40 Some escaped newlines had spaces between the backslash and the newline. Also slightly changed the comment on xstat().
Jack Jansen <jack.jansen@cwi.nl>
parents: 20539
diff changeset
496 COMMON_STAT_RESULT_FIELDS
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
497 { "st_rsize" },
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
498 { "st_creator" },
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
499 { "st_type "},
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
500 {0}
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
501 };
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
502
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
503 static PyStructSequence_Desc xstat_result_desc = {
21313
91dd223829c6 Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents: 21113
diff changeset
504 "mac.xstat_result",
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
505 stat_result__doc__,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
506 xstat_result_fields,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
507 13
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
508 };
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
509
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
510 static PyTypeObject XStatResultType;
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
511 #endif
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
512
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
513 static PyObject *
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
514 _pystat_from_struct_stat(struct stat st, void* _mst)
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
515 {
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
516 PyObject *v;
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
517
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
518 #if TARGET_API_MAC_OS8
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
519 struct macstat *mst;
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
520
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
521 if (_mst != NULL)
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
522 v = PyStructSequence_New(&XStatResultType);
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
523 else
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
524 #endif
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
525 v = PyStructSequence_New(&StatResultType);
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
526 PyStructSequence_SET_ITEM(v, 0, PyInt_FromLong((long)st.st_mode));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
527 PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long)st.st_ino));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
528 PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long)st.st_dev));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
529 PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long)st.st_nlink));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
530 PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long)st.st_uid));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
531 PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long)st.st_gid));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
532 PyStructSequence_SET_ITEM(v, 6, PyInt_FromLong((long)st.st_size));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
533 PyStructSequence_SET_ITEM(v, 7,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
534 PyFloat_FromDouble((double)st.st_atime));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
535 PyStructSequence_SET_ITEM(v, 8,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
536 PyFloat_FromDouble((double)st.st_mtime));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
537 PyStructSequence_SET_ITEM(v, 9,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
538 PyFloat_FromDouble((double)st.st_ctime));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
539 #if TARGET_API_MAC_OS8
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
540 if (_mst != NULL) {
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
541 mst = (struct macstat *) _mst;
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
542 PyStructSequence_SET_ITEM(v, 10,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
543 PyInt_FromLong((long)mst->st_rsize));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
544 PyStructSequence_SET_ITEM(v, 11,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
545 PyString_FromStringAndSize(mst->st_creator,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
546 4));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
547 PyStructSequence_SET_ITEM(v, 12,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
548 PyString_FromStringAndSize(mst->st_type,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
549 4));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
550 }
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
551 #endif
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
552
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
553 if (PyErr_Occurred()) {
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
554 Py_DECREF(v);
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
555 return NULL;
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
556 }
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
557
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
558 return v;
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
559 }
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
560
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
561
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
562 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
563 mac_stat(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
564 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
565 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
566 {
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
567 struct stat st;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
568 char *path;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
569 int res;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
570 if (!PyArg_ParseTuple(args, "s", &path))
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
571 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
572 Py_BEGIN_ALLOW_THREADS
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
573 res = stat(path, &st);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
574 Py_END_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
575 if (res != 0)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
576 return mac_error();
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
577
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
578 return _pystat_from_struct_stat(st, NULL);
7434
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
579 }
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
580
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
581 #ifdef WEHAVE_FSTAT
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
582 static PyObject *
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
583 mac_fstat(self, args)
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
584 PyObject *self;
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
585 PyObject *args;
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
586 {
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
587 struct stat st;
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
588 long fd;
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
589 int res;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
590 if (!PyArg_ParseTuple(args, "l", &fd))
7434
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
591 return NULL;
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
592 Py_BEGIN_ALLOW_THREADS
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
593 res = fstat((int)fd, &st);
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
594 Py_END_ALLOW_THREADS
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
595 if (res != 0)
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
596 return mac_error();
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
597
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
598 return _pystat_from_struct_stat(st, NULL);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
599 }
7434
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
600 #endif /* WEHAVE_FSTAT */
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
601
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15835
diff changeset
602 #if TARGET_API_MAC_OS8
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
603 static PyObject *
2929
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
604 mac_xstat(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
605 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
606 PyObject *args;
2929
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
607 {
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
608 struct macstat mst;
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
609 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
610 char *path;
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
611 int res;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
612 if (!PyArg_ParseTuple(args, "s", &path))
2929
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
613 return NULL;
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
614 /*
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
615 ** 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
616 ** 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
617 ** the former.
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
618 */
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
619 Py_BEGIN_ALLOW_THREADS
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
620 res = macstat(path, &mst);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
621 Py_END_ALLOW_THREADS
2929
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
622 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
623 return mac_error();
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
624 Py_BEGIN_ALLOW_THREADS
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
625 res = stat(path, &st);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
626 Py_END_ALLOW_THREADS
4414
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
627 if (res != 0)
02a68d623805 Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents: 3942
diff changeset
628 return mac_error();
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
629
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
630 return _pystat_from_struct_stat(st, (void*) &mst);
2929
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
631 }
12836
3fe304050434 Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12686
diff changeset
632 #endif
2929
7d1ecec25c06 add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents: 2722
diff changeset
633
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
634 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
635 mac_sync(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
636 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
637 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
638 {
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
639 int res;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
640 if (!PyArg_ParseTuple(args, ""))
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
641 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
642 Py_BEGIN_ALLOW_THREADS
22410
457bf184e7ba sync() has different return values depending on whether we build with GUSI or not.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21313
diff changeset
643 #ifdef USE_GUSI2
457bf184e7ba sync() has different return values depending on whether we build with GUSI or not.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21313
diff changeset
644 sync();
457bf184e7ba sync() has different return values depending on whether we build with GUSI or not.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21313
diff changeset
645 res = 0;
457bf184e7ba sync() has different return values depending on whether we build with GUSI or not.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21313
diff changeset
646 #else
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
647 res = sync();
22410
457bf184e7ba sync() has different return values depending on whether we build with GUSI or not.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21313
diff changeset
648 #endif
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
649 Py_END_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
650 if (res != 0)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
651 return mac_error();
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
652 Py_INCREF(Py_None);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
653 return Py_None;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
654 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
655
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
656 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
657 mac_unlink(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
658 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
659 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
660 {
1822
76d0f2b3b9ee Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1821
diff changeset
661 return mac_1str(args, (int (*)(const char *))unlink);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
662 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
663
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
664 static PyObject *
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
665 mac_write(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
666 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
667 PyObject *args;
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
668 {
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
669 int fd, size;
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
670 char *buffer;
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
671 if (!PyArg_ParseTuple(args, "is#", &fd, &buffer, &size))
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
672 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
673 Py_BEGIN_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
674 size = write(fd, buffer, size);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
675 Py_END_ALLOW_THREADS
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
676 if (size < 0)
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
677 return mac_error();
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
678 return PyInt_FromLong((long)size);
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
679 }
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
680
4468
600f5b8a16cb Malloc debugging now flagged with USE_MALLOC_DEBUG
Jack Jansen <jack.jansen@cwi.nl>
parents: 4414
diff changeset
681 #ifdef USE_MALLOC_DEBUG
14205
3ae185b8ff03 Added a prototype for mstats().
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
682 void *mstats(char *);
3ae185b8ff03 Added a prototype for mstats().
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
683
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
684 static PyObject *
2179
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
685 mac_mstats(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
686 PyObject*self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
687 PyObject *args;
2179
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
688 {
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
689 mstats("python");
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
690 Py_INCREF(Py_None);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
691 return Py_None;
2179
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
692 }
5141
a4c8b8871376 Comments around identifier after #endif
Jack Jansen <jack.jansen@cwi.nl>
parents: 5079
diff changeset
693 #endif /* USE_MALLOC_DEBUG */
2179
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
694
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
695 static struct PyMethodDef mac_methods[] = {
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
696 {"chdir", mac_chdir, 1},
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
697 {"close", mac_close, 1},
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
698 #ifdef WEHAVE_DUP
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
699 {"dup", mac_dup, 1},
1821
40594f80ab3c Intermediate version of changes after porting to MPW 3.2
Guido van Rossum <guido@python.org>
parents: 1808
diff changeset
700 #endif
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
701 #ifdef WEHAVE_FDOPEN
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
702 {"fdopen", mac_fdopen, 1},
2032
609bfb8ae7f5 Ported to MetroWerks, which misses file-descriptor like functionality.
Jack Jansen <jack.jansen@cwi.nl>
parents: 1822
diff changeset
703 #endif
7434
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
704 #ifdef WEHAVE_FSTAT
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
705 {"fstat", mac_fstat, 1},
7434
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
706 #endif
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15835
diff changeset
707 #if TARGET_API_MAC_OS8
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
708 {"getbootvol", mac_getbootvol, 1}, /* non-standard */
12836
3fe304050434 Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12686
diff changeset
709 #endif
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
710 {"getcwd", mac_getcwd, 1},
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
711 {"listdir", mac_listdir, 1},
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
712 {"lseek", mac_lseek, 1},
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
713 {"mkdir", mac_mkdir, 1},
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
714 {"open", mac_open, 1},
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
715 {"read", mac_read, 1},
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
716 {"rename", mac_rename, 1},
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
717 {"rmdir", mac_rmdir, 1},
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
718 {"stat", mac_stat, 1},
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15835
diff changeset
719 #if TARGET_API_MAC_OS8
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
720 {"xstat", mac_xstat, 1},
12836
3fe304050434 Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12686
diff changeset
721 #endif
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
722 {"sync", mac_sync, 1},
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
723 {"remove", mac_unlink, 1},
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
724 {"unlink", mac_unlink, 1},
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
725 {"write", mac_write, 1},
4468
600f5b8a16cb Malloc debugging now flagged with USE_MALLOC_DEBUG
Jack Jansen <jack.jansen@cwi.nl>
parents: 4414
diff changeset
726 #ifdef USE_MALLOC_DEBUG
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
727 {"mstats", mac_mstats, 1},
2179
8da03decef59 More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents: 2091
diff changeset
728 #endif
1620
8454579ab52f As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents: 1522
diff changeset
729
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
730 {NULL, NULL} /* Sentinel */
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
731 };
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
732
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
733 static int
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
734 ins(PyObject *d, char *symbol, long value)
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
735 {
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
736 PyObject* v = PyInt_FromLong(value);
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
737 if (!v || PyDict_SetItemString(d, symbol, v) < 0)
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
738 return -1; /* triggers fatal error */
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
739
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
740 Py_DECREF(v);
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
741 return 0;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
742 }
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
743
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
744 static int
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
745 all_ins(PyObject *d)
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
746 {
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
747 #ifdef F_OK
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
748 if (ins(d, "F_OK", (long)F_OK)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
749 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
750 #ifdef R_OK
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
751 if (ins(d, "R_OK", (long)R_OK)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
752 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
753 #ifdef W_OK
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
754 if (ins(d, "W_OK", (long)W_OK)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
755 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
756 #ifdef X_OK
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
757 if (ins(d, "X_OK", (long)X_OK)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
758 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
759 #ifdef NGROUPS_MAX
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
760 if (ins(d, "NGROUPS_MAX", (long)NGROUPS_MAX)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
761 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
762 #ifdef TMP_MAX
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
763 if (ins(d, "TMP_MAX", (long)TMP_MAX)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
764 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
765 #ifdef WNOHANG
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
766 if (ins(d, "WNOHANG", (long)WNOHANG)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
767 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
768 #ifdef O_RDONLY
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
769 if (ins(d, "O_RDONLY", (long)O_RDONLY)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
770 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
771 #ifdef O_WRONLY
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
772 if (ins(d, "O_WRONLY", (long)O_WRONLY)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
773 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
774 #ifdef O_RDWR
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
775 if (ins(d, "O_RDWR", (long)O_RDWR)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
776 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
777 #ifdef O_NDELAY
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
778 if (ins(d, "O_NDELAY", (long)O_NDELAY)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
779 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
780 #ifdef O_NONBLOCK
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
781 if (ins(d, "O_NONBLOCK", (long)O_NONBLOCK)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
782 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
783 #ifdef O_APPEND
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
784 if (ins(d, "O_APPEND", (long)O_APPEND)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
785 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
786 #ifdef O_DSYNC
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
787 if (ins(d, "O_DSYNC", (long)O_DSYNC)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
788 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
789 #ifdef O_RSYNC
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
790 if (ins(d, "O_RSYNC", (long)O_RSYNC)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
791 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
792 #ifdef O_SYNC
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
793 if (ins(d, "O_SYNC", (long)O_SYNC)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
794 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
795 #ifdef O_NOCTTY
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
796 if (ins(d, "O_NOCTTY", (long)O_NOCTTY)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
797 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
798 #ifdef O_CREAT
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
799 if (ins(d, "O_CREAT", (long)O_CREAT)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
800 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
801 #ifdef O_EXCL
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
802 if (ins(d, "O_EXCL", (long)O_EXCL)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
803 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
804 #ifdef O_TRUNC
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
805 if (ins(d, "O_TRUNC", (long)O_TRUNC)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
806 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
807 #ifdef O_BINARY
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
808 if (ins(d, "O_BINARY", (long)O_BINARY)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
809 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
810 #ifdef O_TEXT
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
811 if (ins(d, "O_TEXT", (long)O_TEXT)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
812 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
813
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
814 #ifdef HAVE_SPAWNV
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
815 if (ins(d, "P_WAIT", (long)_P_WAIT)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
816 if (ins(d, "P_NOWAIT", (long)_P_NOWAIT)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
817 if (ins(d, "P_OVERLAY", (long)_OLD_P_OVERLAY)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
818 if (ins(d, "P_NOWAITO", (long)_P_NOWAITO)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
819 if (ins(d, "P_DETACH", (long)_P_DETACH)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
820 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
821
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
822 #if defined(PYOS_OS2)
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
823 if (insertvalues(d)) return -1;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
824 #endif
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
825 return 0;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
826 }
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
827
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
828
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
829 void
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
830 initmac()
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
831 {
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
832 PyObject *m, *d;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
833
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
834 m = Py_InitModule("mac", mac_methods);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
835 d = PyModule_GetDict(m);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
836
18960
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
837 if (all_ins(d))
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
838 return;
9aa5d66cd13d (Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
839
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
840 /* Initialize mac.error exception */
21113
ed3dce17fc79 Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
Jack Jansen <jack.jansen@cwi.nl>
parents: 20896
diff changeset
841 PyDict_SetItemString(d, "error", PyExc_OSError);
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
842
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
843 PyStructSequence_InitType(&StatResultType, &stat_result_desc);
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
844 PyDict_SetItemString(d, "stat_result", (PyObject*) &StatResultType);
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
845
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
846 #if TARGET_API_MAC_OS8
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
847 PyStructSequence_InitType(&XStatResultType, &xstat_result_desc);
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
848 PyDict_SetItemString(d, "xstat_result", (PyObject*) &XStatResultType);
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 19181
diff changeset
849 #endif
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
850 }