blob: 0d132481a03278a24359cb2fbbdf7f2817927c14 [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>
Guido van Rossum43021931994-09-12 10:40:46 +00008#include <fcntl.h>
9
Guido van Rossum55db5151996-12-10 00:32:31 +000010static PyObject *
Peter Schneider-Kamp41c36ff2000-07-10 12:29:26 +000011sgi_nap(PyObject *self, PyObject *args)
Guido van Rossum86d25681992-05-15 11:05:54 +000012{
Antoine Pitrouc83ea132010-05-09 14:46:46 +000013 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;
Guido van Rossum86d25681992-05-15 11:05:54 +000021}
22
Guido van Rossum43021931994-09-12 10:40:46 +000023extern char *_getpty(int *, int, mode_t, int);
24
Guido van Rossum55db5151996-12-10 00:32:31 +000025static PyObject *
Peter Schneider-Kamp41c36ff2000-07-10 12:29:26 +000026sgi__getpty(PyObject *self, PyObject *args)
Guido van Rossum43021931994-09-12 10:40:46 +000027{
Antoine Pitrouc83ea132010-05-09 14:46:46 +000028 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);
Guido van Rossum43021931994-09-12 10:40:46 +000042}
43
Guido van Rossum55db5151996-12-10 00:32:31 +000044static PyMethodDef sgi_methods[] = {
Antoine Pitrouc83ea132010-05-09 14:46:46 +000045 {"nap", sgi_nap, METH_VARARGS},
46 {"_getpty", sgi__getpty, METH_VARARGS},
47 {NULL, NULL} /* sentinel */
Guido van Rossum86d25681992-05-15 11:05:54 +000048};
49
50
51void
Thomas Woutersf3f33dc2000-07-21 06:00:07 +000052initsgi(void)
Guido van Rossum86d25681992-05-15 11:05:54 +000053{
Antoine Pitrouc83ea132010-05-09 14:46:46 +000054 Py_InitModule("sgi", sgi_methods);
Guido van Rossum86d25681992-05-15 11:05:54 +000055}