blob: f7e12635c153441485df8436f52ce89d3007495f [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{
13 long ticks;
Neal Norwitzb0aaec52002-04-02 18:26:33 +000014 if (!PyArg_ParseTuple(args, "l:nap", &ticks))
Guido van Rossum86d25681992-05-15 11:05:54 +000015 return NULL;
Guido van Rossum55db5151996-12-10 00:32:31 +000016 Py_BEGIN_ALLOW_THREADS
Guido van Rossum86d25681992-05-15 11:05:54 +000017 sginap(ticks);
Guido van Rossum55db5151996-12-10 00:32:31 +000018 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{
28 int oflag;
29 int mode;
30 int nofork;
31 char *name;
32 int fildes;
Neal Norwitzb0aaec52002-04-02 18:26:33 +000033 if (!PyArg_ParseTuple(args, "iii:_getpty", &oflag, &mode, &nofork))
Guido van Rossum43021931994-09-12 10:40:46 +000034 return NULL;
35 errno = 0;
36 name = _getpty(&fildes, oflag, (mode_t)mode, nofork);
37 if (name == NULL) {
Guido van Rossum55db5151996-12-10 00:32:31 +000038 PyErr_SetFromErrno(PyExc_IOError);
Guido van Rossum43021931994-09-12 10:40:46 +000039 return NULL;
40 }
Guido van Rossum55db5151996-12-10 00:32:31 +000041 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[] = {
Neal Norwitzb0aaec52002-04-02 18:26:33 +000045 {"nap", sgi_nap, METH_VARARGS},
46 {"_getpty", sgi__getpty, METH_VARARGS},
Guido van Rossum86d25681992-05-15 11:05:54 +000047 {NULL, NULL} /* sentinel */
48};
49
50
51void
Thomas Woutersf3f33dc2000-07-21 06:00:07 +000052initsgi(void)
Guido van Rossum86d25681992-05-15 11:05:54 +000053{
Guido van Rossum55db5151996-12-10 00:32:31 +000054 Py_InitModule("sgi", sgi_methods);
Guido van Rossum86d25681992-05-15 11:05:54 +000055}