Mercurial > cpython-lru_cache-weakref
annotate Mac/Modules/macmodule.c @ 25135:0f0016632be4 legacy-trunk
_formatparam(), set_param(): RFC 2231 encoding support by Oleg
Broytmann in SF patch #600096. Specifically, the former function now
encodes the triplets, while the latter adds optional charset and
language arguments.
| author | Barry Warsaw <barry@python.org> |
|---|---|
| date | Fri, 06 Sep 2002 03:55:04 +0000 |
| parents | 4f9d5ea4f37d |
| children | 74d1ad61f843 |
| rev | line source |
|---|---|
| 1495 | 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 | 3 The Netherlands. |
| 1495 | 4 |
| 5 All Rights Reserved | |
| 6 | |
| 7 Permission to use, copy, modify, and distribute this software and its | |
| 8 documentation for any purpose and without fee is hereby granted, | |
| 9 provided that the above copyright notice appear in all copies and that | |
| 10 both that copyright notice and this permission notice appear in | |
| 11 supporting documentation, and that the names of Stichting Mathematisch | |
| 12 Centrum or CWI not be used in advertising or publicity pertaining to | |
| 13 distribution of the software without specific, written prior permission. | |
| 14 | |
| 15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO | |
| 16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
| 17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE | |
| 18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
| 19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
| 20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | |
| 21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
| 22 | |
| 23 ******************************************************************/ | |
| 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 | 26 |
| 5071 | 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 | 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 | 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 |
| 3394 | 49 #include <sys/types.h> |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
50 #include <sys/stat.h> |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
51 #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
|
52 #if TARGET_API_MAC_OS8 |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
53 #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
|
54 #endif |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
55 #endif /* USE_GUSI */ |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
56 |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
57 #ifdef USE_GUSI2 |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
58 #include <unistd.h> |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
59 #include <fcntl.h> |
| 3394 | 60 #else |
|
12686
bc96c912dce8
Fixed to work again without USE_GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
12284
diff
changeset
|
61 #define mode_t int |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
62 #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
|
63 #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
|
64 #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
|
65 #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
|
66 #endif |
|
2032
609bfb8ae7f5
Ported to MetroWerks, which misses file-descriptor like functionality.
Jack Jansen <jack.jansen@cwi.nl>
parents:
1822
diff
changeset
|
67 #endif |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
68 |
| 3400 | 69 /* Optional routines, for some compiler/runtime combinations */ |
| 70 #if defined(USE_GUSI) || !defined(__MWERKS__) | |
| 71 #define WEHAVE_FDOPEN | |
| 72 #endif | |
| 73 #if defined(MPW) || defined(USE_GUSI) | |
| 74 #define WEHAVE_DUP | |
| 75 #endif | |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
76 #if defined(USE_GUSI) |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
77 #define WEHAVE_FSTAT |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
78 #endif |
|
2222
bbb56dc3b526
Make malloc stats routine available under MetroWerks
Jack Jansen <jack.jansen@cwi.nl>
parents:
2179
diff
changeset
|
79 |
|
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
|
80 #include "macdefs.h" |
| 3394 | 81 #ifdef USE_GUSI |
| 82 #include <dirent.h> | |
| 83 #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
|
84 #include "dirent.h" |
| 3394 | 85 #endif |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
86 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
87 #ifndef MAXPATHLEN |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
88 #define MAXPATHLEN 1024 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
89 #endif |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
90 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
91 /* 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
|
92 |
| 3400 | 93 #ifndef USE_GUSI |
| 94 | |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 int sync(void); |
| 3400 | 102 |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
103 int unlink(const char *); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
104 |
| 3400 | 105 #endif /* USE_GUSI */ |
| 106 | |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
107 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
|
108 char *getbootvol(void); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
109 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
110 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
111 /* 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
|
112 |
| 5071 | 113 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
114 mac_error() |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
115 { |
|
21113
ed3dce17fc79
Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
Jack Jansen <jack.jansen@cwi.nl>
parents:
20896
diff
changeset
|
116 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
|
117 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
118 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
119 /* MAC generic methods */ |
| 1495 | 120 |
| 5071 | 121 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
122 mac_1str(args, func) |
| 5071 | 123 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
|
124 int (*func)(const char *); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
125 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
126 char *path1; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
127 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
128 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
|
129 return NULL; |
| 5071 | 130 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
131 res = (*func)(path1); |
| 5071 | 132 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
133 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
134 return mac_error(); |
| 5071 | 135 Py_INCREF(Py_None); |
| 136 return Py_None; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
137 } |
| 1495 | 138 |
| 5071 | 139 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
140 mac_2str(args, func) |
| 5071 | 141 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
|
142 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
|
143 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
144 char *path1, *path2; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
145 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
146 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
|
147 return NULL; |
| 5071 | 148 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
149 res = (*func)(path1, path2); |
| 5071 | 150 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
151 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
152 return mac_error(); |
| 5071 | 153 Py_INCREF(Py_None); |
| 154 return Py_None; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
155 } |
| 1495 | 156 |
| 5071 | 157 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
158 mac_strint(args, func) |
| 5071 | 159 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
|
160 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
|
161 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
162 char *path; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
163 int i; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
164 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
165 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
|
166 return NULL; |
| 5071 | 167 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
168 res = (*func)(path, i); |
| 5071 | 169 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
170 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
171 return mac_error(); |
| 5071 | 172 Py_INCREF(Py_None); |
| 173 return Py_None; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
174 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
175 |
| 5071 | 176 static PyObject * |
| 1495 | 177 mac_chdir(self, args) |
| 5071 | 178 PyObject *self; |
| 179 PyObject *args; | |
| 1495 | 180 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
181 return mac_1str(args, chdir); |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
182 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
183 |
| 5071 | 184 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
185 mac_close(self, args) |
| 5071 | 186 PyObject *self; |
| 187 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
188 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
189 int fd, res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
190 if (!PyArg_ParseTuple(args, "i", &fd)) |
| 1495 | 191 return NULL; |
| 5071 | 192 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
193 res = close(fd); |
| 5071 | 194 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
195 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
196 return mac_error(); |
| 5071 | 197 Py_INCREF(Py_None); |
| 198 return Py_None; | |
| 1495 | 199 } |
| 200 | |
| 3400 | 201 #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
|
202 |
| 5071 | 203 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
204 mac_dup(self, args) |
| 5071 | 205 PyObject *self; |
| 206 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
207 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
208 int fd; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
209 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
|
210 return NULL; |
| 5071 | 211 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
212 fd = dup(fd); |
| 5071 | 213 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
214 if (fd < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
215 return mac_error(); |
| 5071 | 216 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
|
217 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
218 |
| 3400 | 219 #endif |
|
1821
40594f80ab3c
Intermediate version of changes after porting to MPW 3.2
Guido van Rossum <guido@python.org>
parents:
1808
diff
changeset
|
220 |
| 3400 | 221 #ifdef WEHAVE_FDOPEN |
| 5071 | 222 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
223 mac_fdopen(self, args) |
| 5071 | 224 PyObject *self; |
| 225 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
226 { |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
227 extern int fclose(FILE *); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
228 int fd; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
229 char *mode; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
230 FILE *fp; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
231 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
|
232 return NULL; |
| 5071 | 233 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
234 fp = fdopen(fd, mode); |
| 5071 | 235 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
236 if (fp == NULL) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
237 return mac_error(); |
| 5071 | 238 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
|
239 } |
|
2032
609bfb8ae7f5
Ported to MetroWerks, which misses file-descriptor like functionality.
Jack Jansen <jack.jansen@cwi.nl>
parents:
1822
diff
changeset
|
240 #endif |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
241 |
|
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
|
242 #if TARGET_API_MAC_OS8 |
| 5071 | 243 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
244 mac_getbootvol(self, args) |
| 5071 | 245 PyObject *self; |
| 246 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
247 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
248 char *res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
249 if (!PyArg_ParseTuple(args, "")) |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
250 return NULL; |
| 5071 | 251 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
252 res = getbootvol(); |
| 5071 | 253 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
254 if (res == NULL) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
255 return mac_error(); |
| 5071 | 256 return PyString_FromString(res); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
257 } |
|
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
|
258 #endif |
| 1495 | 259 |
| 5071 | 260 static PyObject * |
| 1495 | 261 mac_getcwd(self, args) |
| 5071 | 262 PyObject *self; |
| 263 PyObject *args; | |
| 1495 | 264 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
265 char path[MAXPATHLEN]; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
266 char *res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
267 if (!PyArg_ParseTuple(args, "")) |
| 1495 | 268 return NULL; |
| 5071 | 269 Py_BEGIN_ALLOW_THREADS |
| 3400 | 270 #ifdef USE_GUSI |
| 271 res = getcwd(path, sizeof path); | |
| 272 #else | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
273 res = getwd(path); |
| 3400 | 274 #endif |
| 5071 | 275 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
276 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
|
277 return mac_error(); |
| 1495 | 278 } |
| 5071 | 279 return PyString_FromString(res); |
| 1495 | 280 } |
| 281 | |
| 5071 | 282 static PyObject * |
| 1495 | 283 mac_listdir(self, args) |
| 5071 | 284 PyObject *self; |
| 285 PyObject *args; | |
| 1495 | 286 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
287 char *name; |
| 5071 | 288 PyObject *d, *v; |
| 1495 | 289 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
|
290 struct dirent *ep; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
291 if (!PyArg_ParseTuple(args, "s", &name)) |
| 1495 | 292 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
|
293 #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
|
294 /* 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
|
295 ** 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
|
296 */ |
|
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
|
297 { |
|
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
|
298 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
|
299 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
|
300 |
|
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
|
301 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
|
302 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
|
303 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
|
304 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
|
305 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
|
306 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
|
307 } |
|
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
|
308 } |
|
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 #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
|
310 |
| 5071 | 311 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
312 if ((dirp = opendir(name)) == NULL) { |
| 5071 | 313 Py_BLOCK_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
314 return mac_error(); |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
315 } |
| 5071 | 316 if ((d = PyList_New(0)) == NULL) { |
| 1495 | 317 closedir(dirp); |
| 5071 | 318 Py_BLOCK_THREADS |
| 1495 | 319 return NULL; |
| 320 } | |
| 321 while ((ep = readdir(dirp)) != NULL) { | |
| 5071 | 322 v = PyString_FromString(ep->d_name); |
| 1495 | 323 if (v == NULL) { |
| 5071 | 324 Py_DECREF(d); |
| 1495 | 325 d = NULL; |
| 326 break; | |
| 327 } | |
| 5071 | 328 if (PyList_Append(d, v) != 0) { |
| 329 Py_DECREF(v); | |
| 330 Py_DECREF(d); | |
| 1495 | 331 d = NULL; |
| 332 break; | |
| 333 } | |
| 5071 | 334 Py_DECREF(v); |
| 1495 | 335 } |
| 336 closedir(dirp); | |
| 5071 | 337 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
338 |
| 1495 | 339 return d; |
| 340 } | |
| 341 | |
| 5071 | 342 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
343 mac_lseek(self, args) |
| 5071 | 344 PyObject *self; |
| 345 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
346 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
347 int fd; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
348 int where; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
349 int how; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
350 long res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
351 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
|
352 return NULL; |
| 5071 | 353 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
354 res = lseek(fd, (long)where, how); |
| 5071 | 355 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
356 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
357 return mac_error(); |
| 5071 | 358 return PyInt_FromLong(res); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
359 } |
| 3394 | 360 |
| 5071 | 361 static PyObject * |
| 1495 | 362 mac_mkdir(self, args) |
| 5071 | 363 PyObject *self; |
| 364 PyObject *args; | |
| 1495 | 365 { |
|
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
|
366 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
|
367 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
|
368 int mode = 0777; /* Unused */ |
| 5071 | 369 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
|
370 return NULL; |
| 5071 | 371 Py_BEGIN_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
|
372 res = mkdir(path, mode); |
| 5071 | 373 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
|
374 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
|
375 return mac_error(); |
| 5071 | 376 Py_INCREF(Py_None); |
| 377 return Py_None; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
378 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
379 |
| 5071 | 380 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
381 mac_open(self, args) |
| 5071 | 382 PyObject *self; |
| 383 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
384 { |
| 1495 | 385 char *path; |
| 386 int mode; | |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
387 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
|
388 int fd; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
389 if (!PyArg_ParseTuple(args, "si|i", &path, &mode, &perm)) |
| 1495 | 390 return NULL; |
| 5071 | 391 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
392 fd = open(path, mode); |
| 5071 | 393 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
394 if (fd < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
395 return mac_error(); |
| 5071 | 396 return PyInt_FromLong((long)fd); |
| 1495 | 397 } |
| 398 | |
| 5071 | 399 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
400 mac_read(self, args) |
| 5071 | 401 PyObject *self; |
| 402 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
403 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
404 int fd, size; |
| 5071 | 405 PyObject *buffer; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
406 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
|
407 return NULL; |
| 5071 | 408 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
|
409 if (buffer == NULL) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
410 return NULL; |
| 5071 | 411 Py_BEGIN_ALLOW_THREADS |
| 412 size = read(fd, PyString_AsString(buffer), size); | |
| 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 (size < 0) { |
| 5071 | 415 Py_DECREF(buffer); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
416 return mac_error(); |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
417 } |
| 5071 | 418 _PyString_Resize(&buffer, size); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
419 return buffer; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
420 } |
| 1495 | 421 |
| 5071 | 422 static PyObject * |
| 1495 | 423 mac_rename(self, args) |
| 5071 | 424 PyObject *self; |
| 425 PyObject *args; | |
| 1495 | 426 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
427 return mac_2str(args, rename); |
| 1495 | 428 } |
| 429 | |
| 5071 | 430 static PyObject * |
| 1495 | 431 mac_rmdir(self, args) |
| 5071 | 432 PyObject *self; |
| 433 PyObject *args; | |
| 1495 | 434 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
435 return mac_1str(args, rmdir); |
| 1495 | 436 } |
| 437 | |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
438 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
|
439 "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
|
440 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
|
441 (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
|
442 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
|
443 \n\ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
444 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
|
445 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
446 #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
|
447 { "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
|
448 { "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
|
449 { "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
|
450 { "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
|
451 { "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
|
452 { "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
|
453 { "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
|
454 { "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
|
455 { "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
|
456 { "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
|
457 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
458 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
459 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
460 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
|
461 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
|
462 {0} |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
463 }; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
464 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
465 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
|
466 "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
|
467 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
|
468 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
|
469 10 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
470 }; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
471 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
472 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
|
473 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
474 #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
|
475 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
|
476 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
|
477 { "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
|
478 { "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
|
479 { "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
|
480 {0} |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
481 }; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
482 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
483 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
|
484 "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
|
485 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
|
486 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
|
487 13 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
488 }; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
489 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
490 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
|
491 #endif |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
492 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
493 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
|
494 _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
|
495 { |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
496 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
|
497 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
498 #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
|
499 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
|
500 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
501 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
|
502 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
|
503 else |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
504 #endif |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
505 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
|
506 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
|
507 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
|
508 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
|
509 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
|
510 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
|
511 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
|
512 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
|
513 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
|
514 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
|
515 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
|
516 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
|
517 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
|
518 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
|
519 #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
|
520 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
|
521 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
|
522 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
|
523 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
|
524 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
|
525 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
|
526 4)); |
|
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, 12, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
528 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
|
529 4)); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
530 } |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
531 #endif |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
532 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
533 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
|
534 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
|
535 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
|
536 } |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
537 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
538 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
|
539 } |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
540 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
541 |
| 5071 | 542 static PyObject * |
| 1495 | 543 mac_stat(self, args) |
| 5071 | 544 PyObject *self; |
| 545 PyObject *args; | |
| 1495 | 546 { |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
547 struct stat st; |
| 1495 | 548 char *path; |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
549 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
550 if (!PyArg_ParseTuple(args, "s", &path)) |
| 1495 | 551 return NULL; |
| 5071 | 552 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
|
553 res = stat(path, &st); |
| 5071 | 554 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
555 if (res != 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
556 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
|
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 _pystat_from_struct_stat(st, NULL); |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
559 } |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
560 |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
561 #ifdef WEHAVE_FSTAT |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
562 static PyObject * |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
563 mac_fstat(self, args) |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
564 PyObject *self; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
565 PyObject *args; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
566 { |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
567 struct stat st; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
568 long fd; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
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, "l", &fd)) |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
571 return NULL; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
572 Py_BEGIN_ALLOW_THREADS |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
573 res = fstat((int)fd, &st); |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
574 Py_END_ALLOW_THREADS |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
575 if (res != 0) |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
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); |
| 1495 | 579 } |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
580 #endif /* WEHAVE_FSTAT */ |
| 1495 | 581 |
|
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
|
582 #if TARGET_API_MAC_OS8 |
| 5071 | 583 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
|
584 mac_xstat(self, args) |
| 5071 | 585 PyObject *self; |
| 586 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
|
587 { |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
588 struct macstat mst; |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
589 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
|
590 char *path; |
|
7d1ecec25c06
add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents:
2722
diff
changeset
|
591 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
592 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
|
593 return NULL; |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
594 /* |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
595 ** 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
|
596 ** 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
|
597 ** the former. |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
598 */ |
| 5071 | 599 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
|
600 res = macstat(path, &mst); |
| 5071 | 601 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
|
602 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
|
603 return mac_error(); |
| 5071 | 604 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
|
605 res = stat(path, &st); |
| 5071 | 606 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
|
607 if (res != 0) |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
608 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
|
609 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
610 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
|
611 } |
|
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
|
612 #endif |
|
2929
7d1ecec25c06
add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents:
2722
diff
changeset
|
613 |
| 5071 | 614 static PyObject * |
| 1495 | 615 mac_sync(self, args) |
| 5071 | 616 PyObject *self; |
| 617 PyObject *args; | |
| 1495 | 618 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
619 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
620 if (!PyArg_ParseTuple(args, "")) |
| 1495 | 621 return NULL; |
| 5071 | 622 Py_BEGIN_ALLOW_THREADS |
|
22430
7002f24f818f
Solve sync() signature conflict differently: manually return 0 if
Jack Jansen <jack.jansen@cwi.nl>
parents:
21313
diff
changeset
|
623 #ifdef USE_GUSI2 |
|
7002f24f818f
Solve sync() signature conflict differently: manually return 0 if
Jack Jansen <jack.jansen@cwi.nl>
parents:
21313
diff
changeset
|
624 sync(); |
|
7002f24f818f
Solve sync() signature conflict differently: manually return 0 if
Jack Jansen <jack.jansen@cwi.nl>
parents:
21313
diff
changeset
|
625 res = 0; |
|
7002f24f818f
Solve sync() signature conflict differently: manually return 0 if
Jack Jansen <jack.jansen@cwi.nl>
parents:
21313
diff
changeset
|
626 #else |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
627 res = sync(); |
|
22430
7002f24f818f
Solve sync() signature conflict differently: manually return 0 if
Jack Jansen <jack.jansen@cwi.nl>
parents:
21313
diff
changeset
|
628 #endif |
| 5071 | 629 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
630 if (res != 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
631 return mac_error(); |
| 5071 | 632 Py_INCREF(Py_None); |
| 633 return Py_None; | |
| 1495 | 634 } |
| 635 | |
| 5071 | 636 static PyObject * |
| 1495 | 637 mac_unlink(self, args) |
| 5071 | 638 PyObject *self; |
| 639 PyObject *args; | |
| 1495 | 640 { |
|
1822
76d0f2b3b9ee
Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents:
1821
diff
changeset
|
641 return mac_1str(args, (int (*)(const char *))unlink); |
| 1495 | 642 } |
| 643 | |
| 5071 | 644 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
645 mac_write(self, args) |
| 5071 | 646 PyObject *self; |
| 647 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
648 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
649 int fd, size; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
650 char *buffer; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
651 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
|
652 return NULL; |
| 5071 | 653 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
654 size = write(fd, buffer, size); |
| 5071 | 655 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
656 if (size < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
657 return mac_error(); |
| 5071 | 658 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
|
659 } |
| 1495 | 660 |
|
4468
600f5b8a16cb
Malloc debugging now flagged with USE_MALLOC_DEBUG
Jack Jansen <jack.jansen@cwi.nl>
parents:
4414
diff
changeset
|
661 #ifdef USE_MALLOC_DEBUG |
|
14205
3ae185b8ff03
Added a prototype for mstats().
Jack Jansen <jack.jansen@cwi.nl>
parents:
13608
diff
changeset
|
662 void *mstats(char *); |
|
3ae185b8ff03
Added a prototype for mstats().
Jack Jansen <jack.jansen@cwi.nl>
parents:
13608
diff
changeset
|
663 |
| 5071 | 664 static PyObject * |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
665 mac_mstats(self, args) |
| 5071 | 666 PyObject*self; |
| 667 PyObject *args; | |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
668 { |
|
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
669 mstats("python"); |
| 5071 | 670 Py_INCREF(Py_None); |
| 671 return Py_None; | |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
672 } |
|
5141
a4c8b8871376
Comments around identifier after #endif
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
673 #endif /* USE_MALLOC_DEBUG */ |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
674 |
| 5071 | 675 static struct PyMethodDef mac_methods[] = { |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
676 {"chdir", mac_chdir, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
677 {"close", mac_close, 1}, |
| 3400 | 678 #ifdef WEHAVE_DUP |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
679 {"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
|
680 #endif |
| 3400 | 681 #ifdef WEHAVE_FDOPEN |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
682 {"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
|
683 #endif |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
684 #ifdef WEHAVE_FSTAT |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
685 {"fstat", mac_fstat, 1}, |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
686 #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
|
687 #if TARGET_API_MAC_OS8 |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
688 {"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
|
689 #endif |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
690 {"getcwd", mac_getcwd, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
691 {"listdir", mac_listdir, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
692 {"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
|
693 {"mkdir", mac_mkdir, 1}, |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
694 {"open", mac_open, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
695 {"read", mac_read, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
696 {"rename", mac_rename, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
697 {"rmdir", mac_rmdir, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
698 {"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
|
699 #if TARGET_API_MAC_OS8 |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
700 {"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
|
701 #endif |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
702 {"sync", mac_sync, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
703 {"remove", mac_unlink, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
704 {"unlink", mac_unlink, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
705 {"write", mac_write, 1}, |
|
4468
600f5b8a16cb
Malloc debugging now flagged with USE_MALLOC_DEBUG
Jack Jansen <jack.jansen@cwi.nl>
parents:
4414
diff
changeset
|
706 #ifdef USE_MALLOC_DEBUG |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
707 {"mstats", mac_mstats, 1}, |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
708 #endif |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
709 |
| 1495 | 710 {NULL, NULL} /* Sentinel */ |
| 711 }; | |
| 712 | |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
713 static int |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
714 ins(PyObject *d, char *symbol, long value) |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
715 { |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
716 PyObject* v = PyInt_FromLong(value); |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
717 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
|
718 return -1; /* triggers fatal error */ |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
719 |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
720 Py_DECREF(v); |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
721 return 0; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
722 } |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
723 |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
724 static int |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
725 all_ins(PyObject *d) |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
726 { |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
727 #ifdef F_OK |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
728 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
|
729 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
730 #ifdef R_OK |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
731 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
|
732 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
733 #ifdef W_OK |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
734 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
|
735 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
736 #ifdef X_OK |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
737 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
|
738 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
739 #ifdef NGROUPS_MAX |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
740 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
|
741 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
742 #ifdef TMP_MAX |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
743 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
|
744 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
745 #ifdef WNOHANG |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
746 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
|
747 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
748 #ifdef O_RDONLY |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
749 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
|
750 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
751 #ifdef O_WRONLY |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
752 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
|
753 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
754 #ifdef O_RDWR |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
755 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
|
756 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
757 #ifdef O_NDELAY |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
758 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
|
759 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
760 #ifdef O_NONBLOCK |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
761 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
|
762 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
763 #ifdef O_APPEND |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
764 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
|
765 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
766 #ifdef O_DSYNC |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
767 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
|
768 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
769 #ifdef O_RSYNC |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
770 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
|
771 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
772 #ifdef O_SYNC |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
773 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
|
774 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
775 #ifdef O_NOCTTY |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
776 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
|
777 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
778 #ifdef O_CREAT |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
779 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
|
780 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
781 #ifdef O_EXCL |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
782 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
|
783 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
784 #ifdef O_TRUNC |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
785 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
|
786 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
787 #ifdef O_BINARY |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
788 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
|
789 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
790 #ifdef O_TEXT |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
791 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
|
792 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
793 |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
794 #ifdef HAVE_SPAWNV |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
795 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
|
796 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
|
797 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
|
798 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
|
799 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
|
800 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
801 |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
802 #if defined(PYOS_OS2) |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
803 if (insertvalues(d)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
804 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
805 return 0; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
806 } |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
807 |
| 1495 | 808 |
| 809 void | |
| 810 initmac() | |
| 811 { | |
| 5071 | 812 PyObject *m, *d; |
| 1495 | 813 |
| 5071 | 814 m = Py_InitModule("mac", mac_methods); |
| 815 d = PyModule_GetDict(m); | |
| 1495 | 816 |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
817 if (all_ins(d)) |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
818 return; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
819 |
| 1495 | 820 /* 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
|
821 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
|
822 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
823 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
|
824 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
|
825 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
826 #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
|
827 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
|
828 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
|
829 #endif |
| 1495 | 830 } |
