Merged release21-maint changes.
[python/dscho.git] / Modules / sgimodule.c
blobb19efe6f79c04d1f926c823261d0eaf12a691da0
2 /* SGI module -- random SGI-specific things */
4 #include "Python.h"
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <unistd.h>
9 #include <fcntl.h>
11 static PyObject *
12 sgi_nap(PyObject *self, PyObject *args)
14 long ticks;
15 if (!PyArg_Parse(args, "l", &ticks))
16 return NULL;
17 Py_BEGIN_ALLOW_THREADS
18 sginap(ticks);
19 Py_END_ALLOW_THREADS
20 Py_INCREF(Py_None);
21 return Py_None;
24 extern char *_getpty(int *, int, mode_t, int);
26 static PyObject *
27 sgi__getpty(PyObject *self, PyObject *args)
29 int oflag;
30 int mode;
31 int nofork;
32 char *name;
33 int fildes;
34 if (!PyArg_Parse(args, "(iii)", &oflag, &mode, &nofork))
35 return NULL;
36 errno = 0;
37 name = _getpty(&fildes, oflag, (mode_t)mode, nofork);
38 if (name == NULL) {
39 PyErr_SetFromErrno(PyExc_IOError);
40 return NULL;
42 return Py_BuildValue("(si)", name, fildes);
45 static PyMethodDef sgi_methods[] = {
46 {"nap", sgi_nap},
47 {"_getpty", sgi__getpty},
48 {NULL, NULL} /* sentinel */
52 void
53 initsgi(void)
55 Py_InitModule("sgi", sgi_methods);