summaryrefslogtreecommitdiffstats
path: root/RISCOS/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'RISCOS/Modules')
-rw-r--r--RISCOS/Modules/config.c15
-rw-r--r--RISCOS/Modules/drawfmodule.c6
-rw-r--r--RISCOS/Modules/getpath_riscos.c6
-rw-r--r--RISCOS/Modules/riscosmodule.c84
-rw-r--r--RISCOS/Modules/swimodule.c5
5 files changed, 85 insertions, 31 deletions
diff --git a/RISCOS/Modules/config.c b/RISCOS/Modules/config.c
index 75e056f..03f6e3c 100644
--- a/RISCOS/Modules/config.c
+++ b/RISCOS/Modules/config.c
@@ -41,10 +41,11 @@ PERFORMANCE OF THIS SOFTWARE.
/* -- ADDMODULE MARKER 1 -- */
-extern void PyMarshal_Init();
-extern void initimp();
-extern void initriscos();
-extern void initswi();
+extern void PyMarshal_Init(void);
+extern void initimp(void);
+extern void initgc(void);
+extern void initriscos(void);
+extern void initswi(void);
struct _inittab _PyImport_Inittab[] = {
@@ -62,6 +63,12 @@ struct _inittab _PyImport_Inittab[] = {
{"__main__", NULL},
{"__builtin__", NULL},
{"sys", NULL},
+ {"exceptions", NULL},
+
+#ifdef WITH_CYCLE_GC
+ /* This lives in gcmodule.c */
+ {"gc", initgc},
+#endif
/* Sentinel */
{0, 0}
diff --git a/RISCOS/Modules/drawfmodule.c b/RISCOS/Modules/drawfmodule.c
index 1ac4736..db74d36 100644
--- a/RISCOS/Modules/drawfmodule.c
+++ b/RISCOS/Modules/drawfmodule.c
@@ -1,8 +1,8 @@
/* drawf DrawFile functions */
-#include "h.os"
-#include "h.osfile"
-#include "h.drawfile"
+#include "oslib/os.h"
+#include "oslib/osfile.h"
+#include "oslib/drawfile.h"
#include "Python.h"
#include <limits.h>
diff --git a/RISCOS/Modules/getpath_riscos.c b/RISCOS/Modules/getpath_riscos.c
index 8b36952..8705e2c 100644
--- a/RISCOS/Modules/getpath_riscos.c
+++ b/RISCOS/Modules/getpath_riscos.c
@@ -5,7 +5,7 @@ static char *prefix,*exec_prefix,*progpath,*module_search_path=0;
static void
calculate_path()
-{ char *pypath=Py_GETENV("Python$Path");
+{ char *pypath=getenv("Python$Path");
if(pypath)
{ module_search_path=malloc(strlen(pypath)+1);
if (module_search_path) sprintf(module_search_path,"%s",pypath);
@@ -16,9 +16,9 @@ calculate_path()
}
}
if(!module_search_path) module_search_path = "<Python$Dir>.Lib";
- prefix="";
+ prefix="<Python$Dir>";
exec_prefix=prefix;
- progpath="<Python$Dir>";
+ progpath=Py_GetProgramName();
}
/* External interface */
diff --git a/RISCOS/Modules/riscosmodule.c b/RISCOS/Modules/riscosmodule.c
index d5cdd94..9d3510c 100644
--- a/RISCOS/Modules/riscosmodule.c
+++ b/RISCOS/Modules/riscosmodule.c
@@ -1,9 +1,10 @@
/* RISCOS module implementation */
-#include "h.osfscontrol"
-#include "h.osgbpb"
-#include "h.os"
-#include "h.osfile"
+#include "oslib/osfscontrol.h"
+#include "oslib/osgbpb.h"
+#include "oslib/os.h"
+#include "oslib/osfile.h"
+#include "unixstuff.h"
#include "Python.h"
@@ -11,21 +12,26 @@
static os_error *e;
-static PyObject *RiscosError; /* Exception riscos.error */
+/*static PyObject *RiscosError;*/ /* Exception riscos.error */
+
+static PyObject *riscos_error(char *s)
+{
+ PyErr_SetString(PyExc_OSError, s);
+ return NULL;
+}
static PyObject *riscos_oserror(void)
-{ PyErr_SetString(RiscosError,e->errmess);
- return 0;
+{
+ return riscos_error(e->errmess);
}
-static PyObject *riscos_error(char *s) { PyErr_SetString(RiscosError,s);return 0;}
/* RISCOS file commands */
static PyObject *riscos_remove(PyObject *self,PyObject *args)
{ char *path1;
if (!PyArg_Parse(args, "s", &path1)) return NULL;
- if (remove(path1)) return PyErr_SetFromErrno(RiscosError);
+ if (remove(path1)) return PyErr_SetFromErrno(PyExc_OSError);
Py_INCREF(Py_None);
return Py_None;
}
@@ -33,7 +39,7 @@ static PyObject *riscos_remove(PyObject *self,PyObject *args)
static PyObject *riscos_rename(PyObject *self,PyObject *args)
{ char *path1, *path2;
if (!PyArg_Parse(args, "(ss)", &path1, &path2)) return NULL;
- if (rename(path1,path2)) return PyErr_SetFromErrno(RiscosError);;
+ if (rename(path1,path2)) return PyErr_SetFromErrno(PyExc_OSError);
Py_INCREF(Py_None);
return Py_None;
}
@@ -211,12 +217,56 @@ static PyObject *riscos_chmod(PyObject *self,PyObject *args)
return Py_None;
}
+
static PyObject *riscos_utime(PyObject *self,PyObject *args)
-{ char *path;
- int x,y;
- if (!PyArg_Parse(args, "(s(ii))", &path,&x,&y)) return NULL;
- e=xosfile_stamp(path);
- if(e) return riscos_oserror();
+{
+ char *path;
+ long atime, mtime;
+ PyObject* arg;
+
+ if (!PyArg_ParseTuple(args, "sO:utime", &path, &arg))
+ return NULL;
+
+ if (arg == Py_None) {
+ /* optional time values not given */
+ Py_BEGIN_ALLOW_THREADS
+ e=xosfile_stamp(path);
+ Py_END_ALLOW_THREADS
+ if(e) return riscos_oserror();
+ }
+ else if (!PyArg_Parse(arg, "(ll)", &atime, &mtime)) {
+ PyErr_SetString(PyExc_TypeError,
+ "utime() arg 2 must be a tuple (atime, mtime)");
+ return NULL;
+ }
+ else {
+ /* catalogue info*/
+ fileswitch_object_type obj_type;
+ bits load_addr, exec_addr;
+ int size;
+ fileswitch_attr attr;
+
+ /* read old catalogue info */
+ Py_BEGIN_ALLOW_THREADS
+ e=xosfile_read_no_path(path, &obj_type, &load_addr, &exec_addr, &size, &attr);
+ Py_END_ALLOW_THREADS
+ if(e) return riscos_oserror();
+
+ /* check if load and exec address really contain filetype and date */
+ if ( (load_addr & 0xFFF00000U) != 0xFFF00000U)
+ return riscos_error("can't set date for object with load and exec addresses");
+
+ /* convert argument mtime to RISC OS load and exec address */
+ if(acorntime(&exec_addr, &load_addr, (time_t) mtime))
+ return riscos_oserror();
+
+ /* write new load and exec address */
+ Py_BEGIN_ALLOW_THREADS
+ e = xosfile_write(path, load_addr, exec_addr, attr);
+ Py_END_ALLOW_THREADS
+ if(e) return riscos_oserror();
+ }
+
Py_INCREF(Py_None);
return Py_None;
}
@@ -328,9 +378,7 @@ initriscos()
d = PyModule_GetDict(m);
/* Initialize riscos.error exception */
- RiscosError = PyString_FromString("riscos.error");
- if (RiscosError == NULL || PyDict_SetItemString(d, "error", RiscosError) != 0)
- Py_FatalError("can't define riscos.error");
+ PyDict_SetItemString(d, "error", PyExc_OSError);
PyStructSequence_InitType(&StatResultType, &stat_result_desc);
PyDict_SetItemString(d, "stat_result", (PyObject*) &StatResultType);
diff --git a/RISCOS/Modules/swimodule.c b/RISCOS/Modules/swimodule.c
index 12908d5..ec02ae7 100644
--- a/RISCOS/Modules/swimodule.c
+++ b/RISCOS/Modules/swimodule.c
@@ -13,11 +13,10 @@
* Added "errnum" attribute to swi.error, so one can now check to see what the error number was
*/
-#include "h.os"
-#include "h.kernel"
+#include "oslib/os.h"
+#include <kernel.h>
#include "Python.h"
-#include <errno.h>
#define PyBlock_Check(op) ((op)->ob_type == &PyBlockType)