summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2001-08-08 13:46:49 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2001-08-08 13:46:49 (GMT)
commitdeefbe56662b1fe02baa504bfd76c7fcf7d6cac1 (patch)
tree78adb971e6012df23af1b651ec6124f6b2a2eb75
parent086d22fdb4306648aa8d7cee9a339f058efa3c35 (diff)
downloadcpython-deefbe56662b1fe02baa504bfd76c7fcf7d6cac1.zip
cpython-deefbe56662b1fe02baa504bfd76c7fcf7d6cac1.tar.gz
cpython-deefbe56662b1fe02baa504bfd76c7fcf7d6cac1.tar.bz2
- Don't return mac-style pathnames in unix-Python.
- Fixed up a lot more prototypes (gcc also wants them on static routines) - Fixed various other gcc warnings.
-rw-r--r--Mac/Modules/macfsmodule.c185
-rw-r--r--Mac/Modules/macosmodule.c62
2 files changed, 79 insertions, 168 deletions
diff --git a/Mac/Modules/macfsmodule.c b/Mac/Modules/macfsmodule.c
index af5d390..6204cee 100644
--- a/Mac/Modules/macfsmodule.c
+++ b/Mac/Modules/macfsmodule.c
@@ -101,9 +101,7 @@ staticforward mfsrobject *newmfsrobject(FSRef *fsr); /* Forward */
/* ---------------------------------------------------------------- */
static PyObject *
-mfsa_Resolve(self, args)
- mfsaobject *self;
- PyObject *args;
+mfsa_Resolve(mfsaobject *self, PyObject *args)
{
FSSpec from, *fromp, result;
Boolean changed;
@@ -125,9 +123,7 @@ mfsa_Resolve(self, args)
}
static PyObject *
-mfsa_GetInfo(self, args)
- mfsaobject *self;
- PyObject *args;
+mfsa_GetInfo(mfsaobject *self, PyObject *args)
{
Str63 value;
int i;
@@ -144,9 +140,7 @@ mfsa_GetInfo(self, args)
}
static PyObject *
-mfsa_Update(self, args)
- mfsaobject *self;
- PyObject *args;
+mfsa_Update(mfsaobject *self, PyObject *args)
{
FSSpec target, fromfile, *fromfilep;
OSErr err;
@@ -179,9 +173,7 @@ static struct PyMethodDef mfsa_methods[] = {
/* ---------- */
static PyObject *
-mfsa_getattr(self, name)
- mfsaobject *self;
- char *name;
+mfsa_getattr(mfsaobject *self, char *name)
{
if ( strcmp(name, "data") == 0 ) {
int size;
@@ -210,8 +202,7 @@ newmfsaobject(AliasHandle alias)
static void
-mfsa_dealloc(self)
- mfsaobject *self;
+mfsa_dealloc(mfsaobject *self)
{
#if 0
if ( self->alias ) {
@@ -254,7 +245,7 @@ static struct PyMethodDef mfsi_methods[] = {
/* ---------- */
static mfsiobject *
-newmfsiobject()
+newmfsiobject(void)
{
mfsiobject *self;
@@ -266,16 +257,13 @@ newmfsiobject()
}
static void
-mfsi_dealloc(self)
- mfsiobject *self;
+mfsi_dealloc(mfsiobject *self)
{
PyMem_DEL(self);
}
static PyObject *
-mfsi_getattr(self, name)
- mfsiobject *self;
- char *name;
+mfsi_getattr(mfsiobject *self, char *name)
{
if ( strcmp(name, "Type") == 0 )
return PyMac_BuildOSType(self->finfo.fdType);
@@ -293,10 +281,7 @@ mfsi_getattr(self, name)
static int
-mfsi_setattr(self, name, v)
- mfsiobject *self;
- char *name;
- PyObject *v;
+mfsi_setattr(mfsiobject *self, char *name, PyObject *v)
{
int rv;
int i;
@@ -413,9 +398,8 @@ _mfs_GetFSRefFromFSSpec(PyObject *self, FSRef *fsrp)
** Two generally useful routines
*/
static OSErr
-PyMac_GetFileDates(fss, crdat, mddat, bkdat)
- FSSpec *fss;
- unsigned long *crdat, *mddat, *bkdat;
+PyMac_GetFileDates(FSSpec *fss, unsigned long *crdat, unsigned long *mddat,
+ unsigned long *bkdat)
{
CInfoPBRec pb;
OSErr error;
@@ -433,9 +417,8 @@ PyMac_GetFileDates(fss, crdat, mddat, bkdat)
}
static OSErr
-PyMac_SetFileDates(fss, crdat, mddat, bkdat)
- FSSpec *fss;
- unsigned long crdat, mddat, bkdat;
+PyMac_SetFileDates(FSSpec *fss, unsigned long crdat, unsigned long mddat,
+ unsigned long bkdat)
{
CInfoPBRec pb;
OSErr error;
@@ -458,10 +441,12 @@ PyMac_SetFileDates(fss, crdat, mddat, bkdat)
}
static PyObject *
-mfss_as_pathname(self, args)
- mfssobject *self;
- PyObject *args;
+mfss_as_pathname(mfssobject *self, PyObject *args)
{
+#if TARGET_API_MAC_OSX
+ PyErr_SetString(PyExc_NotImplementedError, "FSSpec.as_pathname not supported on this platform");
+ return 0;
+#else
char strbuf[257];
OSErr err;
@@ -473,12 +458,11 @@ mfss_as_pathname(self, args)
return NULL;
}
return PyString_FromString(strbuf);
+#endif
}
static PyObject *
-mfss_as_tuple(self, args)
- mfssobject *self;
- PyObject *args;
+mfss_as_tuple(mfssobject *self, PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
@@ -487,9 +471,7 @@ mfss_as_tuple(self, args)
}
static PyObject *
-mfss_NewAlias(self, args)
- mfssobject *self;
- PyObject *args;
+mfss_NewAlias(mfssobject *self, PyObject *args)
{
FSSpec src, *srcp;
OSErr err;
@@ -512,9 +494,7 @@ mfss_NewAlias(self, args)
}
static PyObject *
-mfss_NewAliasMinimal(self, args)
- mfssobject *self;
- PyObject *args;
+mfss_NewAliasMinimal(mfssobject *self, PyObject *args)
{
OSErr err;
AliasHandle alias;
@@ -530,9 +510,7 @@ mfss_NewAliasMinimal(self, args)
}
static PyObject *
-mfss_FSpMakeFSRef(self, args)
- mfssobject *self;
- PyObject *args;
+mfss_FSpMakeFSRef(mfssobject *self, PyObject *args)
{
#if TARGET_API_MAC_OS8
PyErr_SetString(PyExc_NotImplementedError, "FSRef objects not supported on this platform");
@@ -554,9 +532,7 @@ mfss_FSpMakeFSRef(self, args)
/* XXXX These routines should be replaced by a wrapper to the *FInfo routines */
static PyObject *
-mfss_GetCreatorType(self, args)
- mfssobject *self;
- PyObject *args;
+mfss_GetCreatorType(mfssobject *self, PyObject *args)
{
OSErr err;
FInfo info;
@@ -573,9 +549,7 @@ mfss_GetCreatorType(self, args)
}
static PyObject *
-mfss_SetCreatorType(self, args)
- mfssobject *self;
- PyObject *args;
+mfss_SetCreatorType(mfssobject *self, PyObject *args)
{
OSErr err;
OSType creator, type;
@@ -600,9 +574,7 @@ mfss_SetCreatorType(self, args)
}
static PyObject *
-mfss_GetFInfo(self, args)
- mfssobject *self;
- PyObject *args;
+mfss_GetFInfo(mfssobject *self, PyObject *args)
{
OSErr err;
mfsiobject *fip;
@@ -622,9 +594,7 @@ mfss_GetFInfo(self, args)
}
static PyObject *
-mfss_SetFInfo(self, args)
- mfssobject *self;
- PyObject *args;
+mfss_SetFInfo(mfssobject *self, PyObject *args)
{
OSErr err;
mfsiobject *fip;
@@ -641,9 +611,7 @@ mfss_SetFInfo(self, args)
}
static PyObject *
-mfss_GetDates(self, args)
- mfssobject *self;
- PyObject *args;
+mfss_GetDates(mfssobject *self, PyObject *args)
{
OSErr err;
unsigned long crdat, mddat, bkdat;
@@ -659,9 +627,7 @@ mfss_GetDates(self, args)
}
static PyObject *
-mfss_SetDates(self, args)
- mfssobject *self;
- PyObject *args;
+mfss_SetDates(mfssobject *self, PyObject *args)
{
OSErr err;
double crdat, mddat, bkdat;
@@ -698,9 +664,7 @@ static struct PyMethodDef mfss_methods[] = {
/* ---------- */
static PyObject *
-mfss_getattr(self, name)
- mfssobject *self;
- char *name;
+mfss_getattr(mfssobject *self, char *name)
{
if ( strcmp(name, "data") == 0)
return PyString_FromStringAndSize((char *)&self->fsspec, sizeof(FSSpec));
@@ -708,8 +672,7 @@ mfss_getattr(self, name)
}
mfssobject *
-newmfssobject(fss)
- FSSpec *fss;
+newmfssobject(FSSpec *fss)
{
mfssobject *self;
@@ -721,19 +684,17 @@ newmfssobject(fss)
}
static void
-mfss_dealloc(self)
- mfssobject *self;
+mfss_dealloc(mfssobject *self)
{
PyMem_DEL(self);
}
static PyObject *
-mfss_repr(self)
- mfssobject *self;
+mfss_repr(mfssobject *self)
{
char buf[512];
- sprintf(buf, "FSSpec((%d, %d, '%.*s'))",
+ sprintf(buf, "FSSpec((%d, %ld, '%.*s'))",
self->fsspec.vRefNum,
self->fsspec.parID,
self->fsspec.name[0], self->fsspec.name+1);
@@ -741,8 +702,7 @@ mfss_repr(self)
}
static int
-mfss_compare(v, w)
- mfssobject *v, *w;
+mfss_compare(mfssobject *v, mfssobject *w)
{
int minlen;
int res;
@@ -783,9 +743,7 @@ statichere PyTypeObject Mfsstype = {
/* -------------------------------------------------------- */
#if !TARGET_API_MAC_OS8
static PyObject *
-mfsr_as_fsspec(self, args)
- mfsrobject *self;
- PyObject *args;
+mfsr_as_fsspec(mfsrobject *self, PyObject *args)
{
OSErr err;
FSSpec fss;
@@ -822,9 +780,7 @@ static struct PyMethodDef mfsr_methods[] = {
/* ---------- */
static PyObject *
-mfsr_getattr(self, name)
- mfsrobject *self;
- char *name;
+mfsr_getattr(mfsrobject *self, char *name)
{
if ( strcmp(name, "data") == 0)
return PyString_FromStringAndSize((char *)&self->fsref, sizeof(FSRef));
@@ -832,8 +788,7 @@ mfsr_getattr(self, name)
}
mfsrobject *
-newmfsrobject(fsr)
- FSRef *fsr;
+newmfsrobject(FSRef *fsr)
{
mfsrobject *self;
@@ -845,8 +800,7 @@ newmfsrobject(fsr)
}
static int
-mfsr_compare(v, w)
- mfsrobject *v, *w;
+mfsr_compare(mfsrobject *v, mfsrobject *w)
{
OSErr err;
@@ -860,8 +814,7 @@ mfsr_compare(v, w)
}
static void
-mfsr_dealloc(self)
- mfsrobject *self;
+mfsr_dealloc(mfsrobject *self)
{
PyMem_DEL(self);
}
@@ -890,9 +843,7 @@ statichere PyTypeObject Mfsrtype = {
/* -------------------------------------------------------- */
static PyObject *
-mfs_ResolveAliasFile(self, args)
- PyObject *self; /* Not used */
- PyObject *args;
+mfs_ResolveAliasFile(PyObject *self, PyObject *args)
{
FSSpec fss;
Boolean chain = 1, isfolder, wasaliased;
@@ -910,9 +861,7 @@ mfs_ResolveAliasFile(self, args)
#if !TARGET_API_MAC_CARBON
static PyObject *
-mfs_StandardGetFile(self, args)
- PyObject *self; /* Not used */
- PyObject *args;
+mfs_StandardGetFile(PyObject *self, PyObject *args)
{
SFTypeList list;
short numtypes;
@@ -934,9 +883,7 @@ mfs_StandardGetFile(self, args)
}
static PyObject *
-mfs_PromptGetFile(self, args)
- PyObject *self; /* Not used */
- PyObject *args;
+mfs_PromptGetFile(PyObject *self, PyObject *args)
{
SFTypeList list;
short numtypes;
@@ -959,9 +906,7 @@ mfs_PromptGetFile(self, args)
}
static PyObject *
-mfs_StandardPutFile(self, args)
- PyObject *self; /* Not used */
- PyObject *args;
+mfs_StandardPutFile(PyObject *self, PyObject *args)
{
Str255 prompt, dft;
StandardFileReply reply;
@@ -976,9 +921,7 @@ mfs_StandardPutFile(self, args)
/*
** Set initial directory for file dialogs */
static PyObject *
-mfs_SetFolder(self, args)
- PyObject *self;
- PyObject *args;
+mfs_SetFolder(PyObject *self, PyObject *args)
{
FSSpec spec;
FSSpec ospec;
@@ -1002,9 +945,7 @@ mfs_SetFolder(self, args)
#endif
static PyObject *
-mfs_FSSpec(self, args)
- PyObject *self; /* Not used */
- PyObject *args;
+mfs_FSSpec(PyObject *self, PyObject *args)
{
FSSpec fss;
@@ -1014,9 +955,7 @@ mfs_FSSpec(self, args)
}
static PyObject *
-mfs_FSRef(self, args)
- PyObject *self; /* Not used */
- PyObject *args;
+mfs_FSRef(PyObject *self, PyObject *args)
{
#if TARGET_API_MAC_OS8
PyErr_SetString(PyExc_NotImplementedError, "FSRef objects not supported on this platform");
@@ -1031,9 +970,7 @@ mfs_FSRef(self, args)
}
static PyObject *
-mfs_RawFSSpec(self, args)
- PyObject *self; /* Not used */
- PyObject *args;
+mfs_RawFSSpec(PyObject *self, PyObject *args)
{
FSSpec *fssp;
int size;
@@ -1048,9 +985,7 @@ mfs_RawFSSpec(self, args)
}
static PyObject *
-mfs_RawAlias(self, args)
- PyObject *self; /* Not used */
- PyObject *args;
+mfs_RawAlias(PyObject *self, PyObject *args)
{
char *dataptr;
Handle h;
@@ -1071,9 +1006,7 @@ mfs_RawAlias(self, args)
#if !TARGET_API_MAC_CARBON
static PyObject *
-mfs_GetDirectory(self, args)
- PyObject *self; /* Not used */
- PyObject *args;
+mfs_GetDirectory(PyObject *self, PyObject *args)
{
FSSpec fsdir;
int ok;
@@ -1088,9 +1021,7 @@ mfs_GetDirectory(self, args)
#endif
static PyObject *
-mfs_FindFolder(self, args)
- PyObject *self; /* Not used */
- PyObject *args;
+mfs_FindFolder(PyObject *self, PyObject *args)
{
OSErr err;
short where;
@@ -1110,9 +1041,7 @@ mfs_FindFolder(self, args)
}
static PyObject *
-mfs_FindApplication(self, args)
- PyObject *self; /* Not used */
- PyObject *args;
+mfs_FindApplication(PyObject *self, PyObject *args)
{
OSErr err;
OSType which;
@@ -1129,17 +1058,13 @@ mfs_FindApplication(self, args)
}
static PyObject *
-mfs_FInfo(self, args)
- PyObject *self;
- PyObject *args;
+mfs_FInfo(PyObject *self, PyObject *args)
{
return (PyObject *)newmfsiobject();
}
static PyObject *
-mfs_NewAliasMinimalFromFullPath(self, args)
- PyObject *self; /* Not used */
- PyObject *args;
+mfs_NewAliasMinimalFromFullPath(PyObject *self, PyObject *args)
{
OSErr err;
char *fullpath;
@@ -1277,7 +1202,7 @@ PyObject *PyMac_BuildFSSpec(FSSpec *v)
/* Initialization function for the module (*must* be called initmacfs) */
void
-initmacfs()
+initmacfs(void)
{
PyObject *m, *d;
diff --git a/Mac/Modules/macosmodule.c b/Mac/Modules/macosmodule.c
index c99aa4b..0b8d856 100644
--- a/Mac/Modules/macosmodule.c
+++ b/Mac/Modules/macosmodule.c
@@ -44,8 +44,6 @@ static PyObject *MacOS_Error; /* Exception MacOS.Error */
#define bufferIsSmall -607 /*error returns from Post and Accept */
#endif
-static PyObject *ErrorObject;
-
/* ----------------------------------------------------- */
/* Declarations for objects of type Resource fork */
@@ -63,8 +61,7 @@ staticforward PyTypeObject Rftype;
/* ---------------------------------------------------------------- */
static void
-do_close(self)
- rfobject *self;
+do_close(rfobject *self)
{
if (self->isclosed ) return;
(void)FSClose(self->fRefNum);
@@ -76,9 +73,7 @@ static char rf_read__doc__[] =
;
static PyObject *
-rf_read(self, args)
- rfobject *self;
- PyObject *args;
+rf_read(rfobject *self, PyObject *args)
{
long n;
PyObject *v;
@@ -112,9 +107,7 @@ static char rf_write__doc__[] =
;
static PyObject *
-rf_write(self, args)
- rfobject *self;
- PyObject *args;
+rf_write(rfobject *self, PyObject *args)
{
char *buffer;
long size;
@@ -141,9 +134,7 @@ static char rf_seek__doc__[] =
;
static PyObject *
-rf_seek(self, args)
- rfobject *self;
- PyObject *args;
+rf_seek(rfobject *self, PyObject *args)
{
long amount, pos;
int whence = SEEK_SET;
@@ -157,12 +148,12 @@ rf_seek(self, args)
if (!PyArg_ParseTuple(args, "l|i", &amount, &whence))
return NULL;
- if ( err = GetEOF(self->fRefNum, &eof))
+ if ((err = GetEOF(self->fRefNum, &eof)))
goto ioerr;
switch (whence) {
case SEEK_CUR:
- if (err = GetFPos(self->fRefNum, &pos))
+ if ((err = GetFPos(self->fRefNum, &pos)))
goto ioerr;
break;
case SEEK_END:
@@ -184,7 +175,7 @@ rf_seek(self, args)
return NULL;
}
- if ( err = SetFPos(self->fRefNum, fsFromStart, pos) ) {
+ if ((err = SetFPos(self->fRefNum, fsFromStart, pos)) ) {
ioerr:
PyMac_Error(err);
return NULL;
@@ -199,9 +190,7 @@ static char rf_tell__doc__[] =
;
static PyObject *
-rf_tell(self, args)
- rfobject *self;
- PyObject *args;
+rf_tell(rfobject *self, PyObject *args)
{
long where;
OSErr err;
@@ -212,7 +201,7 @@ rf_tell(self, args)
}
if (!PyArg_ParseTuple(args, ""))
return NULL;
- if ( err = GetFPos(self->fRefNum, &where) ) {
+ if ((err = GetFPos(self->fRefNum, &where)) ) {
PyMac_Error(err);
return NULL;
}
@@ -224,9 +213,7 @@ static char rf_close__doc__[] =
;
static PyObject *
-rf_close(self, args)
- rfobject *self;
- PyObject *args;
+rf_close(rfobject *self, PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
@@ -237,11 +224,11 @@ rf_close(self, args)
static struct PyMethodDef rf_methods[] = {
- {"read", rf_read, 1, rf_read__doc__},
- {"write", rf_write, 1, rf_write__doc__},
- {"seek", rf_seek, 1, rf_seek__doc__},
- {"tell", rf_tell, 1, rf_tell__doc__},
- {"close", rf_close, 1, rf_close__doc__},
+ {"read", (PyCFunction)rf_read, 1, rf_read__doc__},
+ {"write", (PyCFunction)rf_write, 1, rf_write__doc__},
+ {"seek", (PyCFunction)rf_seek, 1, rf_seek__doc__},
+ {"tell", (PyCFunction)rf_tell, 1, rf_tell__doc__},
+ {"close", (PyCFunction)rf_close, 1, rf_close__doc__},
{NULL, NULL} /* sentinel */
};
@@ -250,7 +237,7 @@ static struct PyMethodDef rf_methods[] = {
static rfobject *
-newrfobject()
+newrfobject(void)
{
rfobject *self;
@@ -263,17 +250,14 @@ newrfobject()
static void
-rf_dealloc(self)
- rfobject *self;
+rf_dealloc(rfobject *self)
{
do_close(self);
PyMem_DEL(self);
}
static PyObject *
-rf_getattr(self, name)
- rfobject *self;
- char *name;
+rf_getattr(rfobject *self, char *name)
{
return Py_FindMethod(rf_methods, (PyObject *)self, name);
}
@@ -457,9 +441,7 @@ MacOS_EnableAppswitch(PyObject *self, PyObject *args)
static char setevh_doc[] = "Set python event handler to be called in mainloop";
static PyObject *
-MacOS_SetEventHandler(self, args)
- PyObject *self;
- PyObject *args;
+MacOS_SetEventHandler(PyObject *self, PyObject *args)
{
PyObject *evh = NULL;
@@ -614,6 +596,7 @@ MacOS_openrf(PyObject *self, PyObject *args)
err = HOpenRF(fss.vRefNum, fss.parID, fss.name, permission, &fp->fRefNum);
+#if !TARGET_API_MAC_OSX
if ( err == fnfErr ) {
/* In stead of doing complicated things here to get creator/type
** correct we let the standard i/o library handle it
@@ -635,6 +618,7 @@ MacOS_openrf(PyObject *self, PyObject *args)
fclose(tfp);
err = HOpenRF(fss.vRefNum, fss.parID, fss.name, permission, &fp->fRefNum);
}
+#endif
if ( err ) {
Py_DECREF(fp);
PyMac_Error(err);
@@ -742,7 +726,7 @@ static PyMethodDef MacOS_Methods[] = {
void
-initMacOS()
+initMacOS(void)
{
PyObject *m, *d;
@@ -769,9 +753,11 @@ initMacOS()
if( PyDict_SetItemString(d, "string_id_to_buffer", Py_BuildValue("i", off)) != 0)
return;
}
+#if !TARGET_API_MAC_OSX
if (PyDict_SetItemString(d, "AppearanceCompliant",
Py_BuildValue("i", PyMac_AppearanceCompliant)) != 0)
return;
+#endif
#if TARGET_API_MAC_OSX
#define PY_RUNTIMEMODEL "macho"
#elif TARGET_API_MAC_OS8