annotate Mac/Modules/gestaltmodule.c @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents bd708fe1934b
children 8bb27f4ebe16
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"
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
28
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 #include <Types.h>
5152
bd708fe1934b - Changed GestaltEqu.h to Gestalt.h
Jack Jansen <jack.jansen@cwi.nl>
parents: 5079
diff changeset
30 #include <Gestalt.h>
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
31
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 2392
diff changeset
32 static PyObject *
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 gestalt_gestalt(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 2392
diff changeset
34 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 2392
diff changeset
35 PyObject *args;
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 {
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 OSErr iErr;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 char *str;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 int size;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 OSType selector;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 long response;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 2392
diff changeset
42 if (!PyArg_Parse(args, "s#", &str, &size))
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 return NULL;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 if (size != 4) {
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 2392
diff changeset
45 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
46 return NULL;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 }
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 selector = *(OSType*)str;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 iErr = Gestalt ( selector, &response );
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 if (iErr != 0) {
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 char buf[100];
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 sprintf(buf, "Gestalt error code %d", iErr);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 2392
diff changeset
53 PyErr_SetString(PyExc_RuntimeError, buf);
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 return NULL;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 }
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 2392
diff changeset
56 return PyInt_FromLong(response);
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 }
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
58
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 2392
diff changeset
59 static struct PyMethodDef gestalt_methods[] = {
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 {"gestalt", gestalt_gestalt},
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 {NULL, NULL} /* Sentinel */
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
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
64 void
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 initgestalt()
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 {
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 2392
diff changeset
67 Py_InitModule("gestalt", gestalt_methods);
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 }