You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.1 KiB

35 years ago
35 years ago
26 years ago
35 years ago
35 years ago
26 years ago
35 years ago
35 years ago
35 years ago
  1. /* SGI module -- random SGI-specific things */
  2. #include "Python.h"
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5. #include <fcntl.h>
  6. static PyObject *
  7. sgi_nap(PyObject *self, PyObject *args)
  8. {
  9. long ticks;
  10. if (!PyArg_ParseTuple(args, "l:nap", &ticks))
  11. return NULL;
  12. Py_BEGIN_ALLOW_THREADS
  13. sginap(ticks);
  14. Py_END_ALLOW_THREADS
  15. Py_INCREF(Py_None);
  16. return Py_None;
  17. }
  18. extern char *_getpty(int *, int, mode_t, int);
  19. static PyObject *
  20. sgi__getpty(PyObject *self, PyObject *args)
  21. {
  22. int oflag;
  23. int mode;
  24. int nofork;
  25. char *name;
  26. int fildes;
  27. if (!PyArg_ParseTuple(args, "iii:_getpty", &oflag, &mode, &nofork))
  28. return NULL;
  29. errno = 0;
  30. name = _getpty(&fildes, oflag, (mode_t)mode, nofork);
  31. if (name == NULL) {
  32. PyErr_SetFromErrno(PyExc_IOError);
  33. return NULL;
  34. }
  35. return Py_BuildValue("(si)", name, fildes);
  36. }
  37. static PyMethodDef sgi_methods[] = {
  38. {"nap", sgi_nap, METH_VARARGS},
  39. {"_getpty", sgi__getpty, METH_VARARGS},
  40. {NULL, NULL} /* sentinel */
  41. };
  42. void
  43. initsgi(void)
  44. {
  45. Py_InitModule("sgi", sgi_methods);
  46. }