1992-05-15 08:05:54 -03:00
|
|
|
/***********************************************************
|
2000-06-30 20:50:40 -03:00
|
|
|
Copyright (c) 2000, BeOpen.com.
|
|
|
|
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
|
|
|
|
Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
|
|
|
|
All rights reserved.
|
1992-05-15 08:05:54 -03:00
|
|
|
|
2000-06-30 20:50:40 -03:00
|
|
|
See the file "Misc/COPYRIGHT" for information on usage and
|
|
|
|
redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
1992-05-15 08:05:54 -03:00
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
/* SGI module -- random SGI-specific things */
|
|
|
|
|
1996-12-09 20:32:31 -04:00
|
|
|
#include "Python.h"
|
1992-05-15 08:05:54 -03:00
|
|
|
|
1994-09-12 07:40:46 -03:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
1996-12-09 20:32:31 -04:00
|
|
|
static PyObject *
|
2000-07-10 09:29:26 -03:00
|
|
|
sgi_nap(PyObject *self, PyObject *args)
|
1992-05-15 08:05:54 -03:00
|
|
|
{
|
|
|
|
long ticks;
|
1996-12-09 20:32:31 -04:00
|
|
|
if (!PyArg_Parse(args, "l", &ticks))
|
1992-05-15 08:05:54 -03:00
|
|
|
return NULL;
|
1996-12-09 20:32:31 -04:00
|
|
|
Py_BEGIN_ALLOW_THREADS
|
1992-05-15 08:05:54 -03:00
|
|
|
sginap(ticks);
|
1996-12-09 20:32:31 -04:00
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
1992-05-15 08:05:54 -03:00
|
|
|
}
|
|
|
|
|
1994-09-12 07:40:46 -03:00
|
|
|
extern char *_getpty(int *, int, mode_t, int);
|
|
|
|
|
1996-12-09 20:32:31 -04:00
|
|
|
static PyObject *
|
2000-07-10 09:29:26 -03:00
|
|
|
sgi__getpty(PyObject *self, PyObject *args)
|
1994-09-12 07:40:46 -03:00
|
|
|
{
|
|
|
|
int oflag;
|
|
|
|
int mode;
|
|
|
|
int nofork;
|
|
|
|
char *name;
|
|
|
|
int fildes;
|
1996-12-09 20:32:31 -04:00
|
|
|
if (!PyArg_Parse(args, "(iii)", &oflag, &mode, &nofork))
|
1994-09-12 07:40:46 -03:00
|
|
|
return NULL;
|
|
|
|
errno = 0;
|
|
|
|
name = _getpty(&fildes, oflag, (mode_t)mode, nofork);
|
|
|
|
if (name == NULL) {
|
1996-12-09 20:32:31 -04:00
|
|
|
PyErr_SetFromErrno(PyExc_IOError);
|
1994-09-12 07:40:46 -03:00
|
|
|
return NULL;
|
|
|
|
}
|
1996-12-09 20:32:31 -04:00
|
|
|
return Py_BuildValue("(si)", name, fildes);
|
1994-09-12 07:40:46 -03:00
|
|
|
}
|
|
|
|
|
1996-12-09 20:32:31 -04:00
|
|
|
static PyMethodDef sgi_methods[] = {
|
1992-05-15 08:05:54 -03:00
|
|
|
{"nap", sgi_nap},
|
1994-09-12 07:40:46 -03:00
|
|
|
{"_getpty", sgi__getpty},
|
1992-05-15 08:05:54 -03:00
|
|
|
{NULL, NULL} /* sentinel */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2000-07-21 03:00:07 -03:00
|
|
|
initsgi(void)
|
1992-05-15 08:05:54 -03:00
|
|
|
{
|
1996-12-09 20:32:31 -04:00
|
|
|
Py_InitModule("sgi", sgi_methods);
|
1992-05-15 08:05:54 -03:00
|
|
|
}
|