blob: 49087b2b129ad3d72c917a754a0a8f5ab911efdf [file] [log] [blame]
Guido van Rossum86d25681992-05-15 11:05:54 +00001/***********************************************************
Guido van Rossum524b5881995-01-04 19:10:35 +00002Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
3The Netherlands.
Guido van Rossum86d25681992-05-15 11:05:54 +00004
5 All Rights Reserved
6
Guido van Rossumd266eb41996-10-25 14:44:06 +00007Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
Guido van Rossum86d25681992-05-15 11:05:54 +00009provided that the above copyright notice appear in all copies and that
Guido van Rossumd266eb41996-10-25 14:44:06 +000010both that copyright notice and this permission notice appear in
Guido van Rossum86d25681992-05-15 11:05:54 +000011supporting documentation, and that the names of Stichting Mathematisch
Guido van Rossumd266eb41996-10-25 14:44:06 +000012Centrum or CWI or Corporation for National Research Initiatives or
13CNRI not be used in advertising or publicity pertaining to
14distribution of the software without specific, written prior
15permission.
Guido van Rossum86d25681992-05-15 11:05:54 +000016
Guido van Rossumd266eb41996-10-25 14:44:06 +000017While CWI is the initial source for this software, a modified version
18is made available by the Corporation for National Research Initiatives
19(CNRI) at the Internet address ftp://ftp.python.org.
20
21STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
22REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
23MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
24CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
25DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
26PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
27TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28PERFORMANCE OF THIS SOFTWARE.
Guido van Rossum86d25681992-05-15 11:05:54 +000029
30******************************************************************/
31
32/* SGI module -- random SGI-specific things */
33
34#include "allobjects.h"
35#include "modsupport.h"
Jack Jansen743db361992-08-13 14:13:11 +000036#include "ceval.h"
Guido van Rossum86d25681992-05-15 11:05:54 +000037
Guido van Rossum43021931994-09-12 10:40:46 +000038#include <errno.h>
39#include <sys/types.h>
40#include <sys/stat.h>
41#include <unistd.h>
42#include <fcntl.h>
43
Guido van Rossum86d25681992-05-15 11:05:54 +000044static object *
45sgi_nap(self, args)
46 object *self;
47 object *args;
48{
49 long ticks;
50 if (!getargs(args, "l", &ticks))
51 return NULL;
Jack Jansen743db361992-08-13 14:13:11 +000052 BGN_SAVE
Guido van Rossum86d25681992-05-15 11:05:54 +000053 sginap(ticks);
Jack Jansen743db361992-08-13 14:13:11 +000054 END_SAVE
Guido van Rossum86d25681992-05-15 11:05:54 +000055 INCREF(None);
56 return None;
57}
58
Guido van Rossum43021931994-09-12 10:40:46 +000059extern char *_getpty(int *, int, mode_t, int);
60
61static object *
62sgi__getpty(self, args)
63 object *self;
64 object *args;
65{
66 int oflag;
67 int mode;
68 int nofork;
69 char *name;
70 int fildes;
71 if (!getargs(args, "(iii)", &oflag, &mode, &nofork))
72 return NULL;
73 errno = 0;
74 name = _getpty(&fildes, oflag, (mode_t)mode, nofork);
75 if (name == NULL) {
76 err_errno(IOError);
77 return NULL;
78 }
79 return mkvalue("(si)", name, fildes);
80}
81
Guido van Rossum86d25681992-05-15 11:05:54 +000082static struct methodlist sgi_methods[] = {
83 {"nap", sgi_nap},
Guido van Rossum43021931994-09-12 10:40:46 +000084 {"_getpty", sgi__getpty},
Guido van Rossum86d25681992-05-15 11:05:54 +000085 {NULL, NULL} /* sentinel */
86};
87
88
89void
90initsgi()
91{
92 initmodule("sgi", sgi_methods);
93}
94
Guido van Rossumcd165cc1996-12-09 18:48:32 +000095int _Py_sgi_dummy; /* $%#@!& dl wants at least a byte of bss */
96/* And gcc -Wall doesn't like unused static variables :-( */