blob: b19efe6f79c04d1f926c823261d0eaf12a691da0 [file] [log] [blame]
Guido van Rossum86d25681992-05-15 11:05:54 +00001
2/* SGI module -- random SGI-specific things */
3
Guido van Rossum55db5151996-12-10 00:32:31 +00004#include "Python.h"
Guido van Rossum86d25681992-05-15 11:05:54 +00005
Guido van Rossum43021931994-09-12 10:40:46 +00006#include <sys/types.h>
7#include <sys/stat.h>
8#include <unistd.h>
9#include <fcntl.h>
10
Guido van Rossum55db5151996-12-10 00:32:31 +000011static PyObject *
Peter Schneider-Kamp41c36ff2000-07-10 12:29:26 +000012sgi_nap(PyObject *self, PyObject *args)
Guido van Rossum86d25681992-05-15 11:05:54 +000013{
14 long ticks;
Guido van Rossum55db5151996-12-10 00:32:31 +000015 if (!PyArg_Parse(args, "l", &ticks))
Guido van Rossum86d25681992-05-15 11:05:54 +000016 return NULL;
Guido van Rossum55db5151996-12-10 00:32:31 +000017 Py_BEGIN_ALLOW_THREADS
Guido van Rossum86d25681992-05-15 11:05:54 +000018 sginap(ticks);
Guido van Rossum55db5151996-12-10 00:32:31 +000019 Py_END_ALLOW_THREADS
20 Py_INCREF(Py_None);
21 return Py_None;
Guido van Rossum86d25681992-05-15 11:05:54 +000022}
23
Guido van Rossum43021931994-09-12 10:40:46 +000024extern char *_getpty(int *, int, mode_t, int);
25
Guido van Rossum55db5151996-12-10 00:32:31 +000026static PyObject *
Peter Schneider-Kamp41c36ff2000-07-10 12:29:26 +000027sgi__getpty(PyObject *self, PyObject *args)
Guido van Rossum43021931994-09-12 10:40:46 +000028{
29 int oflag;
30 int mode;
31 int nofork;
32 char *name;
33 int fildes;
Guido van Rossum55db5151996-12-10 00:32:31 +000034 if (!PyArg_Parse(args, "(iii)", &oflag, &mode, &nofork))
Guido van Rossum43021931994-09-12 10:40:46 +000035 return NULL;
36 errno = 0;
37 name = _getpty(&fildes, oflag, (mode_t)mode, nofork);
38 if (name == NULL) {
Guido van Rossum55db5151996-12-10 00:32:31 +000039 PyErr_SetFromErrno(PyExc_IOError);
Guido van Rossum43021931994-09-12 10:40:46 +000040 return NULL;
41 }
Guido van Rossum55db5151996-12-10 00:32:31 +000042 return Py_BuildValue("(si)", name, fildes);
Guido van Rossum43021931994-09-12 10:40:46 +000043}
44
Guido van Rossum55db5151996-12-10 00:32:31 +000045static PyMethodDef sgi_methods[] = {
Guido van Rossum86d25681992-05-15 11:05:54 +000046 {"nap", sgi_nap},
Guido van Rossum43021931994-09-12 10:40:46 +000047 {"_getpty", sgi__getpty},
Guido van Rossum86d25681992-05-15 11:05:54 +000048 {NULL, NULL} /* sentinel */
49};
50
51
52void
Thomas Woutersf3f33dc2000-07-21 06:00:07 +000053initsgi(void)
Guido van Rossum86d25681992-05-15 11:05:54 +000054{
Guido van Rossum55db5151996-12-10 00:32:31 +000055 Py_InitModule("sgi", sgi_methods);
Guido van Rossum86d25681992-05-15 11:05:54 +000056}