diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2003-11-19 14:34:18 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2003-11-19 14:34:18 (GMT) |
commit | 28ecf70db57828db2ca279643bf9aeca7662f35c (patch) | |
tree | 09b7767bbc411f85313b58d6fe7e5e67d9392973 /Mac/Modules | |
parent | 6045b9c93511c767f6cfa2d2fa299c76181acd9b (diff) | |
download | cpython-28ecf70db57828db2ca279643bf9aeca7662f35c.zip cpython-28ecf70db57828db2ca279643bf9aeca7662f35c.tar.gz cpython-28ecf70db57828db2ca279643bf9aeca7662f35c.tar.bz2 |
Getting rid of support for MacOS9 and earlier. This is the first step,
and the biggest in size, but probably the easiest. Hunting through the
source code comes next.
Diffstat (limited to 'Mac/Modules')
-rw-r--r-- | Mac/Modules/Printingmodule.c | 465 | ||||
-rw-r--r-- | Mac/Modules/_dummy_tkinter.c | 28 | ||||
-rw-r--r-- | Mac/Modules/calldll.c | 1194 | ||||
-rw-r--r-- | Mac/Modules/htmlrender/HtmlRendermodule.c | 818 | ||||
-rw-r--r-- | Mac/Modules/htmlrender/htmlscan.py | 63 | ||||
-rw-r--r-- | Mac/Modules/htmlrender/htmlsupport.py | 213 | ||||
-rw-r--r-- | Mac/Modules/macconfig.c | 322 | ||||
-rw-r--r-- | Mac/Modules/macmodule.c | 727 |
8 files changed, 0 insertions, 3830 deletions
diff --git a/Mac/Modules/Printingmodule.c b/Mac/Modules/Printingmodule.c deleted file mode 100644 index e0c4017..0000000 --- a/Mac/Modules/Printingmodule.c +++ /dev/null @@ -1,465 +0,0 @@ -/****************************************************************** -Copyright 1998 by Just van Rossum, Den Haag, The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Just van Rossum not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -JUST VAN ROSSUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -EVENT SHALL JUST VAN ROSSUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -#include "Python.h" -#include "macglue.h" -#include "pymactoolbox.h" -#include <Printing.h> - -static PyObject *ErrorObject; - -/* ----------------------------------------------------- */ - -static int -TPRect_Convert(PyObject *v, TPRect *r) -{ - if (v == Py_None) { - *r = NULL; - return 1; - } - return PyArg_Parse(v, "(hhhh)", &(*r)->left, &(*r)->top, &(*r)->right, &(*r)->bottom); -} - - -static char Pr_NewTPrintRecord__doc__[] = -"creates a new TPrint handle" -; - -static PyObject * -Pr_NewTPrintRecord(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - Handle hPrint; - - if (!PyArg_ParseTuple(args, "")) - return NULL; - hPrint = NewHandleClear((long) sizeof(TPrint)); - if ( hPrint == NULL ) { - PyErr_NoMemory(); - return NULL; - } - return (PyObject *)ResObj_New(hPrint); -} - -static char Pr_PrPurge__doc__[] = -"PrPurge() -> None" -; - -static PyObject * -Pr_PrPurge(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - - if (!PyArg_ParseTuple(args, "")) - return NULL; - PrPurge(); - { - OSErr _err = PrError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - return Py_None; -} - -static char Pr_PrNoPurge__doc__[] = -"PrNoPurge() -> None" -; - -static PyObject * -Pr_PrNoPurge(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - - if (!PyArg_ParseTuple(args, "")) - return NULL; - PrNoPurge(); - { - OSErr _err = PrError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - return Py_None; -} - -static char Pr_PrOpen__doc__[] = -"PrOpen() -> None" -; - -static PyObject * -Pr_PrOpen(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - - if (!PyArg_ParseTuple(args, "")) - return NULL; - PrOpen(); - { - OSErr _err = PrError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - return Py_None; -} - -static char Pr_PrClose__doc__[] = -"PrClose() -> None" -; - -static PyObject * -Pr_PrClose(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - - if (!PyArg_ParseTuple(args, "")) - return NULL; - PrClose(); - { - OSErr _err = PrError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - return Py_None; -} - -static char Pr_PrintDefault__doc__[] = -"PrintDefault(THPrint hPrint) -> None" -; - -static PyObject * -Pr_PrintDefault(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - THPrint hPrint; - - if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint)) - return NULL; - PrintDefault(hPrint); - { - OSErr _err = PrError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - return Py_None; -} - -static char Pr_PrValidate__doc__[] = -"PrValidate(THPrint hPrint) -> None" -; - -static PyObject * -Pr_PrValidate(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - THPrint hPrint; - - if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint)) - return NULL; - PrValidate(hPrint); - { - OSErr _err = PrError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - return Py_None; -} - -static char Pr_PrStlDialog__doc__[] = -"PrStlDialog(THPrint hPrint) -> Boolean" -; - -static PyObject * -Pr_PrStlDialog(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - THPrint hPrint; - Boolean rv; - - if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint)) - return NULL; - rv = PrStlDialog(hPrint); - { - OSErr _err = PrError(); - if (_err != noErr) return PyMac_Error(_err); - } - return Py_BuildValue("h", rv); -} - -static char Pr_PrJobDialog__doc__[] = -"PrJobDialog(THPrint hPrint) -> Boolean" -; - -static PyObject * -Pr_PrJobDialog(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - THPrint hPrint; - Boolean rv; - - if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint)) - return NULL; - rv = PrJobDialog(hPrint); - { - OSErr _err = PrError(); - if (_err != noErr) return PyMac_Error(_err); - } - return Py_BuildValue("h", rv); -} - -static char Pr_PrJobMerge__doc__[] = -"PrJobMerge(THPrint hPrintSrc, THPrint hPrintDst) -> none" -; - -static PyObject * -Pr_PrJobMerge(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - THPrint hPrintSrc, hPrintDst; - - if (!PyArg_ParseTuple(args, "O&O&", ResObj_Convert, &hPrintSrc, ResObj_Convert, &hPrintDst)) - return NULL; - PrJobMerge(hPrintSrc, hPrintDst); - { - OSErr _err = PrError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - return Py_None; -} - -static char Pr_PrOpenDoc__doc__[] = -"PrOpenDoc(THPrint hPrint) -> TPPrPort aTPPort" -; - -static PyObject * -Pr_PrOpenDoc(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - THPrint hPrint; - TPPrPort aTPPort; - - if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint)) - return NULL; - aTPPort = PrOpenDoc(hPrint, NULL, NULL); - { - OSErr _err = PrError(); - if (_err != noErr) return PyMac_Error(_err); - } - return Py_BuildValue("O&", GrafObj_New, aTPPort); -} - -static char Pr_PrCloseDoc__doc__[] = -"PrCloseDoc(TPPrPort pPrPort) -> None" -; - -static PyObject * -Pr_PrCloseDoc(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - TPPrPort pPrPort; - - if (!PyArg_ParseTuple(args, "O&", GrafObj_Convert, &pPrPort)) - return NULL; - PrCloseDoc(pPrPort); - { - OSErr _err = PrError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - return Py_None; -} - -static char Pr_PrOpenPage__doc__[] = -"PrOpenPage(TPPrPort pPrPort, TPRect pPageFrame) -> None" -; - -static PyObject * -Pr_PrOpenPage(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - TPPrPort pPrPort; - Rect dummyrect = {0, 0, 0, 0}; - TPRect pPageFrame = &dummyrect; - - if (!PyArg_ParseTuple(args, "O&O&", GrafObj_Convert, &pPrPort, TPRect_Convert, &pPageFrame)) - return NULL; - PrOpenPage(pPrPort, pPageFrame); - { - OSErr _err = PrError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - return Py_None; -} - -static char Pr_PrClosePage__doc__[] = -"PrClosePage(TPPrPort pPrPort) -> None" -; - -static PyObject * -Pr_PrClosePage(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - TPPrPort pPrPort; - - if (!PyArg_ParseTuple(args, "O&", GrafObj_Convert, &pPrPort)) - return NULL; - PrClosePage(pPrPort); - { - OSErr _err = PrError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - return Py_None; -} - -static char Pr_PrPicFile__doc__[] = -"PrPicFile(THPrint hPrint) -> none" -; - -static PyObject * -Pr_PrPicFile(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - THPrint hPrint; - TPrStatus prStatus; - - if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint)) - return NULL; - PrPicFile(hPrint, NULL, NULL, NULL, &prStatus); - { - OSErr _err = PrError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - return Py_None; -} - -static char Pr_PrGeneral__doc__[] = -"not implemented" -; - -static PyObject * -Pr_PrGeneral(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - - if (!PyArg_ParseTuple(args, "")) - return NULL; - //PrGeneral(); - { - OSErr _err = PrError(); - if (_err != noErr) return PyMac_Error(_err); - } - Py_INCREF(Py_None); - return Py_None; -} - -static char Pr_PrDrvrVers__doc__[] = -"PrDrvrVers() -> version" -; - -static PyObject * -Pr_PrDrvrVers(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - short rv; - - if (!PyArg_ParseTuple(args, "")) - return NULL; - rv = PrDrvrVers(); - { - OSErr _err = PrError(); - if (_err != noErr) return PyMac_Error(_err); - } - return Py_BuildValue("h", rv); -} - -/* List of methods defined in the module */ - -static struct PyMethodDef Pr_methods[] = { - {"NewTPrintRecord", (PyCFunction)Pr_NewTPrintRecord, METH_VARARGS, Pr_NewTPrintRecord__doc__}, - {"PrPurge", (PyCFunction)Pr_PrPurge, METH_VARARGS, Pr_PrPurge__doc__}, - {"PrNoPurge", (PyCFunction)Pr_PrNoPurge, METH_VARARGS, Pr_PrNoPurge__doc__}, - {"PrOpen", (PyCFunction)Pr_PrOpen, METH_VARARGS, Pr_PrOpen__doc__}, - {"PrClose", (PyCFunction)Pr_PrClose, METH_VARARGS, Pr_PrClose__doc__}, - {"PrintDefault",(PyCFunction)Pr_PrintDefault, METH_VARARGS, Pr_PrintDefault__doc__}, - {"PrValidate", (PyCFunction)Pr_PrValidate, METH_VARARGS, Pr_PrValidate__doc__}, - {"PrStlDialog", (PyCFunction)Pr_PrStlDialog, METH_VARARGS, Pr_PrStlDialog__doc__}, - {"PrJobDialog", (PyCFunction)Pr_PrJobDialog, METH_VARARGS, Pr_PrJobDialog__doc__}, - {"PrJobMerge", (PyCFunction)Pr_PrJobMerge, METH_VARARGS, Pr_PrJobMerge__doc__}, - {"PrOpenDoc", (PyCFunction)Pr_PrOpenDoc, METH_VARARGS, Pr_PrOpenDoc__doc__}, - {"PrCloseDoc", (PyCFunction)Pr_PrCloseDoc, METH_VARARGS, Pr_PrCloseDoc__doc__}, - {"PrOpenPage", (PyCFunction)Pr_PrOpenPage, METH_VARARGS, Pr_PrOpenPage__doc__}, - {"PrClosePage", (PyCFunction)Pr_PrClosePage, METH_VARARGS, Pr_PrClosePage__doc__}, - {"PrPicFile", (PyCFunction)Pr_PrPicFile, METH_VARARGS, Pr_PrPicFile__doc__}, -// {"PrGeneral", (PyCFunction)Pr_PrGeneral, METH_VARARGS, Pr_PrGeneral__doc__}, - {"PrDrvrVers", (PyCFunction)Pr_PrDrvrVers, METH_VARARGS, Pr_PrDrvrVers__doc__}, - - {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */ -}; - - -/* Initialization function for the module (*must* be called initPrinting) */ - -static char Printing_module_documentation[] = -"" -; - -void initPrinting(); - -void -initPrinting() -{ - PyObject *m, *d; - - /* Create the module and add the functions */ - m = Py_InitModule4("Printing", Pr_methods, - Printing_module_documentation, - (PyObject*)NULL,PYTHON_API_VERSION); - - /* Add some symbolic constants to the module */ - d = PyModule_GetDict(m); - ErrorObject = PyString_FromString("Printing.error"); - PyDict_SetItemString(d, "error", ErrorObject); - - /* XXXX Add constants here */ - -} - diff --git a/Mac/Modules/_dummy_tkinter.c b/Mac/Modules/_dummy_tkinter.c deleted file mode 100644 index 6faab91..0000000 --- a/Mac/Modules/_dummy_tkinter.c +++ /dev/null @@ -1,28 +0,0 @@ - -/* Dummy _tkinter module for use with Carbon. Gives (slightly) better error - * message when you try to use Tkinter. - */ - -/* Xxo objects */ - -#include "Python.h" - - -/* List of functions defined in the module */ - -static PyMethodDef xx_methods[] = { - {NULL, NULL} /* sentinel */ -}; - - - -DL_EXPORT(void) -init_tkinter(void) -{ - PyObject *m; - - /* Create the module and add the functions */ - m = Py_InitModule("_tkinter", xx_methods); - - PyErr_SetString(PyExc_ImportError, "Tkinter not supported under Carbon (yet)."); -} diff --git a/Mac/Modules/calldll.c b/Mac/Modules/calldll.c deleted file mode 100644 index f390a9d..0000000 --- a/Mac/Modules/calldll.c +++ /dev/null @@ -1,1194 +0,0 @@ -/*********************************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI or Corporation for National Research Initiatives or -CNRI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -While CWI is the initial source for this software, a modified version -is made available by the Corporation for National Research Initiatives -(CNRI) at the Internet address ftp://ftp.python.org. - -STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH -CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* Sanity check */ -#ifndef __powerc -#error Please port this code to your architecture first... -#endif - -/* -** Define to include testroutines (at the end) -*/ -#define TESTSUPPORT - -#include "Python.h" -#include "macglue.h" -#include "macdefs.h" -#include <CodeFragments.h> - -/* Prototypes for routines not in any include file (shame, shame) */ -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); - -static PyObject *ErrorObject; - -/* Debugging macro */ -#ifdef TESTSUPPORT -#define PARANOID(arg) \ - if ( arg == 0 ) {PyErr_SetString(ErrorObject, "Internal error: NULL arg!"); return 0; } -#else -#define PARANOID(arg) /*pass*/ -#endif - -/* Prototypes we use for routines and arguments */ - -typedef long anything; -typedef anything (*anyroutine)(...); - -/* Other constants */ -#define MAXNAME 31 /* Maximum size of names, for printing only */ -#define MAXARG 12 /* Maximum number of arguments */ - -/* -** Routines to convert arguments between Python and C. -** Note return-value converters return NULL if this argument (or return value) -** doesn't return anything. The call-wrapper code collects all return values, -** and does the expected thing based on the number of return values: return None, a single -** value or a tuple of values. -** -** Hence, optional return values are also implementable. -*/ -typedef anything (*py2c_converter)(PyObject *); -typedef PyObject *(*c2py_converter)(anything); -typedef PyObject *(*rv2py_converter)(anything); - - -/* Dummy routine for arguments that are output-only */ -static anything -py2c_dummy(arg) - PyObject *arg; -{ - return 0; -} - -/* Routine to allocate storage for output integers */ -static anything -py2c_alloc(arg) - PyObject *arg; -{ - char *ptr; - - if( (ptr=malloc(sizeof(anything))) == 0 ) - PyErr_NoMemory(); - return (anything)ptr; -} - -/* Dummy routine for arguments that are input-only */ -static PyObject * -c2py_dummy(arg) - anything arg; -{ - return 0; -} - -/* Dummy routine for void return value */ -static PyObject * -rv2py_none(arg) - anything arg; -{ - return 0; -} - -/* Routine to de-allocate storage for input-only arguments */ -static PyObject * -c2py_free(arg) - anything arg; -{ - if ( arg ) - free((char *)arg); - return 0; -} - -/* -** OSErr return value. -*/ -static PyObject * -rv2py_oserr(arg) - anything arg; -{ - OSErr err = (OSErr)arg; - - if (err) - return PyMac_Error(err); - return 0; -} - -/* -** Input integers of all sizes (PPC only) -*/ -static anything -py2c_in_int(arg) - PyObject *arg; -{ - return PyInt_AsLong(arg); -} - -/* -** Integer return values of all sizes (PPC only) -*/ -static PyObject * -rv2py_int(arg) - anything arg; -{ - return PyInt_FromLong((long)arg); -} - -/* -** Integer output parameters -*/ -static PyObject * -c2py_out_long(arg) - anything arg; -{ - PyObject *rv; - - PARANOID(arg); - rv = PyInt_FromLong(*(long *)arg); - free((char *)arg); - return rv; -} - -static PyObject * -c2py_out_short(arg) - anything arg; -{ - PyObject *rv; - - PARANOID(arg); - rv = PyInt_FromLong((long)*(short *)arg); - free((char *)arg); - return rv; -} - -static PyObject * -c2py_out_byte(arg) - anything arg; -{ - PyObject *rv; - - PARANOID(arg); - rv = PyInt_FromLong((long)*(char *)arg); - free((char *)arg); - return rv; -} - -/* -** Strings -*/ -static anything -py2c_in_string(arg) - PyObject *arg; -{ - return (anything)PyString_AsString(arg); -} - -/* -** Pascal-style strings -*/ -static anything -py2c_in_pstring(arg) - PyObject *arg; -{ - unsigned char *p; - int size; - - if( (size = PyString_Size(arg)) < 0) - return 0; - if ( size > 255 ) { - PyErr_SetString(ErrorObject, "Pstring must be <= 255 chars"); - return 0; - } - if( (p=(unsigned char *)malloc(256)) == 0 ) { - PyErr_NoMemory(); - return 0; - } - p[0] = size; - memcpy(p+1, PyString_AsString(arg), size); - return (anything)p; -} - -static anything -py2c_out_pstring(arg) - PyObject *arg; -{ - unsigned char *p; - - if( (p=(unsigned char *)malloc(256)) == 0 ) { - PyErr_NoMemory(); - return 0; - } - p[0] = 0; - return (anything)p; -} - -static PyObject * -c2py_out_pstring(arg) - anything arg; -{ - unsigned char *p = (unsigned char *)arg; - PyObject *rv; - - PARANOID(arg); - rv = PyString_FromStringAndSize((char *)p+1, p[0]); - free(p); - return rv; -} - -static PyObject * -rv2py_pstring(arg) - anything arg; -{ - unsigned char *p = (unsigned char *)arg; - PyObject *rv; - - if ( arg == NULL ) return NULL; - rv = PyString_FromStringAndSize((char *)p+1, p[0]); - return rv; -} - -/* -** C objects. -*/ -static anything -py2c_in_cobject(arg) - PyObject *arg; -{ - if ( arg == Py_None ) - return 0; - return (anything)PyCObject_AsVoidPtr(arg); -} - -static PyObject * -c2py_out_cobject(arg) - anything arg; -{ - void **ptr = (void **)arg; - PyObject *rv; - - PARANOID(arg); - if ( *ptr == 0 ) { - Py_INCREF(Py_None); - rv = Py_None; - } else { - rv = PyCObject_FromVoidPtr(*ptr, 0); - } - free((char *)ptr); - return rv; -} - -static PyObject * -rv2py_cobject(arg) - anything arg; -{ - void *ptr = (void *)arg; - PyObject *rv; - - if ( ptr == 0 ) return NULL; - rv = PyCObject_FromVoidPtr(ptr, 0); - return rv; -} - -/* -** Handles. -*/ -static anything -py2c_in_handle(arg) - PyObject *arg; -{ - Handle h = 0; - ResObj_Convert(arg, &h); - return (anything)h; -} - -static PyObject * -c2py_out_handle(arg) - anything arg; -{ - Handle *rv = (Handle *)arg; - PyObject *prv; - - PARANOID(arg); - if ( *rv == 0 ) { - Py_INCREF(Py_None); - prv = Py_None; - } else { - prv = ResObj_New(*rv); - } - free((char *)rv); - return prv; -} - -static PyObject * -rv2py_handle(arg) - anything arg; -{ - Handle rv = (Handle)arg; - - if ( rv == NULL ) return NULL; - return ResObj_New(rv); -} - -typedef struct { - char *name; /* Name */ - py2c_converter get; /* Get argument */ - int get_uses_arg; /* True if the above consumes an argument */ - c2py_converter put; /* Put result value */ -} conventry; - -static conventry converters[] = { - {"InByte", py2c_in_int, 1, c2py_dummy}, - {"InShort", py2c_in_int, 1, c2py_dummy}, - {"InLong", py2c_in_int, 1, c2py_dummy}, - {"OutLong", py2c_alloc, 0, c2py_out_long}, - {"OutShort", py2c_alloc, 0, c2py_out_short}, - {"OutByte", py2c_alloc, 0, c2py_out_byte}, - {"InString", py2c_in_string, 1, c2py_dummy}, - {"InPstring", py2c_in_pstring,1, c2py_free}, - {"OutPstring", py2c_out_pstring,0, c2py_out_pstring}, - {"InCobject", py2c_in_cobject,1, c2py_dummy}, - {"OutCobject", py2c_alloc, 0, c2py_out_cobject}, - {"InHandle", py2c_in_handle, 1, c2py_dummy}, - {"OutHandle", py2c_alloc, 0, c2py_out_handle}, - {0, 0, 0, 0} -}; - -typedef struct { - char *name; - rv2py_converter rtn; -} rvconventry; - -static rvconventry rvconverters[] = { - {"None", rv2py_none}, - {"OSErr", rv2py_oserr}, - {"Byte", rv2py_int}, - {"Short", rv2py_int}, - {"Long", rv2py_int}, - {"Pstring", rv2py_pstring}, - {"Cobject", rv2py_cobject}, - {"Handle", rv2py_handle}, - {0, 0} -}; - -static conventry * -getconverter(name) - char *name; -{ - int i; - char buf[256]; - - for(i=0; converters[i].name; i++ ) - if ( strcmp(name, converters[i].name) == 0 ) - return &converters[i]; - sprintf(buf, "Unknown argtype: %s", name); - PyErr_SetString(ErrorObject, buf); - return 0; -} - -static rvconventry * -getrvconverter(name) - char *name; -{ - int i; - char buf[256]; - - for(i=0; rvconverters[i].name; i++ ) - if ( strcmp(name, rvconverters[i].name) == 0 ) - return &rvconverters[i]; - sprintf(buf, "Unknown return value type: %s", name); - PyErr_SetString(ErrorObject, buf); - return 0; -} - -static int -argparse_conv(obj, ptr) - PyObject *obj; - conventry **ptr; -{ - char *name; - int i; - conventry *item; - - if( (name=PyString_AsString(obj)) == NULL ) - return 0; - if( (item=getconverter(name)) == NULL ) - return 0; - *ptr = item; - return 1; -} - -static int -argparse_rvconv(obj, ptr) - PyObject *obj; - rvconventry **ptr; -{ - char *name; - int i; - rvconventry *item; - - if( (name=PyString_AsString(obj)) == NULL ) - return 0; - if( (item=getrvconverter(name)) == NULL ) - return 0; - *ptr = item; - return 1; -} - -/* ----------------------------------------------------- */ - -/* Declarations for objects of type fragment */ - -typedef struct { - PyObject_HEAD - CFragConnectionID conn_id; - char name[MAXNAME+1]; -} cdfobject; - -static PyTypeObject Cdftype; - - - -/* ---------------------------------------------------------------- */ - -/* Declarations for objects of type routine */ - -typedef struct { - PyObject_HEAD - anyroutine rtn; - char name[MAXNAME+1]; -} cdrobject; - -static PyTypeObject Cdrtype; - - - -/* ---------------------------------------------------------------- */ - -/* Declarations for objects of type callable */ - - -typedef struct { - PyObject_HEAD - cdrobject *routine; /* The routine to call */ - int npargs; /* Python argument count */ - int ncargs; /* C argument count + 1 */ - rvconventry *rvconv; /* Return value converter */ - conventry *argconv[MAXARG]; /* Value converter list */ -} cdcobject; - -static PyTypeObject Cdctype; - - - -/* -------------------------------------------------------- */ - - -static struct PyMethodDef cdr_methods[] = { - - {NULL, NULL} /* sentinel */ -}; - -/* ---------- */ - - -static cdrobject * -newcdrobject(name, routine) - unsigned char *name; - anyroutine routine; -{ - cdrobject *self; - int nlen; - - self = PyObject_NEW(cdrobject, &Cdrtype); - if (self == NULL) - return NULL; - if ( name[0] > MAXNAME ) - nlen = MAXNAME; - else - nlen = name[0]; - memcpy(self->name, name+1, nlen); - self->name[nlen] = '\0'; - self->rtn = routine; - return self; -} - -static void -cdr_dealloc(self) - cdrobject *self; -{ - PyObject_DEL(self); -} - -static PyObject * -cdr_repr(self) - cdrobject *self; -{ - PyObject *s; - char buf[256]; - - sprintf(buf, "<Calldll routine %s address 0x%x>", self->name, self->rtn); - s = PyString_FromString(buf); - return s; -} - -static char Cdrtype__doc__[] = -"C Routine address" -; - -static PyTypeObject Cdrtype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "calldll.routine", /*tp_name*/ - sizeof(cdrobject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)cdr_dealloc, /*tp_dealloc*/ - (printfunc)0, /*tp_print*/ - (getattrfunc)0, /*tp_getattr*/ - (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)0, /*tp_compare*/ - (reprfunc)cdr_repr, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ - (ternaryfunc)0, /*tp_call*/ - (reprfunc)0, /*tp_str*/ - - /* Space for future expansion */ - 0L,0L,0L,0L, - Cdrtype__doc__ /* Documentation string */ -}; - -/* End of code for routine objects */ -/* -------------------------------------------------------- */ - - -static struct PyMethodDef cdc_methods[] = { - - {NULL, NULL} /* sentinel */ -}; - -/* ---------- */ - - -static cdcobject * -newcdcobject(routine, npargs, ncargs, rvconv, argconv) - cdrobject *routine; - int npargs; - int ncargs; - rvconventry *rvconv; - conventry *argconv[]; -{ - cdcobject *self; - int i; - - self = PyObject_NEW(cdcobject, &Cdctype); - if (self == NULL) - return NULL; - self->routine = routine; - Py_INCREF(routine); - self->npargs = npargs; - self->ncargs = ncargs; - self->rvconv = rvconv; - for(i=0; i<MAXARG; i++) - if ( i < ncargs ) - self->argconv[i] = argconv[i]; - else - self->argconv[i] = 0; - return self; -} - -static void -cdc_dealloc(self) - cdcobject *self; -{ - Py_XDECREF(self->routine); - PyObject_DEL(self); -} - - -static PyObject * -cdc_repr(self) - cdcobject *self; -{ - PyObject *s; - char buf[256]; - int i; - - sprintf(buf, "<callable %s = %s(", self->rvconv->name, self->routine->name); - for(i=0; i< self->ncargs; i++) { - strcat(buf, self->argconv[i]->name); - if ( i < self->ncargs-1 ) - strcat(buf, ", "); - } - strcat(buf, ") >"); - - s = PyString_FromString(buf); - return s; -} - -/* -** And this is what we all do it for: call a C function. -*/ -static PyObject * -cdc_call(self, args, kwargs) - cdcobject *self; - PyObject *args; - PyObject *kwargs; -{ - char buf[256]; - int i, pargindex; - anything c_args[MAXARG] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - anything c_rv; - conventry *cp; - PyObject *curarg; - anyroutine func; - PyObject *returnvalues[MAXARG+1]; - PyObject *rv; - - if( kwargs ) { - PyErr_SetString(PyExc_TypeError, "Keyword args not allowed"); - return 0; - } - if( !PyTuple_Check(args) ) { - PyErr_SetString(PyExc_TypeError, "Arguments not in tuple"); - return 0; - } - if( PyTuple_Size(args) != self->npargs ) { - sprintf(buf, "%d arguments, expected %d", PyTuple_Size(args), self->npargs); - PyErr_SetString(PyExc_TypeError, buf); - return 0; - } - - /* Decode arguments */ - pargindex = 0; - for(i=0; i<self->ncargs; i++) { - cp = self->argconv[i]; - if ( cp->get_uses_arg ) { - curarg = PyTuple_GET_ITEM(args, pargindex); - pargindex++; - } else { - curarg = (PyObject *)NULL; - } - c_args[i] = (*cp->get)(curarg); - } - if (PyErr_Occurred()) - return 0; - - /* Call function */ - func = self->routine->rtn; - c_rv = (*func)(c_args[0], c_args[1], c_args[2], c_args[3], - c_args[4], c_args[5], c_args[6], c_args[7], - c_args[8], c_args[9], c_args[10], c_args[11]); - - /* Decode return value, and store into returnvalues if needed */ - pargindex = 0; - curarg = (*self->rvconv->rtn)(c_rv); - if ( curarg ) - returnvalues[pargindex++] = curarg; - - /* Decode returnvalue parameters and cleanup any storage allocated */ - for(i=0; i<self->ncargs; i++) { - cp = self->argconv[i]; - curarg = (*cp->put)(c_args[i]); - if(curarg) - returnvalues[pargindex++] = curarg; - /* NOTE: We only check errors at the end (so we free() everything) */ - } - if ( PyErr_Occurred() ) { - /* An error did occur. Free the python objects created */ - for(i=0; i<pargindex; i++) - Py_XDECREF(returnvalues[i]); - return NULL; - } - - /* Zero and one return values cases are special: */ - if ( pargindex == 0 ) { - Py_INCREF(Py_None); - return Py_None; - } - if ( pargindex == 1 ) - return returnvalues[0]; - - /* More than one return value: put in a tuple */ - rv = PyTuple_New(pargindex); - for(i=0; i<pargindex; i++) - if(rv) - PyTuple_SET_ITEM(rv, i, returnvalues[i]); - else - Py_XDECREF(returnvalues[i]); - return rv; -} - -static char Cdctype__doc__[] = -"" -; - -static PyTypeObject Cdctype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "calldll.callable", /*tp_name*/ - sizeof(cdcobject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)cdc_dealloc, /*tp_dealloc*/ - (printfunc)0, /*tp_print*/ - (getattrfunc)0, /*tp_getattr*/ - (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)0, /*tp_compare*/ - (reprfunc)cdc_repr, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ - (ternaryfunc)cdc_call, /*tp_call*/ - (reprfunc)0, /*tp_str*/ - - /* Space for future expansion */ - 0L,0L,0L,0L, - Cdctype__doc__ /* Documentation string */ -}; - -/* End of code for callable objects */ -/* ---------------------------------------------------------------- */ - -static char cdf_keys__doc__[] = -"Return list of symbol names in fragment"; - -static PyObject * -cdf_keys(self, args) - cdfobject *self; - PyObject *args; -{ - long symcount; - PyObject *rv, *obj; - Str255 symname; - Ptr dummy1; - CFragSymbolClass dummy2; - int i; - OSErr err; - - if (!PyArg_ParseTuple(args, "")) - return NULL; - if ( (err=CountSymbols(self->conn_id, &symcount)) < 0 ) - return PyMac_Error(err); - if ( (rv=PyList_New(symcount)) == NULL ) - return NULL; - for (i=0; i<symcount; i++) { - if ((err=GetIndSymbol(self->conn_id, i, symname, &dummy1, &dummy2)) < 0 ) { - Py_XDECREF(rv); - return PyMac_Error(err); - } - if ((obj=PyString_FromStringAndSize((char *)symname+1, symname[0])) == NULL ) { - Py_XDECREF(rv); - return PyMac_Error(err); - } - if (PyList_SetItem(rv, i, obj) < 0 ) { - Py_XDECREF(rv); - return NULL; - } - } - return rv; -} - - -static struct PyMethodDef cdf_methods[] = { - {"keys", (PyCFunction)cdf_keys, METH_VARARGS, - cdf_keys__doc__}, - - {NULL, NULL} /* sentinel */ -}; - -/* ---------- */ - - -static cdfobject * -newcdfobject(conn_id, name) - CFragConnectionID conn_id; - unsigned char *name; -{ - cdfobject *self; - int nlen; - - self = PyObject_NEW(cdfobject, &Cdftype); - if (self == NULL) - return NULL; - self->conn_id = conn_id; - if ( name[0] > MAXNAME ) - nlen = MAXNAME; - else - nlen = name[0]; - strncpy(self->name, (char *)name+1, nlen); - self->name[nlen] = '\0'; - return self; -} - -static void -cdf_dealloc(self) - cdfobject *self; -{ - PyObject_DEL(self); -} - -static PyObject * -cdf_repr(self) - cdfobject *self; -{ - PyObject *s; - char buf[256]; - - sprintf(buf, "<fragment %s connection, id 0x%x>", self->name, self->conn_id); - s = PyString_FromString(buf); - return s; -} - -static PyObject * -cdf_getattr_helper(self, name) - cdfobject *self; - char *name; -{ - unsigned char *rtn_name; - anyroutine rtn; - OSErr err; - Str255 errMessage; - CFragSymbolClass class; - char buf[256]; - - rtn_name = Pstring(name); - err = FindSymbol(self->conn_id, rtn_name, (Ptr *)&rtn, &class); - if ( err ) { - sprintf(buf, "%.*s: %s", rtn_name[0], rtn_name+1, PyMac_StrError(err)); - PyErr_SetString(ErrorObject, buf); - return NULL; - } - if( class != kTVectorCFragSymbol ) { - PyErr_SetString(ErrorObject, "Symbol is not a routine"); - return NULL; - } - - return (PyObject *)newcdrobject(rtn_name, rtn); -} - -static PyObject * -cdf_getattr(self, name) - cdfobject *self; - char *name; -{ - PyObject *rv; - - if ((rv=Py_FindMethod(cdf_methods, (PyObject *)self, name))) - return rv; - PyErr_Clear(); - return cdf_getattr_helper(self, name); -} - -/* -------------------------------------------------------- */ -/* Code to access cdf objects as mappings */ - -static int -cdf_length(self) - cdfobject *self; -{ - long symcount; - OSErr err; - - err = CountSymbols(self->conn_id, &symcount); - if ( err ) { - PyMac_Error(err); - return -1; - } - return symcount; -} - -static PyObject * -cdf_subscript(self, key) - cdfobject *self; - PyObject *key; -{ - char *name; - - if ((name=PyString_AsString(key)) == 0 ) - return 0; - return cdf_getattr_helper(self, name); -} - -static int -cdf_ass_sub(self, v, w) - cdfobject *self; - PyObject *v, *w; -{ - /* XXXX Put w in self under key v */ - return 0; -} - -static PyMappingMethods cdf_as_mapping = { - (inquiry)cdf_length, /*mp_length*/ - (binaryfunc)cdf_subscript, /*mp_subscript*/ - (objobjargproc)cdf_ass_sub, /*mp_ass_subscript*/ -}; - -/* -------------------------------------------------------- */ - -static char Cdftype__doc__[] = -"Code Fragment library symbol table" -; - -static PyTypeObject Cdftype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "calldll.fragment", /*tp_name*/ - sizeof(cdfobject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)cdf_dealloc, /*tp_dealloc*/ - (printfunc)0, /*tp_print*/ - (getattrfunc)cdf_getattr, /*tp_getattr*/ - (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)0, /*tp_compare*/ - (reprfunc)cdf_repr, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - &cdf_as_mapping, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ - (ternaryfunc)0, /*tp_call*/ - (reprfunc)0, /*tp_str*/ - - /* Space for future expansion */ - 0L,0L,0L,0L, - Cdftype__doc__ /* Documentation string */ -}; - -/* End of code for fragment objects */ -/* -------------------------------------------------------- */ - - -static char cdll_getlibrary__doc__[] = -"Load a shared library fragment and return the symbol table" -; - -static PyObject * -cdll_getlibrary(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - Str255 frag_name; - OSErr err; - Str255 errMessage; - Ptr main_addr; - CFragConnectionID conn_id; - char buf[256]; - - if (!PyArg_ParseTuple(args, "O&", PyMac_GetStr255, frag_name)) - return NULL; - - /* Find the library connection ID */ - err = GetSharedLibrary(frag_name, kCompiledCFragArch, kLoadCFrag, &conn_id, &main_addr, - errMessage); - if ( err ) { - sprintf(buf, "%.*s: %s", errMessage[0], errMessage+1, PyMac_StrError(err)); - PyErr_SetString(ErrorObject, buf); - return NULL; - } - return (PyObject *)newcdfobject(conn_id, frag_name); -} - -static char cdll_getdiskfragment__doc__[] = -"Load a fragment from a disk file and return the symbol table" -; - -static PyObject * -cdll_getdiskfragment(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - FSSpec fsspec; - Str255 frag_name; - OSErr err; - Str255 errMessage; - Ptr main_addr; - CFragConnectionID conn_id; - char buf[256]; - Boolean isfolder, didsomething; - - if (!PyArg_ParseTuple(args, "O&O&", PyMac_GetFSSpec, &fsspec, - PyMac_GetStr255, frag_name)) - return NULL; - err = ResolveAliasFile(&fsspec, 1, &isfolder, &didsomething); - if ( err ) - return PyErr_Mac(ErrorObject, err); - - /* Load the fragment (or return the connID if it is already loaded */ - err = GetDiskFragment(&fsspec, 0, 0, frag_name, - kLoadCFrag, &conn_id, &main_addr, - errMessage); - if ( err ) { - sprintf(buf, "%.*s: %s", errMessage[0], errMessage+1, PyMac_StrError(err)); - PyErr_SetString(ErrorObject, buf); - return NULL; - } - return (PyObject *)newcdfobject(conn_id, frag_name); -} - -static char cdll_newcall__doc__[] = -"" -; - -static PyObject * -cdll_newcall(self, args) - PyObject *self; /* Not used */ - PyObject *args; -{ - cdrobject *routine; - conventry *argconv[MAXARG] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - rv2py_converter rvconv; - int npargs, ncargs; - - /* Note: the next format depends on MAXARG */ - if (!PyArg_ParseTuple(args, "O!O&|O&O&O&O&O&O&O&O&O&O&O&O&", &Cdrtype, &routine, - argparse_rvconv, &rvconv, - argparse_conv, &argconv[0], argparse_conv, &argconv[1], - argparse_conv, &argconv[2], argparse_conv, &argconv[3], - argparse_conv, &argconv[4], argparse_conv, &argconv[5], - argparse_conv, &argconv[6], argparse_conv, &argconv[7], - argparse_conv, &argconv[8], argparse_conv, &argconv[9], - argparse_conv, &argconv[10], argparse_conv, &argconv[11])) - return NULL; - npargs = 0; - for(ncargs=0; ncargs < MAXARG && argconv[ncargs]; ncargs++) { - if( argconv[ncargs]->get_uses_arg ) npargs++; - } - return (PyObject *)newcdcobject(routine, npargs, ncargs, rvconv, argconv); -} - -/* List of methods defined in the module */ - -static struct PyMethodDef cdll_methods[] = { - {"getlibrary", (PyCFunction)cdll_getlibrary, METH_VARARGS, - cdll_getlibrary__doc__}, - {"getdiskfragment", (PyCFunction)cdll_getdiskfragment, METH_VARARGS, - cdll_getdiskfragment__doc__}, - {"newcall", (PyCFunction)cdll_newcall, METH_VARARGS, - cdll_newcall__doc__}, - - {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */ -}; - - -/* Initialization function for the module (*must* be called initcalldll) */ - -static char calldll_module_documentation[] = -"" -; - -void -initcalldll() -{ - PyObject *m, *d; - - /* Create the module and add the functions */ - m = Py_InitModule4("calldll", cdll_methods, - calldll_module_documentation, - (PyObject*)NULL,PYTHON_API_VERSION); - - /* Add some symbolic constants to the module */ - d = PyModule_GetDict(m); - ErrorObject = PyString_FromString("calldll.error"); - PyDict_SetItemString(d, "error", ErrorObject); - - /* XXXX Add constants here */ - - /* Check for errors */ - if (PyErr_Occurred()) - Py_FatalError("can't initialize module calldll"); -} - -#ifdef TESTSUPPORT - -/* Test routine */ -int cdll_b_bbbbbbbb(char a1,char a2,char a3,char a4,char a5,char a6,char a7,char a8) -{ - return a1+a2+a3+a4+a5+a6+a7+a8; -} - -short cdll_h_hhhhhhhh(short a1,short a2,short a3,short a4,short a5,short a6,short a7,short a8) -{ - return a1+a2+a3+a4+a5+a6+a7+a8; -} - -int cdll_l_llllllll(int a1,int a2,int a3,int a4,int a5,int a6,int a7,int a8) -{ - return a1+a2+a3+a4+a5+a6+a7+a8; -} - -void cdll_N_ssssssss(char *a1,char *a2,char *a3,char *a4,char *a5,char *a6,char *a7,char *a8) -{ - printf("cdll_N_ssssssss args: %s %s %s %s %s %s %s %s\n", a1, a2, a3, a4, - a5, a6, a7, a8); -} - -OSErr cdll_o_l(long l) -{ - return (OSErr)l; -} - -void cdll_N_pp(unsigned char *in, unsigned char *out) -{ - out[0] = in[0] + 5; - strcpy((char *)out+1, "Was: "); - memcpy(out+6, in+1, in[0]); -} - -void cdll_N_bb(char a1, char *a2) -{ - *a2 = a1; -} - -void cdll_N_hh(short a1, short *a2) -{ - *a2 = a1; -} - -void cdll_N_ll(long a1, long *a2) -{ - *a2 = a1; -} - -void cdll_N_sH(char *a1, Handle a2) -{ - int len; - - len = strlen(a1); - SetHandleSize(a2, len); - HLock(a2); - memcpy(*a2, a1, len); - HUnlock(a2); -} -#endif diff --git a/Mac/Modules/htmlrender/HtmlRendermodule.c b/Mac/Modules/htmlrender/HtmlRendermodule.c deleted file mode 100644 index 08df21f..0000000 --- a/Mac/Modules/htmlrender/HtmlRendermodule.c +++ /dev/null @@ -1,818 +0,0 @@ - -/* ======================= Module HtmlRender ======================== */ - -#include "Python.h" - - - -#define SystemSevenOrLater 1 - -#include "macglue.h" -#include <Memory.h> -#include <Dialogs.h> -#include <Menus.h> -#include <Controls.h> - -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyTypeObject Window_Type; -#define WinObj_Check(x) ((x)->ob_type == &Window_Type) - -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyTypeObject Dialog_Type; -#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) - -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); - -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); - -extern PyObject *WinObj_WhichWindow(WindowPtr); - -#include <HTMLRendering.h> - -static PyObject *Html_Error; - -/* --------------------- Object type HtmlObject --------------------- */ - -PyTypeObject HtmlObject_Type; - -#define HtmlObj_Check(x) ((x)->ob_type == &HtmlObject_Type) - -typedef struct HtmlObjectObject { - PyObject_HEAD - HRReference ob_itself; -} HtmlObjectObject; - -PyObject *HtmlObj_New(itself) - HRReference itself; -{ - HtmlObjectObject *it; - it = PyObject_NEW(HtmlObjectObject, &HtmlObject_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - return (PyObject *)it; -} -HtmlObj_Convert(v, p_itself) - PyObject *v; - HRReference *p_itself; -{ - if (!HtmlObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "HtmlObject required"); - return 0; - } - *p_itself = ((HtmlObjectObject *)v)->ob_itself; - return 1; -} - -static void HtmlObj_dealloc(self) - HtmlObjectObject *self; -{ - /* Cleanup of self->ob_itself goes here */ - PyObject_DEL(self); -} - -static PyObject *HtmlObj_HRDisposeReference(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = HRDisposeReference(_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRSetGrafPtr(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - GrafPtr grafPtr; - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &grafPtr)) - return NULL; - _err = HRSetGrafPtr(_self->ob_itself, - grafPtr); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRActivate(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = HRActivate(_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRDeactivate(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = HRDeactivate(_self->ob_itself); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRDraw(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - RgnHandle updateRgnH; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &updateRgnH)) - return NULL; - _err = HRDraw(_self->ob_itself, - updateRgnH); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRSetRenderingRect(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - Rect renderingRect; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &renderingRect)) - return NULL; - _err = HRSetRenderingRect(_self->ob_itself, - &renderingRect); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRGetRenderedImageSize(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - Point renderingSize; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = HRGetRenderedImageSize(_self->ob_itself, - &renderingSize); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, renderingSize); - return _res; -} - -static PyObject *HtmlObj_HRScrollToLocation(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - Point location; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = HRScrollToLocation(_self->ob_itself, - &location); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, location); - return _res; -} - -static PyObject *HtmlObj_HRForceQuickdraw(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - Boolean forceQuickdraw; - if (!PyArg_ParseTuple(_args, "b", - &forceQuickdraw)) - return NULL; - _err = HRForceQuickdraw(_self->ob_itself, - forceQuickdraw); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRSetScrollbarState(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - HRScrollbarState hScrollbarState; - HRScrollbarState vScrollbarState; - if (!PyArg_ParseTuple(_args, "hh", - &hScrollbarState, - &vScrollbarState)) - return NULL; - _err = HRSetScrollbarState(_self->ob_itself, - hScrollbarState, - vScrollbarState); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRSetDrawBorder(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - Boolean drawBorder; - if (!PyArg_ParseTuple(_args, "b", - &drawBorder)) - return NULL; - _err = HRSetDrawBorder(_self->ob_itself, - drawBorder); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRSetGrowboxCutout(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - Boolean allowCutout; - if (!PyArg_ParseTuple(_args, "b", - &allowCutout)) - return NULL; - _err = HRSetGrowboxCutout(_self->ob_itself, - allowCutout); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRGoToFile(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - FSSpec fsspec; - Boolean addToHistory; - Boolean forceRefresh; - if (!PyArg_ParseTuple(_args, "O&bb", - PyMac_GetFSSpec, &fsspec, - &addToHistory, - &forceRefresh)) - return NULL; - _err = HRGoToFile(_self->ob_itself, - &fsspec, - addToHistory, - forceRefresh); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRGoToURL(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - char * url; - Boolean addToHistory; - Boolean forceRefresh; - if (!PyArg_ParseTuple(_args, "sbb", - &url, - &addToHistory, - &forceRefresh)) - return NULL; - _err = HRGoToURL(_self->ob_itself, - url, - addToHistory, - forceRefresh); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRGoToAnchor(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - char * anchorName; - if (!PyArg_ParseTuple(_args, "s", - &anchorName)) - return NULL; - _err = HRGoToAnchor(_self->ob_itself, - anchorName); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRGoToPtr(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - char *buffer__in__; - long buffer__len__; - int buffer__in_len__; - Boolean addToHistory; - Boolean forceRefresh; - if (!PyArg_ParseTuple(_args, "s#bb", - &buffer__in__, &buffer__in_len__, - &addToHistory, - &forceRefresh)) - return NULL; - buffer__len__ = buffer__in_len__; - _err = HRGoToPtr(_self->ob_itself, - buffer__in__, buffer__len__, - addToHistory, - forceRefresh); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - buffer__error__: ; - return _res; -} - -static PyObject *HtmlObj_HRGetRootURL(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - Handle rootURLH; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rootURLH)) - return NULL; - _err = HRGetRootURL(_self->ob_itself, - rootURLH); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRGetBaseURL(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - Handle baseURLH; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &baseURLH)) - return NULL; - _err = HRGetBaseURL(_self->ob_itself, - baseURLH); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRGetHTMLURL(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - Handle HTMLURLH; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &HTMLURLH)) - return NULL; - _err = HRGetHTMLURL(_self->ob_itself, - HTMLURLH); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRGetTitle(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - StringPtr title; - if (!PyArg_ParseTuple(_args, "s", - &title)) - return NULL; - _err = HRGetTitle(_self->ob_itself, - title); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRGetHTMLFile(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - FSSpec fsspec; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = HRGetHTMLFile(_self->ob_itself, - &fsspec); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - PyMac_BuildFSSpec, fsspec); - return _res; -} - -static PyObject *HtmlObj_HRUnregisterWasURLVisitedUPP(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - HRUnregisterWasURLVisitedUPP(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRUnregisterNewURLUPP(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - HRUnregisterNewURLUPP(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *HtmlObj_HRUnregisterURLToFSSpecUPP(_self, _args) - HtmlObjectObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - HRUnregisterURLToFSSpecUPP(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyMethodDef HtmlObj_methods[] = { - {"HRDisposeReference", (PyCFunction)HtmlObj_HRDisposeReference, 1, - "() -> None"}, - {"HRSetGrafPtr", (PyCFunction)HtmlObj_HRSetGrafPtr, 1, - "(GrafPtr grafPtr) -> None"}, - {"HRActivate", (PyCFunction)HtmlObj_HRActivate, 1, - "() -> None"}, - {"HRDeactivate", (PyCFunction)HtmlObj_HRDeactivate, 1, - "() -> None"}, - {"HRDraw", (PyCFunction)HtmlObj_HRDraw, 1, - "(RgnHandle updateRgnH) -> None"}, - {"HRSetRenderingRect", (PyCFunction)HtmlObj_HRSetRenderingRect, 1, - "(Rect renderingRect) -> None"}, - {"HRGetRenderedImageSize", (PyCFunction)HtmlObj_HRGetRenderedImageSize, 1, - "() -> (Point renderingSize)"}, - {"HRScrollToLocation", (PyCFunction)HtmlObj_HRScrollToLocation, 1, - "() -> (Point location)"}, - {"HRForceQuickdraw", (PyCFunction)HtmlObj_HRForceQuickdraw, 1, - "(Boolean forceQuickdraw) -> None"}, - {"HRSetScrollbarState", (PyCFunction)HtmlObj_HRSetScrollbarState, 1, - "(HRScrollbarState hScrollbarState, HRScrollbarState vScrollbarState) -> None"}, - {"HRSetDrawBorder", (PyCFunction)HtmlObj_HRSetDrawBorder, 1, - "(Boolean drawBorder) -> None"}, - {"HRSetGrowboxCutout", (PyCFunction)HtmlObj_HRSetGrowboxCutout, 1, - "(Boolean allowCutout) -> None"}, - {"HRGoToFile", (PyCFunction)HtmlObj_HRGoToFile, 1, - "(FSSpec fsspec, Boolean addToHistory, Boolean forceRefresh) -> None"}, - {"HRGoToURL", (PyCFunction)HtmlObj_HRGoToURL, 1, - "(char * url, Boolean addToHistory, Boolean forceRefresh) -> None"}, - {"HRGoToAnchor", (PyCFunction)HtmlObj_HRGoToAnchor, 1, - "(char * anchorName) -> None"}, - {"HRGoToPtr", (PyCFunction)HtmlObj_HRGoToPtr, 1, - "(Buffer buffer, Boolean addToHistory, Boolean forceRefresh) -> None"}, - {"HRGetRootURL", (PyCFunction)HtmlObj_HRGetRootURL, 1, - "(Handle rootURLH) -> None"}, - {"HRGetBaseURL", (PyCFunction)HtmlObj_HRGetBaseURL, 1, - "(Handle baseURLH) -> None"}, - {"HRGetHTMLURL", (PyCFunction)HtmlObj_HRGetHTMLURL, 1, - "(Handle HTMLURLH) -> None"}, - {"HRGetTitle", (PyCFunction)HtmlObj_HRGetTitle, 1, - "(StringPtr title) -> None"}, - {"HRGetHTMLFile", (PyCFunction)HtmlObj_HRGetHTMLFile, 1, - "() -> (FSSpec fsspec)"}, - {"HRUnregisterWasURLVisitedUPP", (PyCFunction)HtmlObj_HRUnregisterWasURLVisitedUPP, 1, - "() -> None"}, - {"HRUnregisterNewURLUPP", (PyCFunction)HtmlObj_HRUnregisterNewURLUPP, 1, - "() -> None"}, - {"HRUnregisterURLToFSSpecUPP", (PyCFunction)HtmlObj_HRUnregisterURLToFSSpecUPP, 1, - "() -> None"}, - {NULL, NULL, 0} -}; - -PyMethodChain HtmlObj_chain = { HtmlObj_methods, NULL }; - -static PyObject *HtmlObj_getattr(self, name) - HtmlObjectObject *self; - char *name; -{ - return Py_FindMethodInChain(&HtmlObj_chain, (PyObject *)self, name); -} - -#define HtmlObj_setattr NULL - -#define HtmlObj_compare NULL - -#define HtmlObj_repr NULL - -#define HtmlObj_hash NULL - -PyTypeObject HtmlObject_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "HtmlRender.HtmlObject", /*tp_name*/ - sizeof(HtmlObjectObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) HtmlObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) HtmlObj_getattr, /*tp_getattr*/ - (setattrfunc) HtmlObj_setattr, /*tp_setattr*/ - (cmpfunc) HtmlObj_compare, /*tp_compare*/ - (reprfunc) HtmlObj_repr, /*tp_repr*/ - (PyNumberMethods *)0, /* tp_as_number */ - (PySequenceMethods *)0, /* tp_as_sequence */ - (PyMappingMethods *)0, /* tp_as_mapping */ - (hashfunc) HtmlObj_hash, /*tp_hash*/ -}; - -/* ------------------- End object type HtmlObject ------------------- */ - - -static PyObject *Html_HRGetHTMLRenderingLibVersion(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - NumVersion returnVers; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _err = HRGetHTMLRenderingLibVersion(&returnVers); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - PyMac_BuildNumVersion, returnVers); - return _res; -} - -static PyObject *Html_HRNewReference(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - HRReference hrRef; - OSType rendererType; - GrafPtr grafPtr; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetOSType, &rendererType, - GrafObj_Convert, &grafPtr)) - return NULL; - _err = HRNewReference(&hrRef, - rendererType, - grafPtr); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - HtmlObj_New, hrRef); - return _res; -} - -static PyObject *Html_HRFreeMemory(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - SInt32 _rv; - Size inBytesNeeded; - if (!PyArg_ParseTuple(_args, "l", - &inBytesNeeded)) - return NULL; - _rv = HRFreeMemory(inBytesNeeded); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *Html_HRScreenConfigurationChanged(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - HRScreenConfigurationChanged(); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Html_HRIsHREvent(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Boolean _rv; - EventRecord eventRecord; - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetEventRecord, &eventRecord)) - return NULL; - _rv = HRIsHREvent(&eventRecord); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Html_HRUtilCreateFullURL(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - char * rootURL; - char * linkURL; - Handle fullURLH; - if (!PyArg_ParseTuple(_args, "ssO&", - &rootURL, - &linkURL, - ResObj_Convert, &fullURLH)) - return NULL; - _err = HRUtilCreateFullURL(rootURL, - linkURL, - fullURLH); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Html_HRUtilGetFSSpecFromURL(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - char * rootURL; - char * linkURL; - FSSpec destSpec; - if (!PyArg_ParseTuple(_args, "ss", - &rootURL, - &linkURL)) - return NULL; - _err = HRUtilGetFSSpecFromURL(rootURL, - linkURL, - &destSpec); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - PyMac_BuildFSSpec, destSpec); - return _res; -} - -static PyObject *Html_HRUtilGetURLFromFSSpec(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - OSStatus _err; - FSSpec fsspec; - Handle urlHandle; - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetFSSpec, &fsspec, - ResObj_Convert, &urlHandle)) - return NULL; - _err = HRUtilGetURLFromFSSpec(&fsspec, - urlHandle); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Html_HRHTMLRenderingLibAvailable(_self, _args) - PyObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - int _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = HRHTMLRenderingLibAvailable(); - _res = Py_BuildValue("i", - _rv); - return _res; -} - -static PyMethodDef Html_methods[] = { - {"HRGetHTMLRenderingLibVersion", (PyCFunction)Html_HRGetHTMLRenderingLibVersion, 1, - "() -> (NumVersion returnVers)"}, - {"HRNewReference", (PyCFunction)Html_HRNewReference, 1, - "(OSType rendererType, GrafPtr grafPtr) -> (HRReference hrRef)"}, - {"HRFreeMemory", (PyCFunction)Html_HRFreeMemory, 1, - "(Size inBytesNeeded) -> (SInt32 _rv)"}, - {"HRScreenConfigurationChanged", (PyCFunction)Html_HRScreenConfigurationChanged, 1, - "() -> None"}, - {"HRIsHREvent", (PyCFunction)Html_HRIsHREvent, 1, - "(EventRecord eventRecord) -> (Boolean _rv)"}, - {"HRUtilCreateFullURL", (PyCFunction)Html_HRUtilCreateFullURL, 1, - "(char * rootURL, char * linkURL, Handle fullURLH) -> None"}, - {"HRUtilGetFSSpecFromURL", (PyCFunction)Html_HRUtilGetFSSpecFromURL, 1, - "(char * rootURL, char * linkURL) -> (FSSpec destSpec)"}, - {"HRUtilGetURLFromFSSpec", (PyCFunction)Html_HRUtilGetURLFromFSSpec, 1, - "(FSSpec fsspec, Handle urlHandle) -> None"}, - {"HRHTMLRenderingLibAvailable", (PyCFunction)Html_HRHTMLRenderingLibAvailable, 1, - "() -> (int _rv)"}, - {NULL, NULL, 0} -}; - - - - -void initHtmlRender() -{ - PyObject *m; - PyObject *d; - - - - - m = Py_InitModule("HtmlRender", Html_methods); - d = PyModule_GetDict(m); - Html_Error = PyMac_GetOSErrException(); - if (Html_Error == NULL || - PyDict_SetItemString(d, "Error", Html_Error) != 0) - Py_FatalError("can't initialize HtmlRender.Error"); - HtmlObject_Type.ob_type = &PyType_Type; - Py_INCREF(&HtmlObject_Type); - if (PyDict_SetItemString(d, "HtmlObjectType", (PyObject *)&HtmlObject_Type) != 0) - Py_FatalError("can't initialize HtmlObjectType"); -} - -/* ===================== End module HtmlRender ====================== */ - diff --git a/Mac/Modules/htmlrender/htmlscan.py b/Mac/Modules/htmlrender/htmlscan.py deleted file mode 100644 index 81f107c..0000000 --- a/Mac/Modules/htmlrender/htmlscan.py +++ /dev/null @@ -1,63 +0,0 @@ -# Scan an Apple header file, generating a Python file of generator calls. - -import sys -import os -from bgenlocations import TOOLBOXDIR, BGENDIR -sys.path.append(BGENDIR) - -from scantools import Scanner - -LONG = "HtmlRendering" -SHORT = "html" -OBJECT = "HRReference" - -def main(): -## input = LONG + ".h" - input = "Macintosh HD:ufs:jack:SWdev:Universal:Interfaces:CIncludes:HTMLRendering.h" - output = SHORT + "gen.py" - defsoutput = TOOLBOXDIR + LONG + ".py" - scanner = MyScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Testing definitions output code ===" - execfile(defsoutput, {}, {}) - print "=== Done scanning and generating, now importing the generated code... ===" - exec "import " + SHORT + "support" - print "=== Done. It's up to you to compile it now! ===" - -class MyScanner(Scanner): - - def destination(self, type, name, arglist): - classname = "Function" - listname = "functions" - if arglist: - t, n, m = arglist[0] - if t == OBJECT and m == "InMode": - classname = "Method" - listname = "methods" - return classname, listname - - def makeblacklistnames(self): - return [ - "HRDisposeReference", - ] - - def makeblacklisttypes(self): - return [ - "HRNewURLUPP", - "HRURLToFSSpecUPP", - "HRWasURLVisitedUPP", - ] - - def makerepairinstructions(self): - return [ - ([('char', '*', 'OutMode'), ('UInt32', '*', 'InMode')], - [('InBuffer', '*', 'InMode')]), - ] - - def writeinitialdefs(self): - self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") - - -if __name__ == "__main__": - main() diff --git a/Mac/Modules/htmlrender/htmlsupport.py b/Mac/Modules/htmlrender/htmlsupport.py deleted file mode 100644 index e769018..0000000 --- a/Mac/Modules/htmlrender/htmlsupport.py +++ /dev/null @@ -1,213 +0,0 @@ -# This script generates the Dialogs interface for Python. -# It uses the "bgen" package to generate C code. -# It execs the file dlggen.py which contain the function definitions -# (dlggen.py was generated by dlgscan.py, scanning the <Dialogs.h> header file). - -from macsupport import * - -# Create the type objects - -HRReference = OpaqueByValueType("HRReference", "HtmlObj") - -HRScrollbarState = Type("HRScrollbarState", "h") -URLSourceType = Type("URLSourceType", "H") -GrafPtr = OpaqueByValueType("GrafPtr", "GrafObj") -RgnHandle = OpaqueByValueType("RgnHandle", "ResObj") -char_ptr = Type("char *", "s") -StringPtr = Type("StringPtr", "s") - -### An OptHandle is either a handle or None (in case NULL is passed in). -### This is needed for GetDialogItem(). -##OptHandle = OpaqueByValueType("Handle", "OptResObj") -## -##ModalFilterProcPtr = InputOnlyType("PyObject*", "O") -##ModalFilterProcPtr.passInput = lambda name: "NewModalFilterProc(Dlg_PassFilterProc(%s))" % name -##ModalFilterUPP = ModalFilterProcPtr -## -## -##DITLMethod = Type("DITLMethod", "h") -##DialogItemIndex = Type("DialogItemIndex", "h") -##DialogItemType = Type("DialogItemType", "h") -##DialogItemIndexZeroBased = Type("DialogItemIndexZeroBased", "h") -##AlertType = Type("AlertType", "h") -##StringPtr = Str255 -##EventMask = Type("EventMask", "h") -## -includestuff = includestuff + """ -#include <HTMLRendering.h> -""" -## -###ifndef HAVE_UNIVERSAL_HEADERS -###define NewModalFilterProc(x) (x) -###endif -## -###define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */ -## -##/* XXX Shouldn't this be a stack? */ -##static PyObject *Dlg_FilterProc_callback = NULL; -## -##static PyObject *DlgObj_New(DialogPtr); /* Forward */ -## -##static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog, -## EventRecord *event, -## short *itemHit) -##{ -## Boolean rv; -## PyObject *args, *res; -## PyObject *callback = Dlg_FilterProc_callback; -## if (callback == NULL) -## return 0; /* Default behavior */ -## Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */ -## args = Py_BuildValue("O&O&", WinObj_WhichWindow, dialog, PyMac_BuildEventRecord, event); -## if (args == NULL) -## res = NULL; -## else { -## res = PyEval_CallObject(callback, args); -## Py_DECREF(args); -## } -## if (res == NULL) { -## PySys_WriteStderr("Exception in Dialog Filter\\n"); -## PyErr_Print(); -## *itemHit = -1; /* Fake return item */ -## return 1; /* We handled it */ -## } -## else { -## Dlg_FilterProc_callback = callback; -## if (PyInt_Check(res)) { -## *itemHit = PyInt_AsLong(res); -## rv = 1; -## } -## else -## rv = PyObject_IsTrue(res); -## } -## Py_DECREF(res); -## return rv; -##} -## -##static ModalFilterProcPtr -##Dlg_PassFilterProc(PyObject *callback) -##{ -## PyObject *tmp = Dlg_FilterProc_callback; -## Dlg_FilterProc_callback = NULL; -## if (callback == Py_None) { -## Py_XDECREF(tmp); -## return NULL; -## } -## Py_INCREF(callback); -## Dlg_FilterProc_callback = callback; -## Py_XDECREF(tmp); -## return &Dlg_UnivFilterProc; -##} -## -##static PyObject *Dlg_UserItemProc_callback = NULL; -## -##static pascal void Dlg_UnivUserItemProc(DialogPtr dialog, -## short item) -##{ -## PyObject *args, *res; -## -## if (Dlg_UserItemProc_callback == NULL) -## return; /* Default behavior */ -## Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */ -## args = Py_BuildValue("O&h", WinObj_WhichWindow, dialog, item); -## if (args == NULL) -## res = NULL; -## else { -## res = PyEval_CallObject(Dlg_UserItemProc_callback, args); -## Py_DECREF(args); -## } -## if (res == NULL) { -## PySys_WriteStderr("Exception in Dialog UserItem proc\\n"); -## PyErr_Print(); -## } -## Py_XDECREF(res); -## return; -##} -## -##extern PyMethodChain WinObj_chain; -##""" -## - -# Define a class which specializes our object definition -class MyObjectDefinition(GlobalObjectDefinition): - pass -## def __init__(self, name, prefix = None, itselftype = None): -## GlobalObjectDefinition.__init__(self, name, prefix, itselftype) -## self.basechain = "&WinObj_chain" -## def outputInitStructMembers(self): -## GlobalObjectDefinition.outputInitStructMembers(self) -## Output("SetWRefCon(itself, (long)it);") -## def outputCheckNewArg(self): -## Output("if (itself == NULL) return Py_None;") -## def outputCheckConvertArg(self): -## Output("if (v == Py_None) { *p_itself = NULL; return 1; }") -## Output("if (PyInt_Check(v)) { *p_itself = (DialogPtr)PyInt_AsLong(v);") -## Output(" return 1; }") - def outputFreeIt(self, itselfname): - Output("HRDisposeReference(%s);", itselfname) - -# Create the generator groups and link them -module = MacModule('HtmlRender', 'Html', includestuff, finalstuff, initstuff) -object = MyObjectDefinition('HtmlObject', 'HtmlObj', 'HRReference') -module.addobject(object) - -# Create the generator classes used to populate the lists -Function = OSErrFunctionGenerator -Method = OSErrMethodGenerator - -# Create and populate the lists -functions = [] -methods = [] -execfile("htmlgen.py") - -f = Function(int, 'HRHTMLRenderingLibAvailable') -functions.append(f) - -# add the populated lists to the generator groups -for f in functions: module.add(f) -for f in methods: object.add(f) - -### Some methods that are currently macro's in C, but will be real routines -### in MacOS 8. -## -##f = Method(ExistingDialogPtr, 'GetDialogWindow', (DialogRef, 'dialog', InMode)) -##object.add(f) -##f = Method(SInt16, 'GetDialogDefaultItem', (DialogRef, 'dialog', InMode)) -##object.add(f) -##f = Method(SInt16, 'GetDialogCancelItem', (DialogRef, 'dialog', InMode)) -##object.add(f) -##f = Method(SInt16, 'GetDialogKeyboardFocusItem', (DialogRef, 'dialog', InMode)) -##object.add(f) -##f = Method(void, 'SetGrafPortOfDialog', (DialogRef, 'dialog', InMode)) -##object.add(f) -## -##setuseritembody = """ -## PyObject *new = NULL; -## -## -## if (!PyArg_ParseTuple(_args, "|O", &new)) -## return NULL; -## -## if (Dlg_UserItemProc_callback && new && new != Py_None) { -## PyErr_SetString(Dlg_Error, "Another UserItemProc is already installed"); -## return NULL; -## } -## -## if (new == Py_None) { -## new = NULL; -## _res = Py_None; -## Py_INCREF(Py_None); -## } else { -## Py_INCREF(new); -## _res = Py_BuildValue("O&", ResObj_New, (Handle)NewUserItemProc(Dlg_UnivUserItemProc)); -## } -## -## Dlg_UserItemProc_callback = new; -## return _res; -##""" -##f = ManualGenerator("SetUserItemHandler", setuseritembody) -##module.add(f) - -# generate output -SetOutputFileName('HtmlRendermodule.c') -module.generate() diff --git a/Mac/Modules/macconfig.c b/Mac/Modules/macconfig.c deleted file mode 100644 index 7a6d3d9..0000000 --- a/Mac/Modules/macconfig.c +++ /dev/null @@ -1,322 +0,0 @@ -/*********************************************************** -Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* Macintosh Python configuration file */ - -#include "Python.h" -/* Table of built-in modules. - These are initialized when first imported. - Note: selection of optional extensions is now generally done by the - makesetup script. */ - -extern void initarray(); -extern void initmath(); -#ifndef WITHOUT_COMPLEX -extern void initcmath(); -#endif -extern void initparser(); -extern void initmac(); -extern void initMacOS(); -extern void initregex(); -extern void initstrop(); -extern void initstruct(); -extern void inittime(); -extern void initdbm(); -extern void initfcntl(); -extern void initnis(); -extern void initpwd(); -extern void initgrp(); -extern void initcrypt(); -extern void initselect(); -extern void init_socket(); -extern void initaudioop(); -extern void initimageop(); -extern void initrgbimg(); -extern void initmd5(); -extern void initmpz(); -extern void initrotor(); -extern void inital(); -extern void initcd(); -extern void initcl(); -extern void initfm(); -extern void initgl(); -extern void initimgfile(); -extern void initimgformat(); -extern void initsgi(); -extern void initsv(); -extern void initfl(); -extern void initthread(); -extern void inittiming(); -extern void initsignal(); -extern void initdl(); -extern void initsyslog(); -extern void initgestalt(); -extern void initbinascii(); -extern void initoperator(); -extern void initerrno(); -extern void initpcre(); -extern void initunicodedata(); -extern void init_codecs(); -extern void initNav(); -extern void inithfsplus(); -#ifdef USE_MACCTB -extern void initctb(); -#endif -#ifdef USE_MACSPEECH -extern void initmacspeech(); -#endif -#ifdef USE_IC -extern void initicglue(); -#endif -#ifdef USE_TOOLBOX -#ifndef USE_CORE_TOOLBOX -#define USE_CORE_TOOLBOX -#endif -extern void init_AH(); -extern void init_App(); -extern void init_Fm(); -extern void init_Help(); -extern void init_IBCarbon(); -extern void init_Icn(); -extern void init_List(); -extern void init_Mlte(); -extern void init_Qdoffs(); -extern void init_Snd(); -extern void init_Sndihooks(); -extern void init_Scrap(); -extern void init_TE(); -extern void initColorPicker(); -extern void initPrinting(); -extern void init_CF(); -#endif -#ifdef USE_CORE_TOOLBOX -extern void init_AE(); -extern void init_Ctl(); -extern void init_Dlg(); -extern void init_Drag(); -extern void init_Evt(); -extern void init_File(); -extern void init_Folder(); -extern void init_Menu(); -extern void init_Qd(); -extern void init_Res(); -extern void init_Win(); -#endif -#ifdef USE_QT -extern void init_Cm(); -extern void init_Qt(); -#endif - -#ifdef USE_IMG -extern void initimgcolormap(); -extern void initimgformat(); -extern void initimggif(); -extern void initimgjpeg(); -extern void initimgpbm(); -extern void initimgppm(); -extern void initimgpgm(); -extern void initimgtiff(); -extern void initimgsgi(); -extern void initimgpng(); -extern void initimgop(); -#endif -#ifdef USE_TK -extern void init_tkinter(); -#endif -#ifdef USE_GUSI -extern void init_socket(); -extern void initselect(); -#endif -#ifdef USE_WASTE -extern void initwaste(); -#endif -#ifdef USE_GDBM -extern void initgdbm(); -#endif -#ifdef USE_ZLIB -extern void initzlib(); -#endif -#ifdef WITH_THREAD -extern void initthread(); -#endif -#ifdef WITH_HOTSHOT -extern void init_hotshot(); -#endif -#ifdef USE_PYEXPAT -extern void initpyexpat(); -#endif -extern void initgc(); -extern void init_random(); - -extern void initcPickle(); -extern void initcStringIO(); -extern void init_codecs(); -extern void initsha(); -extern void init_locale(); -extern void init_sre(); -extern void initxreadlines(); -extern void initzipimport(); -extern void inititertools(); -/* -- ADDMODULE MARKER 1 -- */ - -extern void PyMarshal_Init(); -extern void initimp(); - -struct _inittab _PyImport_Inittab[] = { - - {"array", initarray}, - {"math", initmath}, -#ifndef WITHOUT_COMPLEX - {"cmath", initcmath}, -#endif - {"parser", initparser}, - {"mac", initmac}, - {"MacOS", initMacOS}, - {"regex", initregex}, - {"strop", initstrop}, - {"struct", initstruct}, - {"time", inittime}, - {"audioop", initaudioop}, - {"imageop", initimageop}, - {"rgbimg", initrgbimg}, - {"md5", initmd5}, - {"rotor", initrotor}, - {"gestalt", initgestalt}, - {"binascii", initbinascii}, - {"operator", initoperator}, - {"errno", initerrno}, - {"pcre", initpcre}, - {"unicodedata", initunicodedata}, - {"_codecs", init_codecs}, - {"sha", initsha}, - {"Nav", initNav}, -#ifdef USE_MACCTB - {"ctb", initctb}, -#endif -/* This could probably be made to work on other compilers... */ -#ifdef USE_MACSPEECH - {"macspeech", initmacspeech}, -#endif -#ifdef USE_IC - {"icglue", initicglue}, -#endif -#ifdef USE_CORE_TOOLBOX - {"_AE", init_AE}, - {"_Ctl", init_Ctl}, - {"_Dlg", init_Dlg}, - {"_Drag", init_Drag}, - {"_Evt", init_Evt}, - {"_File", init_File}, - {"_Folder", init_Folder}, - {"_Menu", init_Menu}, - {"_Qd", init_Qd}, - {"_Win", init_Win}, - {"_Res", init_Res}, -#endif -#ifdef USE_TOOLBOX - {"_AH", init_AH}, - {"_App", init_App}, - {"_Fm", init_Fm}, - {"_IBCarbon", init_IBCarbon}, - {"_Icn", init_Icn}, - {"_List", init_List}, - {"_Mlte", init_Mlte}, - {"_Qdoffs", init_Qdoffs}, - {"_Snd", init_Snd}, - {"_Sndihooks", init_Sndihooks}, - /* Carbon scrap manager is completely different */ - {"_Scrap", init_Scrap}, - {"_TE", init_TE}, - {"ColorPicker", initColorPicker}, - {"_CF", init_CF}, - {"hfsplus", inithfsplus}, -#endif /* USE_TOOLBOX */ -#ifdef USE_QT - {"_Cm", init_Cm}, - {"_Qt", init_Qt}, -#endif -#ifdef USE_IMG - {"imgcolormap", initimgcolormap}, - {"imgformat", initimgformat}, - {"imggif", initimggif}, - {"imgjpeg", initimgjpeg}, - {"imgpbm", initimgpbm}, - {"imgppm", initimgppm}, - {"imgpgm", initimgpgm}, - {"imgtiff", initimgtiff}, - {"imgsgi", initimgsgi}, - {"imgpng", initimgpng}, - {"imgop", initimgop}, -#endif -#ifdef USE_TK - {"_tkinter", init_tkinter}, -#endif -#ifdef USE_GUSI - {"_socket", init_socket}, - {"select", initselect}, -#endif -#ifdef USE_WASTE - {"waste", initwaste}, -#endif -#ifdef USE_GDBM - {"gdbm", initgdbm}, -#endif /* USE_GDBM */ -#ifdef USE_ZLIB - {"zlib", initzlib}, -#endif -#ifdef WITH_THREAD - {"thread", initthread}, -#endif -#ifdef WITH_HOTSHOT - {"_hotshot", init_hotshot}, -#endif -#ifdef USE_PYEXPAT - {"pyexpat", initpyexpat}, -#endif - {"gc", initgc}, - {"_random", init_random}, - {"cPickle", initcPickle}, - {"cStringIO", initcStringIO}, - {"_locale", init_locale}, - {"_sre", init_sre}, - {"xreadlines", initxreadlines}, - {"zipimport", initzipimport}, - {"itertools", inititertools}, -/* -- ADDMODULE MARKER 2 -- */ - - /* This module "lives in" with marshal.c */ - {"marshal", PyMarshal_Init}, - - /* This module "lives in" with import.c */ - {"imp", initimp}, - - /* These entries are here for sys.builtin_module_names */ - {"__main__", NULL}, - {"__builtin__", NULL}, - {"exceptions", NULL}, - {"sys", NULL}, - - /* Sentinel */ - {0, 0} -}; diff --git a/Mac/Modules/macmodule.c b/Mac/Modules/macmodule.c deleted file mode 100644 index fb62286..0000000 --- a/Mac/Modules/macmodule.c +++ /dev/null @@ -1,727 +0,0 @@ -/*********************************************************** -Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* Mac module implementation */ - -#include "Python.h" -#include "structseq.h" -#include "ceval.h" - -#include <stdio.h> -#include <string.h> -#include <errno.h> - -#ifdef USE_GUSI -/* Remove defines from macstat.h */ -#undef S_IFMT -#undef S_IFDIR -#undef S_IFREG -#undef S_IREAD -#undef S_IWRITE -#undef S_IEXEC - -#include <sys/types.h> -#include <sys/stat.h> -#else /* USE_GUSI */ -#endif /* USE_GUSI */ - -#ifdef USE_GUSI2 -#include <unistd.h> -#include <fcntl.h> -#else -#define mode_t int -#include <fcntl.h> -#ifdef _POSIX -#include <unistd.h> -#include <stat.h> -#endif -#endif - -/* Optional routines, for some compiler/runtime combinations */ -#if defined(USE_GUSI) || !defined(__MWERKS__) -#define WEHAVE_FDOPEN -#endif -#if defined(MPW) || defined(USE_GUSI) -#define WEHAVE_DUP -#endif -#if defined(USE_GUSI) -#define WEHAVE_FSTAT -#endif - -#include "macdefs.h" -#ifdef USE_GUSI -#include <dirent.h> -#else -#include "dirent.h" -#endif - -#ifndef MAXPATHLEN -#define MAXPATHLEN 1024 -#endif - -/* Prototypes for Unix simulation on Mac */ - -#ifndef USE_GUSI - -int chdir(const char *path); -int mkdir(const char *path, int mode); -DIR * opendir(char *); -void closedir(DIR *); -struct dirent * readdir(DIR *); -int rmdir(const char *path); -int sync(void); - -int unlink(const char *); - -#endif /* USE_GUSI */ - -char *getwd(char *); -char *getbootvol(void); - - -/* Set a MAC-specific error from errno, and return NULL */ - -static PyObject * -mac_error() -{ - return PyErr_SetFromErrno(PyExc_OSError); -} - -/* MAC generic methods */ - -static PyObject * -mac_1str(args, func) - PyObject *args; - int (*func)(const char *); -{ - char *path1; - int res; - if (!PyArg_ParseTuple(args, "s", &path1)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = (*func)(path1); - Py_END_ALLOW_THREADS - if (res < 0) - return mac_error(); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -mac_2str(args, func) - PyObject *args; - int (*func)(const char *, const char *); -{ - char *path1, *path2; - int res; - if (!PyArg_ParseTuple(args, "ss", &path1, &path2)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = (*func)(path1, path2); - Py_END_ALLOW_THREADS - if (res < 0) - return mac_error(); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -mac_strint(args, func) - PyObject *args; - int (*func)(const char *, int); -{ - char *path; - int i; - int res; - if (!PyArg_ParseTuple(args, "si", &path, &i)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = (*func)(path, i); - Py_END_ALLOW_THREADS - if (res < 0) - return mac_error(); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -mac_chdir(self, args) - PyObject *self; - PyObject *args; -{ - return mac_1str(args, chdir); -} - -static PyObject * -mac_close(self, args) - PyObject *self; - PyObject *args; -{ - int fd, res; - if (!PyArg_ParseTuple(args, "i", &fd)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = close(fd); - Py_END_ALLOW_THREADS - if (res < 0) - return mac_error(); - Py_INCREF(Py_None); - return Py_None; -} - -#ifdef WEHAVE_DUP - -static PyObject * -mac_dup(self, args) - PyObject *self; - PyObject *args; -{ - int fd; - if (!PyArg_ParseTuple(args, "i", &fd)) - return NULL; - Py_BEGIN_ALLOW_THREADS - fd = dup(fd); - Py_END_ALLOW_THREADS - if (fd < 0) - return mac_error(); - return PyInt_FromLong((long)fd); -} - -#endif - -#ifdef WEHAVE_FDOPEN -static PyObject * -mac_fdopen(self, args) - PyObject *self; - PyObject *args; -{ - extern int fclose(FILE *); - int fd; - char *mode = "r"; - int bufsize = -1; - FILE *fp; - PyObject *f; - if (!PyArg_ParseTuple(args, "i|si", &fd, &mode, &bufsize)) - return NULL; - Py_BEGIN_ALLOW_THREADS - fp = fdopen(fd, mode); - Py_END_ALLOW_THREADS - if (fp == NULL) - return mac_error(); - f = PyFile_FromFile(fp, "<fdopen>", mode, fclose); - if (f != NULL) - PyFile_SetBufSize(f, bufsize); - return f; -} -#endif - -static PyObject * -mac_getcwd(self, args) - PyObject *self; - PyObject *args; -{ - char path[MAXPATHLEN]; - char *res; - if (!PyArg_ParseTuple(args, "")) - return NULL; - Py_BEGIN_ALLOW_THREADS -#ifdef USE_GUSI - res = getcwd(path, sizeof path); -#else - res = getwd(path); -#endif - Py_END_ALLOW_THREADS - if (res == NULL) { - return mac_error(); - } - return PyString_FromString(res); -} - -static PyObject * -mac_listdir(self, args) - PyObject *self; - PyObject *args; -{ - char *name; - PyObject *d, *v; - DIR *dirp; - struct dirent *ep; - if (!PyArg_ParseTuple(args, "s", &name)) - return NULL; -#ifdef USE_GUSI - /* Work around a bug in GUSI: if you opendir() a file it will - ** actually opendir() the parent directory. - */ - { - struct stat stb; - int res; - - res = stat(name, &stb); - if ( res < 0 ) - return mac_error(); - if (!S_ISDIR(stb.st_mode) ) { - errno = ENOTDIR; - return mac_error(); - } - } -#endif - - Py_BEGIN_ALLOW_THREADS - if ((dirp = opendir(name)) == NULL) { - Py_BLOCK_THREADS - return mac_error(); - } - if ((d = PyList_New(0)) == NULL) { - closedir(dirp); - Py_BLOCK_THREADS - return NULL; - } - while ((ep = readdir(dirp)) != NULL) { - v = PyString_FromString(ep->d_name); - if (v == NULL) { - Py_DECREF(d); - d = NULL; - break; - } - if (PyList_Append(d, v) != 0) { - Py_DECREF(v); - Py_DECREF(d); - d = NULL; - break; - } - Py_DECREF(v); - } - closedir(dirp); - Py_END_ALLOW_THREADS - - return d; -} - -static PyObject * -mac_lseek(self, args) - PyObject *self; - PyObject *args; -{ - int fd; - int where; - int how; - long res; - if (!PyArg_ParseTuple(args, "iii", &fd, &where, &how)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = lseek(fd, (long)where, how); - Py_END_ALLOW_THREADS - if (res < 0) - return mac_error(); - return PyInt_FromLong(res); -} - -static PyObject * -mac_mkdir(self, args) - PyObject *self; - PyObject *args; -{ - int res; - char *path; - int mode = 0777; /* Unused */ - if (!PyArg_ParseTuple(args, "s|i", &path, &mode)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = mkdir(path, mode); - Py_END_ALLOW_THREADS - if (res < 0) - return mac_error(); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -mac_open(self, args) - PyObject *self; - PyObject *args; -{ - char *path; - int mode; - int perm; /* Accepted but ignored */ - int fd; - if (!PyArg_ParseTuple(args, "si|i", &path, &mode, &perm)) - return NULL; - Py_BEGIN_ALLOW_THREADS - fd = open(path, mode); - Py_END_ALLOW_THREADS - if (fd < 0) - return mac_error(); - return PyInt_FromLong((long)fd); -} - -static PyObject * -mac_read(self, args) - PyObject *self; - PyObject *args; -{ - int fd, size; - PyObject *buffer; - if (!PyArg_ParseTuple(args, "ii", &fd, &size)) - return NULL; - buffer = PyString_FromStringAndSize((char *)NULL, size); - if (buffer == NULL) - return NULL; - Py_BEGIN_ALLOW_THREADS - size = read(fd, PyString_AsString(buffer), size); - Py_END_ALLOW_THREADS - if (size < 0) { - Py_DECREF(buffer); - return mac_error(); - } - _PyString_Resize(&buffer, size); - return buffer; -} - -static PyObject * -mac_rename(self, args) - PyObject *self; - PyObject *args; -{ - return mac_2str(args, rename); -} - -static PyObject * -mac_rmdir(self, args) - PyObject *self; - PyObject *args; -{ - return mac_1str(args, rmdir); -} - -static char stat_result__doc__[] = -"stat_result: Result from stat or lstat.\n\n\ -This object may be accessed either as a tuple of\n\ - (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)\n\ -or via the attributes st_mode, st_ino, st_dev, st_nlink, st_uid, and so on.\n\ -\n\ -See os.stat for more information.\n"; - -#define COMMON_STAT_RESULT_FIELDS \ - { "st_mode", "protection bits" }, \ - { "st_ino", "inode" }, \ - { "st_dev", "device" }, \ - { "st_nlink", "number of hard links" }, \ - { "st_uid", "user ID of owner" }, \ - { "st_gid", "group ID of owner" }, \ - { "st_size", "total size, in bytes" }, \ - { "st_atime", "time of last access" }, \ - { "st_mtime", "time of last modification" }, \ - { "st_ctime", "time of last change" }, - - - -static PyStructSequence_Field stat_result_fields[] = { - COMMON_STAT_RESULT_FIELDS - {0} -}; - -static PyStructSequence_Desc stat_result_desc = { - "mac.stat_result", - stat_result__doc__, - stat_result_fields, - 10 -}; - -static PyTypeObject StatResultType; - -static PyObject * -_pystat_from_struct_stat(struct stat st, void* _mst) -{ - PyObject *v; - - v = PyStructSequence_New(&StatResultType); - PyStructSequence_SET_ITEM(v, 0, PyInt_FromLong((long)st.st_mode)); - PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long)st.st_ino)); - PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long)st.st_dev)); - PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long)st.st_nlink)); - PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long)st.st_uid)); - PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long)st.st_gid)); - PyStructSequence_SET_ITEM(v, 6, PyInt_FromLong((long)st.st_size)); - PyStructSequence_SET_ITEM(v, 7, - PyFloat_FromDouble((double)st.st_atime)); - PyStructSequence_SET_ITEM(v, 8, - PyFloat_FromDouble((double)st.st_mtime)); - PyStructSequence_SET_ITEM(v, 9, - PyFloat_FromDouble((double)st.st_ctime)); - if (PyErr_Occurred()) { - Py_DECREF(v); - return NULL; - } - - return v; -} - - -static PyObject * -mac_stat(self, args) - PyObject *self; - PyObject *args; -{ - struct stat st; - char *path; - int res; - if (!PyArg_ParseTuple(args, "s", &path)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = stat(path, &st); - Py_END_ALLOW_THREADS - if (res != 0) - return mac_error(); - - return _pystat_from_struct_stat(st, NULL); -} - -#ifdef WEHAVE_FSTAT -static PyObject * -mac_fstat(self, args) - PyObject *self; - PyObject *args; -{ - struct stat st; - long fd; - int res; - if (!PyArg_ParseTuple(args, "l", &fd)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = fstat((int)fd, &st); - Py_END_ALLOW_THREADS - if (res != 0) - return mac_error(); - - return _pystat_from_struct_stat(st, NULL); -} -#endif /* WEHAVE_FSTAT */ - -static PyObject * -mac_sync(self, args) - PyObject *self; - PyObject *args; -{ - int res; - if (!PyArg_ParseTuple(args, "")) - return NULL; - Py_BEGIN_ALLOW_THREADS -#ifdef USE_GUSI2 - sync(); - res = 0; -#else - res = sync(); -#endif - Py_END_ALLOW_THREADS - if (res != 0) - return mac_error(); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -mac_unlink(self, args) - PyObject *self; - PyObject *args; -{ - return mac_1str(args, (int (*)(const char *))unlink); -} - -static PyObject * -mac_write(self, args) - PyObject *self; - PyObject *args; -{ - int fd, size; - char *buffer; - if (!PyArg_ParseTuple(args, "is#", &fd, &buffer, &size)) - return NULL; - Py_BEGIN_ALLOW_THREADS - size = write(fd, buffer, size); - Py_END_ALLOW_THREADS - if (size < 0) - return mac_error(); - return PyInt_FromLong((long)size); -} - -#ifdef USE_MALLOC_DEBUG -void *mstats(char *); - -static PyObject * -mac_mstats(self, args) - PyObject*self; - PyObject *args; -{ - mstats("python"); - Py_INCREF(Py_None); - return Py_None; -} -#endif /* USE_MALLOC_DEBUG */ - -static struct PyMethodDef mac_methods[] = { - {"chdir", mac_chdir, 1}, - {"close", mac_close, 1}, -#ifdef WEHAVE_DUP - {"dup", mac_dup, 1}, -#endif -#ifdef WEHAVE_FDOPEN - {"fdopen", mac_fdopen, 1}, -#endif -#ifdef WEHAVE_FSTAT - {"fstat", mac_fstat, 1}, -#endif - {"getcwd", mac_getcwd, 1}, - {"listdir", mac_listdir, 1}, - {"lseek", mac_lseek, 1}, - {"mkdir", mac_mkdir, 1}, - {"open", mac_open, 1}, - {"read", mac_read, 1}, - {"rename", mac_rename, 1}, - {"rmdir", mac_rmdir, 1}, - {"stat", mac_stat, 1}, - {"sync", mac_sync, 1}, - {"remove", mac_unlink, 1}, - {"unlink", mac_unlink, 1}, - {"write", mac_write, 1}, -#ifdef USE_MALLOC_DEBUG - {"mstats", mac_mstats, 1}, -#endif - - {NULL, NULL} /* Sentinel */ -}; - -static int -ins(PyObject *d, char *symbol, long value) -{ - PyObject* v = PyInt_FromLong(value); - if (!v || PyDict_SetItemString(d, symbol, v) < 0) - return -1; /* triggers fatal error */ - - Py_DECREF(v); - return 0; -} - -static int -all_ins(PyObject *d) -{ -#ifdef F_OK - if (ins(d, "F_OK", (long)F_OK)) return -1; -#endif -#ifdef R_OK - if (ins(d, "R_OK", (long)R_OK)) return -1; -#endif -#ifdef W_OK - if (ins(d, "W_OK", (long)W_OK)) return -1; -#endif -#ifdef X_OK - if (ins(d, "X_OK", (long)X_OK)) return -1; -#endif -#ifdef NGROUPS_MAX - if (ins(d, "NGROUPS_MAX", (long)NGROUPS_MAX)) return -1; -#endif -#ifdef TMP_MAX - if (ins(d, "TMP_MAX", (long)TMP_MAX)) return -1; -#endif -#ifdef WNOHANG - if (ins(d, "WNOHANG", (long)WNOHANG)) return -1; -#endif -#ifdef O_RDONLY - if (ins(d, "O_RDONLY", (long)O_RDONLY)) return -1; -#endif -#ifdef O_WRONLY - if (ins(d, "O_WRONLY", (long)O_WRONLY)) return -1; -#endif -#ifdef O_RDWR - if (ins(d, "O_RDWR", (long)O_RDWR)) return -1; -#endif -#ifdef O_NDELAY - if (ins(d, "O_NDELAY", (long)O_NDELAY)) return -1; -#endif -#ifdef O_NONBLOCK - if (ins(d, "O_NONBLOCK", (long)O_NONBLOCK)) return -1; -#endif -#ifdef O_APPEND - if (ins(d, "O_APPEND", (long)O_APPEND)) return -1; -#endif -#ifdef O_DSYNC - if (ins(d, "O_DSYNC", (long)O_DSYNC)) return -1; -#endif -#ifdef O_RSYNC - if (ins(d, "O_RSYNC", (long)O_RSYNC)) return -1; -#endif -#ifdef O_SYNC - if (ins(d, "O_SYNC", (long)O_SYNC)) return -1; -#endif -#ifdef O_NOCTTY - if (ins(d, "O_NOCTTY", (long)O_NOCTTY)) return -1; -#endif -#ifdef O_CREAT - if (ins(d, "O_CREAT", (long)O_CREAT)) return -1; -#endif -#ifdef O_EXCL - if (ins(d, "O_EXCL", (long)O_EXCL)) return -1; -#endif -#ifdef O_TRUNC - if (ins(d, "O_TRUNC", (long)O_TRUNC)) return -1; -#endif -#ifdef O_BINARY - if (ins(d, "O_BINARY", (long)O_BINARY)) return -1; -#endif -#ifdef O_TEXT - if (ins(d, "O_TEXT", (long)O_TEXT)) return -1; -#endif - -#ifdef HAVE_SPAWNV - if (ins(d, "P_WAIT", (long)_P_WAIT)) return -1; - if (ins(d, "P_NOWAIT", (long)_P_NOWAIT)) return -1; - if (ins(d, "P_OVERLAY", (long)_OLD_P_OVERLAY)) return -1; - if (ins(d, "P_NOWAITO", (long)_P_NOWAITO)) return -1; - if (ins(d, "P_DETACH", (long)_P_DETACH)) return -1; -#endif - -#if defined(PYOS_OS2) - if (insertvalues(d)) return -1; -#endif - return 0; -} - - -void -initmac() -{ - PyObject *m, *d; - - m = Py_InitModule("mac", mac_methods); - d = PyModule_GetDict(m); - - if (all_ins(d)) - return; - - /* Initialize mac.error exception */ - PyDict_SetItemString(d, "error", PyExc_OSError); - - PyStructSequence_InitType(&StatResultType, &stat_result_desc); - PyDict_SetItemString(d, "stat_result", (PyObject*) &StatResultType); - -} |