| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | /***********************************************************
 | 
					
						
							| 
									
										
										
										
											1997-01-31 16:15:11 +00:00
										 |  |  | Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 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. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ******************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "Python.h"
 | 
					
						
							|  |  |  | #include "macglue.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern int ResObj_Convert(PyObject *, Handle *); /* From Resmodule.c */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-05-19 12:34:59 +00:00
										 |  |  | #ifdef WITHOUT_FRAMEWORKS
 | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | #include <InternetConfig.h>
 | 
					
						
							| 
									
										
										
										
											2001-05-19 12:34:59 +00:00
										 |  |  | #else
 | 
					
						
							|  |  |  | #include <Carbon/Carbon.h>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject *ErrorObject; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ----------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Declarations for objects of type ic_instance */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  | 	PyObject_HEAD | 
					
						
							|  |  |  | 	ICInstance inst; | 
					
						
							|  |  |  | } iciobject; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-07-17 16:30:39 +00:00
										 |  |  | static PyTypeObject Icitype; | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ---------------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char ici_ICGetSeed__doc__[] =  | 
					
						
							|  |  |  | "()->int; Returns int that changes when configuration does" | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2001-09-04 22:20:39 +00:00
										 |  |  | ici_ICGetSeed(iciobject *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 	OSStatus err; | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	long seed; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((err=ICGetSeed(self->inst, &seed)) != 0 ) | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		return PyMac_Error(err); | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	return Py_BuildValue("i", (int)seed); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char ici_ICBegin__doc__[] =  | 
					
						
							|  |  |  | "(perm)->None; Lock config file for read/write" | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2001-09-04 22:20:39 +00:00
										 |  |  | ici_ICBegin(iciobject *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 	OSStatus err; | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	int perm; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "i", &perm)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((err=ICBegin(self->inst, (ICPerm)perm)) != 0 ) | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		return PyMac_Error(err); | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char ici_ICFindPrefHandle__doc__[] =  | 
					
						
							|  |  |  | "(key, handle)->attrs; Lookup key, store result in handle, return attributes" | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2001-09-04 22:20:39 +00:00
										 |  |  | ici_ICFindPrefHandle(iciobject *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 	OSStatus err; | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	Str255 key; | 
					
						
							|  |  |  | 	ICAttr attr; | 
					
						
							|  |  |  | 	Handle h; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "O&O&", PyMac_GetStr255, &key, ResObj_Convert, &h)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((err=ICFindPrefHandle(self->inst, key, &attr, h)) != 0 ) | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		return PyMac_Error(err); | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	return Py_BuildValue("i", (int)attr); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char ici_ICSetPref__doc__[] =  | 
					
						
							|  |  |  | "(key, attr, data)->None; Set preference key to data with attributes" | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2001-09-04 22:20:39 +00:00
										 |  |  | ici_ICSetPref(iciobject *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 	OSStatus err; | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	Str255 key; | 
					
						
							|  |  |  | 	int attr; | 
					
						
							|  |  |  | 	char *data; | 
					
						
							|  |  |  | 	int datalen; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "O&is#", PyMac_GetStr255, &key, &attr,  | 
					
						
							|  |  |  | 					&data, &datalen)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((err=ICSetPref(self->inst, key, (ICAttr)attr, (Ptr)data,  | 
					
						
							|  |  |  | 			(long)datalen)) != 0) | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		return PyMac_Error(err); | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char ici_ICCountPref__doc__[] =  | 
					
						
							|  |  |  | "()->int; Return number of preferences" | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2001-09-04 22:20:39 +00:00
										 |  |  | ici_ICCountPref(iciobject *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 	OSStatus err; | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	long count; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((err=ICCountPref(self->inst, &count)) != 0 ) | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		return PyMac_Error(err); | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	return Py_BuildValue("i", (int)count); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char ici_ICGetIndPref__doc__[] =  | 
					
						
							|  |  |  | "(num)->key; Return key of preference with given index" | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2001-09-04 22:20:39 +00:00
										 |  |  | ici_ICGetIndPref(iciobject *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 	OSStatus err; | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	long num; | 
					
						
							|  |  |  | 	Str255 key; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "l", &num)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((err=ICGetIndPref(self->inst, num, key)) != 0 ) | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		return PyMac_Error(err); | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	return Py_BuildValue("O&", PyMac_BuildStr255, key); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char ici_ICDeletePref__doc__[] =  | 
					
						
							|  |  |  | "(key)->None; Delete preference" | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2001-09-04 22:20:39 +00:00
										 |  |  | ici_ICDeletePref(iciobject *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 	OSStatus err; | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	Str255 key; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "O&", PyMac_GetStr255, key)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((err=ICDeletePref(self->inst, key)) != 0 ) | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		return PyMac_Error(err); | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char ici_ICEnd__doc__[] =  | 
					
						
							|  |  |  | "()->None; Unlock file after ICBegin call" | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2001-09-04 22:20:39 +00:00
										 |  |  | ici_ICEnd(iciobject *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 	OSStatus err; | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((err=ICEnd(self->inst)) != 0 ) | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		return PyMac_Error(err); | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char ici_ICEditPreferences__doc__[] =  | 
					
						
							|  |  |  | "(key)->None; Ask user to edit preferences, staring with key" | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2001-09-04 22:20:39 +00:00
										 |  |  | ici_ICEditPreferences(iciobject *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 	OSStatus err; | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	Str255 key; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "O&", PyMac_GetStr255, key)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((err=ICEditPreferences(self->inst, key)) != 0 ) | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		return PyMac_Error(err); | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char ici_ICParseURL__doc__[] =  | 
					
						
							|  |  |  | "(hint, data, selStart, selEnd, handle)->selStart, selEnd; Find an URL, return in handle" | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2001-09-04 22:20:39 +00:00
										 |  |  | ici_ICParseURL(iciobject *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 	OSStatus err; | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	Str255 hint; | 
					
						
							|  |  |  | 	char *data; | 
					
						
							|  |  |  | 	int datalen; | 
					
						
							|  |  |  | 	long selStart, selEnd; | 
					
						
							|  |  |  | 	Handle h; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "O&s#llO&", PyMac_GetStr255, hint, &data, &datalen, | 
					
						
							|  |  |  | 				&selStart, &selEnd, ResObj_Convert, &h)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((err=ICParseURL(self->inst, hint, (Ptr)data, (long)datalen, | 
					
						
							|  |  |  | 				&selStart, &selEnd, h)) != 0 ) | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		return PyMac_Error(err); | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	return Py_BuildValue("ii", (int)selStart, (int)selEnd); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char ici_ICLaunchURL__doc__[] =  | 
					
						
							|  |  |  | "(hint, data, selStart, selEnd)->None; Find an URL and launch the correct app" | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2001-09-04 22:20:39 +00:00
										 |  |  | ici_ICLaunchURL(iciobject *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 	OSStatus err; | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	Str255 hint; | 
					
						
							|  |  |  | 	char *data; | 
					
						
							|  |  |  | 	int datalen; | 
					
						
							|  |  |  | 	long selStart, selEnd; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "O&s#ll", PyMac_GetStr255, hint, &data, &datalen, | 
					
						
							|  |  |  | 				&selStart, &selEnd)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((err=ICLaunchURL(self->inst, hint, (Ptr)data, (long)datalen, | 
					
						
							|  |  |  | 				&selStart, &selEnd)) != 0 ) | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		return PyMac_Error(err); | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	return Py_BuildValue("ii", (int)selStart, (int)selEnd); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char ici_ICMapFilename__doc__[] =  | 
					
						
							|  |  |  | "(filename)->mapinfo; Get filemap info for given filename" | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2001-09-04 22:20:39 +00:00
										 |  |  | ici_ICMapFilename(iciobject *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 	OSStatus err; | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	Str255 filename; | 
					
						
							|  |  |  | 	ICMapEntry entry; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "O&", PyMac_GetStr255, filename)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((err=ICMapFilename(self->inst, filename, &entry)) != 0 ) | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		return PyMac_Error(err); | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	return Py_BuildValue("hO&O&O&lO&O&O&O&O&", entry.version,  | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		PyMac_BuildOSType, entry.fileType, | 
					
						
							|  |  |  | 		PyMac_BuildOSType, entry.fileCreator,  | 
					
						
							|  |  |  | 		PyMac_BuildOSType, entry.postCreator,  | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 		entry.flags, | 
					
						
							|  |  |  | 		PyMac_BuildStr255, entry.extension, | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		PyMac_BuildStr255, entry.creatorAppName, | 
					
						
							|  |  |  | 		PyMac_BuildStr255, entry.postAppName, | 
					
						
							|  |  |  | 		PyMac_BuildStr255, entry.MIMEType, | 
					
						
							|  |  |  | 		PyMac_BuildStr255, entry.entryName); | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char ici_ICMapTypeCreator__doc__[] =  | 
					
						
							|  |  |  | "(type, creator, filename)->mapinfo; Get filemap info for given tp/cr/filename" | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2001-09-04 22:20:39 +00:00
										 |  |  | ici_ICMapTypeCreator(iciobject *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 	OSStatus err; | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	OSType type, creator; | 
					
						
							|  |  |  | 	Str255 filename; | 
					
						
							|  |  |  | 	ICMapEntry entry; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "O&O&O&", | 
					
						
							|  |  |  | 			PyMac_GetOSType, &type, | 
					
						
							|  |  |  | 			PyMac_GetOSType, &creator, | 
					
						
							|  |  |  | 			PyMac_GetStr255, filename)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((err=ICMapTypeCreator(self->inst, type, creator, filename, &entry)) != 0 ) | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		return PyMac_Error(err); | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	return Py_BuildValue("hO&O&O&lO&O&O&O&O&", entry.version,  | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		PyMac_BuildOSType, entry.fileType, | 
					
						
							|  |  |  | 		PyMac_BuildOSType, entry.fileCreator,  | 
					
						
							|  |  |  | 		PyMac_BuildOSType, entry.postCreator,  | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 		entry.flags, | 
					
						
							|  |  |  | 		PyMac_BuildStr255, entry.extension, | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		PyMac_BuildStr255, entry.creatorAppName, | 
					
						
							|  |  |  | 		PyMac_BuildStr255, entry.postAppName, | 
					
						
							|  |  |  | 		PyMac_BuildStr255, entry.MIMEType, | 
					
						
							|  |  |  | 		PyMac_BuildStr255, entry.entryName); | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct PyMethodDef ici_methods[] = { | 
					
						
							|  |  |  |  {"ICGetSeed",	(PyCFunction)ici_ICGetSeed,	METH_VARARGS,	ici_ICGetSeed__doc__}, | 
					
						
							|  |  |  |  {"ICBegin",	(PyCFunction)ici_ICBegin,	METH_VARARGS,	ici_ICBegin__doc__}, | 
					
						
							|  |  |  |  {"ICFindPrefHandle",	(PyCFunction)ici_ICFindPrefHandle,	METH_VARARGS,	ici_ICFindPrefHandle__doc__}, | 
					
						
							|  |  |  |  {"ICSetPref",	(PyCFunction)ici_ICSetPref,	METH_VARARGS,	ici_ICSetPref__doc__}, | 
					
						
							|  |  |  |  {"ICCountPref",	(PyCFunction)ici_ICCountPref,	METH_VARARGS,	ici_ICCountPref__doc__}, | 
					
						
							|  |  |  |  {"ICGetIndPref",	(PyCFunction)ici_ICGetIndPref,	METH_VARARGS,	ici_ICGetIndPref__doc__}, | 
					
						
							|  |  |  |  {"ICDeletePref",	(PyCFunction)ici_ICDeletePref,	METH_VARARGS,	ici_ICDeletePref__doc__}, | 
					
						
							|  |  |  |  {"ICEnd",	(PyCFunction)ici_ICEnd,	METH_VARARGS,	ici_ICEnd__doc__}, | 
					
						
							|  |  |  |  {"ICEditPreferences",	(PyCFunction)ici_ICEditPreferences,	METH_VARARGS,	ici_ICEditPreferences__doc__}, | 
					
						
							|  |  |  |  {"ICParseURL",	(PyCFunction)ici_ICParseURL,	METH_VARARGS,	ici_ICParseURL__doc__}, | 
					
						
							|  |  |  |  {"ICLaunchURL",	(PyCFunction)ici_ICLaunchURL,	METH_VARARGS,	ici_ICLaunchURL__doc__}, | 
					
						
							|  |  |  |  {"ICMapFilename",	(PyCFunction)ici_ICMapFilename,	METH_VARARGS,	ici_ICMapFilename__doc__}, | 
					
						
							|  |  |  |  {"ICMapTypeCreator",	(PyCFunction)ici_ICMapTypeCreator,	METH_VARARGS,	ici_ICMapTypeCreator__doc__}, | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  | 	{NULL,		NULL}		/* sentinel */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ---------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static iciobject * | 
					
						
							|  |  |  | newiciobject(OSType creator) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	iciobject *self; | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 	OSStatus err; | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	self = PyObject_NEW(iciobject, &Icitype); | 
					
						
							|  |  |  | 	if (self == NULL) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((err=ICStart(&self->inst, creator)) != 0 ) { | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 		(void)PyMac_Error(err); | 
					
						
							| 
									
										
										
										
											2002-05-22 14:31:48 +00:00
										 |  |  | 		PyObject_DEL(self); | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 		return NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return self; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							| 
									
										
										
										
											2001-09-04 22:20:39 +00:00
										 |  |  | ici_dealloc(iciobject *self) | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	(void)ICStop(self->inst); | 
					
						
							| 
									
										
										
										
											2002-05-22 14:31:48 +00:00
										 |  |  | 	PyObject_DEL(self); | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2001-09-04 22:20:39 +00:00
										 |  |  | ici_getattr(iciobject *self, char *name) | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	return Py_FindMethod(ici_methods, (PyObject *)self, name); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char Icitype__doc__[] =  | 
					
						
							|  |  |  | "Internet Config instance" | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyTypeObject Icitype = { | 
					
						
							|  |  |  | 	PyObject_HEAD_INIT(&PyType_Type) | 
					
						
							|  |  |  | 	0,				/*ob_size*/ | 
					
						
							| 
									
										
										
										
											2001-12-08 18:02:58 +00:00
										 |  |  | 	"icglue.ic_instance",		/*tp_name*/ | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 	sizeof(iciobject),		/*tp_basicsize*/ | 
					
						
							|  |  |  | 	0,				/*tp_itemsize*/ | 
					
						
							|  |  |  | 	/* methods */ | 
					
						
							|  |  |  | 	(destructor)ici_dealloc,	/*tp_dealloc*/ | 
					
						
							|  |  |  | 	(printfunc)0,		/*tp_print*/ | 
					
						
							|  |  |  | 	(getattrfunc)ici_getattr,	/*tp_getattr*/ | 
					
						
							|  |  |  | 	(setattrfunc)0,	/*tp_setattr*/ | 
					
						
							|  |  |  | 	(cmpfunc)0,		/*tp_compare*/ | 
					
						
							|  |  |  | 	(reprfunc)0,		/*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, | 
					
						
							|  |  |  | 	Icitype__doc__ /* Documentation string */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* End of code for ic_instance objects */ | 
					
						
							|  |  |  | /* -------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char ic_ICStart__doc__[] = | 
					
						
							|  |  |  | "(OSType)->ic_instance; Create an Internet Config instance" | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2001-09-04 22:20:39 +00:00
										 |  |  | ic_ICStart(PyObject *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	OSType creator; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "O&", PyMac_GetOSType, &creator)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	return (PyObject *)newiciobject(creator); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* List of methods defined in the module */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct PyMethodDef ic_methods[] = { | 
					
						
							|  |  |  | 	{"ICStart",	(PyCFunction)ic_ICStart,	METH_VARARGS,	ic_ICStart__doc__}, | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  | 	{NULL,	 (PyCFunction)NULL, 0, NULL}		/* sentinel */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Initialization function for the module (*must* be called initicglue) */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char icglue_module_documentation[] =  | 
					
						
							|  |  |  | "Implements low-level Internet Config interface" | 
					
						
							|  |  |  | ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void | 
					
						
							| 
									
										
										
										
											2001-09-04 22:20:39 +00:00
										 |  |  | initicglue(void) | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	PyObject *m, *d; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Create the module and add the functions */ | 
					
						
							|  |  |  | 	m = Py_InitModule4("icglue", ic_methods, | 
					
						
							|  |  |  | 		icglue_module_documentation, | 
					
						
							|  |  |  | 		(PyObject*)NULL,PYTHON_API_VERSION); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Add some symbolic constants to the module */ | 
					
						
							|  |  |  | 	d = PyModule_GetDict(m); | 
					
						
							| 
									
										
										
										
											2002-01-11 12:38:08 +00:00
										 |  |  | 	ErrorObject = PyMac_GetOSErrException(); | 
					
						
							|  |  |  | 	if (ErrorObject == NULL || | 
					
						
							|  |  |  | 	    PyDict_SetItemString(d, "error", ErrorObject) != 0) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											1997-01-07 16:18:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* XXXX Add constants here */ | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* Check for errors */ | 
					
						
							|  |  |  | 	if (PyErr_Occurred()) | 
					
						
							|  |  |  | 		Py_FatalError("can't initialize module icglue"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 |