Mercurial > cpython-lru_cache-weakref
annotate RISCOS/Modules/riscosmodule.c @ 32527:0da660e05e69 legacy-trunk
"#if WITH_THREAD" is incorrect; must be #ifdef instead; WITH_THREAD
isn't always set to an integer value when it's defined.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Wed, 07 Jul 2004 20:42:07 +0000 |
| parents | 90342f395721 |
| children | c2c12814f854 a5298f371be7 |
| 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 { |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
22 PyErr_SetString(PyExc_OSError, s); |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
23 return NULL; |
|
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 { |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
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 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 static PyObject *riscos_remove(PyObject *self,PyObject *args) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 { char *path1; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 if (!PyArg_Parse(args, "s", &path1)) return NULL; |
|
20652
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
37 if (remove(path1)) return PyErr_SetFromErrno(PyExc_OSError); |
|
16941
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 Py_INCREF(Py_None); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
39 return Py_None; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
40 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 static PyObject *riscos_rename(PyObject *self,PyObject *args) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 { char *path1, *path2; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 if (!PyArg_Parse(args, "(ss)", &path1, &path2)) return NULL; |
|
20652
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
45 if (rename(path1,path2)) return PyErr_SetFromErrno(PyExc_OSError); |
|
16941
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
46 Py_INCREF(Py_None); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 return Py_None; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
49 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 static PyObject *riscos_system(PyObject *self,PyObject *args) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 { char *command; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
52 if (!PyArg_Parse(args, "s", &command)) return NULL; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 return PyInt_FromLong(system(command)); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
55 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 static PyObject *riscos_chdir(PyObject *self,PyObject *args) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 { char *path; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 if (!PyArg_Parse(args, "s", &path)) return NULL; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
59 e=xosfscontrol_dir(path); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 if(e) return riscos_oserror(); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 Py_INCREF(Py_None); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
62 return Py_None; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
63 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 static PyObject *canon(char *path) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
66 { int len; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
67 PyObject *obj; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
68 char *buf; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
69 e=xosfscontrol_canonicalise_path(path,0,0,0,0,&len); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
70 if(e) return riscos_oserror(); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
71 obj=PyString_FromStringAndSize(NULL,-len); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
72 if(obj==NULL) return NULL; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
73 buf=PyString_AsString(obj); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
74 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
|
75 if(len!=1) return riscos_error("Error expanding path"); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
76 if(!e) return obj; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
77 Py_DECREF(obj); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
78 return riscos_oserror(); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
79 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
80 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
81 static PyObject *riscos_getcwd(PyObject *self,PyObject *args) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
82 { if(!PyArg_NoArgs(args)) return NULL; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
83 return canon("@"); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
85 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
86 static PyObject *riscos_expand(PyObject *self,PyObject *args) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
87 { char *path; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
88 if (!PyArg_Parse(args, "s", &path)) return NULL; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
89 return canon(path); |
|
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 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
92 static PyObject *riscos_mkdir(PyObject *self,PyObject *args) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
93 { char *path; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
94 int mode; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
95 if (!PyArg_ParseTuple(args, "s|i", &path, &mode)) return NULL; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
96 e=xosfile_create_dir(path,0); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
97 if(e) return riscos_oserror(); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
98 Py_INCREF(Py_None); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
99 return Py_None; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
100 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
101 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
102 static PyObject *riscos_listdir(PyObject *self,PyObject *args) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
103 { char *path,buf[256]; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
104 PyObject *d, *v; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
105 int c=0,count; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
106 if (!PyArg_Parse(args, "s", &path)) return NULL; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
107 d=PyList_New(0); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
108 if(!d) return NULL; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
109 for(;;) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
110 { e=xosgbpb_dir_entries(path,(osgbpb_string_list*)buf, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
111 1,c,256,0,&count,&c); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
112 if(e) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
113 { Py_DECREF(d);return riscos_oserror(); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
114 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
115 if(count) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
116 { v=PyString_FromString(buf); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
117 if(!v) { Py_DECREF(d);return 0;} |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
118 if(PyList_Append(d,v)) {Py_DECREF(d);Py_DECREF(v);return 0;} |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
119 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
120 if(c==-1) break; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
121 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
122 return d; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
123 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
124 |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
125 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
|
126 "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
|
127 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
|
128 (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
|
129 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
|
130 \n\ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
131 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
|
132 \n\ |
|
23832
ed1ba37a46b7
Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
133 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
|
134 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
135 static PyStructSequence_Field stat_result_fields[] = { |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
136 { "st_mode", "protection bits" }, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
137 { "st_ino", "inode" }, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
138 { "st_dev", "device" }, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
139 { "st_nlink", "number of hard links" }, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
140 { "st_uid", "user ID of owner" }, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
141 { "st_gid", "group ID of owner" }, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
142 { "st_size", "total size, in bytes" }, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
143 { "st_atime", "time of last access" }, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
144 { "st_mtime", "time of last modification" }, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
145 { "st_ctime", "time of last change" }, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
146 { "st_ftype", "file type" }, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
147 { "st_attrs", "attributes" }, |
|
20726
587b74854f8c
SF patch #475657 (Dietmar Schwertberger)
Guido van Rossum <guido@python.org>
parents:
20652
diff
changeset
|
148 { "st_obtype", "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
|
149 { 0 } |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
150 }; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
151 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
152 static PyStructSequence_Desc stat_result_desc = { |
|
21313
91dd223829c6
Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents:
20726
diff
changeset
|
153 "riscos.stat_result", |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
154 stat_result__doc__, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
155 stat_result_fields, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
156 13 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
157 }; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
158 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
159 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
|
160 |
|
16941
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
161 static PyObject *riscos_stat(PyObject *self,PyObject *args) |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
162 { |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
163 PyObject *v; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
164 char *path; |
|
16941
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
165 int ob,len; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
166 bits t=0; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
167 bits ld,ex,at,ft,mode; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
168 if (!PyArg_Parse(args, "s", &path)) return NULL; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
169 e=xosfile_read_stamped_no_path(path,&ob,&ld,&ex,&len,&at,&ft); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
170 if(e) return riscos_oserror(); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
171 switch (ob) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
172 { case osfile_IS_FILE:mode=0100000;break; /* OCTAL */ |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 case osfile_IS_DIR:mode=040000;break; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
174 case osfile_IS_IMAGE:mode=0140000;break; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
175 default:return riscos_error("Not found"); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
176 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
177 if(ft!=-1) t=unixtime(ld,ex); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
178 mode|=(at&7)<<6; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
179 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
|
180 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
181 v = PyStructSequence_New(&StatResultType); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
182 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
183 PyStructSequence_SET_ITEM(v, 0, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
184 PyInt_FromLong((long) mode)); /*st_mode*/ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
185 PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long) 0)); /*st_ino*/ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
186 PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long) 0)); /*st_dev*/ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
187 PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long) 0)); /*st_nlink*/ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
188 PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long) 0)); /*st_uid*/ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
189 PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long) 0)); /*st_gid*/ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
190 PyStructSequence_SET_ITEM(v, 6, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
191 PyInt_FromLong((long) len)); /*st_size*/ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
192 PyStructSequence_SET_ITEM(v, 7, PyInt_FromLong((long) t)); /*st_atime*/ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
193 PyStructSequence_SET_ITEM(v, 8, PyInt_FromLong((long) t)); /*st_mtime*/ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
194 PyStructSequence_SET_ITEM(v, 9, PyInt_FromLong((long) t)); /*st_ctime*/ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
195 PyStructSequence_SET_ITEM(v, 10, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
196 PyInt_FromLong((long) ft)); /*file type*/ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
197 PyStructSequence_SET_ITEM(v, 11, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
198 PyInt_FromLong((long) at)); /*attributes*/ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
199 PyStructSequence_SET_ITEM(v, 12, |
|
20726
587b74854f8c
SF patch #475657 (Dietmar Schwertberger)
Guido van Rossum <guido@python.org>
parents:
20652
diff
changeset
|
200 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
|
201 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
202 if (PyErr_Occurred()) { |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
203 Py_DECREF(v); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
204 return NULL; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
205 } |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
206 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
207 return v; |
|
16941
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
208 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
209 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
210 static PyObject *riscos_chmod(PyObject *self,PyObject *args) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
211 { char *path; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
212 bits mode; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
213 bits attr; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
214 attr=(mode&0x700)>>8; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
215 attr|=(mode&7)<<4; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
216 if (!PyArg_Parse(args, "(si)", &path,(int*)&mode)) return NULL; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
217 e=xosfile_write_attr(path,attr); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
218 if(e) return riscos_oserror(); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
219 Py_INCREF(Py_None); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
220 return Py_None; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
221 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
222 |
|
20652
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
223 |
|
16941
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
224 static PyObject *riscos_utime(PyObject *self,PyObject *args) |
|
20652
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
225 { |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
226 char *path; |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
227 long atime, mtime; |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
228 PyObject* arg; |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
229 |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
230 if (!PyArg_ParseTuple(args, "sO:utime", &path, &arg)) |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
231 return NULL; |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
232 |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
233 if (arg == Py_None) { |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
234 /* optional time values not given */ |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
235 Py_BEGIN_ALLOW_THREADS |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
236 e=xosfile_stamp(path); |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
237 Py_END_ALLOW_THREADS |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
238 if(e) return riscos_oserror(); |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
239 } |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
240 else if (!PyArg_Parse(arg, "(ll)", &atime, &mtime)) { |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
241 PyErr_SetString(PyExc_TypeError, |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
242 "utime() arg 2 must be a tuple (atime, mtime)"); |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
243 return NULL; |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
244 } |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
245 else { |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
246 /* catalogue info*/ |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
247 fileswitch_object_type obj_type; |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
248 bits load_addr, exec_addr; |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
249 int size; |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
250 fileswitch_attr attr; |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
251 |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
252 /* read old catalogue info */ |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
253 Py_BEGIN_ALLOW_THREADS |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
254 e=xosfile_read_no_path(path, &obj_type, &load_addr, &exec_addr, &size, &attr); |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
255 Py_END_ALLOW_THREADS |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
256 if(e) return riscos_oserror(); |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
257 |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
258 /* check if load and exec address really contain filetype and date */ |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
259 if ( (load_addr & 0xFFF00000U) != 0xFFF00000U) |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
260 return riscos_error("can't set date for object with load and exec addresses"); |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
261 |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
262 /* convert argument mtime to RISC OS load and exec address */ |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
263 if(acorntime(&exec_addr, &load_addr, (time_t) mtime)) |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
264 return riscos_oserror(); |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
265 |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
266 /* write new load and exec address */ |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
267 Py_BEGIN_ALLOW_THREADS |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
268 e = xosfile_write(path, load_addr, exec_addr, attr); |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
269 Py_END_ALLOW_THREADS |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
270 if(e) return riscos_oserror(); |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
271 } |
|
2d3cee9f1633
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20539
diff
changeset
|
272 |
|
16941
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
273 Py_INCREF(Py_None); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
274 return Py_None; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
275 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
276 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
277 static PyObject *riscos_settype(PyObject *self,PyObject *args) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
278 { char *path,*name; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
279 int type; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
280 if (!PyArg_Parse(args, "(si)", &path,&type)) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
281 { PyErr_Clear(); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
282 if (!PyArg_Parse(args, "(ss)", &path,&name)) return NULL; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
283 e=xosfscontrol_file_type_from_string(name,(bits*)&type); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
284 if(e) return riscos_oserror(); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
285 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
286 e=xosfile_set_type(path,type); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
287 if(e) return riscos_oserror(); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
288 Py_INCREF(Py_None); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
289 return Py_None; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
290 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
291 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
292 static PyObject *riscos_getenv(PyObject *self,PyObject *args) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
293 { char *name,*value; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
294 if(!PyArg_Parse(args,"s",&name)) return NULL; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
295 value=getenv(name); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
296 if(value) return PyString_FromString(value); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
297 Py_INCREF(Py_None); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
298 return Py_None; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
299 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
300 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
301 static PyObject *riscos_putenv(PyObject *self,PyObject *args) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
302 { char *name,*value; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
303 int len; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
304 os_var_type type=os_VARTYPE_LITERAL_STRING; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
305 if(!PyArg_ParseTuple(args,"ss|i",&name,&value,&type)) return NULL; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
306 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
|
307 &&type!=os_VARTYPE_LITERAL_STRING) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
308 return riscos_error("Bad putenv type"); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
309 len=strlen(value); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
310 if(type!=os_VARTYPE_LITERAL_STRING) len++; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
311 /* Other types need null terminator! */ |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
312 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
|
313 if(e) return riscos_oserror(); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
314 Py_INCREF(Py_None); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
315 return Py_None; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
316 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
317 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
318 static PyObject *riscos_delenv(PyObject *self,PyObject *args) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
319 { char *name; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
320 if(!PyArg_Parse(args,"s",&name)) return NULL; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
321 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
|
322 if(e) return riscos_oserror(); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
323 Py_INCREF(Py_None); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
324 return Py_None; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
325 } |
|
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 static PyObject *riscos_getenvdict(PyObject *self,PyObject *args) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
328 { PyObject *dict; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
329 char value[257]; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
330 char *which="*"; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
331 int size; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
332 char *context=NULL; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
333 if(!PyArg_ParseTuple(args,"|s",&which)) return NULL; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
334 dict = PyDict_New(); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
335 if (!dict) return NULL; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
336 /* XXX This part ignores errors */ |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
337 while(!xos_read_var_val(which,value,sizeof(value)-1,(int)context, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
338 os_VARTYPE_EXPANDED,&size,(int *)&context,0)) |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
339 { PyObject *v; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
340 value[size]='\0'; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
341 v = PyString_FromString(value); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
342 if (v == NULL) continue; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
343 PyDict_SetItemString(dict, context, v); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
344 Py_DECREF(v); |
|
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 return dict; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
347 } |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
348 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
349 static PyMethodDef riscos_methods[] = { |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
350 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
351 {"unlink", riscos_remove}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
352 {"remove", riscos_remove}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
353 {"rename", riscos_rename}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
354 {"system", riscos_system}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
355 {"rmdir", riscos_remove}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
356 {"chdir", riscos_chdir}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
357 {"getcwd", riscos_getcwd}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
358 {"expand", riscos_expand}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
359 {"mkdir", riscos_mkdir,1}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
360 {"listdir", riscos_listdir}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
361 {"stat", riscos_stat}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
362 {"lstat", riscos_stat}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
363 {"chmod", riscos_chmod}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
364 {"utime", riscos_utime}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
365 {"settype", riscos_settype}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
366 {"getenv", riscos_getenv}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
367 {"putenv", riscos_putenv}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
368 {"delenv", riscos_delenv}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
369 {"getenvdict", riscos_getenvdict,1}, |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
370 {NULL, NULL} /* Sentinel */ |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
371 }; |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
372 |
|
29066
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
373 static int |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
374 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
|
375 { |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
376 return PyModule_AddIntConstant(module, symbol, value); |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
377 } |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
378 |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
379 |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
380 static int |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
381 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
|
382 { |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
383 #ifdef F_OK |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
384 if (ins(d, "F_OK", (long)F_OK)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
385 #endif |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
386 #ifdef R_OK |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
387 if (ins(d, "R_OK", (long)R_OK)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
388 #endif |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
389 #ifdef W_OK |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
390 if (ins(d, "W_OK", (long)W_OK)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
391 #endif |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
392 #ifdef X_OK |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
393 if (ins(d, "X_OK", (long)X_OK)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
394 #endif |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
395 #ifdef NGROUPS_MAX |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
396 if (ins(d, "NGROUPS_MAX", (long)NGROUPS_MAX)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
397 #endif |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
398 #ifdef TMP_MAX |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
399 if (ins(d, "TMP_MAX", (long)TMP_MAX)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
400 #endif |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
401 #ifdef WCONTINUED |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
402 if (ins(d, "WCONTINUED", (long)WCONTINUED)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
403 #endif |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
404 #ifdef WNOHANG |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
405 if (ins(d, "WNOHANG", (long)WNOHANG)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
406 #endif |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
407 #ifdef WUNTRACED |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
408 if (ins(d, "WUNTRACED", (long)WUNTRACED)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
409 #endif |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
410 #ifdef O_RDONLY |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
411 if (ins(d, "O_RDONLY", (long)O_RDONLY)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
412 #endif |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
413 #ifdef O_WRONLY |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
414 if (ins(d, "O_WRONLY", (long)O_WRONLY)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
415 #endif |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
416 #ifdef O_RDWR |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
417 if (ins(d, "O_RDWR", (long)O_RDWR)) return -1; |
|
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 O_NDELAY |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
420 if (ins(d, "O_NDELAY", (long)O_NDELAY)) return -1; |
|
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 O_NONBLOCK |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
423 if (ins(d, "O_NONBLOCK", (long)O_NONBLOCK)) return -1; |
|
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 O_APPEND |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
426 if (ins(d, "O_APPEND", (long)O_APPEND)) return -1; |
|
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 O_DSYNC |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
429 if (ins(d, "O_DSYNC", (long)O_DSYNC)) return -1; |
|
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 O_RSYNC |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
432 if (ins(d, "O_RSYNC", (long)O_RSYNC)) return -1; |
|
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 O_SYNC |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
435 if (ins(d, "O_SYNC", (long)O_SYNC)) return -1; |
|
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 O_NOCTTY |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
438 if (ins(d, "O_NOCTTY", (long)O_NOCTTY)) return -1; |
|
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 O_CREAT |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
441 if (ins(d, "O_CREAT", (long)O_CREAT)) return -1; |
|
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_EXCL |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
444 if (ins(d, "O_EXCL", (long)O_EXCL)) return -1; |
|
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_TRUNC |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
447 if (ins(d, "O_TRUNC", (long)O_TRUNC)) return -1; |
|
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_BINARY |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
450 if (ins(d, "O_BINARY", (long)O_BINARY)) return -1; |
|
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_TEXT |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
453 if (ins(d, "O_TEXT", (long)O_TEXT)) return -1; |
|
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_LARGEFILE |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
456 if (ins(d, "O_LARGEFILE", (long)O_LARGEFILE)) return -1; |
|
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 |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
459 /* MS Windows */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
460 #ifdef O_NOINHERIT |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
461 /* Don't inherit in child processes. */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
462 if (ins(d, "O_NOINHERIT", (long)O_NOINHERIT)) return -1; |
|
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_SHORT_LIVED |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
465 /* Optimize for short life (keep in memory). */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
466 /* MS forgot to define this one with a non-underscore form too. */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
467 if (ins(d, "O_SHORT_LIVED", (long)_O_SHORT_LIVED)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
468 #endif |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
469 #ifdef O_TEMPORARY |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
470 /* Automatically delete when last handle is closed. */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
471 if (ins(d, "O_TEMPORARY", (long)O_TEMPORARY)) return -1; |
|
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_RANDOM |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
474 /* Optimize for random access. */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
475 if (ins(d, "O_RANDOM", (long)O_RANDOM)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
476 #endif |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
477 #ifdef O_SEQUENTIAL |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
478 /* Optimize for sequential access. */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
479 if (ins(d, "O_SEQUENTIAL", (long)O_SEQUENTIAL)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
480 #endif |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
481 |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
482 /* GNU extensions. */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
483 #ifdef O_DIRECT |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
484 /* Direct disk access. */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
485 if (ins(d, "O_DIRECT", (long)O_DIRECT)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
486 #endif |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
487 #ifdef O_DIRECTORY |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
488 /* Must be a directory. */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
489 if (ins(d, "O_DIRECTORY", (long)O_DIRECTORY)) return -1; |
|
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 #ifdef O_NOFOLLOW |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
492 /* Do not follow links. */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
493 if (ins(d, "O_NOFOLLOW", (long)O_NOFOLLOW)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
494 #endif |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
495 |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
496 /* These come from sysexits.h */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
497 #ifdef EX_OK |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
498 if (ins(d, "EX_OK", (long)EX_OK)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
499 #endif /* EX_OK */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
500 #ifdef EX_USAGE |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
501 if (ins(d, "EX_USAGE", (long)EX_USAGE)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
502 #endif /* EX_USAGE */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
503 #ifdef EX_DATAERR |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
504 if (ins(d, "EX_DATAERR", (long)EX_DATAERR)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
505 #endif /* EX_DATAERR */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
506 #ifdef EX_NOINPUT |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
507 if (ins(d, "EX_NOINPUT", (long)EX_NOINPUT)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
508 #endif /* EX_NOINPUT */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
509 #ifdef EX_NOUSER |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
510 if (ins(d, "EX_NOUSER", (long)EX_NOUSER)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
511 #endif /* EX_NOUSER */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
512 #ifdef EX_NOHOST |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
513 if (ins(d, "EX_NOHOST", (long)EX_NOHOST)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
514 #endif /* EX_NOHOST */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
515 #ifdef EX_UNAVAILABLE |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
516 if (ins(d, "EX_UNAVAILABLE", (long)EX_UNAVAILABLE)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
517 #endif /* EX_UNAVAILABLE */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
518 #ifdef EX_SOFTWARE |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
519 if (ins(d, "EX_SOFTWARE", (long)EX_SOFTWARE)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
520 #endif /* EX_SOFTWARE */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
521 #ifdef EX_OSERR |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
522 if (ins(d, "EX_OSERR", (long)EX_OSERR)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
523 #endif /* EX_OSERR */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
524 #ifdef EX_OSFILE |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
525 if (ins(d, "EX_OSFILE", (long)EX_OSFILE)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
526 #endif /* EX_OSFILE */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
527 #ifdef EX_CANTCREAT |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
528 if (ins(d, "EX_CANTCREAT", (long)EX_CANTCREAT)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
529 #endif /* EX_CANTCREAT */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
530 #ifdef EX_IOERR |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
531 if (ins(d, "EX_IOERR", (long)EX_IOERR)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
532 #endif /* EX_IOERR */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
533 #ifdef EX_TEMPFAIL |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
534 if (ins(d, "EX_TEMPFAIL", (long)EX_TEMPFAIL)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
535 #endif /* EX_TEMPFAIL */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
536 #ifdef EX_PROTOCOL |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
537 if (ins(d, "EX_PROTOCOL", (long)EX_PROTOCOL)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
538 #endif /* EX_PROTOCOL */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
539 #ifdef EX_NOPERM |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
540 if (ins(d, "EX_NOPERM", (long)EX_NOPERM)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
541 #endif /* EX_NOPERM */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
542 #ifdef EX_CONFIG |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
543 if (ins(d, "EX_CONFIG", (long)EX_CONFIG)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
544 #endif /* EX_CONFIG */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
545 #ifdef EX_NOTFOUND |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
546 if (ins(d, "EX_NOTFOUND", (long)EX_NOTFOUND)) return -1; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
547 #endif /* EX_NOTFOUND */ |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
548 |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
549 return 0; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
550 } |
|
16941
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
551 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
552 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
553 void |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
554 initriscos() |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
555 { |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
556 PyObject *m, *d, *stat_m; |
|
16941
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
557 |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
558 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
|
559 |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
560 if (all_ins(m)) |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
561 return; |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
562 |
|
16941
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
563 d = PyModule_GetDict(m); |
|
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
564 |
|
29066
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
565 Py_INCREF(PyExc_OSError); |
|
90342f395721
Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents:
23832
diff
changeset
|
566 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
|
567 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
568 PyStructSequence_InitType(&StatResultType, &stat_result_desc); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
16941
diff
changeset
|
569 PyDict_SetItemString(d, "stat_result", (PyObject*) &StatResultType); |
|
16941
a015aed3a1ac
RISCOS files by dschwertberger
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
570 } |
