Commit 8f54f2a3 authored by Jack Jansen's avatar Jack Jansen

Internet Config is now part of official Apple interfaces, so use the new

headers and libraries.
parent b99e5213
...@@ -35,38 +35,23 @@ PERFORMANCE OF THIS SOFTWARE. ...@@ -35,38 +35,23 @@ PERFORMANCE OF THIS SOFTWARE.
extern int ResObj_Convert(PyObject *, Handle *); /* From Resmodule.c */ extern int ResObj_Convert(PyObject *, Handle *); /* From Resmodule.c */
#ifdef WITHOUT_FRAMEWORKS #ifdef WITHOUT_FRAMEWORKS
#if !TARGET_API_MAC_OS8 // #if !TARGET_API_MAC_OS8
/* The Carbon headers define PRAGMA_ALIGN_SUPPORT to something illegal, // /* The Carbon headers define PRAGMA_ALIGN_SUPPORT to something illegal,
** because you shouldn't use it for Carbon. All good and well, but portable // ** because you shouldn't use it for Carbon. All good and well, but portable
** code still needs it. So, we undefine it here. // ** code still needs it. So, we undefine it here.
*/ // */
#undef PRAGMA_ALIGN_SUPPORTED // #undef PRAGMA_ALIGN_SUPPORTED
#define PRAGMA_ALIGN_SUPPORTED 0 // #define PRAGMA_ALIGN_SUPPORTED 0
#endif /* !TARGET_API_MAC_OS8 */ // #endif /* !TARGET_API_MAC_OS8 */
#include "ICAPI.h" // #include "ICAPI.h"
#include <InternetConfig.h>
#else #else
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
typedef OSStatus ICError;
/* Some fields in ICMapEntry have changed names. */
#define file_type fileType
#define file_creator fileCreator
#define post_creator postCreator
#define creator_app_name creatorAppName
#define post_app_name postAppName
#define MIME_type MIMEType
#define entry_name entryName
#endif #endif
static PyObject *ErrorObject; static PyObject *ErrorObject;
static PyObject *
ici_error(ICError err)
{
PyErr_SetObject(ErrorObject, PyInt_FromLong((long)err));
return NULL;
}
/* ----------------------------------------------------- */ /* ----------------------------------------------------- */
/* Declarations for objects of type ic_instance */ /* Declarations for objects of type ic_instance */
...@@ -90,12 +75,12 @@ static char ici_ICFindConfigFile__doc__[] = ...@@ -90,12 +75,12 @@ static char ici_ICFindConfigFile__doc__[] =
static PyObject * static PyObject *
ici_ICFindConfigFile(iciobject *self, PyObject *args) ici_ICFindConfigFile(iciobject *self, PyObject *args)
{ {
ICError err; OSStatus err;
if (!PyArg_ParseTuple(args, "")) if (!PyArg_ParseTuple(args, ""))
return NULL; return NULL;
if ((err=ICFindConfigFile(self->inst, 0, NULL)) != 0 ) if ((err=ICFindConfigFile(self->inst, 0, NULL)) != 0 )
return ici_error(err); return PyMac_Error(err);
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
...@@ -108,13 +93,13 @@ static char ici_ICFindUserConfigFile__doc__[] = ...@@ -108,13 +93,13 @@ static char ici_ICFindUserConfigFile__doc__[] =
static PyObject * static PyObject *
ici_ICFindUserConfigFile(iciobject *self, PyObject *args) ici_ICFindUserConfigFile(iciobject *self, PyObject *args)
{ {
ICError err; OSStatus err;
ICDirSpec where; ICDirSpec where;
if (!PyArg_ParseTuple(args, "sl", &where.vRefNum, &where.dirID)) if (!PyArg_ParseTuple(args, "sl", &where.vRefNum, &where.dirID))
return NULL; return NULL;
if ((err=ICFindUserConfigFile(self->inst, &where)) != 0 ) if ((err=ICFindUserConfigFile(self->inst, &where)) != 0 )
return ici_error(err); return PyMac_Error(err);
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
...@@ -127,12 +112,12 @@ static char ici_ICChooseConfig__doc__[] = ...@@ -127,12 +112,12 @@ static char ici_ICChooseConfig__doc__[] =
static PyObject * static PyObject *
ici_ICChooseConfig(iciobject *self, PyObject *args) ici_ICChooseConfig(iciobject *self, PyObject *args)
{ {
ICError err; OSStatus err;
if (!PyArg_ParseTuple(args, "")) if (!PyArg_ParseTuple(args, ""))
return NULL; return NULL;
if ((err=ICChooseConfig(self->inst)) != 0 ) if ((err=ICChooseConfig(self->inst)) != 0 )
return ici_error(err); return PyMac_Error(err);
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
...@@ -144,12 +129,12 @@ static char ici_ICChooseNewConfig__doc__[] = ...@@ -144,12 +129,12 @@ static char ici_ICChooseNewConfig__doc__[] =
static PyObject * static PyObject *
ici_ICChooseNewConfig(iciobject *self, PyObject *args) ici_ICChooseNewConfig(iciobject *self, PyObject *args)
{ {
ICError err; OSStatus err;
if (!PyArg_ParseTuple(args, "")) if (!PyArg_ParseTuple(args, ""))
return NULL; return NULL;
if ((err=ICChooseNewConfig(self->inst)) != 0 ) if ((err=ICChooseNewConfig(self->inst)) != 0 )
return ici_error(err); return PyMac_Error(err);
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
...@@ -163,13 +148,13 @@ static char ici_ICGetSeed__doc__[] = ...@@ -163,13 +148,13 @@ static char ici_ICGetSeed__doc__[] =
static PyObject * static PyObject *
ici_ICGetSeed(iciobject *self, PyObject *args) ici_ICGetSeed(iciobject *self, PyObject *args)
{ {
ICError err; OSStatus err;
long seed; long seed;
if (!PyArg_ParseTuple(args, "")) if (!PyArg_ParseTuple(args, ""))
return NULL; return NULL;
if ((err=ICGetSeed(self->inst, &seed)) != 0 ) if ((err=ICGetSeed(self->inst, &seed)) != 0 )
return ici_error(err); return PyMac_Error(err);
return Py_BuildValue("i", (int)seed); return Py_BuildValue("i", (int)seed);
} }
...@@ -181,13 +166,13 @@ static char ici_ICBegin__doc__[] = ...@@ -181,13 +166,13 @@ static char ici_ICBegin__doc__[] =
static PyObject * static PyObject *
ici_ICBegin(iciobject *self, PyObject *args) ici_ICBegin(iciobject *self, PyObject *args)
{ {
ICError err; OSStatus err;
int perm; int perm;
if (!PyArg_ParseTuple(args, "i", &perm)) if (!PyArg_ParseTuple(args, "i", &perm))
return NULL; return NULL;
if ((err=ICBegin(self->inst, (ICPerm)perm)) != 0 ) if ((err=ICBegin(self->inst, (ICPerm)perm)) != 0 )
return ici_error(err); return PyMac_Error(err);
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
...@@ -200,7 +185,7 @@ static char ici_ICFindPrefHandle__doc__[] = ...@@ -200,7 +185,7 @@ static char ici_ICFindPrefHandle__doc__[] =
static PyObject * static PyObject *
ici_ICFindPrefHandle(iciobject *self, PyObject *args) ici_ICFindPrefHandle(iciobject *self, PyObject *args)
{ {
ICError err; OSStatus err;
Str255 key; Str255 key;
ICAttr attr; ICAttr attr;
Handle h; Handle h;
...@@ -208,7 +193,7 @@ ici_ICFindPrefHandle(iciobject *self, PyObject *args) ...@@ -208,7 +193,7 @@ ici_ICFindPrefHandle(iciobject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "O&O&", PyMac_GetStr255, &key, ResObj_Convert, &h)) if (!PyArg_ParseTuple(args, "O&O&", PyMac_GetStr255, &key, ResObj_Convert, &h))
return NULL; return NULL;
if ((err=ICFindPrefHandle(self->inst, key, &attr, h)) != 0 ) if ((err=ICFindPrefHandle(self->inst, key, &attr, h)) != 0 )
return ici_error(err); return PyMac_Error(err);
return Py_BuildValue("i", (int)attr); return Py_BuildValue("i", (int)attr);
} }
...@@ -220,7 +205,7 @@ static char ici_ICSetPref__doc__[] = ...@@ -220,7 +205,7 @@ static char ici_ICSetPref__doc__[] =
static PyObject * static PyObject *
ici_ICSetPref(iciobject *self, PyObject *args) ici_ICSetPref(iciobject *self, PyObject *args)
{ {
ICError err; OSStatus err;
Str255 key; Str255 key;
int attr; int attr;
char *data; char *data;
...@@ -231,7 +216,7 @@ ici_ICSetPref(iciobject *self, PyObject *args) ...@@ -231,7 +216,7 @@ ici_ICSetPref(iciobject *self, PyObject *args)
return NULL; return NULL;
if ((err=ICSetPref(self->inst, key, (ICAttr)attr, (Ptr)data, if ((err=ICSetPref(self->inst, key, (ICAttr)attr, (Ptr)data,
(long)datalen)) != 0) (long)datalen)) != 0)
return ici_error(err); return PyMac_Error(err);
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
...@@ -244,13 +229,13 @@ static char ici_ICCountPref__doc__[] = ...@@ -244,13 +229,13 @@ static char ici_ICCountPref__doc__[] =
static PyObject * static PyObject *
ici_ICCountPref(iciobject *self, PyObject *args) ici_ICCountPref(iciobject *self, PyObject *args)
{ {
ICError err; OSStatus err;
long count; long count;
if (!PyArg_ParseTuple(args, "")) if (!PyArg_ParseTuple(args, ""))
return NULL; return NULL;
if ((err=ICCountPref(self->inst, &count)) != 0 ) if ((err=ICCountPref(self->inst, &count)) != 0 )
return ici_error(err); return PyMac_Error(err);
return Py_BuildValue("i", (int)count); return Py_BuildValue("i", (int)count);
} }
...@@ -262,14 +247,14 @@ static char ici_ICGetIndPref__doc__[] = ...@@ -262,14 +247,14 @@ static char ici_ICGetIndPref__doc__[] =
static PyObject * static PyObject *
ici_ICGetIndPref(iciobject *self, PyObject *args) ici_ICGetIndPref(iciobject *self, PyObject *args)
{ {
ICError err; OSStatus err;
long num; long num;
Str255 key; Str255 key;
if (!PyArg_ParseTuple(args, "l", &num)) if (!PyArg_ParseTuple(args, "l", &num))
return NULL; return NULL;
if ((err=ICGetIndPref(self->inst, num, key)) != 0 ) if ((err=ICGetIndPref(self->inst, num, key)) != 0 )
return ici_error(err); return PyMac_Error(err);
return Py_BuildValue("O&", PyMac_BuildStr255, key); return Py_BuildValue("O&", PyMac_BuildStr255, key);
} }
...@@ -281,13 +266,13 @@ static char ici_ICDeletePref__doc__[] = ...@@ -281,13 +266,13 @@ static char ici_ICDeletePref__doc__[] =
static PyObject * static PyObject *
ici_ICDeletePref(iciobject *self, PyObject *args) ici_ICDeletePref(iciobject *self, PyObject *args)
{ {
ICError err; OSStatus err;
Str255 key; Str255 key;
if (!PyArg_ParseTuple(args, "O&", PyMac_GetStr255, key)) if (!PyArg_ParseTuple(args, "O&", PyMac_GetStr255, key))
return NULL; return NULL;
if ((err=ICDeletePref(self->inst, key)) != 0 ) if ((err=ICDeletePref(self->inst, key)) != 0 )
return ici_error(err); return PyMac_Error(err);
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
...@@ -300,12 +285,12 @@ static char ici_ICEnd__doc__[] = ...@@ -300,12 +285,12 @@ static char ici_ICEnd__doc__[] =
static PyObject * static PyObject *
ici_ICEnd(iciobject *self, PyObject *args) ici_ICEnd(iciobject *self, PyObject *args)
{ {
ICError err; OSStatus err;
if (!PyArg_ParseTuple(args, "")) if (!PyArg_ParseTuple(args, ""))
return NULL; return NULL;
if ((err=ICEnd(self->inst)) != 0 ) if ((err=ICEnd(self->inst)) != 0 )
return ici_error(err); return PyMac_Error(err);
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
...@@ -318,13 +303,13 @@ static char ici_ICEditPreferences__doc__[] = ...@@ -318,13 +303,13 @@ static char ici_ICEditPreferences__doc__[] =
static PyObject * static PyObject *
ici_ICEditPreferences(iciobject *self, PyObject *args) ici_ICEditPreferences(iciobject *self, PyObject *args)
{ {
ICError err; OSStatus err;
Str255 key; Str255 key;
if (!PyArg_ParseTuple(args, "O&", PyMac_GetStr255, key)) if (!PyArg_ParseTuple(args, "O&", PyMac_GetStr255, key))
return NULL; return NULL;
if ((err=ICEditPreferences(self->inst, key)) != 0 ) if ((err=ICEditPreferences(self->inst, key)) != 0 )
return ici_error(err); return PyMac_Error(err);
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
...@@ -337,7 +322,7 @@ static char ici_ICParseURL__doc__[] = ...@@ -337,7 +322,7 @@ static char ici_ICParseURL__doc__[] =
static PyObject * static PyObject *
ici_ICParseURL(iciobject *self, PyObject *args) ici_ICParseURL(iciobject *self, PyObject *args)
{ {
ICError err; OSStatus err;
Str255 hint; Str255 hint;
char *data; char *data;
int datalen; int datalen;
...@@ -349,7 +334,7 @@ ici_ICParseURL(iciobject *self, PyObject *args) ...@@ -349,7 +334,7 @@ ici_ICParseURL(iciobject *self, PyObject *args)
return NULL; return NULL;
if ((err=ICParseURL(self->inst, hint, (Ptr)data, (long)datalen, if ((err=ICParseURL(self->inst, hint, (Ptr)data, (long)datalen,
&selStart, &selEnd, h)) != 0 ) &selStart, &selEnd, h)) != 0 )
return ici_error(err); return PyMac_Error(err);
return Py_BuildValue("ii", (int)selStart, (int)selEnd); return Py_BuildValue("ii", (int)selStart, (int)selEnd);
} }
...@@ -361,7 +346,7 @@ static char ici_ICLaunchURL__doc__[] = ...@@ -361,7 +346,7 @@ static char ici_ICLaunchURL__doc__[] =
static PyObject * static PyObject *
ici_ICLaunchURL(iciobject *self, PyObject *args) ici_ICLaunchURL(iciobject *self, PyObject *args)
{ {
ICError err; OSStatus err;
Str255 hint; Str255 hint;
char *data; char *data;
int datalen; int datalen;
...@@ -372,7 +357,7 @@ ici_ICLaunchURL(iciobject *self, PyObject *args) ...@@ -372,7 +357,7 @@ ici_ICLaunchURL(iciobject *self, PyObject *args)
return NULL; return NULL;
if ((err=ICLaunchURL(self->inst, hint, (Ptr)data, (long)datalen, if ((err=ICLaunchURL(self->inst, hint, (Ptr)data, (long)datalen,
&selStart, &selEnd)) != 0 ) &selStart, &selEnd)) != 0 )
return ici_error(err); return PyMac_Error(err);
return Py_BuildValue("ii", (int)selStart, (int)selEnd); return Py_BuildValue("ii", (int)selStart, (int)selEnd);
} }
...@@ -384,24 +369,24 @@ static char ici_ICMapFilename__doc__[] = ...@@ -384,24 +369,24 @@ static char ici_ICMapFilename__doc__[] =
static PyObject * static PyObject *
ici_ICMapFilename(iciobject *self, PyObject *args) ici_ICMapFilename(iciobject *self, PyObject *args)
{ {
ICError err; OSStatus err;
Str255 filename; Str255 filename;
ICMapEntry entry; ICMapEntry entry;
if (!PyArg_ParseTuple(args, "O&", PyMac_GetStr255, filename)) if (!PyArg_ParseTuple(args, "O&", PyMac_GetStr255, filename))
return NULL; return NULL;
if ((err=ICMapFilename(self->inst, filename, &entry)) != 0 ) if ((err=ICMapFilename(self->inst, filename, &entry)) != 0 )
return ici_error(err); return PyMac_Error(err);
return Py_BuildValue("hO&O&O&lO&O&O&O&O&", entry.version, return Py_BuildValue("hO&O&O&lO&O&O&O&O&", entry.version,
PyMac_BuildOSType, entry.file_type, PyMac_BuildOSType, entry.fileType,
PyMac_BuildOSType, entry.file_creator, PyMac_BuildOSType, entry.fileCreator,
PyMac_BuildOSType, entry.post_creator, PyMac_BuildOSType, entry.postCreator,
entry.flags, entry.flags,
PyMac_BuildStr255, entry.extension, PyMac_BuildStr255, entry.extension,
PyMac_BuildStr255, entry.creator_app_name, PyMac_BuildStr255, entry.creatorAppName,
PyMac_BuildStr255, entry.post_app_name, PyMac_BuildStr255, entry.postAppName,
PyMac_BuildStr255, entry.MIME_type, PyMac_BuildStr255, entry.MIMEType,
PyMac_BuildStr255, entry.entry_name); PyMac_BuildStr255, entry.entryName);
} }
...@@ -412,7 +397,7 @@ static char ici_ICMapTypeCreator__doc__[] = ...@@ -412,7 +397,7 @@ static char ici_ICMapTypeCreator__doc__[] =
static PyObject * static PyObject *
ici_ICMapTypeCreator(iciobject *self, PyObject *args) ici_ICMapTypeCreator(iciobject *self, PyObject *args)
{ {
ICError err; OSStatus err;
OSType type, creator; OSType type, creator;
Str255 filename; Str255 filename;
ICMapEntry entry; ICMapEntry entry;
...@@ -423,17 +408,17 @@ ici_ICMapTypeCreator(iciobject *self, PyObject *args) ...@@ -423,17 +408,17 @@ ici_ICMapTypeCreator(iciobject *self, PyObject *args)
PyMac_GetStr255, filename)) PyMac_GetStr255, filename))
return NULL; return NULL;
if ((err=ICMapTypeCreator(self->inst, type, creator, filename, &entry)) != 0 ) if ((err=ICMapTypeCreator(self->inst, type, creator, filename, &entry)) != 0 )
return ici_error(err); return PyMac_Error(err);
return Py_BuildValue("hO&O&O&lO&O&O&O&O&", entry.version, return Py_BuildValue("hO&O&O&lO&O&O&O&O&", entry.version,
PyMac_BuildOSType, entry.file_type, PyMac_BuildOSType, entry.fileType,
PyMac_BuildOSType, entry.file_creator, PyMac_BuildOSType, entry.fileCreator,
PyMac_BuildOSType, entry.post_creator, PyMac_BuildOSType, entry.postCreator,
entry.flags, entry.flags,
PyMac_BuildStr255, entry.extension, PyMac_BuildStr255, entry.extension,
PyMac_BuildStr255, entry.creator_app_name, PyMac_BuildStr255, entry.creatorAppName,
PyMac_BuildStr255, entry.post_app_name, PyMac_BuildStr255, entry.postAppName,
PyMac_BuildStr255, entry.MIME_type, PyMac_BuildStr255, entry.MIMEType,
PyMac_BuildStr255, entry.entry_name); PyMac_BuildStr255, entry.entryName);
} }
...@@ -468,13 +453,13 @@ static iciobject * ...@@ -468,13 +453,13 @@ static iciobject *
newiciobject(OSType creator) newiciobject(OSType creator)
{ {
iciobject *self; iciobject *self;
ICError err; OSStatus err;
self = PyObject_NEW(iciobject, &Icitype); self = PyObject_NEW(iciobject, &Icitype);
if (self == NULL) if (self == NULL)
return NULL; return NULL;
if ((err=ICStart(&self->inst, creator)) != 0 ) { if ((err=ICStart(&self->inst, creator)) != 0 ) {
(void)ici_error(err); (void)PyMac_Error(err);
PyMem_DEL(self); PyMem_DEL(self);
return NULL; return NULL;
} }
...@@ -569,8 +554,10 @@ initicglue(void) ...@@ -569,8 +554,10 @@ initicglue(void)
/* Add some symbolic constants to the module */ /* Add some symbolic constants to the module */
d = PyModule_GetDict(m); d = PyModule_GetDict(m);
ErrorObject = PyString_FromString("icglue.error"); ErrorObject = PyMac_GetOSErrException();
PyDict_SetItemString(d, "error", ErrorObject); if (ErrorObject == NULL ||
PyDict_SetItemString(d, "error", ErrorObject) != 0)
return;
/* XXXX Add constants here */ /* XXXX Add constants here */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment