Commit deefbe56 authored by Jack Jansen's avatar Jack Jansen

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