PageRenderTime 28ms CodeModel.GetById 16ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/Modules/sgimodule.c

http://unladen-swallow.googlecode.com/
C | 55 lines | 45 code | 9 blank | 1 comment | 4 complexity | 050b91a4d4ef2210c1c7c4379ab2cac0 MD5 | raw file
 1
 2/* SGI module -- random SGI-specific things */
 3
 4#include "Python.h"
 5
 6#include <sys/types.h>
 7#include <sys/stat.h>
 8#include <fcntl.h>
 9
10static PyObject *
11sgi_nap(PyObject *self, PyObject *args)
12{
13	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;
21}
22
23extern char *_getpty(int *, int, mode_t, int);
24
25static PyObject *
26sgi__getpty(PyObject *self, PyObject *args)
27{
28	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);
42}
43
44static PyMethodDef sgi_methods[] = {
45	{"nap",		sgi_nap,	METH_VARARGS},
46	{"_getpty",	sgi__getpty,	METH_VARARGS},
47	{NULL,		NULL}		/* sentinel */
48};
49
50
51void
52initsgi(void)
53{
54	Py_InitModule("sgi", sgi_methods);
55}