Bump version number to 2.4.2 to pick up the latest minor bug fixes.
[python/dscho.git] / Mac / Modules / macmodule.c
blob8b3bcc53148eaf4d5c5bdee1bfe76a5847c0b71b
1 /***********************************************************
2 Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam,
3 The Netherlands.
5 All Rights Reserved
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.
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.
23 ******************************************************************/
25 /* Mac module implementation */
27 #include "Python.h"
28 #include "structseq.h"
29 #include "ceval.h"
31 #include <stdio.h>
32 #include <string.h>
33 #include <errno.h>
35 #if TARGET_API_MAC_OS8
36 /* Skip for Carbon */
37 #include "macstat.h"
38 #endif
40 #ifdef USE_GUSI
41 /* Remove defines from macstat.h */
42 #undef S_IFMT
43 #undef S_IFDIR
44 #undef S_IFREG
45 #undef S_IREAD
46 #undef S_IWRITE
47 #undef S_IEXEC
49 #include <sys/types.h>
50 #include <sys/stat.h>
51 #else /* USE_GUSI */
52 #if TARGET_API_MAC_OS8
53 #define stat macstat
54 #endif
55 #endif /* USE_GUSI */
57 #ifdef USE_GUSI2
58 #include <unistd.h>
59 #include <fcntl.h>
60 #else
61 #define mode_t int
62 #include <fcntl.h>
63 #ifdef _POSIX
64 #include <unistd.h>
65 #include <stat.h>
66 #endif
67 #endif
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
76 #if defined(USE_GUSI)
77 #define WEHAVE_FSTAT
78 #endif
80 #include "macdefs.h"
81 #ifdef USE_GUSI
82 #include <dirent.h>
83 #else
84 #include "dirent.h"
85 #endif
87 #ifndef MAXPATHLEN
88 #define MAXPATHLEN 1024
89 #endif
91 /* Prototypes for Unix simulation on Mac */
93 #ifndef USE_GUSI
95 int chdir(const char *path);
96 int mkdir(const char *path, int mode);
97 DIR * opendir(char *);
98 void closedir(DIR *);
99 struct dirent * readdir(DIR *);
100 int rmdir(const char *path);
101 int sync(void);
103 int unlink(const char *);
105 #endif /* USE_GUSI */
107 char *getwd(char *);
108 char *getbootvol(void);
111 /* Set a MAC-specific error from errno, and return NULL */
113 static PyObject *
114 mac_error()
116 return PyErr_SetFromErrno(PyExc_OSError);
119 /* MAC generic methods */
121 static PyObject *
122 mac_1str(args, func)
123 PyObject *args;
124 int (*func)(const char *);
126 char *path1;
127 int res;
128 if (!PyArg_ParseTuple(args, "s", &path1))
129 return NULL;
130 Py_BEGIN_ALLOW_THREADS
131 res = (*func)(path1);
132 Py_END_ALLOW_THREADS
133 if (res < 0)
134 return mac_error();
135 Py_INCREF(Py_None);
136 return Py_None;
139 static PyObject *
140 mac_2str(args, func)
141 PyObject *args;
142 int (*func)(const char *, const char *);
144 char *path1, *path2;
145 int res;
146 if (!PyArg_ParseTuple(args, "ss", &path1, &path2))
147 return NULL;
148 Py_BEGIN_ALLOW_THREADS
149 res = (*func)(path1, path2);
150 Py_END_ALLOW_THREADS
151 if (res < 0)
152 return mac_error();
153 Py_INCREF(Py_None);
154 return Py_None;
157 static PyObject *
158 mac_strint(args, func)
159 PyObject *args;
160 int (*func)(const char *, int);
162 char *path;
163 int i;
164 int res;
165 if (!PyArg_ParseTuple(args, "si", &path, &i))
166 return NULL;
167 Py_BEGIN_ALLOW_THREADS
168 res = (*func)(path, i);
169 Py_END_ALLOW_THREADS
170 if (res < 0)
171 return mac_error();
172 Py_INCREF(Py_None);
173 return Py_None;
176 static PyObject *
177 mac_chdir(self, args)
178 PyObject *self;
179 PyObject *args;
181 return mac_1str(args, chdir);
184 static PyObject *
185 mac_close(self, args)
186 PyObject *self;
187 PyObject *args;
189 int fd, res;
190 if (!PyArg_ParseTuple(args, "i", &fd))
191 return NULL;
192 Py_BEGIN_ALLOW_THREADS
193 res = close(fd);
194 Py_END_ALLOW_THREADS
195 if (res < 0)
196 return mac_error();
197 Py_INCREF(Py_None);
198 return Py_None;
201 #ifdef WEHAVE_DUP
203 static PyObject *
204 mac_dup(self, args)
205 PyObject *self;
206 PyObject *args;
208 int fd;
209 if (!PyArg_ParseTuple(args, "i", &fd))
210 return NULL;
211 Py_BEGIN_ALLOW_THREADS
212 fd = dup(fd);
213 Py_END_ALLOW_THREADS
214 if (fd < 0)
215 return mac_error();
216 return PyInt_FromLong((long)fd);
219 #endif
221 #ifdef WEHAVE_FDOPEN
222 static PyObject *
223 mac_fdopen(self, args)
224 PyObject *self;
225 PyObject *args;
227 extern int fclose(FILE *);
228 int fd;
229 char *mode;
230 FILE *fp;
231 if (!PyArg_ParseTuple(args, "is", &fd, &mode))
232 return NULL;
233 Py_BEGIN_ALLOW_THREADS
234 fp = fdopen(fd, mode);
235 Py_END_ALLOW_THREADS
236 if (fp == NULL)
237 return mac_error();
238 return PyFile_FromFile(fp, "(fdopen)", mode, fclose);
240 #endif
242 #if TARGET_API_MAC_OS8
243 static PyObject *
244 mac_getbootvol(self, args)
245 PyObject *self;
246 PyObject *args;
248 char *res;
249 if (!PyArg_ParseTuple(args, ""))
250 return NULL;
251 Py_BEGIN_ALLOW_THREADS
252 res = getbootvol();
253 Py_END_ALLOW_THREADS
254 if (res == NULL)
255 return mac_error();
256 return PyString_FromString(res);
258 #endif
260 static PyObject *
261 mac_getcwd(self, args)
262 PyObject *self;
263 PyObject *args;
265 char path[MAXPATHLEN];
266 char *res;
267 if (!PyArg_ParseTuple(args, ""))
268 return NULL;
269 Py_BEGIN_ALLOW_THREADS
270 #ifdef USE_GUSI
271 res = getcwd(path, sizeof path);
272 #else
273 res = getwd(path);
274 #endif
275 Py_END_ALLOW_THREADS
276 if (res == NULL) {
277 return mac_error();
279 return PyString_FromString(res);
282 static PyObject *
283 mac_listdir(self, args)
284 PyObject *self;
285 PyObject *args;
287 char *name;
288 PyObject *d, *v;
289 DIR *dirp;
290 struct dirent *ep;
291 if (!PyArg_ParseTuple(args, "s", &name))
292 return NULL;
293 #ifdef USE_GUSI
294 /* Work around a bug in GUSI: if you opendir() a file it will
295 ** actually opendir() the parent directory.
298 struct stat stb;
299 int res;
301 res = stat(name, &stb);
302 if ( res < 0 )
303 return mac_error();
304 if (!S_ISDIR(stb.st_mode) ) {
305 errno = ENOTDIR;
306 return mac_error();
309 #endif
311 Py_BEGIN_ALLOW_THREADS
312 if ((dirp = opendir(name)) == NULL) {
313 Py_BLOCK_THREADS
314 return mac_error();
316 if ((d = PyList_New(0)) == NULL) {
317 closedir(dirp);
318 Py_BLOCK_THREADS
319 return NULL;
321 while ((ep = readdir(dirp)) != NULL) {
322 v = PyString_FromString(ep->d_name);
323 if (v == NULL) {
324 Py_DECREF(d);
325 d = NULL;
326 break;
328 if (PyList_Append(d, v) != 0) {
329 Py_DECREF(v);
330 Py_DECREF(d);
331 d = NULL;
332 break;
334 Py_DECREF(v);
336 closedir(dirp);
337 Py_END_ALLOW_THREADS
339 return d;
342 static PyObject *
343 mac_lseek(self, args)
344 PyObject *self;
345 PyObject *args;
347 int fd;
348 int where;
349 int how;
350 long res;
351 if (!PyArg_ParseTuple(args, "iii", &fd, &where, &how))
352 return NULL;
353 Py_BEGIN_ALLOW_THREADS
354 res = lseek(fd, (long)where, how);
355 Py_END_ALLOW_THREADS
356 if (res < 0)
357 return mac_error();
358 return PyInt_FromLong(res);
361 static PyObject *
362 mac_mkdir(self, args)
363 PyObject *self;
364 PyObject *args;
366 int res;
367 char *path;
368 int mode = 0777; /* Unused */
369 if (!PyArg_ParseTuple(args, "s|i", &path, &mode))
370 return NULL;
371 Py_BEGIN_ALLOW_THREADS
372 res = mkdir(path, mode);
373 Py_END_ALLOW_THREADS
374 if (res < 0)
375 return mac_error();
376 Py_INCREF(Py_None);
377 return Py_None;
380 static PyObject *
381 mac_open(self, args)
382 PyObject *self;
383 PyObject *args;
385 char *path;
386 int mode;
387 int perm; /* Accepted but ignored */
388 int fd;
389 if (!PyArg_ParseTuple(args, "si|i", &path, &mode, &perm))
390 return NULL;
391 Py_BEGIN_ALLOW_THREADS
392 fd = open(path, mode);
393 Py_END_ALLOW_THREADS
394 if (fd < 0)
395 return mac_error();
396 return PyInt_FromLong((long)fd);
399 static PyObject *
400 mac_read(self, args)
401 PyObject *self;
402 PyObject *args;
404 int fd, size;
405 PyObject *buffer;
406 if (!PyArg_ParseTuple(args, "ii", &fd, &size))
407 return NULL;
408 buffer = PyString_FromStringAndSize((char *)NULL, size);
409 if (buffer == NULL)
410 return NULL;
411 Py_BEGIN_ALLOW_THREADS
412 size = read(fd, PyString_AsString(buffer), size);
413 Py_END_ALLOW_THREADS
414 if (size < 0) {
415 Py_DECREF(buffer);
416 return mac_error();
418 _PyString_Resize(&buffer, size);
419 return buffer;
422 static PyObject *
423 mac_rename(self, args)
424 PyObject *self;
425 PyObject *args;
427 return mac_2str(args, rename);
430 static PyObject *
431 mac_rmdir(self, args)
432 PyObject *self;
433 PyObject *args;
435 return mac_1str(args, rmdir);
438 static char stat_result__doc__[] =
439 "stat_result: Result from stat or lstat.\n\n\
440 This object may be accessed either as a tuple of\n\
441 (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)\n\
442 or via the attributes st_mode, st_ino, st_dev, st_nlink, st_uid, and so on.\n\
444 See os.stat for more information.\n";
446 #define COMMON_STAT_RESULT_FIELDS \
447 { "st_mode", "protection bits" }, \
448 { "st_ino", "inode" }, \
449 { "st_dev", "device" }, \
450 { "st_nlink", "number of hard links" }, \
451 { "st_uid", "user ID of owner" }, \
452 { "st_gid", "group ID of owner" }, \
453 { "st_size", "total size, in bytes" }, \
454 { "st_atime", "time of last access" }, \
455 { "st_mtime", "time of last modification" }, \
456 { "st_ctime", "time of last change" },
460 static PyStructSequence_Field stat_result_fields[] = {
461 COMMON_STAT_RESULT_FIELDS
465 static PyStructSequence_Desc stat_result_desc = {
466 "mac.stat_result",
467 stat_result__doc__,
468 stat_result_fields,
472 static PyTypeObject StatResultType;
474 #ifdef TARGET_API_MAC_OS8
475 static PyStructSequence_Field xstat_result_fields[] = {
476 COMMON_STAT_RESULT_FIELDS
477 { "st_rsize" },
478 { "st_creator" },
479 { "st_type "},
483 static PyStructSequence_Desc xstat_result_desc = {
484 "mac.xstat_result",
485 stat_result__doc__,
486 xstat_result_fields,
490 static PyTypeObject XStatResultType;
491 #endif
493 static PyObject *
494 _pystat_from_struct_stat(struct stat st, void* _mst)
496 PyObject *v;
498 #if TARGET_API_MAC_OS8
499 struct macstat *mst;
501 if (_mst != NULL)
502 v = PyStructSequence_New(&XStatResultType);
503 else
504 #endif
505 v = PyStructSequence_New(&StatResultType);
506 PyStructSequence_SET_ITEM(v, 0, PyInt_FromLong((long)st.st_mode));
507 PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long)st.st_ino));
508 PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long)st.st_dev));
509 PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long)st.st_nlink));
510 PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long)st.st_uid));
511 PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long)st.st_gid));
512 PyStructSequence_SET_ITEM(v, 6, PyInt_FromLong((long)st.st_size));
513 PyStructSequence_SET_ITEM(v, 7,
514 PyFloat_FromDouble((double)st.st_atime));
515 PyStructSequence_SET_ITEM(v, 8,
516 PyFloat_FromDouble((double)st.st_mtime));
517 PyStructSequence_SET_ITEM(v, 9,
518 PyFloat_FromDouble((double)st.st_ctime));
519 #if TARGET_API_MAC_OS8
520 if (_mst != NULL) {
521 mst = (struct macstat *) _mst;
522 PyStructSequence_SET_ITEM(v, 10,
523 PyInt_FromLong((long)mst->st_rsize));
524 PyStructSequence_SET_ITEM(v, 11,
525 PyString_FromStringAndSize(mst->st_creator,
526 4));
527 PyStructSequence_SET_ITEM(v, 12,
528 PyString_FromStringAndSize(mst->st_type,
529 4));
531 #endif
533 if (PyErr_Occurred()) {
534 Py_DECREF(v);
535 return NULL;
538 return v;
542 static PyObject *
543 mac_stat(self, args)
544 PyObject *self;
545 PyObject *args;
547 struct stat st;
548 char *path;
549 int res;
550 if (!PyArg_ParseTuple(args, "s", &path))
551 return NULL;
552 Py_BEGIN_ALLOW_THREADS
553 res = stat(path, &st);
554 Py_END_ALLOW_THREADS
555 if (res != 0)
556 return mac_error();
558 return _pystat_from_struct_stat(st, NULL);
561 #ifdef WEHAVE_FSTAT
562 static PyObject *
563 mac_fstat(self, args)
564 PyObject *self;
565 PyObject *args;
567 struct stat st;
568 long fd;
569 int res;
570 if (!PyArg_ParseTuple(args, "l", &fd))
571 return NULL;
572 Py_BEGIN_ALLOW_THREADS
573 res = fstat((int)fd, &st);
574 Py_END_ALLOW_THREADS
575 if (res != 0)
576 return mac_error();
578 return _pystat_from_struct_stat(st, NULL);
580 #endif /* WEHAVE_FSTAT */
582 #if TARGET_API_MAC_OS8
583 static PyObject *
584 mac_xstat(self, args)
585 PyObject *self;
586 PyObject *args;
588 struct macstat mst;
589 struct stat st;
590 char *path;
591 int res;
592 if (!PyArg_ParseTuple(args, "s", &path))
593 return NULL;
595 ** Convoluted: we want stat() and xstat() to agree, so we call both
596 ** stat and macstat, and use the latter only for values not provided by
597 ** the former.
599 Py_BEGIN_ALLOW_THREADS
600 res = macstat(path, &mst);
601 Py_END_ALLOW_THREADS
602 if (res != 0)
603 return mac_error();
604 Py_BEGIN_ALLOW_THREADS
605 res = stat(path, &st);
606 Py_END_ALLOW_THREADS
607 if (res != 0)
608 return mac_error();
610 return _pystat_from_struct_stat(st, (void*) &mst);
612 #endif
614 static PyObject *
615 mac_sync(self, args)
616 PyObject *self;
617 PyObject *args;
619 int res;
620 if (!PyArg_ParseTuple(args, ""))
621 return NULL;
622 Py_BEGIN_ALLOW_THREADS
623 #ifdef USE_GUSI2
624 sync();
625 res = 0;
626 #else
627 res = sync();
628 #endif
629 Py_END_ALLOW_THREADS
630 if (res != 0)
631 return mac_error();
632 Py_INCREF(Py_None);
633 return Py_None;
636 static PyObject *
637 mac_unlink(self, args)
638 PyObject *self;
639 PyObject *args;
641 return mac_1str(args, (int (*)(const char *))unlink);
644 static PyObject *
645 mac_write(self, args)
646 PyObject *self;
647 PyObject *args;
649 int fd, size;
650 char *buffer;
651 if (!PyArg_ParseTuple(args, "is#", &fd, &buffer, &size))
652 return NULL;
653 Py_BEGIN_ALLOW_THREADS
654 size = write(fd, buffer, size);
655 Py_END_ALLOW_THREADS
656 if (size < 0)
657 return mac_error();
658 return PyInt_FromLong((long)size);
661 #ifdef USE_MALLOC_DEBUG
662 void *mstats(char *);
664 static PyObject *
665 mac_mstats(self, args)
666 PyObject*self;
667 PyObject *args;
669 mstats("python");
670 Py_INCREF(Py_None);
671 return Py_None;
673 #endif /* USE_MALLOC_DEBUG */
675 static struct PyMethodDef mac_methods[] = {
676 {"chdir", mac_chdir, 1},
677 {"close", mac_close, 1},
678 #ifdef WEHAVE_DUP
679 {"dup", mac_dup, 1},
680 #endif
681 #ifdef WEHAVE_FDOPEN
682 {"fdopen", mac_fdopen, 1},
683 #endif
684 #ifdef WEHAVE_FSTAT
685 {"fstat", mac_fstat, 1},
686 #endif
687 #if TARGET_API_MAC_OS8
688 {"getbootvol", mac_getbootvol, 1}, /* non-standard */
689 #endif
690 {"getcwd", mac_getcwd, 1},
691 {"listdir", mac_listdir, 1},
692 {"lseek", mac_lseek, 1},
693 {"mkdir", mac_mkdir, 1},
694 {"open", mac_open, 1},
695 {"read", mac_read, 1},
696 {"rename", mac_rename, 1},
697 {"rmdir", mac_rmdir, 1},
698 {"stat", mac_stat, 1},
699 #if TARGET_API_MAC_OS8
700 {"xstat", mac_xstat, 1},
701 #endif
702 {"sync", mac_sync, 1},
703 {"remove", mac_unlink, 1},
704 {"unlink", mac_unlink, 1},
705 {"write", mac_write, 1},
706 #ifdef USE_MALLOC_DEBUG
707 {"mstats", mac_mstats, 1},
708 #endif
710 {NULL, NULL} /* Sentinel */
713 static int
714 ins(PyObject *d, char *symbol, long value)
716 PyObject* v = PyInt_FromLong(value);
717 if (!v || PyDict_SetItemString(d, symbol, v) < 0)
718 return -1; /* triggers fatal error */
720 Py_DECREF(v);
721 return 0;
724 static int
725 all_ins(PyObject *d)
727 #ifdef F_OK
728 if (ins(d, "F_OK", (long)F_OK)) return -1;
729 #endif
730 #ifdef R_OK
731 if (ins(d, "R_OK", (long)R_OK)) return -1;
732 #endif
733 #ifdef W_OK
734 if (ins(d, "W_OK", (long)W_OK)) return -1;
735 #endif
736 #ifdef X_OK
737 if (ins(d, "X_OK", (long)X_OK)) return -1;
738 #endif
739 #ifdef NGROUPS_MAX
740 if (ins(d, "NGROUPS_MAX", (long)NGROUPS_MAX)) return -1;
741 #endif
742 #ifdef TMP_MAX
743 if (ins(d, "TMP_MAX", (long)TMP_MAX)) return -1;
744 #endif
745 #ifdef WNOHANG
746 if (ins(d, "WNOHANG", (long)WNOHANG)) return -1;
747 #endif
748 #ifdef O_RDONLY
749 if (ins(d, "O_RDONLY", (long)O_RDONLY)) return -1;
750 #endif
751 #ifdef O_WRONLY
752 if (ins(d, "O_WRONLY", (long)O_WRONLY)) return -1;
753 #endif
754 #ifdef O_RDWR
755 if (ins(d, "O_RDWR", (long)O_RDWR)) return -1;
756 #endif
757 #ifdef O_NDELAY
758 if (ins(d, "O_NDELAY", (long)O_NDELAY)) return -1;
759 #endif
760 #ifdef O_NONBLOCK
761 if (ins(d, "O_NONBLOCK", (long)O_NONBLOCK)) return -1;
762 #endif
763 #ifdef O_APPEND
764 if (ins(d, "O_APPEND", (long)O_APPEND)) return -1;
765 #endif
766 #ifdef O_DSYNC
767 if (ins(d, "O_DSYNC", (long)O_DSYNC)) return -1;
768 #endif
769 #ifdef O_RSYNC
770 if (ins(d, "O_RSYNC", (long)O_RSYNC)) return -1;
771 #endif
772 #ifdef O_SYNC
773 if (ins(d, "O_SYNC", (long)O_SYNC)) return -1;
774 #endif
775 #ifdef O_NOCTTY
776 if (ins(d, "O_NOCTTY", (long)O_NOCTTY)) return -1;
777 #endif
778 #ifdef O_CREAT
779 if (ins(d, "O_CREAT", (long)O_CREAT)) return -1;
780 #endif
781 #ifdef O_EXCL
782 if (ins(d, "O_EXCL", (long)O_EXCL)) return -1;
783 #endif
784 #ifdef O_TRUNC
785 if (ins(d, "O_TRUNC", (long)O_TRUNC)) return -1;
786 #endif
787 #ifdef O_BINARY
788 if (ins(d, "O_BINARY", (long)O_BINARY)) return -1;
789 #endif
790 #ifdef O_TEXT
791 if (ins(d, "O_TEXT", (long)O_TEXT)) return -1;
792 #endif
794 #ifdef HAVE_SPAWNV
795 if (ins(d, "P_WAIT", (long)_P_WAIT)) return -1;
796 if (ins(d, "P_NOWAIT", (long)_P_NOWAIT)) return -1;
797 if (ins(d, "P_OVERLAY", (long)_OLD_P_OVERLAY)) return -1;
798 if (ins(d, "P_NOWAITO", (long)_P_NOWAITO)) return -1;
799 if (ins(d, "P_DETACH", (long)_P_DETACH)) return -1;
800 #endif
802 #if defined(PYOS_OS2)
803 if (insertvalues(d)) return -1;
804 #endif
805 return 0;
809 void
810 initmac()
812 PyObject *m, *d;
814 m = Py_InitModule("mac", mac_methods);
815 d = PyModule_GetDict(m);
817 if (all_ins(d))
818 return;
820 /* Initialize mac.error exception */
821 PyDict_SetItemString(d, "error", PyExc_OSError);
823 PyStructSequence_InitType(&StatResultType, &stat_result_desc);
824 PyDict_SetItemString(d, "stat_result", (PyObject*) &StatResultType);
826 #if TARGET_API_MAC_OS8
827 PyStructSequence_InitType(&XStatResultType, &xstat_result_desc);
828 PyDict_SetItemString(d, "xstat_result", (PyObject*) &XStatResultType);
829 #endif