Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 1 | /*********************************************************** |
Guido van Rossum | 524b588 | 1995-01-04 19:10:35 +0000 | [diff] [blame] | 2 | Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
| 3 | The Netherlands. |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 4 | |
| 5 | All Rights Reserved |
| 6 | |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 7 | Permission to use, copy, modify, and distribute this software and its |
| 8 | documentation for any purpose and without fee is hereby granted, |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 9 | provided that the above copyright notice appear in all copies and that |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 10 | both that copyright notice and this permission notice appear in |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 11 | supporting documentation, and that the names of Stichting Mathematisch |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 12 | Centrum or CWI or Corporation for National Research Initiatives or |
| 13 | CNRI not be used in advertising or publicity pertaining to |
| 14 | distribution of the software without specific, written prior |
| 15 | permission. |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 16 | |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 17 | While CWI is the initial source for this software, a modified version |
| 18 | is made available by the Corporation for National Research Initiatives |
| 19 | (CNRI) at the Internet address ftp://ftp.python.org. |
| 20 | |
| 21 | STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
| 22 | REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
| 23 | MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
| 24 | CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
| 25 | DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 26 | PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 27 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 28 | PERFORMANCE OF THIS SOFTWARE. |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 29 | |
| 30 | ******************************************************************/ |
| 31 | |
| 32 | /* SGI module -- random SGI-specific things */ |
| 33 | |
| 34 | #include "allobjects.h" |
| 35 | #include "modsupport.h" |
Jack Jansen | 743db36 | 1992-08-13 14:13:11 +0000 | [diff] [blame] | 36 | #include "ceval.h" |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 37 | |
Guido van Rossum | 4302193 | 1994-09-12 10:40:46 +0000 | [diff] [blame] | 38 | #include <errno.h> |
| 39 | #include <sys/types.h> |
| 40 | #include <sys/stat.h> |
| 41 | #include <unistd.h> |
| 42 | #include <fcntl.h> |
| 43 | |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 44 | static object * |
| 45 | sgi_nap(self, args) |
| 46 | object *self; |
| 47 | object *args; |
| 48 | { |
| 49 | long ticks; |
| 50 | if (!getargs(args, "l", &ticks)) |
| 51 | return NULL; |
Jack Jansen | 743db36 | 1992-08-13 14:13:11 +0000 | [diff] [blame] | 52 | BGN_SAVE |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 53 | sginap(ticks); |
Jack Jansen | 743db36 | 1992-08-13 14:13:11 +0000 | [diff] [blame] | 54 | END_SAVE |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 55 | INCREF(None); |
| 56 | return None; |
| 57 | } |
| 58 | |
Guido van Rossum | 4302193 | 1994-09-12 10:40:46 +0000 | [diff] [blame] | 59 | extern char *_getpty(int *, int, mode_t, int); |
| 60 | |
| 61 | static object * |
| 62 | sgi__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 Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 82 | static struct methodlist sgi_methods[] = { |
| 83 | {"nap", sgi_nap}, |
Guido van Rossum | 4302193 | 1994-09-12 10:40:46 +0000 | [diff] [blame] | 84 | {"_getpty", sgi__getpty}, |
Guido van Rossum | 86d2568 | 1992-05-15 11:05:54 +0000 | [diff] [blame] | 85 | {NULL, NULL} /* sentinel */ |
| 86 | }; |
| 87 | |
| 88 | |
| 89 | void |
| 90 | initsgi() |
| 91 | { |
| 92 | initmodule("sgi", sgi_methods); |
| 93 | } |
| 94 | |
Guido van Rossum | 234f942 | 1993-06-17 12:35:49 +0000 | [diff] [blame] | 95 | static int dummy; /* $%#@!& dl wants at least a byte of bss */ |