Mercurial > cpython-lru_cache-weakref
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 |
| rev | line source |
|---|---|
| 862 | 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 | 4 |
| 5 All Rights Reserved | |
| 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 | 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 | 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 | 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 | 29 |
| 30 ******************************************************************/ | |
| 31 | |
| 32 /* SGI module -- random SGI-specific things */ | |
| 33 | |
| 4650 | 34 #include "Python.h" |
| 862 | 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 | 41 static PyObject * |
| 862 | 42 sgi_nap(self, args) |
| 4650 | 43 PyObject *self; |
| 44 PyObject *args; | |
| 862 | 45 { |
| 46 long ticks; | |
| 4650 | 47 if (!PyArg_Parse(args, "l", &ticks)) |
| 862 | 48 return NULL; |
| 4650 | 49 Py_BEGIN_ALLOW_THREADS |
| 862 | 50 sginap(ticks); |
| 4650 | 51 Py_END_ALLOW_THREADS |
| 52 Py_INCREF(Py_None); | |
| 53 return Py_None; | |
| 862 | 54 } |
| 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 | 58 static PyObject * |
|
1878
27d4f1f9346c
Added _getpty interface.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
59 sgi__getpty(self, args) |
| 4650 | 60 PyObject *self; |
| 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 | 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 | 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 | 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 | 79 static PyMethodDef sgi_methods[] = { |
| 862 | 80 {"nap", sgi_nap}, |
|
1878
27d4f1f9346c
Added _getpty interface.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
81 {"_getpty", sgi__getpty}, |
| 862 | 82 {NULL, NULL} /* sentinel */ |
| 83 }; | |
| 84 | |
| 85 | |
| 86 void | |
| 87 initsgi() | |
| 88 { | |
| 4650 | 89 Py_InitModule("sgi", sgi_methods); |
| 862 | 90 } |
