1992-05-15 13:05:54 +02:00
|
|
|
|
|
|
|
/* SGI module -- random SGI-specific things */
|
|
|
|
|
1996-12-10 01:32:31 +01:00
|
|
|
#include "Python.h"
|
1992-05-15 13:05:54 +02:00
|
|
|
|
1994-09-12 12:40:46 +02:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
1996-12-10 01:32:31 +01:00
|
|
|
static PyObject *
|
2000-07-10 14:29:26 +02:00
|
|
|
sgi_nap(PyObject *self, PyObject *args)
|
1992-05-15 13:05:54 +02:00
|
|
|
{
|
|
|
|
long ticks;
|
2002-04-02 20:26:33 +02:00
|
|
|
if (!PyArg_ParseTuple(args, "l:nap", &ticks))
|
1992-05-15 13:05:54 +02:00
|
|
|
return NULL;
|
1996-12-10 01:32:31 +01:00
|
|
|
Py_BEGIN_ALLOW_THREADS
|
1992-05-15 13:05:54 +02:00
|
|
|
sginap(ticks);
|
1996-12-10 01:32:31 +01:00
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
1992-05-15 13:05:54 +02:00
|
|
|
}
|
|
|
|
|
1994-09-12 12:40:46 +02:00
|
|
|
extern char *_getpty(int *, int, mode_t, int);
|
|
|
|
|
1996-12-10 01:32:31 +01:00
|
|
|
static PyObject *
|
2000-07-10 14:29:26 +02:00
|
|
|
sgi__getpty(PyObject *self, PyObject *args)
|
1994-09-12 12:40:46 +02:00
|
|
|
{
|
|
|
|
int oflag;
|
|
|
|
int mode;
|
|
|
|
int nofork;
|
|
|
|
char *name;
|
|
|
|
int fildes;
|
2002-04-02 20:26:33 +02:00
|
|
|
if (!PyArg_ParseTuple(args, "iii:_getpty", &oflag, &mode, &nofork))
|
1994-09-12 12:40:46 +02:00
|
|
|
return NULL;
|
|
|
|
errno = 0;
|
|
|
|
name = _getpty(&fildes, oflag, (mode_t)mode, nofork);
|
|
|
|
if (name == NULL) {
|
1996-12-10 01:32:31 +01:00
|
|
|
PyErr_SetFromErrno(PyExc_IOError);
|
1994-09-12 12:40:46 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
1996-12-10 01:32:31 +01:00
|
|
|
return Py_BuildValue("(si)", name, fildes);
|
1994-09-12 12:40:46 +02:00
|
|
|
}
|
|
|
|
|
1996-12-10 01:32:31 +01:00
|
|
|
static PyMethodDef sgi_methods[] = {
|
2002-04-02 20:26:33 +02:00
|
|
|
{"nap", sgi_nap, METH_VARARGS},
|
|
|
|
{"_getpty", sgi__getpty, METH_VARARGS},
|
1992-05-15 13:05:54 +02:00
|
|
|
{NULL, NULL} /* sentinel */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2000-07-21 08:00:07 +02:00
|
|
|
initsgi(void)
|
1992-05-15 13:05:54 +02:00
|
|
|
{
|
1996-12-10 01:32:31 +01:00
|
|
|
Py_InitModule("sgi", sgi_methods);
|
1992-05-15 13:05:54 +02:00
|
|
|
}
|