annotate Modules/fcntlmodule.c @ 27998:e27f58a50737 legacy-trunk

SF bug #690377: Dud footnote reference in distutils docs
author Raymond Hettinger <python@rcn.com>
date Fri, 21 Feb 2003 02:47:09 +0000
parents 6ca1c0d3ef19
children 898ce4e96f59
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
1
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 /* fcntl module */
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
4 #include "Python.h"
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
5
4600
d36250aefb82 Keep gcc -Wall happy.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
6 #ifdef HAVE_SYS_FILE_H
d36250aefb82 Keep gcc -Wall happy.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
7 #include <sys/file.h>
d36250aefb82 Keep gcc -Wall happy.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
8 #endif
d36250aefb82 Keep gcc -Wall happy.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
9
4623
1fab981465c8 Include <sys/ioctl.h>, to keep gcc -Wall happy.
Guido van Rossum <guido@python.org>
parents: 4600
diff changeset
10 #include <sys/ioctl.h>
3662
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
11 #include <fcntl.h>
26998
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
12 #ifdef HAVE_STROPTS_H
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
13 #include <stropts.h>
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
14 #endif
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
15
17743
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
16 static int
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
17 conv_descriptor(PyObject *object, int *target)
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
18 {
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
19 int fd = PyObject_AsFileDescriptor(object);
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
20
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
21 if (fd < 0)
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
22 return 0;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
23 *target = fd;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
24 return 1;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
25 }
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
26
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
27
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 /* fcntl(fd, opt, [arg]) */
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
29
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
30 static PyObject *
13519
070e41f2697b ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
31 fcntl_fcntl(PyObject *self, PyObject *args)
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 {
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 int fd;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 int code;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 int arg;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 int ret;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 char *str;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 int len;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 char buf[1024];
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
40
17743
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
41 if (PyArg_ParseTuple(args, "O&is#:fcntl",
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
42 conv_descriptor, &fd, &code, &str, &len)) {
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 if (len > sizeof buf) {
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
44 PyErr_SetString(PyExc_ValueError,
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
45 "fcntl string arg too long");
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 return NULL;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 }
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 memcpy(buf, str, len);
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
49 Py_BEGIN_ALLOW_THREADS
3153
9a896086d3c3 add BGN/END_SAVE macros around fcntl/ioctl calls
Guido van Rossum <guido@python.org>
parents: 2061
diff changeset
50 ret = fcntl(fd, code, buf);
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
51 Py_END_ALLOW_THREADS
3153
9a896086d3c3 add BGN/END_SAVE macros around fcntl/ioctl calls
Guido van Rossum <guido@python.org>
parents: 2061
diff changeset
52 if (ret < 0) {
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
53 PyErr_SetFromErrno(PyExc_IOError);
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 return NULL;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 }
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
56 return PyString_FromStringAndSize(buf, len);
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 }
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
58
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
59 PyErr_Clear();
13814
45d8f23df218 Rob Hooft (Patch #101046): use PyArg_ParseTuple everywhere.
Guido van Rossum <guido@python.org>
parents: 13651
diff changeset
60 arg = 0;
17743
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
61 if (!PyArg_ParseTuple(args,
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
62 "O&i|i;fcntl requires a file or file descriptor,"
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
63 " an integer and optionally a third integer or a string",
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
64 conv_descriptor, &fd, &code, &arg)) {
13814
45d8f23df218 Rob Hooft (Patch #101046): use PyArg_ParseTuple everywhere.
Guido van Rossum <guido@python.org>
parents: 13651
diff changeset
65 return NULL;
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 }
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
67 Py_BEGIN_ALLOW_THREADS
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 ret = fcntl(fd, code, arg);
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
69 Py_END_ALLOW_THREADS
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
70 if (ret < 0) {
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
71 PyErr_SetFromErrno(PyExc_IOError);
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
72 return NULL;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
73 }
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
74 return PyInt_FromLong((long)ret);
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
75 }
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
76
23832
ed1ba37a46b7 Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents: 22114
diff changeset
77 PyDoc_STRVAR(fcntl_doc,
9506
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
78 "fcntl(fd, opt, [arg])\n\
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
79 \n\
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
80 Perform the requested operation on file descriptor fd. The operation\n\
17765
2f0df9f0b088 Fix the fcntl() docstring so the user is not mis-directed to the FCNTL
Fred Drake <fdrake@acm.org>
parents: 17743
diff changeset
81 is defined by op and is operating system dependent. These constants are\n\
2f0df9f0b088 Fix the fcntl() docstring so the user is not mis-directed to the FCNTL
Fred Drake <fdrake@acm.org>
parents: 17743
diff changeset
82 available from the fcntl module. The argument arg is optional, and\n\
2f0df9f0b088 Fix the fcntl() docstring so the user is not mis-directed to the FCNTL
Fred Drake <fdrake@acm.org>
parents: 17743
diff changeset
83 defaults to 0; it may be an int or a string. If arg is given as a string,\n\
2f0df9f0b088 Fix the fcntl() docstring so the user is not mis-directed to the FCNTL
Fred Drake <fdrake@acm.org>
parents: 17743
diff changeset
84 the return value of fcntl is a string of that length, containing the\n\
2f0df9f0b088 Fix the fcntl() docstring so the user is not mis-directed to the FCNTL
Fred Drake <fdrake@acm.org>
parents: 17743
diff changeset
85 resulting value put in the arg buffer by the operating system.The length\n\
2f0df9f0b088 Fix the fcntl() docstring so the user is not mis-directed to the FCNTL
Fred Drake <fdrake@acm.org>
parents: 17743
diff changeset
86 of the arg string is not allowed to exceed 1024 bytes. If the arg given\n\
2f0df9f0b088 Fix the fcntl() docstring so the user is not mis-directed to the FCNTL
Fred Drake <fdrake@acm.org>
parents: 17743
diff changeset
87 is an integer or if none is specified, the result value is an integer\n\
23832
ed1ba37a46b7 Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents: 22114
diff changeset
88 corresponding to the return value of the fcntl call in the C code.");
9506
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
89
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
90
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
91 /* ioctl(fd, opt, [arg]) */
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
92
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
93 static PyObject *
13519
070e41f2697b ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
94 fcntl_ioctl(PyObject *self, PyObject *args)
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
95 {
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
96 int fd;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
97 int code;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
98 int arg;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
99 int ret;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
100 char *str;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
101 int len;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
102 char buf[1024];
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
103
17743
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
104 if (PyArg_ParseTuple(args, "O&is#:ioctl",
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
105 conv_descriptor, &fd, &code, &str, &len)) {
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
106 if (len > sizeof buf) {
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
107 PyErr_SetString(PyExc_ValueError,
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
108 "ioctl string arg too long");
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
109 return NULL;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
110 }
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
111 memcpy(buf, str, len);
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
112 Py_BEGIN_ALLOW_THREADS
3153
9a896086d3c3 add BGN/END_SAVE macros around fcntl/ioctl calls
Guido van Rossum <guido@python.org>
parents: 2061
diff changeset
113 ret = ioctl(fd, code, buf);
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
114 Py_END_ALLOW_THREADS
3153
9a896086d3c3 add BGN/END_SAVE macros around fcntl/ioctl calls
Guido van Rossum <guido@python.org>
parents: 2061
diff changeset
115 if (ret < 0) {
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
116 PyErr_SetFromErrno(PyExc_IOError);
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
117 return NULL;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
118 }
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
119 return PyString_FromStringAndSize(buf, len);
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
120 }
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
121
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
122 PyErr_Clear();
13814
45d8f23df218 Rob Hooft (Patch #101046): use PyArg_ParseTuple everywhere.
Guido van Rossum <guido@python.org>
parents: 13651
diff changeset
123 arg = 0;
17830
d890a21bebda fcntl.ioctl(): Update error message; necessity noted by Michael Hudson.
Fred Drake <fdrake@acm.org>
parents: 17765
diff changeset
124 if (!PyArg_ParseTuple(args,
d890a21bebda fcntl.ioctl(): Update error message; necessity noted by Michael Hudson.
Fred Drake <fdrake@acm.org>
parents: 17765
diff changeset
125 "O&i|i;ioctl requires a file or file descriptor,"
d890a21bebda fcntl.ioctl(): Update error message; necessity noted by Michael Hudson.
Fred Drake <fdrake@acm.org>
parents: 17765
diff changeset
126 " an integer and optionally a third integer or a string",
17743
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
127 conv_descriptor, &fd, &code, &arg)) {
13814
45d8f23df218 Rob Hooft (Patch #101046): use PyArg_ParseTuple everywhere.
Guido van Rossum <guido@python.org>
parents: 13651
diff changeset
128 return NULL;
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
129 }
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
130 Py_BEGIN_ALLOW_THREADS
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
131 ret = ioctl(fd, code, arg);
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
132 Py_END_ALLOW_THREADS
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
133 if (ret < 0) {
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
134 PyErr_SetFromErrno(PyExc_IOError);
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
135 return NULL;
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
136 }
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
137 return PyInt_FromLong((long)ret);
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
138 }
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
139
23832
ed1ba37a46b7 Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents: 22114
diff changeset
140 PyDoc_STRVAR(ioctl_doc,
9506
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
141 "ioctl(fd, opt, [arg])\n\
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
142 \n\
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
143 Perform the requested operation on file descriptor fd. The operation\n\
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
144 is defined by op and is operating system dependent. Typically these\n\
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
145 codes can be retrieved from the library module IOCTL. The argument arg\n\
13814
45d8f23df218 Rob Hooft (Patch #101046): use PyArg_ParseTuple everywhere.
Guido van Rossum <guido@python.org>
parents: 13651
diff changeset
146 is optional, and defaults to 0; it may be an int or a string. If arg is\n\
45d8f23df218 Rob Hooft (Patch #101046): use PyArg_ParseTuple everywhere.
Guido van Rossum <guido@python.org>
parents: 13651
diff changeset
147 given as a string, the return value of ioctl is a string of that length,\n\
45d8f23df218 Rob Hooft (Patch #101046): use PyArg_ParseTuple everywhere.
Guido van Rossum <guido@python.org>
parents: 13651
diff changeset
148 containing the resulting value put in the arg buffer by the operating system.\n\
45d8f23df218 Rob Hooft (Patch #101046): use PyArg_ParseTuple everywhere.
Guido van Rossum <guido@python.org>
parents: 13651
diff changeset
149 The length of the arg string is not allowed to exceed 1024 bytes. If the arg\n\
45d8f23df218 Rob Hooft (Patch #101046): use PyArg_ParseTuple everywhere.
Guido van Rossum <guido@python.org>
parents: 13651
diff changeset
150 given is an integer or if none is specified, the result value is an integer\n\
23832
ed1ba37a46b7 Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents: 22114
diff changeset
151 corresponding to the return value of the ioctl call in the C code.");
9506
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
152
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
153
3598
6c9260ae0d16 Added flock().
Guido van Rossum <guido@python.org>
parents: 3153
diff changeset
154 /* flock(fd, operation) */
6c9260ae0d16 Added flock().
Guido van Rossum <guido@python.org>
parents: 3153
diff changeset
155
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
156 static PyObject *
13519
070e41f2697b ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
157 fcntl_flock(PyObject *self, PyObject *args)
3598
6c9260ae0d16 Added flock().
Guido van Rossum <guido@python.org>
parents: 3153
diff changeset
158 {
6c9260ae0d16 Added flock().
Guido van Rossum <guido@python.org>
parents: 3153
diff changeset
159 int fd;
6c9260ae0d16 Added flock().
Guido van Rossum <guido@python.org>
parents: 3153
diff changeset
160 int code;
6c9260ae0d16 Added flock().
Guido van Rossum <guido@python.org>
parents: 3153
diff changeset
161 int ret;
6c9260ae0d16 Added flock().
Guido van Rossum <guido@python.org>
parents: 3153
diff changeset
162
17743
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
163 if (!PyArg_ParseTuple(args, "O&i:flock",
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
164 conv_descriptor, &fd, &code))
3598
6c9260ae0d16 Added flock().
Guido van Rossum <guido@python.org>
parents: 3153
diff changeset
165 return NULL;
6c9260ae0d16 Added flock().
Guido van Rossum <guido@python.org>
parents: 3153
diff changeset
166
9786
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
167 #ifdef HAVE_FLOCK
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
168 Py_BEGIN_ALLOW_THREADS
3598
6c9260ae0d16 Added flock().
Guido van Rossum <guido@python.org>
parents: 3153
diff changeset
169 ret = flock(fd, code);
9786
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
170 Py_END_ALLOW_THREADS
3662
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
171 #else
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
172
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
173 #ifndef LOCK_SH
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
174 #define LOCK_SH 1 /* shared lock */
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
175 #define LOCK_EX 2 /* exclusive lock */
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
176 #define LOCK_NB 4 /* don't block when locking */
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
177 #define LOCK_UN 8 /* unlock */
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
178 #endif
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
179 {
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
180 struct flock l;
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
181 if (code == LOCK_UN)
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
182 l.l_type = F_UNLCK;
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
183 else if (code & LOCK_SH)
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
184 l.l_type = F_RDLCK;
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
185 else if (code & LOCK_EX)
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
186 l.l_type = F_WRLCK;
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
187 else {
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
188 PyErr_SetString(PyExc_ValueError,
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
189 "unrecognized flock argument");
3662
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
190 return NULL;
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
191 }
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
192 l.l_whence = l.l_start = l.l_len = 0;
9786
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
193 Py_BEGIN_ALLOW_THREADS
3662
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
194 ret = fcntl(fd, (code & LOCK_NB) ? F_SETLK : F_SETLKW, &l);
9786
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
195 Py_END_ALLOW_THREADS
3662
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
196 }
399470a958c2 A fcntl implementation for systems (like Solaris) without flock() call.
Guido van Rossum <guido@python.org>
parents: 3598
diff changeset
197 #endif /* HAVE_FLOCK */
3598
6c9260ae0d16 Added flock().
Guido van Rossum <guido@python.org>
parents: 3153
diff changeset
198 if (ret < 0) {
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
199 PyErr_SetFromErrno(PyExc_IOError);
3598
6c9260ae0d16 Added flock().
Guido van Rossum <guido@python.org>
parents: 3153
diff changeset
200 return NULL;
6c9260ae0d16 Added flock().
Guido van Rossum <guido@python.org>
parents: 3153
diff changeset
201 }
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
202 Py_INCREF(Py_None);
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
203 return Py_None;
3598
6c9260ae0d16 Added flock().
Guido van Rossum <guido@python.org>
parents: 3153
diff changeset
204 }
6c9260ae0d16 Added flock().
Guido van Rossum <guido@python.org>
parents: 3153
diff changeset
205
23832
ed1ba37a46b7 Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents: 22114
diff changeset
206 PyDoc_STRVAR(flock_doc,
9506
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
207 "flock(fd, operation)\n\
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
208 \n\
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
209 Perform the lock operation op on file descriptor fd. See the Unix \n\
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
210 manual flock(3) for details. (On some systems, this function is\n\
23832
ed1ba37a46b7 Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents: 22114
diff changeset
211 emulated using fcntl().)");
9506
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
212
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
213
4293
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
214 /* lockf(fd, operation) */
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
215 static PyObject *
13519
070e41f2697b ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
216 fcntl_lockf(PyObject *self, PyObject *args)
4293
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
217 {
9786
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
218 int fd, code, ret, whence = 0;
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
219 PyObject *lenobj = NULL, *startobj = NULL;
3598
6c9260ae0d16 Added flock().
Guido van Rossum <guido@python.org>
parents: 3153
diff changeset
220
17743
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
221 if (!PyArg_ParseTuple(args, "O&i|OOi:lockf",
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
222 conv_descriptor, &fd, &code,
9786
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
223 &lenobj, &startobj, &whence))
4293
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
224 return NULL;
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
225
22114
c454b76d51e7 OS/2 EMX port changes (Modules part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21712
diff changeset
226 #if defined(PYOS_OS2) && defined(PYCC_GCC)
c454b76d51e7 OS/2 EMX port changes (Modules part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21712
diff changeset
227 PyErr_SetString(PyExc_NotImplementedError,
c454b76d51e7 OS/2 EMX port changes (Modules part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21712
diff changeset
228 "lockf not supported on OS/2 (EMX)");
c454b76d51e7 OS/2 EMX port changes (Modules part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21712
diff changeset
229 return NULL;
c454b76d51e7 OS/2 EMX port changes (Modules part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21712
diff changeset
230 #else
4293
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
231 #ifndef LOCK_SH
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
232 #define LOCK_SH 1 /* shared lock */
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
233 #define LOCK_EX 2 /* exclusive lock */
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
234 #define LOCK_NB 4 /* don't block when locking */
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
235 #define LOCK_UN 8 /* unlock */
22114
c454b76d51e7 OS/2 EMX port changes (Modules part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21712
diff changeset
236 #endif /* LOCK_SH */
4293
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
237 {
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
238 struct flock l;
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
239 if (code == LOCK_UN)
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
240 l.l_type = F_UNLCK;
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
241 else if (code & LOCK_SH)
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
242 l.l_type = F_RDLCK;
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
243 else if (code & LOCK_EX)
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
244 l.l_type = F_WRLCK;
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
245 else {
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
246 PyErr_SetString(PyExc_ValueError,
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
247 "unrecognized flock argument");
4293
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
248 return NULL;
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
249 }
9786
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
250 l.l_start = l.l_len = 0;
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
251 if (startobj != NULL) {
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
252 #if !defined(HAVE_LARGEFILE_SUPPORT)
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
253 l.l_start = PyInt_AsLong(startobj);
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
254 #else
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
255 l.l_start = PyLong_Check(startobj) ?
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
256 PyLong_AsLongLong(startobj) :
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
257 PyInt_AsLong(startobj);
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
258 #endif
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
259 if (PyErr_Occurred())
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
260 return NULL;
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
261 }
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
262 if (lenobj != NULL) {
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
263 #if !defined(HAVE_LARGEFILE_SUPPORT)
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
264 l.l_len = PyInt_AsLong(lenobj);
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
265 #else
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
266 l.l_len = PyLong_Check(lenobj) ?
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
267 PyLong_AsLongLong(lenobj) :
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
268 PyInt_AsLong(lenobj);
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
269 #endif
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
270 if (PyErr_Occurred())
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
271 return NULL;
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
272 }
4293
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
273 l.l_whence = whence;
9786
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
274 Py_BEGIN_ALLOW_THREADS
4293
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
275 ret = fcntl(fd, (code & LOCK_NB) ? F_SETLK : F_SETLKW, &l);
9786
40f723ac26e8 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
276 Py_END_ALLOW_THREADS
4293
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
277 }
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
278 if (ret < 0) {
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
279 PyErr_SetFromErrno(PyExc_IOError);
4293
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
280 return NULL;
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
281 }
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
282 Py_INCREF(Py_None);
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
283 return Py_None;
22114
c454b76d51e7 OS/2 EMX port changes (Modules part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21712
diff changeset
284 #endif /* defined(PYOS_OS2) && defined(PYCC_GCC) */
4293
69bbc21f55cf Added lockf() call
Guido van Rossum <guido@python.org>
parents: 3662
diff changeset
285 }
3598
6c9260ae0d16 Added flock().
Guido van Rossum <guido@python.org>
parents: 3153
diff changeset
286
23832
ed1ba37a46b7 Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents: 22114
diff changeset
287 PyDoc_STRVAR(lockf_doc,
16245
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
288 "lockf (fd, operation, length=0, start=0, whence=0)\n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
289 \n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
290 This is essentially a wrapper around the fcntl() locking calls. fd is the\n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
291 file descriptor of the file to lock or unlock, and operation is one of the\n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
292 following values:\n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
293 \n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
294 LOCK_UN - unlock\n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
295 LOCK_SH - acquire a shared lock\n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
296 LOCK_EX - acquire an exclusive lock\n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
297 \n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
298 When operation is LOCK_SH or LOCK_EX, it can also be bit-wise OR'd with\n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
299 LOCK_NB to avoid blocking on lock acquisition. If LOCK_NB is used and the\n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
300 lock cannot be acquired, an IOError will be raised and the exception will\n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
301 have an errno attribute set to EACCES or EAGAIN (depending on the operating\n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
302 system -- for portability, check for either value).\n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
303 \n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
304 length is the number of bytes to lock, with the default meaning to lock to\n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
305 EOF. start is the byte offset, relative to whence, to that the lock\n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
306 starts. whence is as with fileobj.seek(), specifically:\n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
307 \n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
308 0 - relative to the start of the file (SEEK_SET)\n\
09736aeab831 Let's keep things portable to non GCC compilers, please.
Sjoerd Mullender <sjoerd@acm.org>
parents: 16238
diff changeset
309 1 - relative to the current buffer position (SEEK_CUR)\n\
23832
ed1ba37a46b7 Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents: 22114
diff changeset
310 2 - relative to the end of the file (SEEK_END)");
9506
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
311
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
312 /* List of functions */
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
313
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
314 static PyMethodDef fcntl_methods[] = {
13814
45d8f23df218 Rob Hooft (Patch #101046): use PyArg_ParseTuple everywhere.
Guido van Rossum <guido@python.org>
parents: 13651
diff changeset
315 {"fcntl", fcntl_fcntl, METH_VARARGS, fcntl_doc},
45d8f23df218 Rob Hooft (Patch #101046): use PyArg_ParseTuple everywhere.
Guido van Rossum <guido@python.org>
parents: 13651
diff changeset
316 {"ioctl", fcntl_ioctl, METH_VARARGS, ioctl_doc},
45d8f23df218 Rob Hooft (Patch #101046): use PyArg_ParseTuple everywhere.
Guido van Rossum <guido@python.org>
parents: 13651
diff changeset
317 {"flock", fcntl_flock, METH_VARARGS, flock_doc},
45d8f23df218 Rob Hooft (Patch #101046): use PyArg_ParseTuple everywhere.
Guido van Rossum <guido@python.org>
parents: 13651
diff changeset
318 {"lockf", fcntl_lockf, METH_VARARGS, lockf_doc},
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
319 {NULL, NULL} /* sentinel */
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
320 };
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
321
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
322
23832
ed1ba37a46b7 Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents: 22114
diff changeset
323 PyDoc_STRVAR(module_doc,
9506
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
324 "This module performs file control and I/O control on file \n\
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
325 descriptors. It is an interface to the fcntl() and ioctl() Unix\n\
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
326 routines. File descriptors can be obtained with the fileno() method of\n\
23832
ed1ba37a46b7 Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents: 22114
diff changeset
327 a file or socket object.");
9506
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
328
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
329 /* Module initialisation */
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
330
5912
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
331 static int
13519
070e41f2697b ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
332 ins(PyObject* d, char* symbol, long value)
5912
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
333 {
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
334 PyObject* v = PyInt_FromLong(value);
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
335 if (!v || PyDict_SetItemString(d, symbol, v) < 0)
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
336 return -1;
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
337
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
338 Py_DECREF(v);
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
339 return 0;
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
340 }
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
341
26998
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
342 #define INS(x) if (ins(d, #x, (long)x)) return -1
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
343
5912
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
344 static int
13519
070e41f2697b ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
345 all_ins(PyObject* d)
5912
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
346 {
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
347 if (ins(d, "LOCK_SH", (long)LOCK_SH)) return -1;
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
348 if (ins(d, "LOCK_EX", (long)LOCK_EX)) return -1;
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
349 if (ins(d, "LOCK_NB", (long)LOCK_NB)) return -1;
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
350 if (ins(d, "LOCK_UN", (long)LOCK_UN)) return -1;
21585
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
351 /* GNU extensions, as of glibc 2.2.4 */
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
352 #ifdef LOCK_MAND
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
353 if (ins(d, "LOCK_MAND", (long)LOCK_MAND)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
354 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
355 #ifdef LOCK_READ
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
356 if (ins(d, "LOCK_READ", (long)LOCK_READ)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
357 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
358 #ifdef LOCK_WRITE
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
359 if (ins(d, "LOCK_WRITE", (long)LOCK_WRITE)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
360 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
361 #ifdef LOCK_RW
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
362 if (ins(d, "LOCK_RW", (long)LOCK_RW)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
363 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
364
17743
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
365 #ifdef F_DUPFD
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
366 if (ins(d, "F_DUPFD", (long)F_DUPFD)) return -1;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
367 #endif
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
368 #ifdef F_GETFD
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
369 if (ins(d, "F_GETFD", (long)F_GETFD)) return -1;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
370 #endif
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
371 #ifdef F_SETFD
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
372 if (ins(d, "F_SETFD", (long)F_SETFD)) return -1;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
373 #endif
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
374 #ifdef F_GETFL
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
375 if (ins(d, "F_GETFL", (long)F_GETFL)) return -1;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
376 #endif
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
377 #ifdef F_SETFL
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
378 if (ins(d, "F_SETFL", (long)F_SETFL)) return -1;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
379 #endif
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
380 #ifdef F_GETLK
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
381 if (ins(d, "F_GETLK", (long)F_GETLK)) return -1;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
382 #endif
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
383 #ifdef F_SETLK
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
384 if (ins(d, "F_SETLK", (long)F_SETLK)) return -1;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
385 #endif
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
386 #ifdef F_SETLKW
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
387 if (ins(d, "F_SETLKW", (long)F_SETLKW)) return -1;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
388 #endif
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
389 #ifdef F_GETOWN
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
390 if (ins(d, "F_GETOWN", (long)F_GETOWN)) return -1;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
391 #endif
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
392 #ifdef F_SETOWN
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
393 if (ins(d, "F_SETOWN", (long)F_SETOWN)) return -1;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
394 #endif
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
395 #ifdef F_GETSIG
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
396 if (ins(d, "F_GETSIG", (long)F_GETSIG)) return -1;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
397 #endif
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
398 #ifdef F_SETSIG
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
399 if (ins(d, "F_SETSIG", (long)F_SETSIG)) return -1;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
400 #endif
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
401 #ifdef F_RDLCK
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
402 if (ins(d, "F_RDLCK", (long)F_RDLCK)) return -1;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
403 #endif
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
404 #ifdef F_WRLCK
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
405 if (ins(d, "F_WRLCK", (long)F_WRLCK)) return -1;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
406 #endif
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
407 #ifdef F_UNLCK
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
408 if (ins(d, "F_UNLCK", (long)F_UNLCK)) return -1;
3ee9a3f60bc7 Modify to allow file objects wherever file descriptors are needed.
Fred Drake <fdrake@acm.org>
parents: 16245
diff changeset
409 #endif
21585
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
410 /* LFS constants */
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
411 #ifdef F_GETLK64
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
412 if (ins(d, "F_GETLK64", (long)F_GETLK64)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
413 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
414 #ifdef F_SETLK64
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
415 if (ins(d, "F_SETLK64", (long)F_SETLK64)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
416 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
417 #ifdef F_SETLKW64
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
418 if (ins(d, "F_SETLKW64", (long)F_SETLKW64)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
419 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
420 /* GNU extensions, as of glibc 2.2.4. */
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
421 #ifdef F_SETLEASE
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
422 if (ins(d, "F_SETLEASE", (long)F_SETLEASE)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
423 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
424 #ifdef F_GETLEASE
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
425 if (ins(d, "F_GETLEASE", (long)F_GETLEASE)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
426 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
427 #ifdef F_NOTIFY
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
428 if (ins(d, "F_NOTIFY", (long)F_NOTIFY)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
429 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
430 /* Old BSD flock(). */
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
431 #ifdef F_EXLCK
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
432 if (ins(d, "F_EXLCK", (long)F_EXLCK)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
433 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
434 #ifdef F_SHLCK
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
435 if (ins(d, "F_SHLCK", (long)F_SHLCK)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
436 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
437
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
438 /* For F_{GET|SET}FL */
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
439 #ifdef FD_CLOEXEC
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
440 if (ins(d, "FD_CLOEXEC", (long)FD_CLOEXEC)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
441 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
442
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
443 /* For F_NOTIFY */
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
444 #ifdef DN_ACCESS
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
445 if (ins(d, "DN_ACCESS", (long)DN_ACCESS)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
446 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
447 #ifdef DN_MODIFY
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
448 if (ins(d, "DN_MODIFY", (long)DN_MODIFY)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
449 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
450 #ifdef DN_CREATE
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
451 if (ins(d, "DN_CREATE", (long)DN_CREATE)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
452 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
453 #ifdef DN_DELETE
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
454 if (ins(d, "DN_DELETE", (long)DN_DELETE)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
455 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
456 #ifdef DN_RENAME
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
457 if (ins(d, "DN_RENAME", (long)DN_RENAME)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
458 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
459 #ifdef DN_ATTRIB
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
460 if (ins(d, "DN_ATTRIB", (long)DN_ATTRIB)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
461 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
462 #ifdef DN_MULTISHOT
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
463 if (ins(d, "DN_MULTISHOT", (long)DN_MULTISHOT)) return -1;
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
464 #endif
fdc39e27a494 Add fcntl.h constants from glibc 2.2.4. Fixes #496171.
Martin v. Löwis <martin@v.loewis.de>
parents: 17830
diff changeset
465
26998
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
466 #ifdef HAVE_STROPTS_H
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
467 /* Unix 98 guarantees that these are in stropts.h. */
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
468 INS(I_PUSH);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
469 INS(I_POP);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
470 INS(I_LOOK);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
471 INS(I_FLUSH);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
472 INS(I_FLUSHBAND);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
473 INS(I_SETSIG);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
474 INS(I_GETSIG);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
475 INS(I_FIND);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
476 INS(I_PEEK);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
477 INS(I_SRDOPT);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
478 INS(I_GRDOPT);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
479 INS(I_NREAD);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
480 INS(I_FDINSERT);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
481 INS(I_STR);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
482 INS(I_SWROPT);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
483 INS(I_GWROPT);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
484 INS(I_SENDFD);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
485 INS(I_RECVFD);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
486 INS(I_LIST);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
487 INS(I_ATMARK);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
488 INS(I_CKBAND);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
489 INS(I_GETBAND);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
490 INS(I_CANPUT);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
491 INS(I_SETCLTIME);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
492 INS(I_GETCLTIME);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
493 INS(I_LINK);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
494 INS(I_UNLINK);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
495 INS(I_PLINK);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
496 INS(I_PUNLINK);
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
497 #endif
6ca1c0d3ef19 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal.
Martin v. Löwis <martin@v.loewis.de>
parents: 24471
diff changeset
498
6055
72d004971b26 Keep gcc -Wall happy
Guido van Rossum <guido@python.org>
parents: 5912
diff changeset
499 return 0;
5912
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
500 }
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
501
24471
f66b3a3509c7 Excise DL_EXPORT/DL_IMPORT from Modules/*. Required adding a prototype
Mark Hammond <mhammond@skippinet.com.au>
parents: 23832
diff changeset
502 PyMODINIT_FUNC
13651
8a063423e0b7 Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents: 13519
diff changeset
503 initfcntl(void)
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
504 {
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
505 PyObject *m, *d;
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
506
9506
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
507 /* Create the module and add the functions and documentation */
04426224302a Doc strings by Chris Petrilli.
Guido van Rossum <guido@python.org>
parents: 6055
diff changeset
508 m = Py_InitModule3("fcntl", fcntl_methods, module_doc);
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
509
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
510 /* Add some symbolic constants to the module */
4757
e1f1725cae6d Grandly renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4623
diff changeset
511 d = PyModule_GetDict(m);
5912
f527c12f2e55 Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
Guido van Rossum <guido@python.org>
parents: 4758
diff changeset
512 all_ins(d);
960
7d3a053c6765 struct: pack/unpack binary structs; fcntl: fcntl(), ioctl().
Guido van Rossum <guido@python.org>
parents:
diff changeset
513 }