/Mac/Modules/gestaltmodule.c

http://unladen-swallow.googlecode.com/ · C · 55 lines · 25 code · 6 blank · 24 comment · 3 complexity · 82daa3bf112e77110775838a46fa3e99 MD5 · raw file

  1. /***********************************************************
  2. Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam,
  3. The Netherlands.
  4. All Rights Reserved
  5. Permission to use, copy, modify, and distribute this software and its
  6. documentation for any purpose and without fee is hereby granted,
  7. provided that the above copyright notice appear in all copies and that
  8. both that copyright notice and this permission notice appear in
  9. supporting documentation, and that the names of Stichting Mathematisch
  10. Centrum or CWI not be used in advertising or publicity pertaining to
  11. distribution of the software without specific, written prior permission.
  12. STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  13. THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  14. FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  15. FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  16. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  17. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  18. OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19. ******************************************************************/
  20. /* Macintosh Gestalt interface */
  21. #include "Python.h"
  22. #include "pymactoolbox.h"
  23. #include <Carbon/Carbon.h>
  24. static PyObject *
  25. gestalt_gestalt(PyObject *self, PyObject *args)
  26. {
  27. OSErr iErr;
  28. OSType selector;
  29. SInt32 response;
  30. if (!PyArg_ParseTuple(args, "O&", PyMac_GetOSType, &selector))
  31. return NULL;
  32. iErr = Gestalt ( selector, &response );
  33. if (iErr != 0)
  34. return PyMac_Error(iErr);
  35. return PyInt_FromLong(response);
  36. }
  37. static struct PyMethodDef gestalt_methods[] = {
  38. {"gestalt", gestalt_gestalt, METH_VARARGS},
  39. {NULL, NULL} /* Sentinel */
  40. };
  41. void
  42. initgestalt(void)
  43. {
  44. Py_InitModule("gestalt", gestalt_methods);
  45. }