annotate Modules/sgimodule.c @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents 2743759e3979
children 916fb024ce94
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 /***********************************************************
2061
172ba04a5191 Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents: 1878
diff changeset
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
172ba04a5191 Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents: 1878
diff changeset
3 The Netherlands.
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 All Rights Reserved
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
7 Permission to use, copy, modify, and distribute this software and its
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
8 documentation for any purpose and without fee is hereby granted,
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 provided that the above copyright notice appear in all copies and that
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
10 both that copyright notice and this permission notice appear in
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 supporting documentation, and that the names of Stichting Mathematisch
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
12 Centrum or CWI or Corporation for National Research Initiatives or
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
13 CNRI not be used in advertising or publicity pertaining to
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
14 distribution of the software without specific, written prior
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
15 permission.
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
16
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
17 While CWI is the initial source for this software, a modified version
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
18 is made available by the Corporation for National Research Initiatives
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
19 (CNRI) at the Internet address ftp://ftp.python.org.
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
20
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
28 PERFORMANCE OF THIS SOFTWARE.
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
29
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 ******************************************************************/
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
31
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 /* SGI module -- random SGI-specific things */
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
33
4650
2743759e3979 Great renaming.
Guido van Rossum <guido@python.org>
parents: 4622
diff changeset
34 #include "Python.h"
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
35
1878
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
36 #include <sys/types.h>
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
37 #include <sys/stat.h>
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
38 #include <unistd.h>
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
39 #include <fcntl.h>
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
40
4650
2743759e3979 Great renaming.
Guido van Rossum <guido@python.org>
parents: 4622
diff changeset
41 static PyObject *
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 sgi_nap(self, args)
4650
2743759e3979 Great renaming.
Guido van Rossum <guido@python.org>
parents: 4622
diff changeset
43 PyObject *self;
2743759e3979 Great renaming.
Guido van Rossum <guido@python.org>
parents: 4622
diff changeset
44 PyObject *args;
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 {
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 long ticks;
4650
2743759e3979 Great renaming.
Guido van Rossum <guido@python.org>
parents: 4622
diff changeset
47 if (!PyArg_Parse(args, "l", &ticks))
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 return NULL;
4650
2743759e3979 Great renaming.
Guido van Rossum <guido@python.org>
parents: 4622
diff changeset
49 Py_BEGIN_ALLOW_THREADS
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 sginap(ticks);
4650
2743759e3979 Great renaming.
Guido van Rossum <guido@python.org>
parents: 4622
diff changeset
51 Py_END_ALLOW_THREADS
2743759e3979 Great renaming.
Guido van Rossum <guido@python.org>
parents: 4622
diff changeset
52 Py_INCREF(Py_None);
2743759e3979 Great renaming.
Guido van Rossum <guido@python.org>
parents: 4622
diff changeset
53 return Py_None;
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 }
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
55
1878
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
56 extern char *_getpty(int *, int, mode_t, int);
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
57
4650
2743759e3979 Great renaming.
Guido van Rossum <guido@python.org>
parents: 4622
diff changeset
58 static PyObject *
1878
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
59 sgi__getpty(self, args)
4650
2743759e3979 Great renaming.
Guido van Rossum <guido@python.org>
parents: 4622
diff changeset
60 PyObject *self;
2743759e3979 Great renaming.
Guido van Rossum <guido@python.org>
parents: 4622
diff changeset
61 PyObject *args;
1878
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
62 {
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
63 int oflag;
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
64 int mode;
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
65 int nofork;
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
66 char *name;
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
67 int fildes;
4650
2743759e3979 Great renaming.
Guido van Rossum <guido@python.org>
parents: 4622
diff changeset
68 if (!PyArg_Parse(args, "(iii)", &oflag, &mode, &nofork))
1878
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
69 return NULL;
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
70 errno = 0;
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
71 name = _getpty(&fildes, oflag, (mode_t)mode, nofork);
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
72 if (name == NULL) {
4650
2743759e3979 Great renaming.
Guido van Rossum <guido@python.org>
parents: 4622
diff changeset
73 PyErr_SetFromErrno(PyExc_IOError);
1878
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
74 return NULL;
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
75 }
4650
2743759e3979 Great renaming.
Guido van Rossum <guido@python.org>
parents: 4622
diff changeset
76 return Py_BuildValue("(si)", name, fildes);
1878
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
77 }
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
78
4650
2743759e3979 Great renaming.
Guido van Rossum <guido@python.org>
parents: 4622
diff changeset
79 static PyMethodDef sgi_methods[] = {
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 {"nap", sgi_nap},
1878
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
81 {"_getpty", sgi__getpty},
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
82 {NULL, NULL} /* sentinel */
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
83 };
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
84
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
85
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
86 void
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
87 initsgi()
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
88 {
4650
2743759e3979 Great renaming.
Guido van Rossum <guido@python.org>
parents: 4622
diff changeset
89 Py_InitModule("sgi", sgi_methods);
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
90 }