Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 1 | |
| 2 | /* SGI module -- random SGI-specific things */ |
| 3 | |
Guido van Rossum | 55db515 | 1996-12-10 00:32:31 +0000 | [diff] [blame] | 4 | #include "Python.h" |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 5 | |
Guido van Rossum | 4302193 | 1994-09-12 10:40:46 +0000 | [diff] [blame] | 6 | #include <sys/types.h> |
| 7 | #include <sys/stat.h> |
Guido van Rossum | 4302193 | 1994-09-12 10:40:46 +0000 | [diff] [blame] | 8 | #include <fcntl.h> |
| 9 | |
Guido van Rossum | 55db515 | 1996-12-10 00:32:31 +0000 | [diff] [blame] | 10 | static PyObject * |
Peter Schneider-Kamp | 41c36ff | 2000-07-10 12:29:26 +0000 | [diff] [blame] | 11 | sgi_nap(PyObject *self, PyObject *args) |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 12 | { |
| 13 | long ticks; |
Neal Norwitz | b0aaec5 | 2002-04-02 18:26:33 +0000 | [diff] [blame] | 14 | if (!PyArg_ParseTuple(args, "l:nap", &ticks)) |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 15 | return NULL; |
Guido van Rossum | 55db515 | 1996-12-10 00:32:31 +0000 | [diff] [blame] | 16 | Py_BEGIN_ALLOW_THREADS |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 17 | sginap(ticks); |
Guido van Rossum | 55db515 | 1996-12-10 00:32:31 +0000 | [diff] [blame] | 18 | Py_END_ALLOW_THREADS |
| 19 | Py_INCREF(Py_None); |
| 20 | return Py_None; |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 21 | } |
| 22 | |
Guido van Rossum | 4302193 | 1994-09-12 10:40:46 +0000 | [diff] [blame] | 23 | extern char *_getpty(int *, int, mode_t, int); |
| 24 | |
Guido van Rossum | 55db515 | 1996-12-10 00:32:31 +0000 | [diff] [blame] | 25 | static PyObject * |
Peter Schneider-Kamp | 41c36ff | 2000-07-10 12:29:26 +0000 | [diff] [blame] | 26 | sgi__getpty(PyObject *self, PyObject *args) |
Guido van Rossum | 4302193 | 1994-09-12 10:40:46 +0000 | [diff] [blame] | 27 | { |
| 28 | int oflag; |
| 29 | int mode; |
| 30 | int nofork; |
| 31 | char *name; |
| 32 | int fildes; |
Neal Norwitz | b0aaec5 | 2002-04-02 18:26:33 +0000 | [diff] [blame] | 33 | if (!PyArg_ParseTuple(args, "iii:_getpty", &oflag, &mode, &nofork)) |
Guido van Rossum | 4302193 | 1994-09-12 10:40:46 +0000 | [diff] [blame] | 34 | return NULL; |
| 35 | errno = 0; |
| 36 | name = _getpty(&fildes, oflag, (mode_t)mode, nofork); |
| 37 | if (name == NULL) { |
Guido van Rossum | 55db515 | 1996-12-10 00:32:31 +0000 | [diff] [blame] | 38 | PyErr_SetFromErrno(PyExc_IOError); |
Guido van Rossum | 4302193 | 1994-09-12 10:40:46 +0000 | [diff] [blame] | 39 | return NULL; |
| 40 | } |
Guido van Rossum | 55db515 | 1996-12-10 00:32:31 +0000 | [diff] [blame] | 41 | return Py_BuildValue("(si)", name, fildes); |
Guido van Rossum | 4302193 | 1994-09-12 10:40:46 +0000 | [diff] [blame] | 42 | } |
| 43 | |
Guido van Rossum | 55db515 | 1996-12-10 00:32:31 +0000 | [diff] [blame] | 44 | static PyMethodDef sgi_methods[] = { |
Neal Norwitz | b0aaec5 | 2002-04-02 18:26:33 +0000 | [diff] [blame] | 45 | {"nap", sgi_nap, METH_VARARGS}, |
| 46 | {"_getpty", sgi__getpty, METH_VARARGS}, |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 47 | {NULL, NULL} /* sentinel */ |
| 48 | }; |
| 49 | |
| 50 | |
| 51 | void |
Thomas Wouters | f3f33dc | 2000-07-21 06:00:07 +0000 | [diff] [blame] | 52 | initsgi(void) |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 53 | { |
Guido van Rossum | 55db515 | 1996-12-10 00:32:31 +0000 | [diff] [blame] | 54 | Py_InitModule("sgi", sgi_methods); |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 55 | } |