annotate Mac/Modules/gestaltmodule.c @ 27998:e27f58a50737 legacy-trunk

SF bug #690377: Dud footnote reference in distutils docs
author Raymond Hettinger <python@rcn.com>
date Fri, 21 Feb 2003 02:47:09 +0000
parents bd252b1832a2
children 16c682e3e57f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2392
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
1 /***********************************************************
5079
d6b292a33cfe Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents: 5071
diff changeset
2 Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam,
2392
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
3 The Netherlands.
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
4
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
5 All Rights Reserved
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
6
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
7 Permission to use, copy, modify, and distribute this software and its
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
8 documentation for any purpose and without fee is hereby granted,
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
9 provided that the above copyright notice appear in all copies and that
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
10 both that copyright notice and this permission notice appear in
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
11 supporting documentation, and that the names of Stichting Mathematisch
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
12 Centrum or CWI not be used in advertising or publicity pertaining to
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
13 distribution of the software without specific, written prior permission.
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
14
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
22
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
23 ******************************************************************/
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
24
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 /* Macintosh Gestalt interface */
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
26
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 2392
diff changeset
27 #include "Python.h"
11220
8bb27f4ebe16 Return MacOS.Error in stead of RuntimeError in case of failure so the user
Jack Jansen <jack.jansen@cwi.nl>
parents: 5152
diff changeset
28 #include "macglue.h"
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
29
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 11220
diff changeset
30 #ifdef WITHOUT_FRAMEWORKS
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 #include <Types.h>
5152
bd708fe1934b - Changed GestaltEqu.h to Gestalt.h
Jack Jansen <jack.jansen@cwi.nl>
parents: 5079
diff changeset
32 #include <Gestalt.h>
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 11220
diff changeset
33 #else
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 11220
diff changeset
34 #include <Carbon/Carbon.h>
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 11220
diff changeset
35 #endif
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
36
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 2392
diff changeset
37 static PyObject *
19711
bd252b1832a2 Added prototypes to shut gcc -Wstrict-prototypes up.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17814
diff changeset
38 gestalt_gestalt(PyObject *self, PyObject *args)
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 {
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 OSErr iErr;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 char *str;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 int size;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 OSType selector;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 long response;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 2392
diff changeset
45 if (!PyArg_Parse(args, "s#", &str, &size))
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 return NULL;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 if (size != 4) {
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 2392
diff changeset
48 PyErr_SetString(PyExc_TypeError, "gestalt arg must be 4-char string");
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 return NULL;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 }
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 selector = *(OSType*)str;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 iErr = Gestalt ( selector, &response );
11220
8bb27f4ebe16 Return MacOS.Error in stead of RuntimeError in case of failure so the user
Jack Jansen <jack.jansen@cwi.nl>
parents: 5152
diff changeset
53 if (iErr != 0)
8bb27f4ebe16 Return MacOS.Error in stead of RuntimeError in case of failure so the user
Jack Jansen <jack.jansen@cwi.nl>
parents: 5152
diff changeset
54 return PyMac_Error(iErr);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 2392
diff changeset
55 return PyInt_FromLong(response);
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
56 }
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
57
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 2392
diff changeset
58 static struct PyMethodDef gestalt_methods[] = {
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
59 {"gestalt", gestalt_gestalt},
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 {NULL, NULL} /* Sentinel */
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 };
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
62
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 void
19711
bd252b1832a2 Added prototypes to shut gcc -Wstrict-prototypes up.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17814
diff changeset
64 initgestalt(void)
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 {
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 2392
diff changeset
66 Py_InitModule("gestalt", gestalt_methods);
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 }