blob: 3494d646e3d2c6c525f3224174b9feb4e5978b6f [file] [log] [blame]
Guido van Rossum40d94e01995-02-19 15:51:11 +00001/***********************************************************
2Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
3The 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
27#include "allobjects.h"
28#include "modsupport.h"
29
30#include <Types.h>
31#include <GestaltEqu.h>
32
33static object *
34gestalt_gestalt(self, args)
35 object *self;
36 object *args;
37{
38 OSErr iErr;
39 char *str;
40 int size;
41 OSType selector;
42 long response;
43 if (!getargs(args, "s#", &str, &size))
44 return NULL;
45 if (size != 4) {
46 err_setstr(TypeError, "gestalt arg must be 4-char string");
47 return NULL;
48 }
49 selector = *(OSType*)str;
50 iErr = Gestalt ( selector, &response );
51 if (iErr != 0) {
52 char buf[100];
53 sprintf(buf, "Gestalt error code %d", iErr);
54 err_setstr(RuntimeError, buf);
55 return NULL;
56 }
57 return newintobject(response);
58}
59
60static struct methodlist gestalt_methods[] = {
61 {"gestalt", gestalt_gestalt},
62 {NULL, NULL} /* Sentinel */
63};
64
65void
66initgestalt()
67{
68 initmodule("gestalt", gestalt_methods);
69}