1
2 /* SGI module -- random SGI-specific things */
3
4 #include "Python.h"
5
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <fcntl.h>
9
10 static PyObject *
sgi_nap(PyObject * self,PyObject * args)11 sgi_nap(PyObject *self, PyObject *args)
12 {
13 long ticks;
14 if (!PyArg_ParseTuple(args, "l:nap", &ticks))
15 return NULL;
16 Py_BEGIN_ALLOW_THREADS
17 sginap(ticks);
18 Py_END_ALLOW_THREADS
19 Py_INCREF(Py_None);
20 return Py_None;
21 }
22
23 extern char *_getpty(int *, int, mode_t, int);
24
25 static PyObject *
sgi__getpty(PyObject * self,PyObject * args)26 sgi__getpty(PyObject *self, PyObject *args)
27 {
28 int oflag;
29 int mode;
30 int nofork;
31 char *name;
32 int fildes;
33 if (!PyArg_ParseTuple(args, "iii:_getpty", &oflag, &mode, &nofork))
34 return NULL;
35 errno = 0;
36 name = _getpty(&fildes, oflag, (mode_t)mode, nofork);
37 if (name == NULL) {
38 PyErr_SetFromErrno(PyExc_IOError);
39 return NULL;
40 }
41 return Py_BuildValue("(si)", name, fildes);
42 }
43
44 static PyMethodDef sgi_methods[] = {
45 {"nap", sgi_nap, METH_VARARGS},
46 {"_getpty", sgi__getpty, METH_VARARGS},
47 {NULL, NULL} /* sentinel */
48 };
49
50
51 void
initsgi(void)52 initsgi(void)
53 {
54 Py_InitModule("sgi", sgi_methods);
55 }
56