blob: 56757ab5ef850c19e511798f31d861bd3a89fa16 [file] [log] [blame]
Guido van Rossum40d94e01995-02-19 15:51:11 +00001/***********************************************************
Jack Jansen42218ce1997-01-31 16:15:11 +00002Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam,
Guido van Rossum40d94e01995-02-19 15:51:11 +00003The Netherlands.
4
5 All Rights Reserved
6
Antoine Pitrouc7c96a92010-05-09 15:15:40 +00007Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
Guido van Rossum40d94e01995-02-19 15:51:11 +00009provided that the above copyright notice appear in all copies and that
Antoine Pitrouc7c96a92010-05-09 15:15:40 +000010both that copyright notice and this permission notice appear in
Guido van Rossum40d94e01995-02-19 15:51:11 +000011supporting documentation, and that the names of Stichting Mathematisch
12Centrum or CWI not be used in advertising or publicity pertaining to
13distribution of the software without specific, written prior permission.
14
15STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
16THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
18FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
23******************************************************************/
24
Guido van Rossum2d167031994-09-16 10:54:21 +000025/* Macintosh Gestalt interface */
26
Jack Jansenf5c20571997-01-30 15:48:07 +000027#include "Python.h"
Jack Jansen7107c1a2003-11-20 13:31:00 +000028#include "pymactoolbox.h"
Guido van Rossum2d167031994-09-16 10:54:21 +000029
Jack Jansen0194ad52001-05-12 22:46:35 +000030#include <Carbon/Carbon.h>
Guido van Rossum2d167031994-09-16 10:54:21 +000031
Jack Jansenf5c20571997-01-30 15:48:07 +000032static PyObject *
Jack Jansenf894f6f2001-09-04 22:29:31 +000033gestalt_gestalt(PyObject *self, PyObject *args)
Guido van Rossum2d167031994-09-16 10:54:21 +000034{
Antoine Pitrouc7c96a92010-05-09 15:15:40 +000035 OSErr iErr;
36 OSType selector;
37 SInt32 response;
38 if (!PyArg_ParseTuple(args, "O&", PyMac_GetOSType, &selector))
39 return NULL;
40 iErr = Gestalt ( selector, &response );
41 if (iErr != 0)
42 return PyMac_Error(iErr);
43 return PyInt_FromLong(response);
Guido van Rossum2d167031994-09-16 10:54:21 +000044}
45
Jack Jansenf5c20571997-01-30 15:48:07 +000046static struct PyMethodDef gestalt_methods[] = {
Antoine Pitrouc7c96a92010-05-09 15:15:40 +000047 {"gestalt", gestalt_gestalt, METH_VARARGS},
48 {NULL, NULL} /* Sentinel */
Guido van Rossum2d167031994-09-16 10:54:21 +000049};
50
51void
Jack Jansenf894f6f2001-09-04 22:29:31 +000052initgestalt(void)
Guido van Rossum2d167031994-09-16 10:54:21 +000053{
Antoine Pitrouc7c96a92010-05-09 15:15:40 +000054 Py_InitModule("gestalt", gestalt_methods);
Guido van Rossum2d167031994-09-16 10:54:21 +000055}