blob: fa1c93c4531fcae4c3dde87e42b54dc99a0dc7fe [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
7Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
9provided that the above copyright notice appear in all copies and that
10both that copyright notice and this permission notice appear in
11supporting 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{
35 OSErr iErr;
Guido van Rossum2d167031994-09-16 10:54:21 +000036 OSType selector;
Ronald Oussoren6cc9fd72008-05-18 20:47:13 +000037 SInt32 response;
Georg Brandlbf92f462006-05-29 21:58:42 +000038 if (!PyArg_ParseTuple(args, "O&", PyMac_GetOSType, &selector))
Guido van Rossum2d167031994-09-16 10:54:21 +000039 return NULL;
Guido van Rossum2d167031994-09-16 10:54:21 +000040 iErr = Gestalt ( selector, &response );
Jack Jansen95026921999-08-23 11:37:51 +000041 if (iErr != 0)
42 return PyMac_Error(iErr);
Jack Jansenf5c20571997-01-30 15:48:07 +000043 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[] = {
Georg Brandlbf92f462006-05-29 21:58:42 +000047 {"gestalt", gestalt_gestalt, METH_VARARGS},
Guido van Rossum2d167031994-09-16 10:54:21 +000048 {NULL, NULL} /* Sentinel */
49};
50
51void
Jack Jansenf894f6f2001-09-04 22:29:31 +000052initgestalt(void)
Guido van Rossum2d167031994-09-16 10:54:21 +000053{
Jack Jansenf5c20571997-01-30 15:48:07 +000054 Py_InitModule("gestalt", gestalt_methods);
Guido van Rossum2d167031994-09-16 10:54:21 +000055}