annotate RISCOS/Modules/riscosmodule.c @ 80661:94de77bd0b4b 2.7

Issue #16194: document imp.load_dynamic problems when read several extension modules from the same binary object file.
author Andrew Svetlov <andrew.svetlov@gmail.com>
date Thu, 29 Nov 2012 19:51:28 +0200
parents fd25030223b0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 /* RISCOS module implementation */
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
20652
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
3 #include "oslib/osfscontrol.h"
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
4 #include "oslib/osgbpb.h"
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
5 #include "oslib/os.h"
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
6 #include "oslib/osfile.h"
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
7 #include "unixstuff.h"
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
8
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
9 #include <sys/fcntl.h>
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
10
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 #include "Python.h"
20726
587b74854f8c SF patch #475657 (Dietmar Schwertberger)
Guido van Rossum <guido@python.org>
parents: 20652
diff changeset
12 #include "structseq.h"
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
13
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 #include <errno.h>
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
15
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 static os_error *e;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
17
20652
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
18 /*static PyObject *RiscosError;*/ /* Exception riscos.error */
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
19
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
20 static PyObject *riscos_error(char *s)
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
21 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
22 PyErr_SetString(PyExc_OSError, s);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
23 return NULL;
20652
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
24 }
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
25
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 static PyObject *riscos_oserror(void)
20652
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
27 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
28 return riscos_error(e->errmess);
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
30
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
31
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 /* RISCOS file commands */
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
33
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
34 static PyObject *
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
35 riscos_remove(PyObject *self, PyObject *args)
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
36 {
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
37 char *path1;
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
38 if (!PyArg_ParseTuple(args, "s:remove", &path1)) return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
39 if (remove(path1)) return PyErr_SetFromErrno(PyExc_OSError);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
40 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
41 return Py_None;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
43
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
44 static PyObject *
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
45 riscos_rename(PyObject *self, PyObject *args)
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
46 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
47 char *path1, *path2;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
48 if (!PyArg_ParseTuple(args, "ss:rename", &path1, &path2))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
49 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
50 if (rename(path1,path2)) return PyErr_SetFromErrno(PyExc_OSError);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
51 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
52 return Py_None;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
54
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
55 static PyObject *
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
56 riscos_system(PyObject *self, PyObject *args)
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
57 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
58 char *command;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
59 if (!PyArg_ParseTuple(args, "s:system", &command)) return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
60 return PyInt_FromLong(system(command));
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
62
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
63 static PyObject *
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
64 riscos_chdir(PyObject *self, PyObject *args)
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
65 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
66 char *path;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
67 if (!PyArg_ParseTuple(args, "s:chdir", &path)) return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
68 e=xosfscontrol_dir(path);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
69 if(e) return riscos_oserror();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
70 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
71 return Py_None;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
72 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
73
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
74 static PyObject *
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
75 canon(char *path)
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
76 {
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
77 int len;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
78 PyObject *obj;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
79 char *buf;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 e=xosfscontrol_canonicalise_path(path,0,0,0,0,&len);
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
81 if(e) return riscos_oserror();
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
82 obj=PyString_FromStringAndSize(NULL,-len);
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
83 if(obj==NULL) return NULL;
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
84 buf=PyString_AsString(obj);
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
85 e=xosfscontrol_canonicalise_path(path,buf,0,0,1-len,&len);
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
86 if(len!=1) return riscos_error("Error expanding path");
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
87 if(!e) return obj;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
88 Py_DECREF(obj);
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
89 return riscos_oserror();
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
90 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
91
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
92 static PyObject *
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
93 riscos_getcwd(PyObject *self, PyObject *unused)
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
94 {
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
95 return canon("@");
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
96 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
97
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
98 static PyObject *
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
99 riscos_expand(PyObject *self, PyObject *args)
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
100 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
101 char *path;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
102 if (!PyArg_ParseTuple(args, "s:expand", &path)) return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
103 return canon(path);
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
104 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
105
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
106 static PyObject *
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
107 riscos_mkdir(PyObject *self, PyObject *args)
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
108 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
109 char *path;
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
110 int mode;
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
111 if (!PyArg_ParseTuple(args, "s|i:mkdir", &path, &mode)) return NULL;
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
112 e=xosfile_create_dir(path,0);
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
113 if(e) return riscos_oserror();
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
114 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
115 return Py_None;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
116 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
117
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
118 static PyObject *
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
119 riscos_listdir(PyObject *self, PyObject *args)
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
120 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
121 char *path,buf[256];
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
122 PyObject *d, *v;
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
123 int c=0,count;
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
124 if (!PyArg_ParseTuple(args, "s:listdir", &path)) return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
125 d=PyList_New(0);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
126 if(!d) return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
127 for(;;)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
128 { e=xosgbpb_dir_entries(path,(osgbpb_string_list*)buf,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
129 1,c,256,0,&count,&c);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
130 if(e)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
131 { Py_DECREF(d);return riscos_oserror();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
132 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
133 if(count)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
134 { v=PyString_FromString(buf);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
135 if(!v) { Py_DECREF(d);return 0;}
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
136 if(PyList_Append(d,v)) {Py_DECREF(d);Py_DECREF(v);return 0;}
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
137 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
138 if(c==-1) break;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
139 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
140 return d;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
141 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
142
23832
ed1ba37a46b7 Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents: 21313
diff changeset
143 PyDoc_STRVAR(stat_result__doc__,
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
144 "stat_result: Result from stat or lstat.\n\n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
145 This object may be accessed either as a tuple of\n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
146 (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)\n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
147 or via the attributes st_mode, st_ino, st_dev, st_nlink, st_uid, and so on.\n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
148 \n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
149 RiscOS: The fields st_ftype, st_attrs, and st_obtype are also available.\n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
150 \n\
23832
ed1ba37a46b7 Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents: 21313
diff changeset
151 See os.stat for more information.");
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
152
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
153 static PyStructSequence_Field stat_result_fields[] = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
154 { "st_mode", "protection bits" },
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
155 { "st_ino", "inode" },
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
156 { "st_dev", "device" },
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
157 { "st_nlink", "number of hard links" },
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
158 { "st_uid", "user ID of owner" },
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
159 { "st_gid", "group ID of owner" },
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
160 { "st_size", "total size, in bytes" },
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
161 { "st_atime", "time of last access" },
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
162 { "st_mtime", "time of last modification" },
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
163 { "st_ctime", "time of last change" },
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
164 { "st_ftype", "file type" },
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
165 { "st_attrs", "attributes" },
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
166 { "st_obtype", "object type" },
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
167 { 0 }
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
168 };
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
169
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
170 static PyStructSequence_Desc stat_result_desc = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
171 "riscos.stat_result",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
172 stat_result__doc__,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
173 stat_result_fields,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
174 13
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
175 };
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
176
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
177 static PyTypeObject StatResultType;
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
178
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
179 static PyObject *
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
180 riscos_stat(PyObject *self, PyObject *args)
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
181 {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
182 PyObject *v;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
183 char *path;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
184 int ob,len;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
185 bits t=0;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
186 bits ld,ex,at,ft,mode;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
187 if (!PyArg_ParseTuple(args, "s:stat", &path)) return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
188 e=xosfile_read_stamped_no_path(path,&ob,&ld,&ex,&len,&at,&ft);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
189 if(e) return riscos_oserror();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
190 switch (ob)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
191 { case osfile_IS_FILE:mode=0100000;break; /* OCTAL */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
192 case osfile_IS_DIR:mode=040000;break;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
193 case osfile_IS_IMAGE:mode=0140000;break;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
194 default:return riscos_error("Not found");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
195 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
196 if(ft!=-1) t=unixtime(ld,ex);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
197 mode|=(at&7)<<6;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
198 mode|=((at&112)*9)>>4;
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
199
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
200 v = PyStructSequence_New(&StatResultType);
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
201
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
202 PyStructSequence_SET_ITEM(v, 0,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
203 PyInt_FromLong((long) mode)); /*st_mode*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
204 PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long) 0)); /*st_ino*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
205 PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long) 0)); /*st_dev*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
206 PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long) 0)); /*st_nlink*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
207 PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long) 0)); /*st_uid*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
208 PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long) 0)); /*st_gid*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
209 PyStructSequence_SET_ITEM(v, 6,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
210 PyInt_FromLong((long) len)); /*st_size*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
211 PyStructSequence_SET_ITEM(v, 7, PyInt_FromLong((long) t)); /*st_atime*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
212 PyStructSequence_SET_ITEM(v, 8, PyInt_FromLong((long) t)); /*st_mtime*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
213 PyStructSequence_SET_ITEM(v, 9, PyInt_FromLong((long) t)); /*st_ctime*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
214 PyStructSequence_SET_ITEM(v, 10,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
215 PyInt_FromLong((long) ft)); /*file type*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
216 PyStructSequence_SET_ITEM(v, 11,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
217 PyInt_FromLong((long) at)); /*attributes*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
218 PyStructSequence_SET_ITEM(v, 12,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
219 PyInt_FromLong((long) ob)); /*object type*/
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
220
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
221 if (PyErr_Occurred()) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
222 Py_DECREF(v);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
223 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
224 }
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
225
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
226 return v;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
227 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
228
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
229 static PyObject *
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
230 riscos_chmod(PyObject *self,PyObject *args)
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
231 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
232 char *path;
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
233 bits mode;
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
234 bits attr;
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
235 attr=(mode&0x700)>>8;
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
236 attr|=(mode&7)<<4;
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
237 if (!PyArg_ParseTuple(args, "si:chmod", &path,(int*)&mode)) return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
238 e=xosfile_write_attr(path,attr);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
239 if(e) return riscos_oserror();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
240 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
241 return Py_None;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
242 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
243
20652
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
244
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
245 static PyObject *
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
246 riscos_utime(PyObject *self, PyObject *args)
20652
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
247 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
248 char *path;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
249 long atime, mtime;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
250 PyObject* arg;
20652
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
251
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
252 if (!PyArg_ParseTuple(args, "sO:utime", &path, &arg))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
253 return NULL;
20652
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
254
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
255 if (arg == Py_None) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
256 /* optional time values not given */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
257 Py_BEGIN_ALLOW_THREADS
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
258 e=xosfile_stamp(path);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
259 Py_END_ALLOW_THREADS
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
260 if(e) return riscos_oserror();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
261 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
262 else if (!PyArg_Parse(arg, "(ll)", &atime, &mtime)) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
263 PyErr_SetString(PyExc_TypeError,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
264 "utime() arg 2 must be a tuple (atime, mtime)");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
265 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
266 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
267 else {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
268 /* catalogue info*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
269 fileswitch_object_type obj_type;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
270 bits load_addr, exec_addr;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
271 int size;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
272 fileswitch_attr attr;
20652
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
273
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
274 /* read old catalogue info */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
275 Py_BEGIN_ALLOW_THREADS
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
276 e=xosfile_read_no_path(path, &obj_type, &load_addr, &exec_addr, &size, &attr);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
277 Py_END_ALLOW_THREADS
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
278 if(e) return riscos_oserror();
20652
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
279
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
280 /* check if load and exec address really contain filetype and date */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
281 if ( (load_addr & 0xFFF00000U) != 0xFFF00000U)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
282 return riscos_error("can't set date for object with load and exec addresses");
20652
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
283
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
284 /* convert argument mtime to RISC OS load and exec address */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
285 if(acorntime(&exec_addr, &load_addr, (time_t) mtime))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
286 return riscos_oserror();
20652
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
287
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
288 /* write new load and exec address */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
289 Py_BEGIN_ALLOW_THREADS
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
290 e = xosfile_write(path, load_addr, exec_addr, attr);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
291 Py_END_ALLOW_THREADS
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
292 if(e) return riscos_oserror();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
293 }
20652
2d3cee9f1633 SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
294
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
295 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
296 return Py_None;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
297 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
298
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
299 static PyObject *
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
300 riscos_settype(PyObject *self, PyObject *args)
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
301 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
302 char *path,*name;
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
303 int type;
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
304 if (!PyArg_ParseTuple(args, "si:settype", &path,&type))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
305 {
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
306 PyErr_Clear();
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
307 if (!PyArg_ParseTuple(args, "ss:settype", &path,&name)) return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
308 e=xosfscontrol_file_type_from_string(name,(bits*)&type);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
309 if(e) return riscos_oserror();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
310 }
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
311 e=xosfile_set_type(path,type);
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
312 if(e) return riscos_oserror();
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
313 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
314 return Py_None;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
315 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
316
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
317 static PyObject *
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
318 riscos_getenv(PyObject *self, PyObject *args)
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
319 {
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
320 char *name,*value;
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
321 if(!PyArg_ParseTuple(args,"s:getenv",&name)) return NULL;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
322 value=getenv(name);
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
323 if(value) return PyString_FromString(value);
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
324 Py_INCREF(Py_None);
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
325 return Py_None;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
326 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
327
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
328 static PyObject *
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
329 riscos_putenv(PyObject *self, PyObject *args)
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
330 {
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
331 char *name,*value;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
332 int len;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
333 os_var_type type=os_VARTYPE_LITERAL_STRING;
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
334 if(!PyArg_ParseTuple(args,"ss|i:putenv",&name,&value,&type)) return NULL;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
335 if(type!=os_VARTYPE_STRING&&type!=os_VARTYPE_MACRO&&type!=os_VARTYPE_EXPANDED
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
336 &&type!=os_VARTYPE_LITERAL_STRING)
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
337 return riscos_error("Bad putenv type");
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
338 len=strlen(value);
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
339 if(type!=os_VARTYPE_LITERAL_STRING) len++;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
340 /* Other types need null terminator! */
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
341 e=xos_set_var_val(name,(byte*)value,len,0,type,0,0);
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
342 if(e) return riscos_oserror();
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
343 Py_INCREF(Py_None);
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
344 return Py_None;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
345 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
346
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
347 static PyObject *
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
348 riscos_delenv(PyObject *self, PyObject *args)
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
349 {
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
350 char *name;
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
351 if(!PyArg_ParseTuple(args,"s:delenv",&name)) return NULL;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
352 e=xos_set_var_val(name,NULL,-1,0,0,0,0);
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
353 if(e) return riscos_oserror();
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
354 Py_INCREF(Py_None);
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
355 return Py_None;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
356 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
357
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
358 static PyObject *
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
359 riscos_getenvdict(PyObject *self, PyObject *args)
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
360 {
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
361 PyObject *dict;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
362 char value[257];
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
363 char *which="*";
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
364 int size;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
365 char *context=NULL;
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
366 if(!PyArg_ParseTuple(args,"|s:getenvdict",&which)) return NULL;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
367 dict = PyDict_New();
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
368 if (!dict) return NULL;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
369 /* XXX This part ignores errors */
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
370 while(!xos_read_var_val(which,value,sizeof(value)-1,(int)context,
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
371 os_VARTYPE_EXPANDED,&size,(int *)&context,0))
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
372 { PyObject *v;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
373 value[size]='\0';
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
374 v = PyString_FromString(value);
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
375 if (v == NULL) continue;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
376 PyDict_SetItemString(dict, context, v);
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
377 Py_DECREF(v);
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
378 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
379 return dict;
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
380 }
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
381
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
382 static PyMethodDef riscos_methods[] = {
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
383
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
384 {"unlink", riscos_remove, METH_VARARGS},
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 29066
diff changeset
385 {"remove", riscos_remove, METH_VARARGS},
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
386 {"rename", riscos_rename, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
387 {"system", riscos_system, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
388 {"rmdir", riscos_remove, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
389 {"chdir", riscos_chdir, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
390 {"getcwd", riscos_getcwd, METH_NOARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
391 {"expand", riscos_expand, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
392 {"mkdir", riscos_mkdir, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
393 {"listdir", riscos_listdir, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
394 {"stat", riscos_stat, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
395 {"lstat", riscos_stat, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
396 {"chmod", riscos_chmod, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
397 {"utime", riscos_utime, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
398 {"settype", riscos_settype, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
399 {"getenv", riscos_getenv, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
400 {"putenv", riscos_putenv, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
401 {"delenv", riscos_delenv, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
402 {"getenvdict", riscos_getenvdict, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
403 {NULL, NULL} /* Sentinel */
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
404 };
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
405
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
406 static int
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
407 ins(PyObject *module, char *symbol, long value)
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
408 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
409 return PyModule_AddIntConstant(module, symbol, value);
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
410 }
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
411
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
412
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
413 static int
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
414 all_ins(PyObject *d)
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
415 {
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
416 #ifdef F_OK
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
417 if (ins(d, "F_OK", (long)F_OK)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
418 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
419 #ifdef R_OK
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
420 if (ins(d, "R_OK", (long)R_OK)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
421 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
422 #ifdef W_OK
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
423 if (ins(d, "W_OK", (long)W_OK)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
424 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
425 #ifdef X_OK
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
426 if (ins(d, "X_OK", (long)X_OK)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
427 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
428 #ifdef NGROUPS_MAX
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
429 if (ins(d, "NGROUPS_MAX", (long)NGROUPS_MAX)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
430 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
431 #ifdef TMP_MAX
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
432 if (ins(d, "TMP_MAX", (long)TMP_MAX)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
433 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
434 #ifdef WCONTINUED
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
435 if (ins(d, "WCONTINUED", (long)WCONTINUED)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
436 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
437 #ifdef WNOHANG
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
438 if (ins(d, "WNOHANG", (long)WNOHANG)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
439 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
440 #ifdef WUNTRACED
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
441 if (ins(d, "WUNTRACED", (long)WUNTRACED)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
442 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
443 #ifdef O_RDONLY
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
444 if (ins(d, "O_RDONLY", (long)O_RDONLY)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
445 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
446 #ifdef O_WRONLY
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
447 if (ins(d, "O_WRONLY", (long)O_WRONLY)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
448 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
449 #ifdef O_RDWR
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
450 if (ins(d, "O_RDWR", (long)O_RDWR)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
451 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
452 #ifdef O_NDELAY
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
453 if (ins(d, "O_NDELAY", (long)O_NDELAY)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
454 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
455 #ifdef O_NONBLOCK
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
456 if (ins(d, "O_NONBLOCK", (long)O_NONBLOCK)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
457 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
458 #ifdef O_APPEND
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
459 if (ins(d, "O_APPEND", (long)O_APPEND)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
460 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
461 #ifdef O_DSYNC
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
462 if (ins(d, "O_DSYNC", (long)O_DSYNC)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
463 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
464 #ifdef O_RSYNC
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
465 if (ins(d, "O_RSYNC", (long)O_RSYNC)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
466 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
467 #ifdef O_SYNC
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
468 if (ins(d, "O_SYNC", (long)O_SYNC)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
469 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
470 #ifdef O_NOCTTY
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
471 if (ins(d, "O_NOCTTY", (long)O_NOCTTY)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
472 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
473 #ifdef O_CREAT
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
474 if (ins(d, "O_CREAT", (long)O_CREAT)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
475 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
476 #ifdef O_EXCL
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
477 if (ins(d, "O_EXCL", (long)O_EXCL)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
478 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
479 #ifdef O_TRUNC
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
480 if (ins(d, "O_TRUNC", (long)O_TRUNC)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
481 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
482 #ifdef O_BINARY
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
483 if (ins(d, "O_BINARY", (long)O_BINARY)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
484 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
485 #ifdef O_TEXT
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
486 if (ins(d, "O_TEXT", (long)O_TEXT)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
487 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
488 #ifdef O_LARGEFILE
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
489 if (ins(d, "O_LARGEFILE", (long)O_LARGEFILE)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
490 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
491
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
492 /* MS Windows */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
493 #ifdef O_NOINHERIT
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
494 /* Don't inherit in child processes. */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
495 if (ins(d, "O_NOINHERIT", (long)O_NOINHERIT)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
496 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
497 #ifdef _O_SHORT_LIVED
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
498 /* Optimize for short life (keep in memory). */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
499 /* MS forgot to define this one with a non-underscore form too. */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
500 if (ins(d, "O_SHORT_LIVED", (long)_O_SHORT_LIVED)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
501 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
502 #ifdef O_TEMPORARY
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
503 /* Automatically delete when last handle is closed. */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
504 if (ins(d, "O_TEMPORARY", (long)O_TEMPORARY)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
505 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
506 #ifdef O_RANDOM
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
507 /* Optimize for random access. */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
508 if (ins(d, "O_RANDOM", (long)O_RANDOM)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
509 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
510 #ifdef O_SEQUENTIAL
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
511 /* Optimize for sequential access. */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
512 if (ins(d, "O_SEQUENTIAL", (long)O_SEQUENTIAL)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
513 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
514
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
515 /* GNU extensions. */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
516 #ifdef O_DIRECT
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
517 /* Direct disk access. */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
518 if (ins(d, "O_DIRECT", (long)O_DIRECT)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
519 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
520 #ifdef O_DIRECTORY
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
521 /* Must be a directory. */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
522 if (ins(d, "O_DIRECTORY", (long)O_DIRECTORY)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
523 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
524 #ifdef O_NOFOLLOW
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
525 /* Do not follow links. */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
526 if (ins(d, "O_NOFOLLOW", (long)O_NOFOLLOW)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
527 #endif
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
528
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
529 /* These come from sysexits.h */
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
530 #ifdef EX_OK
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
531 if (ins(d, "EX_OK", (long)EX_OK)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
532 #endif /* EX_OK */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
533 #ifdef EX_USAGE
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
534 if (ins(d, "EX_USAGE", (long)EX_USAGE)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
535 #endif /* EX_USAGE */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
536 #ifdef EX_DATAERR
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
537 if (ins(d, "EX_DATAERR", (long)EX_DATAERR)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
538 #endif /* EX_DATAERR */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
539 #ifdef EX_NOINPUT
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
540 if (ins(d, "EX_NOINPUT", (long)EX_NOINPUT)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
541 #endif /* EX_NOINPUT */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
542 #ifdef EX_NOUSER
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
543 if (ins(d, "EX_NOUSER", (long)EX_NOUSER)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
544 #endif /* EX_NOUSER */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
545 #ifdef EX_NOHOST
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
546 if (ins(d, "EX_NOHOST", (long)EX_NOHOST)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
547 #endif /* EX_NOHOST */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
548 #ifdef EX_UNAVAILABLE
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
549 if (ins(d, "EX_UNAVAILABLE", (long)EX_UNAVAILABLE)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
550 #endif /* EX_UNAVAILABLE */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
551 #ifdef EX_SOFTWARE
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
552 if (ins(d, "EX_SOFTWARE", (long)EX_SOFTWARE)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
553 #endif /* EX_SOFTWARE */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
554 #ifdef EX_OSERR
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
555 if (ins(d, "EX_OSERR", (long)EX_OSERR)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
556 #endif /* EX_OSERR */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
557 #ifdef EX_OSFILE
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
558 if (ins(d, "EX_OSFILE", (long)EX_OSFILE)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
559 #endif /* EX_OSFILE */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
560 #ifdef EX_CANTCREAT
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
561 if (ins(d, "EX_CANTCREAT", (long)EX_CANTCREAT)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
562 #endif /* EX_CANTCREAT */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
563 #ifdef EX_IOERR
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
564 if (ins(d, "EX_IOERR", (long)EX_IOERR)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
565 #endif /* EX_IOERR */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
566 #ifdef EX_TEMPFAIL
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
567 if (ins(d, "EX_TEMPFAIL", (long)EX_TEMPFAIL)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
568 #endif /* EX_TEMPFAIL */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
569 #ifdef EX_PROTOCOL
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
570 if (ins(d, "EX_PROTOCOL", (long)EX_PROTOCOL)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
571 #endif /* EX_PROTOCOL */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
572 #ifdef EX_NOPERM
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
573 if (ins(d, "EX_NOPERM", (long)EX_NOPERM)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
574 #endif /* EX_NOPERM */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
575 #ifdef EX_CONFIG
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
576 if (ins(d, "EX_CONFIG", (long)EX_CONFIG)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
577 #endif /* EX_CONFIG */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
578 #ifdef EX_NOTFOUND
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
579 if (ins(d, "EX_NOTFOUND", (long)EX_NOTFOUND)) return -1;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
580 #endif /* EX_NOTFOUND */
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
581
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
582 return 0;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
583 }
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
584
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
585
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
586 void
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
587 initriscos()
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
588 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
589 PyObject *m, *d, *stat_m;
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
590
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
591 m = Py_InitModule("riscos", riscos_methods);
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
592
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
593 if (all_ins(m))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
594 return;
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 23832
diff changeset
595
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
596 d = PyModule_GetDict(m);
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
597
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
598 Py_INCREF(PyExc_OSError);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
599 PyModule_AddObject(m, "error", PyExc_OSError);
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 16941
diff changeset
600
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
601 PyStructSequence_InitType(&StatResultType, &stat_result_desc);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
602 PyDict_SetItemString(d, "stat_result", (PyObject*) &StatResultType);
16941
a015aed3a1ac RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff changeset
603 }