Mercurial > cpython-lru_cache-weakref
annotate Modules/posixmodule.c @ 16798:258dcafe2d0b legacy-trunk
Gustavo Niemeyer <niemeyer@conectiva.com>:
Fixed recno support (keys are integers rather than strings).
Work around DB bug that cause stdin to be closed by rnopen() when the
DB file needed to exist but did not (no longer segfaults).
This closes SF tracker patch #403445.
Also wrapped some long lines and added whitespace around operators -- FLD.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Tue, 27 Feb 2001 18:56:46 +0000 |
| parents | dae39ebbc004 |
| children | 3fadc37cfa92 |
| rev | line source |
|---|---|
|
145
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
117
diff
changeset
|
1 |
| 6 | 2 /* POSIX module implementation */ |
| 3 | |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
4 /* This file is also used for Windows NT and MS-Win. In that case the module |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
5 actually calls itself 'nt', not 'posix', and a few functions are |
|
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
6 either unimplemented or implemented differently. The source |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
7 assumes that for Windows NT, the macro 'MS_WIN32' is defined independent |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
8 of the compiler used. Different compilers define their own feature |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
9 test macro, e.g. '__BORLANDC__' or '_MSC_VER'. */ |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
10 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
11 /* See also ../Dos/dosmodule.c */ |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
12 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
13 static char posix__doc__ [] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
14 "This module provides access to operating system functionality that is\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
15 standardized by the C Standard and the POSIX standard (a thinly\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
16 disguised Unix interface). Refer to the library manual and\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
17 corresponding Unix manual entries for more information on calls."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
18 |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
19 #include "Python.h" |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
20 |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
21 #if defined(PYOS_OS2) |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
22 #define INCL_DOS |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
23 #define INCL_DOSERRORS |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
24 #define INCL_DOSPROCESS |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
25 #define INCL_NOPMAPI |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
26 #include <os2.h> |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
27 #endif |
| 6 | 28 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
29 #include <sys/types.h> |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
30 #include <sys/stat.h> |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
31 #ifdef HAVE_SYS_WAIT_H |
|
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
32 #include <sys/wait.h> /* For WNOHANG */ |
|
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
33 #endif |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
34 |
| 4600 | 35 #ifdef HAVE_SIGNAL_H |
| 36 #include <signal.h> | |
| 37 #endif | |
| 38 | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
39 #ifdef HAVE_FCNTL_H |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
40 #include <fcntl.h> |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
41 #endif /* HAVE_FCNTL_H */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
42 |
|
16792
dae39ebbc004
conditionally include unistd.h to pick up confstr declaration. attempt to
Skip Montanaro <skip@pobox.com>
parents:
16607
diff
changeset
|
43 /* pick up declaration of confstr on some systems? */ |
|
dae39ebbc004
conditionally include unistd.h to pick up confstr declaration. attempt to
Skip Montanaro <skip@pobox.com>
parents:
16607
diff
changeset
|
44 #ifdef HAVE_UNISTD_H |
|
dae39ebbc004
conditionally include unistd.h to pick up confstr declaration. attempt to
Skip Montanaro <skip@pobox.com>
parents:
16607
diff
changeset
|
45 #include <unistd.h> |
|
dae39ebbc004
conditionally include unistd.h to pick up confstr declaration. attempt to
Skip Montanaro <skip@pobox.com>
parents:
16607
diff
changeset
|
46 #endif /* HAVE_UNISTD_H */ |
|
dae39ebbc004
conditionally include unistd.h to pick up confstr declaration. attempt to
Skip Montanaro <skip@pobox.com>
parents:
16607
diff
changeset
|
47 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
48 /* Various compilers have only certain posix functions */ |
|
6027
494e550cb18d
Added a bunch of XXX comments about things I'd like to see changed...
Guido van Rossum <guido@python.org>
parents:
5967
diff
changeset
|
49 /* XXX Gosh I wish these were all moved into config.h */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
50 #if defined(PYCC_VACPP) && defined(PYOS_OS2) |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
51 #include <process.h> |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
52 #else |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
53 #if defined(__WATCOMC__) && !defined(__QNX__) /* Watcom compiler */ |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
54 #define HAVE_GETCWD 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
55 #define HAVE_OPENDIR 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
56 #define HAVE_SYSTEM 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
57 #if defined(__OS2__) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
58 #define HAVE_EXECV 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
59 #define HAVE_WAIT 1 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
60 #endif |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
61 #include <process.h> |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
62 #else |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
63 #ifdef __BORLANDC__ /* Borland compiler */ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
64 #define HAVE_EXECV 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
65 #define HAVE_GETCWD 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
66 #define HAVE_GETEGID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
67 #define HAVE_GETEUID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
68 #define HAVE_GETGID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
69 #define HAVE_GETPPID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
70 #define HAVE_GETUID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
71 #define HAVE_KILL 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
72 #define HAVE_OPENDIR 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
73 #define HAVE_PIPE 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
74 #define HAVE_POPEN 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
75 #define HAVE_SYSTEM 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
76 #define HAVE_WAIT 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
77 #else |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
78 #ifdef _MSC_VER /* Microsoft compiler */ |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
79 #define HAVE_GETCWD 1 |
|
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
80 #ifdef MS_WIN32 |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
81 #define HAVE_SPAWNV 1 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
82 #define HAVE_EXECV 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
83 #define HAVE_PIPE 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
84 #define HAVE_POPEN 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
85 #define HAVE_SYSTEM 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
86 #else /* 16-bit Windows */ |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
87 #endif /* !MS_WIN32 */ |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
88 #else /* all other compilers */ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
89 /* Unix functions that the configure script doesn't check for */ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
90 #define HAVE_EXECV 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
91 #define HAVE_FORK 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
92 #define HAVE_GETCWD 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
93 #define HAVE_GETEGID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
94 #define HAVE_GETEUID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
95 #define HAVE_GETGID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
96 #define HAVE_GETPPID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
97 #define HAVE_GETUID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
98 #define HAVE_KILL 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
99 #define HAVE_OPENDIR 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
100 #define HAVE_PIPE 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
101 #define HAVE_POPEN 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
102 #define HAVE_SYSTEM 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
103 #define HAVE_WAIT 1 |
|
9939
faf351e31571
Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents:
9824
diff
changeset
|
104 #define HAVE_TTYNAME 1 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
105 #endif /* _MSC_VER */ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
106 #endif /* __BORLANDC__ */ |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
107 #endif /* ! __WATCOMC__ || __QNX__ */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
108 #endif /* ! __IBMC__ */ |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
109 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
110 #ifndef _MSC_VER |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
111 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
112 #ifdef HAVE_UNISTD_H |
|
1191
38f0054f44a7
Added separate main program for the Mac: macmain.c
Guido van Rossum <guido@python.org>
parents:
1181
diff
changeset
|
113 #include <unistd.h> |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
114 #endif |
|
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
115 |
|
14837
b7787a9052e3
Add missing prototypes for the benefit of SunOS 4.1.4 */
Guido van Rossum <guido@python.org>
parents:
14767
diff
changeset
|
116 #if defined(sun) && !defined(__SVR4) |
|
b7787a9052e3
Add missing prototypes for the benefit of SunOS 4.1.4 */
Guido van Rossum <guido@python.org>
parents:
14767
diff
changeset
|
117 /* SunOS 4.1.4 doesn't have prototypes for these: */ |
|
b7787a9052e3
Add missing prototypes for the benefit of SunOS 4.1.4 */
Guido van Rossum <guido@python.org>
parents:
14767
diff
changeset
|
118 extern int rename(const char *, const char *); |
|
b7787a9052e3
Add missing prototypes for the benefit of SunOS 4.1.4 */
Guido van Rossum <guido@python.org>
parents:
14767
diff
changeset
|
119 extern int pclose(FILE *); |
|
b7787a9052e3
Add missing prototypes for the benefit of SunOS 4.1.4 */
Guido van Rossum <guido@python.org>
parents:
14767
diff
changeset
|
120 extern int fclose(FILE *); |
|
16607
941a76f38747
Add a few more missing prototypes to the SunOS 4.1.4 section (no SF
Thomas Wouters <thomas@python.org>
parents:
16367
diff
changeset
|
121 extern int fsync(int); |
|
941a76f38747
Add a few more missing prototypes to the SunOS 4.1.4 section (no SF
Thomas Wouters <thomas@python.org>
parents:
16367
diff
changeset
|
122 extern int lstat(const char *, struct stat *); |
|
941a76f38747
Add a few more missing prototypes to the SunOS 4.1.4 section (no SF
Thomas Wouters <thomas@python.org>
parents:
16367
diff
changeset
|
123 extern int symlink(const char *, const char *); |
|
14837
b7787a9052e3
Add missing prototypes for the benefit of SunOS 4.1.4 */
Guido van Rossum <guido@python.org>
parents:
14767
diff
changeset
|
124 #endif |
|
b7787a9052e3
Add missing prototypes for the benefit of SunOS 4.1.4 */
Guido van Rossum <guido@python.org>
parents:
14767
diff
changeset
|
125 |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
126 #ifdef NeXT |
|
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
127 /* NeXT's <unistd.h> and <utime.h> aren't worth much */ |
|
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
128 #undef HAVE_UNISTD_H |
|
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
129 #undef HAVE_UTIME_H |
|
5584
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
130 #define HAVE_WAITPID |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
131 /* #undef HAVE_GETCWD */ |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
132 #define UNION_WAIT /* This should really be checked for by autoconf */ |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
133 #endif |
|
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
134 |
|
13694
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13675
diff
changeset
|
135 #ifndef HAVE_UNISTD_H |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
136 #if defined(PYCC_VACPP) |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
137 extern int mkdir(char *); |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
138 #else |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
139 #if ( defined(__WATCOMC__) || defined(_MSC_VER) ) && !defined(__QNX__) |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
140 extern int mkdir(const char *); |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
141 #else |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
142 extern int mkdir(const char *, mode_t); |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
143 #endif |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
144 #endif |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
145 #if defined(__IBMC__) || defined(__IBMCPP__) |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
146 extern int chdir(char *); |
|
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
147 extern int rmdir(char *); |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
148 #else |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
149 extern int chdir(const char *); |
|
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
150 extern int rmdir(const char *); |
|
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
151 #endif |
|
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
152 extern int chmod(const char *, mode_t); |
|
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
153 extern int chown(const char *, uid_t, gid_t); |
|
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
154 extern char *getcwd(char *, int); |
|
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
155 extern char *strerror(int); |
|
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
156 extern int link(const char *, const char *); |
|
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
157 extern int rename(const char *, const char *); |
|
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
158 extern int stat(const char *, struct stat *); |
|
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
159 extern int unlink(const char *); |
|
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
160 extern int pclose(FILE *); |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
161 #ifdef HAVE_SYMLINK |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
162 extern int symlink(const char *, const char *); |
|
2370
e386035f897d
fix comment opener after #endif
Guido van Rossum <guido@python.org>
parents:
2298
diff
changeset
|
163 #endif /* HAVE_SYMLINK */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
164 #ifdef HAVE_LSTAT |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
165 extern int lstat(const char *, struct stat *); |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
166 #endif /* HAVE_LSTAT */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
167 #endif /* !HAVE_UNISTD_H */ |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
168 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
169 #endif /* !_MSC_VER */ |
| 6 | 170 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
171 #ifdef HAVE_UTIME_H |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
172 #include <utime.h> |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
173 #endif /* HAVE_UTIME_H */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
174 |
|
1915
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
175 #ifdef HAVE_SYS_UTIME_H |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
176 #include <sys/utime.h> |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
177 #define HAVE_UTIME_H /* pretend we do for the rest of this file */ |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
178 #endif /* HAVE_SYS_UTIME_H */ |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
179 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
180 #ifdef HAVE_SYS_TIMES_H |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
181 #include <sys/times.h> |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
182 #endif /* HAVE_SYS_TIMES_H */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
183 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
184 #ifdef HAVE_SYS_PARAM_H |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
185 #include <sys/param.h> |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
186 #endif /* HAVE_SYS_PARAM_H */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
187 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
188 #ifdef HAVE_SYS_UTSNAME_H |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
189 #include <sys/utsname.h> |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
190 #endif /* HAVE_SYS_UTSNAME_H */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
191 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
192 #ifndef MAXPATHLEN |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
193 #define MAXPATHLEN 1024 |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
194 #endif /* MAXPATHLEN */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
195 |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
196 #ifdef HAVE_DIRENT_H |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
197 #include <dirent.h> |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
198 #define NAMLEN(dirent) strlen((dirent)->d_name) |
|
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
199 #else |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
200 #if defined(__WATCOMC__) && !defined(__QNX__) |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
201 #include <direct.h> |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
202 #define NAMLEN(dirent) strlen((dirent)->d_name) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
203 #else |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
204 #define dirent direct |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
205 #define NAMLEN(dirent) (dirent)->d_namlen |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
206 #endif |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
207 #ifdef HAVE_SYS_NDIR_H |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
208 #include <sys/ndir.h> |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
209 #endif |
|
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
210 #ifdef HAVE_SYS_DIR_H |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
211 #include <sys/dir.h> |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
212 #endif |
|
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
213 #ifdef HAVE_NDIR_H |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
214 #include <ndir.h> |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
215 #endif |
|
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
216 #endif |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
217 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
218 #ifdef _MSC_VER |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
219 #include <direct.h> |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
220 #include <io.h> |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
221 #include <process.h> |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
222 #define WINDOWS_LEAN_AND_MEAN |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
223 #include <windows.h> |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
224 #ifdef MS_WIN32 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
225 #define popen _popen |
|
1815
6353fe25cdce
* Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents:
1792
diff
changeset
|
226 #define pclose _pclose |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
227 #else /* 16-bit Windows */ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
228 #include <dos.h> |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
229 #include <ctype.h> |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
230 #endif /* MS_WIN32 */ |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
231 #endif /* _MSC_VER */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
232 |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
233 #if defined(PYCC_VACPP) && defined(PYOS_OS2) |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
234 #include <io.h> |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
235 #endif /* OS2 */ |
| 6 | 236 |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
237 #ifdef UNION_WAIT |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
238 /* Emulate some macros on systems that have a union instead of macros */ |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
239 |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
240 #ifndef WIFEXITED |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
241 #define WIFEXITED(u_wait) (!(u_wait).w_termsig && !(u_wait).w_coredump) |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
242 #endif |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
243 |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
244 #ifndef WEXITSTATUS |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
245 #define WEXITSTATUS(u_wait) (WIFEXITED(u_wait)?((u_wait).w_retcode):-1) |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
246 #endif |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
247 |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
248 #ifndef WTERMSIG |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
249 #define WTERMSIG(u_wait) ((u_wait).w_termsig) |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
250 #endif |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
251 |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
252 #endif /* UNION_WAIT */ |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
253 |
|
11893
610d7d642917
Second attempt to fix the ctermid_r/tmpnam_r warnings: define USE_CTERMID_R
Greg Ward <gward@python.net>
parents:
11892
diff
changeset
|
254 /* Don't use the "_r" form if we don't need it (also, won't have a |
|
610d7d642917
Second attempt to fix the ctermid_r/tmpnam_r warnings: define USE_CTERMID_R
Greg Ward <gward@python.net>
parents:
11892
diff
changeset
|
255 prototype for it, at least on Solaris -- maybe others as well?). */ |
|
610d7d642917
Second attempt to fix the ctermid_r/tmpnam_r warnings: define USE_CTERMID_R
Greg Ward <gward@python.net>
parents:
11892
diff
changeset
|
256 #if defined(HAVE_CTERMID_R) && defined(WITH_THREAD) |
|
610d7d642917
Second attempt to fix the ctermid_r/tmpnam_r warnings: define USE_CTERMID_R
Greg Ward <gward@python.net>
parents:
11892
diff
changeset
|
257 #define USE_CTERMID_R |
|
610d7d642917
Second attempt to fix the ctermid_r/tmpnam_r warnings: define USE_CTERMID_R
Greg Ward <gward@python.net>
parents:
11892
diff
changeset
|
258 #endif |
|
610d7d642917
Second attempt to fix the ctermid_r/tmpnam_r warnings: define USE_CTERMID_R
Greg Ward <gward@python.net>
parents:
11892
diff
changeset
|
259 |
|
610d7d642917
Second attempt to fix the ctermid_r/tmpnam_r warnings: define USE_CTERMID_R
Greg Ward <gward@python.net>
parents:
11892
diff
changeset
|
260 #if defined(HAVE_TMPNAM_R) && defined(WITH_THREAD) |
|
610d7d642917
Second attempt to fix the ctermid_r/tmpnam_r warnings: define USE_CTERMID_R
Greg Ward <gward@python.net>
parents:
11892
diff
changeset
|
261 #define USE_TMPNAM_R |
|
610d7d642917
Second attempt to fix the ctermid_r/tmpnam_r warnings: define USE_CTERMID_R
Greg Ward <gward@python.net>
parents:
11892
diff
changeset
|
262 #endif |
|
610d7d642917
Second attempt to fix the ctermid_r/tmpnam_r warnings: define USE_CTERMID_R
Greg Ward <gward@python.net>
parents:
11892
diff
changeset
|
263 |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
264 /* choose the appropriate stat and fstat functions and return structs */ |
|
13251
86177fb0edd8
Crude way to fix a problem on AIX: #undef STAT before defining it.
Guido van Rossum <guido@python.org>
parents:
13153
diff
changeset
|
265 #undef STAT |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
266 #ifdef MS_WIN64 |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
267 # define STAT _stati64 |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
268 # define FSTAT _fstati64 |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
269 # define STRUCT_STAT struct _stati64 |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
270 #else |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
271 # define STAT stat |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
272 # define FSTAT fstat |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
273 # define STRUCT_STAT struct stat |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
274 #endif |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
275 |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
276 |
| 6 | 277 /* Return a dictionary corresponding to the POSIX environment table */ |
| 278 | |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
279 #if !defined(_MSC_VER) && ( !defined(__WATCOMC__) || defined(__QNX__) ) |
| 6 | 280 extern char **environ; |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
281 #endif /* !_MSC_VER */ |
| 6 | 282 |
| 4672 | 283 static PyObject * |
|
13651
8a063423e0b7
Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents:
13642
diff
changeset
|
284 convertenviron(void) |
| 6 | 285 { |
| 4672 | 286 PyObject *d; |
| 6 | 287 char **e; |
| 4672 | 288 d = PyDict_New(); |
| 6 | 289 if (d == NULL) |
| 290 return NULL; | |
| 291 if (environ == NULL) | |
| 292 return d; | |
|
11172
8e74ed154f60
It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents:
11095
diff
changeset
|
293 /* This part ignores errors */ |
| 6 | 294 for (e = environ; *e != NULL; e++) { |
|
11172
8e74ed154f60
It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents:
11095
diff
changeset
|
295 PyObject *k; |
| 4672 | 296 PyObject *v; |
| 6 | 297 char *p = strchr(*e, '='); |
| 298 if (p == NULL) | |
| 299 continue; | |
|
11172
8e74ed154f60
It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents:
11095
diff
changeset
|
300 k = PyString_FromStringAndSize(*e, (int)(p-*e)); |
|
8e74ed154f60
It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents:
11095
diff
changeset
|
301 if (k == NULL) { |
|
8e74ed154f60
It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents:
11095
diff
changeset
|
302 PyErr_Clear(); |
| 6 | 303 continue; |
|
11172
8e74ed154f60
It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents:
11095
diff
changeset
|
304 } |
|
8e74ed154f60
It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents:
11095
diff
changeset
|
305 v = PyString_FromString(p+1); |
|
8e74ed154f60
It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents:
11095
diff
changeset
|
306 if (v == NULL) { |
|
8e74ed154f60
It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents:
11095
diff
changeset
|
307 PyErr_Clear(); |
|
8e74ed154f60
It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents:
11095
diff
changeset
|
308 Py_DECREF(k); |
|
8e74ed154f60
It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents:
11095
diff
changeset
|
309 continue; |
|
8e74ed154f60
It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents:
11095
diff
changeset
|
310 } |
|
8e74ed154f60
It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents:
11095
diff
changeset
|
311 if (PyDict_GetItem(d, k) == NULL) { |
|
8e74ed154f60
It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents:
11095
diff
changeset
|
312 if (PyDict_SetItem(d, k, v) != 0) |
|
8e74ed154f60
It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents:
11095
diff
changeset
|
313 PyErr_Clear(); |
|
8e74ed154f60
It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents:
11095
diff
changeset
|
314 } |
|
8e74ed154f60
It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents:
11095
diff
changeset
|
315 Py_DECREF(k); |
| 4672 | 316 Py_DECREF(v); |
| 6 | 317 } |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
318 #if defined(PYOS_OS2) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
319 { |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
320 APIRET rc; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
321 char buffer[1024]; /* OS/2 Provides a Documented Max of 1024 Chars */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
322 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
323 rc = DosQueryExtLIBPATH(buffer, BEGIN_LIBPATH); |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
324 if (rc == NO_ERROR) { /* (not a type, envname is NOT 'BEGIN_LIBPATH') */ |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
325 PyObject *v = PyString_FromString(buffer); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
326 PyDict_SetItemString(d, "BEGINLIBPATH", v); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
327 Py_DECREF(v); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
328 } |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
329 rc = DosQueryExtLIBPATH(buffer, END_LIBPATH); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
330 if (rc == NO_ERROR) { /* (not a typo, envname is NOT 'END_LIBPATH') */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
331 PyObject *v = PyString_FromString(buffer); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
332 PyDict_SetItemString(d, "ENDLIBPATH", v); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
333 Py_DECREF(v); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
334 } |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
335 } |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
336 #endif |
| 6 | 337 return d; |
| 338 } | |
| 339 | |
| 340 | |
| 341 /* Set a POSIX-specific error from errno, and return NULL */ | |
| 342 | |
|
8708
acf49c9def7d
Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents:
8497
diff
changeset
|
343 static PyObject * |
|
13651
8a063423e0b7
Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents:
13642
diff
changeset
|
344 posix_error(void) |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
345 { |
|
10133
5718e83020ae
Got rid of the file-global PosixError. This was redundant since it
Barry Warsaw <barry@python.org>
parents:
10092
diff
changeset
|
346 return PyErr_SetFromErrno(PyExc_OSError); |
| 6 | 347 } |
|
8708
acf49c9def7d
Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents:
8497
diff
changeset
|
348 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
349 posix_error_with_filename(char* name) |
|
8708
acf49c9def7d
Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents:
8497
diff
changeset
|
350 { |
|
10133
5718e83020ae
Got rid of the file-global PosixError. This was redundant since it
Barry Warsaw <barry@python.org>
parents:
10092
diff
changeset
|
351 return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); |
|
8708
acf49c9def7d
Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents:
8497
diff
changeset
|
352 } |
|
acf49c9def7d
Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents:
8497
diff
changeset
|
353 |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
354 #ifdef MS_WIN32 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
355 static PyObject * |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
356 win32_error(char* function, char* filename) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
357 { |
|
13974
3e6e3d05d00b
Fix for bug #110670 - Win32 os.listdir raises confusing errors:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13960
diff
changeset
|
358 /* XXX We should pass the function name along in the future. |
|
3e6e3d05d00b
Fix for bug #110670 - Win32 os.listdir raises confusing errors:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13960
diff
changeset
|
359 (_winreg.c also wants to pass the function name.) |
|
3e6e3d05d00b
Fix for bug #110670 - Win32 os.listdir raises confusing errors:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13960
diff
changeset
|
360 This would however require an additional param to the |
|
3e6e3d05d00b
Fix for bug #110670 - Win32 os.listdir raises confusing errors:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13960
diff
changeset
|
361 Windows error object, which is non-trivial. |
|
3e6e3d05d00b
Fix for bug #110670 - Win32 os.listdir raises confusing errors:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13960
diff
changeset
|
362 */ |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
363 errno = GetLastError(); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
364 if (filename) |
|
13974
3e6e3d05d00b
Fix for bug #110670 - Win32 os.listdir raises confusing errors:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13960
diff
changeset
|
365 return PyErr_SetFromWindowsErrWithFilename(errno, filename); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
366 else |
|
13974
3e6e3d05d00b
Fix for bug #110670 - Win32 os.listdir raises confusing errors:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13960
diff
changeset
|
367 return PyErr_SetFromWindowsErr(errno); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
368 } |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
369 #endif |
| 6 | 370 |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
371 #if defined(PYOS_OS2) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
372 /********************************************************************** |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
373 * Helper Function to Trim and Format OS/2 Messages |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
374 **********************************************************************/ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
375 static void |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
376 os2_formatmsg(char *msgbuf, int msglen, char *reason) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
377 { |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
378 msgbuf[msglen] = '\0'; /* OS/2 Doesn't Guarantee a Terminator */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
379 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
380 if (strlen(msgbuf) > 0) { /* If Non-Empty Msg, Trim CRLF */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
381 char *lastc = &msgbuf[ strlen(msgbuf)-1 ]; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
382 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
383 while (lastc > msgbuf && isspace(*lastc)) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
384 *lastc-- = '\0'; /* Trim Trailing Whitespace (CRLF) */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
385 } |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
386 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
387 /* Add Optional Reason Text */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
388 if (reason) { |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
389 strcat(msgbuf, " : "); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
390 strcat(msgbuf, reason); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
391 } |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
392 } |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
393 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
394 /********************************************************************** |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
395 * Decode an OS/2 Operating System Error Code |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
396 * |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
397 * A convenience function to lookup an OS/2 error code and return a |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
398 * text message we can use to raise a Python exception. |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
399 * |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
400 * Notes: |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
401 * The messages for errors returned from the OS/2 kernel reside in |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
402 * the file OSO001.MSG in the \OS2 directory hierarchy. |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
403 * |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
404 **********************************************************************/ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
405 static char * |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
406 os2_strerror(char *msgbuf, int msgbuflen, int errorcode, char *reason) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
407 { |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
408 APIRET rc; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
409 ULONG msglen; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
410 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
411 /* Retrieve Kernel-Related Error Message from OSO001.MSG File */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
412 Py_BEGIN_ALLOW_THREADS |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
413 rc = DosGetMessage(NULL, 0, msgbuf, msgbuflen, |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
414 errorcode, "oso001.msg", &msglen); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
415 Py_END_ALLOW_THREADS |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
416 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
417 if (rc == NO_ERROR) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
418 os2_formatmsg(msgbuf, msglen, reason); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
419 else |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
420 sprintf(msgbuf, "unknown OS error #%d", errorcode); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
421 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
422 return msgbuf; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
423 } |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
424 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
425 /* Set an OS/2-specific error and return NULL. OS/2 kernel |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
426 errors are not in a global variable e.g. 'errno' nor are |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
427 they congruent with posix error numbers. */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
428 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
429 static PyObject * os2_error(int code) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
430 { |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
431 char text[1024]; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
432 PyObject *v; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
433 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
434 os2_strerror(text, sizeof(text), code, ""); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
435 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
436 v = Py_BuildValue("(is)", code, text); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
437 if (v != NULL) { |
|
10133
5718e83020ae
Got rid of the file-global PosixError. This was redundant since it
Barry Warsaw <barry@python.org>
parents:
10092
diff
changeset
|
438 PyErr_SetObject(PyExc_OSError, v); |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
439 Py_DECREF(v); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
440 } |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
441 return NULL; /* Signal to Python that an Exception is Pending */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
442 } |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
443 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
444 #endif /* OS2 */ |
| 6 | 445 |
| 446 /* POSIX generic methods */ | |
| 447 | |
| 4672 | 448 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
449 posix_int(PyObject *args, char *format, int (*func)(int)) |
|
9822
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
450 { |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
451 int fd; |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
452 int res; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
453 if (!PyArg_ParseTuple(args, format, &fd)) |
|
9822
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
454 return NULL; |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
455 Py_BEGIN_ALLOW_THREADS |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
456 res = (*func)(fd); |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
457 Py_END_ALLOW_THREADS |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
458 if (res < 0) |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
459 return posix_error(); |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
460 Py_INCREF(Py_None); |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
461 return Py_None; |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
462 } |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
463 |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
464 |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
465 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
466 posix_1str(PyObject *args, char *format, int (*func)(const char*)) |
| 6 | 467 { |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
468 char *path1; |
| 926 | 469 int res; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
470 if (!PyArg_ParseTuple(args, format, &path1)) |
| 6 | 471 return NULL; |
| 4672 | 472 Py_BEGIN_ALLOW_THREADS |
| 926 | 473 res = (*func)(path1); |
| 4672 | 474 Py_END_ALLOW_THREADS |
| 926 | 475 if (res < 0) |
|
8708
acf49c9def7d
Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents:
8497
diff
changeset
|
476 return posix_error_with_filename(path1); |
| 4672 | 477 Py_INCREF(Py_None); |
| 478 return Py_None; | |
| 6 | 479 } |
| 480 | |
| 4672 | 481 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
482 posix_2str(PyObject *args, char *format, |
|
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
483 int (*func)(const char *, const char *)) |
| 6 | 484 { |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
485 char *path1, *path2; |
| 926 | 486 int res; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
487 if (!PyArg_ParseTuple(args, format, &path1, &path2)) |
| 6 | 488 return NULL; |
| 4672 | 489 Py_BEGIN_ALLOW_THREADS |
| 926 | 490 res = (*func)(path1, path2); |
| 4672 | 491 Py_END_ALLOW_THREADS |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
492 if (res != 0) |
|
8708
acf49c9def7d
Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents:
8497
diff
changeset
|
493 /* XXX how to report both path1 and path2??? */ |
| 6 | 494 return posix_error(); |
| 4672 | 495 Py_INCREF(Py_None); |
| 496 return Py_None; | |
| 6 | 497 } |
| 498 | |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
499 /* pack a system stat C structure into the Python stat tuple |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
500 (used by posix_stat() and posix_fstat()) */ |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
501 static PyObject* |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
502 _pystat_fromstructstat(STRUCT_STAT st) |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
503 { |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
504 PyObject *v = PyTuple_New(10); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
505 if (v == NULL) |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
506 return NULL; |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
507 |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
508 PyTuple_SetItem(v, 0, PyInt_FromLong((long)st.st_mode)); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
509 #ifdef HAVE_LARGEFILE_SUPPORT |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
510 PyTuple_SetItem(v, 1, PyLong_FromLongLong((LONG_LONG)st.st_ino)); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
511 #else |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
512 PyTuple_SetItem(v, 1, PyInt_FromLong((long)st.st_ino)); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
513 #endif |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
514 #if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS) |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
515 PyTuple_SetItem(v, 2, PyLong_FromLongLong((LONG_LONG)st.st_dev)); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
516 #else |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
517 PyTuple_SetItem(v, 2, PyInt_FromLong((long)st.st_dev)); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
518 #endif |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
519 PyTuple_SetItem(v, 3, PyInt_FromLong((long)st.st_nlink)); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
520 PyTuple_SetItem(v, 4, PyInt_FromLong((long)st.st_uid)); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
521 PyTuple_SetItem(v, 5, PyInt_FromLong((long)st.st_gid)); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
522 #ifdef HAVE_LARGEFILE_SUPPORT |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
523 PyTuple_SetItem(v, 6, PyLong_FromLongLong((LONG_LONG)st.st_size)); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
524 #else |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
525 PyTuple_SetItem(v, 6, PyInt_FromLong(st.st_size)); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
526 #endif |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
527 #if SIZEOF_TIME_T > SIZEOF_LONG |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
528 PyTuple_SetItem(v, 7, PyLong_FromLongLong((LONG_LONG)st.st_atime)); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
529 PyTuple_SetItem(v, 8, PyLong_FromLongLong((LONG_LONG)st.st_mtime)); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
530 PyTuple_SetItem(v, 9, PyLong_FromLongLong((LONG_LONG)st.st_ctime)); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
531 #else |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
532 PyTuple_SetItem(v, 7, PyInt_FromLong((long)st.st_atime)); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
533 PyTuple_SetItem(v, 8, PyInt_FromLong((long)st.st_mtime)); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
534 PyTuple_SetItem(v, 9, PyInt_FromLong((long)st.st_ctime)); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
535 #endif |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
536 |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
537 if (PyErr_Occurred()) { |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
538 Py_DECREF(v); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
539 return NULL; |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
540 } |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
541 |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
542 return v; |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
543 } |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
544 |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
545 |
| 4672 | 546 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
547 posix_do_stat(PyObject *self, PyObject *args, char *format, |
|
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
548 int (*statfunc)(const char *, STRUCT_STAT *)) |
| 6 | 549 { |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
550 STRUCT_STAT st; |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
551 char *path; |
| 926 | 552 int res; |
|
12435
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
553 |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
554 #ifdef MS_WIN32 |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
555 int pathlen; |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
556 char pathcopy[MAX_PATH]; |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
557 #endif /* MS_WIN32 */ |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
558 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
559 if (!PyArg_ParseTuple(args, format, &path)) |
| 6 | 560 return NULL; |
|
12435
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
561 |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
562 #ifdef MS_WIN32 |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
563 pathlen = strlen(path); |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
564 /* the library call can blow up if the file name is too long! */ |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
565 if (pathlen > MAX_PATH) { |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
566 errno = ENAMETOOLONG; |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
567 return posix_error(); |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
568 } |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
569 |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
570 if ((pathlen > 0) && (path[pathlen-1] == '\\' || path[pathlen-1] == '/')) { |
|
12564
b0a4350d5c03
Mark Hammond to the rescue:
Guido van Rossum <guido@python.org>
parents:
12533
diff
changeset
|
571 /* exception for specific or current drive root */ |
|
b0a4350d5c03
Mark Hammond to the rescue:
Guido van Rossum <guido@python.org>
parents:
12533
diff
changeset
|
572 if (!((pathlen == 1) || |
|
b0a4350d5c03
Mark Hammond to the rescue:
Guido van Rossum <guido@python.org>
parents:
12533
diff
changeset
|
573 ((pathlen == 3) && |
|
12435
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
574 (path[1] == ':') && |
|
12564
b0a4350d5c03
Mark Hammond to the rescue:
Guido van Rossum <guido@python.org>
parents:
12533
diff
changeset
|
575 (path[2] == '\\' || path[2] == '/')))) |
|
12435
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
576 { |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
577 strncpy(pathcopy, path, pathlen); |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
578 pathcopy[pathlen-1] = '\0'; /* nuke the trailing backslash */ |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
579 path = pathcopy; |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
580 } |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
581 } |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
582 #endif /* MS_WIN32 */ |
|
ca7b99d27a40
Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents:
12393
diff
changeset
|
583 |
| 4672 | 584 Py_BEGIN_ALLOW_THREADS |
| 926 | 585 res = (*statfunc)(path, &st); |
| 4672 | 586 Py_END_ALLOW_THREADS |
| 926 | 587 if (res != 0) |
|
8708
acf49c9def7d
Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents:
8497
diff
changeset
|
588 return posix_error_with_filename(path); |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
589 |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
590 return _pystat_fromstructstat(st); |
| 6 | 591 } |
| 592 | |
| 593 | |
| 594 /* POSIX methods */ | |
| 595 | |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
596 static char posix_access__doc__[] = |
|
9795
836f9408c956
Change the access() code to return 1 if granted, 0 if not granted.
Guido van Rossum <guido@python.org>
parents:
9785
diff
changeset
|
597 "access(path, mode) -> 1 if granted, 0 otherwise\n\ |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
598 Test for access to a file."; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
599 |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
600 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
601 posix_access(PyObject *self, PyObject *args) |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
602 { |
|
9795
836f9408c956
Change the access() code to return 1 if granted, 0 if not granted.
Guido van Rossum <guido@python.org>
parents:
9785
diff
changeset
|
603 char *path; |
|
836f9408c956
Change the access() code to return 1 if granted, 0 if not granted.
Guido van Rossum <guido@python.org>
parents:
9785
diff
changeset
|
604 int mode; |
|
836f9408c956
Change the access() code to return 1 if granted, 0 if not granted.
Guido van Rossum <guido@python.org>
parents:
9785
diff
changeset
|
605 int res; |
|
836f9408c956
Change the access() code to return 1 if granted, 0 if not granted.
Guido van Rossum <guido@python.org>
parents:
9785
diff
changeset
|
606 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
607 if (!PyArg_ParseTuple(args, "si:access", &path, &mode)) |
|
9795
836f9408c956
Change the access() code to return 1 if granted, 0 if not granted.
Guido van Rossum <guido@python.org>
parents:
9785
diff
changeset
|
608 return NULL; |
|
836f9408c956
Change the access() code to return 1 if granted, 0 if not granted.
Guido van Rossum <guido@python.org>
parents:
9785
diff
changeset
|
609 Py_BEGIN_ALLOW_THREADS |
|
836f9408c956
Change the access() code to return 1 if granted, 0 if not granted.
Guido van Rossum <guido@python.org>
parents:
9785
diff
changeset
|
610 res = access(path, mode); |
|
836f9408c956
Change the access() code to return 1 if granted, 0 if not granted.
Guido van Rossum <guido@python.org>
parents:
9785
diff
changeset
|
611 Py_END_ALLOW_THREADS |
|
836f9408c956
Change the access() code to return 1 if granted, 0 if not granted.
Guido van Rossum <guido@python.org>
parents:
9785
diff
changeset
|
612 return(PyInt_FromLong(res == 0 ? 1L : 0L)); |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
613 } |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
614 |
|
9939
faf351e31571
Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents:
9824
diff
changeset
|
615 #ifndef F_OK |
|
faf351e31571
Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents:
9824
diff
changeset
|
616 #define F_OK 0 |
|
faf351e31571
Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents:
9824
diff
changeset
|
617 #endif |
|
faf351e31571
Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents:
9824
diff
changeset
|
618 #ifndef R_OK |
|
faf351e31571
Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents:
9824
diff
changeset
|
619 #define R_OK 4 |
|
faf351e31571
Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents:
9824
diff
changeset
|
620 #endif |
|
faf351e31571
Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents:
9824
diff
changeset
|
621 #ifndef W_OK |
|
faf351e31571
Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents:
9824
diff
changeset
|
622 #define W_OK 2 |
|
faf351e31571
Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents:
9824
diff
changeset
|
623 #endif |
|
faf351e31571
Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents:
9824
diff
changeset
|
624 #ifndef X_OK |
|
faf351e31571
Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents:
9824
diff
changeset
|
625 #define X_OK 1 |
|
faf351e31571
Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents:
9824
diff
changeset
|
626 #endif |
|
faf351e31571
Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents:
9824
diff
changeset
|
627 |
|
faf351e31571
Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents:
9824
diff
changeset
|
628 #ifdef HAVE_TTYNAME |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
629 static char posix_ttyname__doc__[] = |
|
10263
29701e2904ac
The docstring for ttyname(..) claims a second "mode" argument. The
Guido van Rossum <guido@python.org>
parents:
10188
diff
changeset
|
630 "ttyname(fd) -> String\n\ |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
631 Return the name of the terminal device connected to 'fd'."; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
632 |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
633 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
634 posix_ttyname(PyObject *self, PyObject *args) |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
635 { |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
636 int id; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
637 char *ret; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
638 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
639 if (!PyArg_ParseTuple(args, "i:ttyname", &id)) |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
640 return NULL; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
641 |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
642 ret = ttyname(id); |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
643 if (ret == NULL) |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
644 return(posix_error()); |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
645 return(PyString_FromString(ret)); |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
646 } |
|
9939
faf351e31571
Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents:
9824
diff
changeset
|
647 #endif |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
648 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
649 #ifdef HAVE_CTERMID |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
650 static char posix_ctermid__doc__[] = |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
651 "ctermid() -> String\n\ |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
652 Return the name of the controlling terminal for this process."; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
653 |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
654 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
655 posix_ctermid(PyObject *self, PyObject *args) |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
656 { |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
657 char *ret; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
658 char buffer[L_ctermid]; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
659 |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
660 if (!PyArg_ParseTuple(args, ":ctermid")) |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
661 return NULL; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
662 |
|
11893
610d7d642917
Second attempt to fix the ctermid_r/tmpnam_r warnings: define USE_CTERMID_R
Greg Ward <gward@python.net>
parents:
11892
diff
changeset
|
663 #ifdef USE_CTERMID_R |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
664 ret = ctermid_r(buffer); |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
665 #else |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
666 ret = ctermid(buffer); |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
667 #endif |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
668 if (ret == NULL) |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
669 return(posix_error()); |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
670 return(PyString_FromString(buffer)); |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
671 } |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
672 #endif |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
673 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
674 static char posix_chdir__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
675 "chdir(path) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
676 Change the current working directory to the specified path."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
677 |
| 4672 | 678 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
679 posix_chdir(PyObject *self, PyObject *args) |
| 6 | 680 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
681 return posix_1str(args, "s:chdir", chdir); |
| 6 | 682 } |
| 683 | |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
684 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
685 static char posix_chmod__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
686 "chmod(path, mode) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
687 Change the access permissions of a file."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
688 |
| 4672 | 689 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
690 posix_chmod(PyObject *self, PyObject *args) |
| 6 | 691 { |
|
12139
338e055b7cc0
Two robustness patches:
Guido van Rossum <guido@python.org>
parents:
11893
diff
changeset
|
692 char *path; |
|
338e055b7cc0
Two robustness patches:
Guido van Rossum <guido@python.org>
parents:
11893
diff
changeset
|
693 int i; |
|
338e055b7cc0
Two robustness patches:
Guido van Rossum <guido@python.org>
parents:
11893
diff
changeset
|
694 int res; |
|
12140
dade82b9ee19
Oops, the previous patch contained a bug in chmod. Fixed now.
Guido van Rossum <guido@python.org>
parents:
12139
diff
changeset
|
695 if (!PyArg_ParseTuple(args, "si", &path, &i)) |
|
12139
338e055b7cc0
Two robustness patches:
Guido van Rossum <guido@python.org>
parents:
11893
diff
changeset
|
696 return NULL; |
|
338e055b7cc0
Two robustness patches:
Guido van Rossum <guido@python.org>
parents:
11893
diff
changeset
|
697 Py_BEGIN_ALLOW_THREADS |
|
12150
81e5f8000094
Sigh. On Windows, (mode_t)i fails. Assume that there's a prototype
Guido van Rossum <guido@python.org>
parents:
12140
diff
changeset
|
698 res = chmod(path, i); |
|
12139
338e055b7cc0
Two robustness patches:
Guido van Rossum <guido@python.org>
parents:
11893
diff
changeset
|
699 Py_END_ALLOW_THREADS |
|
338e055b7cc0
Two robustness patches:
Guido van Rossum <guido@python.org>
parents:
11893
diff
changeset
|
700 if (res < 0) |
|
338e055b7cc0
Two robustness patches:
Guido van Rossum <guido@python.org>
parents:
11893
diff
changeset
|
701 return posix_error_with_filename(path); |
|
338e055b7cc0
Two robustness patches:
Guido van Rossum <guido@python.org>
parents:
11893
diff
changeset
|
702 Py_INCREF(Py_None); |
|
338e055b7cc0
Two robustness patches:
Guido van Rossum <guido@python.org>
parents:
11893
diff
changeset
|
703 return Py_None; |
| 6 | 704 } |
| 705 | |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
706 |
|
9822
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
707 #ifdef HAVE_FSYNC |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
708 static char posix_fsync__doc__[] = |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
709 "fsync(fildes) -> None\n\ |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
710 force write of file with filedescriptor to disk."; |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
711 |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
712 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
713 posix_fsync(PyObject *self, PyObject *args) |
|
9822
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
714 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
715 return posix_int(args, "i:fsync", fsync); |
|
9822
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
716 } |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
717 #endif /* HAVE_FSYNC */ |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
718 |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
719 #ifdef HAVE_FDATASYNC |
|
14762
5f638a299888
Hopefully fix the problem with undeclared fdatasync() on HP-UX that
Guido van Rossum <guido@python.org>
parents:
14752
diff
changeset
|
720 |
|
14767
60ce37f066d8
It's better to test for __hpux rather than __hppa, and hpux or hppa is
Guido van Rossum <guido@python.org>
parents:
14762
diff
changeset
|
721 #ifdef __hpux |
|
14762
5f638a299888
Hopefully fix the problem with undeclared fdatasync() on HP-UX that
Guido van Rossum <guido@python.org>
parents:
14752
diff
changeset
|
722 extern int fdatasync(int); /* On HP-UX, in libc but not in unistd.h */ |
|
5f638a299888
Hopefully fix the problem with undeclared fdatasync() on HP-UX that
Guido van Rossum <guido@python.org>
parents:
14752
diff
changeset
|
723 #endif |
|
5f638a299888
Hopefully fix the problem with undeclared fdatasync() on HP-UX that
Guido van Rossum <guido@python.org>
parents:
14752
diff
changeset
|
724 |
|
9822
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
725 static char posix_fdatasync__doc__[] = |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
726 "fdatasync(fildes) -> None\n\ |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
727 force write of file with filedescriptor to disk.\n\ |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
728 does not force update of metadata."; |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
729 |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
730 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
731 posix_fdatasync(PyObject *self, PyObject *args) |
|
9822
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
732 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
733 return posix_int(args, "i:fdatasync", fdatasync); |
|
9822
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
734 } |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
735 #endif /* HAVE_FDATASYNC */ |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
736 |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
737 |
| 13513 | 738 #ifdef HAVE_CHOWN |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
739 static char posix_chown__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
740 "chown(path, uid, gid) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
741 Change the owner and group id of path to the numeric uid and gid."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
742 |
| 4672 | 743 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
744 posix_chown(PyObject *self, PyObject *args) |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
745 { |
|
13511
18395ca5c30e
-- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents:
13486
diff
changeset
|
746 char *path; |
|
18395ca5c30e
-- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents:
13486
diff
changeset
|
747 int uid, gid; |
|
18395ca5c30e
-- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents:
13486
diff
changeset
|
748 int res; |
|
18395ca5c30e
-- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents:
13486
diff
changeset
|
749 if (!PyArg_ParseTuple(args, "sii:chown", &path, &uid, &gid)) |
|
18395ca5c30e
-- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents:
13486
diff
changeset
|
750 return NULL; |
|
18395ca5c30e
-- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents:
13486
diff
changeset
|
751 Py_BEGIN_ALLOW_THREADS |
|
18395ca5c30e
-- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents:
13486
diff
changeset
|
752 res = chown(path, (uid_t) uid, (gid_t) gid); |
|
18395ca5c30e
-- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents:
13486
diff
changeset
|
753 Py_END_ALLOW_THREADS |
|
18395ca5c30e
-- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents:
13486
diff
changeset
|
754 if (res < 0) |
|
18395ca5c30e
-- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents:
13486
diff
changeset
|
755 return posix_error_with_filename(path); |
|
18395ca5c30e
-- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents:
13486
diff
changeset
|
756 Py_INCREF(Py_None); |
|
18395ca5c30e
-- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents:
13486
diff
changeset
|
757 return Py_None; |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
758 } |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
759 #endif /* HAVE_CHOWN */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
760 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
761 |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
762 #ifdef HAVE_GETCWD |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
763 static char posix_getcwd__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
764 "getcwd() -> path\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
765 Return a string representing the current working directory."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
766 |
| 4672 | 767 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
768 posix_getcwd(PyObject *self, PyObject *args) |
| 6 | 769 { |
| 770 char buf[1026]; | |
| 926 | 771 char *res; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
772 if (!PyArg_ParseTuple(args, ":getcwd")) |
| 6 | 773 return NULL; |
| 4672 | 774 Py_BEGIN_ALLOW_THREADS |
| 926 | 775 res = getcwd(buf, sizeof buf); |
| 4672 | 776 Py_END_ALLOW_THREADS |
| 926 | 777 if (res == NULL) |
| 6 | 778 return posix_error(); |
| 4672 | 779 return PyString_FromString(buf); |
| 6 | 780 } |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
781 #endif |
| 6 | 782 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
783 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
784 #ifdef HAVE_LINK |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
785 static char posix_link__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
786 "link(src, dst) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
787 Create a hard link to a file."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
788 |
| 4672 | 789 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
790 posix_link(PyObject *self, PyObject *args) |
| 6 | 791 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
792 return posix_2str(args, "ss:link", link); |
| 6 | 793 } |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
794 #endif /* HAVE_LINK */ |
| 6 | 795 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
796 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
797 static char posix_listdir__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
798 "listdir(path) -> list_of_strings\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
799 Return a list containing the names of the entries in the directory.\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
800 \n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
801 path: path of directory to list\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
802 \n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
803 The list is in arbitrary order. It does not include the special\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
804 entries '.' and '..' even if they are present in the directory."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
805 |
| 4672 | 806 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
807 posix_listdir(PyObject *self, PyObject *args) |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
808 { |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
809 /* XXX Should redo this putting the (now four) versions of opendir |
|
6027
494e550cb18d
Added a bunch of XXX comments about things I'd like to see changed...
Guido van Rossum <guido@python.org>
parents:
5967
diff
changeset
|
810 in separate files instead of having them all here... */ |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
811 #if defined(MS_WIN32) && !defined(HAVE_OPENDIR) |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
812 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
813 char *name; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
814 int len; |
| 4672 | 815 PyObject *d, *v; |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
816 HANDLE hFindFile; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
817 WIN32_FIND_DATA FileData; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
818 char namebuf[MAX_PATH+5]; |
|
14586
cd1b9d8d045d
Closes SF bug 113894: on Windows, things like os.listdir("k:") and
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
819 char ch; |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
820 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
821 if (!PyArg_ParseTuple(args, "t#:listdir", &name, &len)) |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
822 return NULL; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
823 if (len >= MAX_PATH) { |
| 4672 | 824 PyErr_SetString(PyExc_ValueError, "path too long"); |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
825 return NULL; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
826 } |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
827 strcpy(namebuf, name); |
|
14586
cd1b9d8d045d
Closes SF bug 113894: on Windows, things like os.listdir("k:") and
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
828 ch = namebuf[len-1]; |
|
cd1b9d8d045d
Closes SF bug 113894: on Windows, things like os.listdir("k:") and
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
829 if (ch != '/' && ch != '\\' && ch != ':') |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
830 namebuf[len++] = '/'; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
831 strcpy(namebuf + len, "*.*"); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
832 |
| 4672 | 833 if ((d = PyList_New(0)) == NULL) |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
834 return NULL; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
835 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
836 hFindFile = FindFirstFile(namebuf, &FileData); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
837 if (hFindFile == INVALID_HANDLE_VALUE) { |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
838 errno = GetLastError(); |
|
8839
c2f9e505f75a
In Win32 version of listdir(), when FindFirstFile() returns
Guido van Rossum <guido@python.org>
parents:
8823
diff
changeset
|
839 if (errno == ERROR_FILE_NOT_FOUND) |
|
c2f9e505f75a
In Win32 version of listdir(), when FindFirstFile() returns
Guido van Rossum <guido@python.org>
parents:
8823
diff
changeset
|
840 return PyList_New(0); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
841 return win32_error("FindFirstFile", name); |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
842 } |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
843 do { |
|
2845
051bacab59af
suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents:
2740
diff
changeset
|
844 if (FileData.cFileName[0] == '.' && |
|
051bacab59af
suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents:
2740
diff
changeset
|
845 (FileData.cFileName[1] == '\0' || |
|
051bacab59af
suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents:
2740
diff
changeset
|
846 FileData.cFileName[1] == '.' && |
|
051bacab59af
suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents:
2740
diff
changeset
|
847 FileData.cFileName[2] == '\0')) |
|
051bacab59af
suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents:
2740
diff
changeset
|
848 continue; |
| 4672 | 849 v = PyString_FromString(FileData.cFileName); |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
850 if (v == NULL) { |
| 4672 | 851 Py_DECREF(d); |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
852 d = NULL; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
853 break; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
854 } |
| 4672 | 855 if (PyList_Append(d, v) != 0) { |
| 856 Py_DECREF(v); | |
| 857 Py_DECREF(d); | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
858 d = NULL; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
859 break; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
860 } |
| 4672 | 861 Py_DECREF(v); |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
862 } while (FindNextFile(hFindFile, &FileData) == TRUE); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
863 |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
864 if (FindClose(hFindFile) == FALSE) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
865 return win32_error("FindClose", name); |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
866 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
867 return d; |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
868 |
|
14586
cd1b9d8d045d
Closes SF bug 113894: on Windows, things like os.listdir("k:") and
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
869 #elif defined(_MSC_VER) /* 16-bit Windows */ |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
870 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
871 #ifndef MAX_PATH |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
872 #define MAX_PATH 250 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
873 #endif |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
874 char *name, *pt; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
875 int len; |
| 4672 | 876 PyObject *d, *v; |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
877 char namebuf[MAX_PATH+5]; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
878 struct _find_t ep; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
879 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
880 if (!PyArg_ParseTuple(args, "t#:listdir", &name, &len)) |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
881 return NULL; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
882 if (len >= MAX_PATH) { |
| 4672 | 883 PyErr_SetString(PyExc_ValueError, "path too long"); |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
884 return NULL; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
885 } |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
886 strcpy(namebuf, name); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
887 for (pt = namebuf; *pt; pt++) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
888 if (*pt == '/') |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
889 *pt = '\\'; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
890 if (namebuf[len-1] != '\\') |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
891 namebuf[len++] = '\\'; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
892 strcpy(namebuf + len, "*.*"); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
893 |
| 4672 | 894 if ((d = PyList_New(0)) == NULL) |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
895 return NULL; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
896 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
897 if (_dos_findfirst(namebuf, _A_RDONLY | |
| 4785 | 898 _A_HIDDEN | _A_SYSTEM | _A_SUBDIR, &ep) != 0) |
| 899 { | |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
900 errno = ENOENT; |
|
10887
af07389c8517
posix_listdir(): When an error occurs, call
Barry Warsaw <barry@python.org>
parents:
10526
diff
changeset
|
901 return posix_error_with_filename(name); |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
902 } |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
903 do { |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
904 if (ep.name[0] == '.' && |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
905 (ep.name[1] == '\0' || |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
906 ep.name[1] == '.' && |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
907 ep.name[2] == '\0')) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
908 continue; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
909 strcpy(namebuf, ep.name); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
910 for (pt = namebuf; *pt; pt++) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
911 if (isupper(*pt)) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
912 *pt = tolower(*pt); |
| 4672 | 913 v = PyString_FromString(namebuf); |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
914 if (v == NULL) { |
| 4672 | 915 Py_DECREF(d); |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
916 d = NULL; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
917 break; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
918 } |
| 4672 | 919 if (PyList_Append(d, v) != 0) { |
| 920 Py_DECREF(v); | |
| 921 Py_DECREF(d); | |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
922 d = NULL; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
923 break; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
924 } |
| 4672 | 925 Py_DECREF(v); |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
926 } while (_dos_findnext(&ep) == 0); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
927 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
928 return d; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
929 |
|
14586
cd1b9d8d045d
Closes SF bug 113894: on Windows, things like os.listdir("k:") and
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
930 #elif defined(PYOS_OS2) |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
931 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
932 #ifndef MAX_PATH |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
933 #define MAX_PATH CCHMAXPATH |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
934 #endif |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
935 char *name, *pt; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
936 int len; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
937 PyObject *d, *v; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
938 char namebuf[MAX_PATH+5]; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
939 HDIR hdir = 1; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
940 ULONG srchcnt = 1; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
941 FILEFINDBUF3 ep; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
942 APIRET rc; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
943 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
944 if (!PyArg_ParseTuple(args, "t#:listdir", &name, &len)) |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
945 return NULL; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
946 if (len >= MAX_PATH) { |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
947 PyErr_SetString(PyExc_ValueError, "path too long"); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
948 return NULL; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
949 } |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
950 strcpy(namebuf, name); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
951 for (pt = namebuf; *pt; pt++) |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
952 if (*pt == '/') |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
953 *pt = '\\'; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
954 if (namebuf[len-1] != '\\') |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
955 namebuf[len++] = '\\'; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
956 strcpy(namebuf + len, "*.*"); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
957 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
958 if ((d = PyList_New(0)) == NULL) |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
959 return NULL; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
960 |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
961 rc = DosFindFirst(namebuf, /* Wildcard Pattern to Match */ |
|
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
962 &hdir, /* Handle to Use While Search Directory */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
963 FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY, |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
964 &ep, sizeof(ep), /* Structure to Receive Directory Entry */ |
|
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
965 &srchcnt, /* Max and Actual Count of Entries Per Iteration */ |
|
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
966 FIL_STANDARD); /* Format of Entry (EAs or Not) */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
967 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
968 if (rc != NO_ERROR) { |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
969 errno = ENOENT; |
|
10887
af07389c8517
posix_listdir(): When an error occurs, call
Barry Warsaw <barry@python.org>
parents:
10526
diff
changeset
|
970 return posix_error_with_filename(name); |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
971 } |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
972 |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
973 if (srchcnt > 0) { /* If Directory is NOT Totally Empty, */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
974 do { |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
975 if (ep.achName[0] == '.' |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
976 && (ep.achName[1] == '\0' || ep.achName[1] == '.' && ep.achName[2] == '\0')) |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
977 continue; /* Skip Over "." and ".." Names */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
978 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
979 strcpy(namebuf, ep.achName); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
980 |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
981 /* Leave Case of Name Alone -- In Native Form */ |
|
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
982 /* (Removed Forced Lowercasing Code) */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
983 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
984 v = PyString_FromString(namebuf); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
985 if (v == NULL) { |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
986 Py_DECREF(d); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
987 d = NULL; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
988 break; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
989 } |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
990 if (PyList_Append(d, v) != 0) { |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
991 Py_DECREF(v); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
992 Py_DECREF(d); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
993 d = NULL; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
994 break; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
995 } |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
996 Py_DECREF(v); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
997 } while (DosFindNext(hdir, &ep, sizeof(ep), &srchcnt) == NO_ERROR && srchcnt > 0); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
998 } |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
999 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
1000 return d; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
1001 #else |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1002 |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
1003 char *name; |
| 4672 | 1004 PyObject *d, *v; |
| 6 | 1005 DIR *dirp; |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1006 struct dirent *ep; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1007 if (!PyArg_ParseTuple(args, "s:listdir", &name)) |
| 6 | 1008 return NULL; |
| 926 | 1009 if ((dirp = opendir(name)) == NULL) { |
|
10887
af07389c8517
posix_listdir(): When an error occurs, call
Barry Warsaw <barry@python.org>
parents:
10526
diff
changeset
|
1010 return posix_error_with_filename(name); |
| 926 | 1011 } |
| 4672 | 1012 if ((d = PyList_New(0)) == NULL) { |
| 6 | 1013 closedir(dirp); |
| 1014 return NULL; | |
| 1015 } | |
| 1016 while ((ep = readdir(dirp)) != NULL) { | |
|
2845
051bacab59af
suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents:
2740
diff
changeset
|
1017 if (ep->d_name[0] == '.' && |
|
051bacab59af
suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents:
2740
diff
changeset
|
1018 (NAMLEN(ep) == 1 || |
| 4600 | 1019 (ep->d_name[1] == '.' && NAMLEN(ep) == 2))) |
|
2845
051bacab59af
suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents:
2740
diff
changeset
|
1020 continue; |
| 4672 | 1021 v = PyString_FromStringAndSize(ep->d_name, NAMLEN(ep)); |
| 6 | 1022 if (v == NULL) { |
| 4672 | 1023 Py_DECREF(d); |
| 6 | 1024 d = NULL; |
| 1025 break; | |
| 1026 } | |
| 4672 | 1027 if (PyList_Append(d, v) != 0) { |
| 1028 Py_DECREF(v); | |
| 1029 Py_DECREF(d); | |
| 6 | 1030 d = NULL; |
| 1031 break; | |
| 1032 } | |
| 4672 | 1033 Py_DECREF(v); |
| 6 | 1034 } |
| 1035 closedir(dirp); | |
|
200
9d01965f4f48
Incorporated MSDOS changes (untested).
Guido van Rossum <guido@python.org>
parents:
199
diff
changeset
|
1036 |
| 6 | 1037 return d; |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1038 |
|
14586
cd1b9d8d045d
Closes SF bug 113894: on Windows, things like os.listdir("k:") and
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
1039 #endif /* which OS */ |
|
cd1b9d8d045d
Closes SF bug 113894: on Windows, things like os.listdir("k:") and
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
1040 } /* end of posix_listdir */ |
| 6 | 1041 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1042 static char posix_mkdir__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1043 "mkdir(path [, mode=0777]) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1044 Create a directory."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1045 |
| 4672 | 1046 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1047 posix_mkdir(PyObject *self, PyObject *args) |
| 6 | 1048 { |
|
3418
0ac5fbaf8aef
Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents:
3387
diff
changeset
|
1049 int res; |
|
0ac5fbaf8aef
Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents:
3387
diff
changeset
|
1050 char *path; |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1051 int mode = 0777; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1052 if (!PyArg_ParseTuple(args, "s|i:mkdir", &path, &mode)) |
|
3418
0ac5fbaf8aef
Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents:
3387
diff
changeset
|
1053 return NULL; |
| 4672 | 1054 Py_BEGIN_ALLOW_THREADS |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
1055 #if ( defined(__WATCOMC__) || defined(_MSC_VER) || defined(PYCC_VACPP) ) && !defined(__QNX__) |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1056 res = mkdir(path); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1057 #else |
|
3418
0ac5fbaf8aef
Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents:
3387
diff
changeset
|
1058 res = mkdir(path, mode); |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1059 #endif |
| 4672 | 1060 Py_END_ALLOW_THREADS |
|
3418
0ac5fbaf8aef
Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents:
3387
diff
changeset
|
1061 if (res < 0) |
|
8708
acf49c9def7d
Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents:
8497
diff
changeset
|
1062 return posix_error_with_filename(path); |
| 4672 | 1063 Py_INCREF(Py_None); |
| 1064 return Py_None; | |
| 6 | 1065 } |
| 1066 | |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1067 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1068 #ifdef HAVE_NICE |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1069 static char posix_nice__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1070 "nice(inc) -> new_priority\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1071 Decrease the priority of process and return new priority."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1072 |
| 4672 | 1073 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1074 posix_nice(PyObject *self, PyObject *args) |
|
1181
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
1075 { |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
1076 int increment, value; |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
1077 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1078 if (!PyArg_ParseTuple(args, "i:nice", &increment)) |
|
1181
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
1079 return NULL; |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
1080 value = nice(increment); |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
1081 if (value == -1) |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
1082 return posix_error(); |
| 4672 | 1083 return PyInt_FromLong((long) value); |
|
1181
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
1084 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1085 #endif /* HAVE_NICE */ |
|
199
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
1086 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1087 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1088 static char posix_rename__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1089 "rename(old, new) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1090 Rename a file or directory."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1091 |
| 4672 | 1092 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1093 posix_rename(PyObject *self, PyObject *args) |
| 6 | 1094 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1095 return posix_2str(args, "ss:rename", rename); |
| 6 | 1096 } |
| 1097 | |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1098 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1099 static char posix_rmdir__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1100 "rmdir(path) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1101 Remove a directory."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1102 |
| 4672 | 1103 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1104 posix_rmdir(PyObject *self, PyObject *args) |
| 6 | 1105 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1106 return posix_1str(args, "s:rmdir", rmdir); |
| 6 | 1107 } |
| 1108 | |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1109 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1110 static char posix_stat__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1111 "stat(path) -> (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1112 Perform a stat system call on the given path."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1113 |
| 4672 | 1114 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1115 posix_stat(PyObject *self, PyObject *args) |
| 6 | 1116 { |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
1117 return posix_do_stat(self, args, "s:stat", STAT); |
| 6 | 1118 } |
| 1119 | |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1120 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1121 #ifdef HAVE_SYSTEM |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1122 static char posix_system__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1123 "system(command) -> exit_status\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1124 Execute the command (a string) in a subshell."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1125 |
| 4672 | 1126 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1127 posix_system(PyObject *self, PyObject *args) |
| 6 | 1128 { |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
1129 char *command; |
| 926 | 1130 long sts; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1131 if (!PyArg_ParseTuple(args, "s:system", &command)) |
| 6 | 1132 return NULL; |
| 4672 | 1133 Py_BEGIN_ALLOW_THREADS |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
1134 sts = system(command); |
| 4672 | 1135 Py_END_ALLOW_THREADS |
| 1136 return PyInt_FromLong(sts); | |
| 6 | 1137 } |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1138 #endif |
| 6 | 1139 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1140 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1141 static char posix_umask__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1142 "umask(new_mask) -> old_mask\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1143 Set the current numeric umask and return the previous umask."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1144 |
| 4672 | 1145 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1146 posix_umask(PyObject *self, PyObject *args) |
| 6 | 1147 { |
| 1148 int i; | |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1149 if (!PyArg_ParseTuple(args, "i:umask", &i)) |
| 6 | 1150 return NULL; |
| 1151 i = umask(i); | |
| 1152 if (i < 0) | |
| 1153 return posix_error(); | |
| 4672 | 1154 return PyInt_FromLong((long)i); |
| 6 | 1155 } |
| 1156 | |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1157 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1158 static char posix_unlink__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1159 "unlink(path) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1160 Remove a file (same as remove(path))."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1161 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1162 static char posix_remove__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1163 "remove(path) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1164 Remove a file (same as unlink(path))."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1165 |
| 4672 | 1166 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1167 posix_unlink(PyObject *self, PyObject *args) |
| 6 | 1168 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1169 return posix_1str(args, "s:remove", unlink); |
| 6 | 1170 } |
| 1171 | |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1172 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1173 #ifdef HAVE_UNAME |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1174 static char posix_uname__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1175 "uname() -> (sysname, nodename, release, version, machine)\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1176 Return a tuple identifying the current operating system."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1177 |
| 4672 | 1178 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1179 posix_uname(PyObject *self, PyObject *args) |
|
658
5b521fe4d1f6
Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents:
643
diff
changeset
|
1180 { |
|
5b521fe4d1f6
Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents:
643
diff
changeset
|
1181 struct utsname u; |
| 926 | 1182 int res; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1183 if (!PyArg_ParseTuple(args, ":uname")) |
|
731
c65fc172f16d
Check empty argument lists.
Guido van Rossum <guido@python.org>
parents:
658
diff
changeset
|
1184 return NULL; |
| 4672 | 1185 Py_BEGIN_ALLOW_THREADS |
| 926 | 1186 res = uname(&u); |
| 4672 | 1187 Py_END_ALLOW_THREADS |
| 926 | 1188 if (res < 0) |
|
658
5b521fe4d1f6
Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents:
643
diff
changeset
|
1189 return posix_error(); |
| 4672 | 1190 return Py_BuildValue("(sssss)", |
| 4785 | 1191 u.sysname, |
| 1192 u.nodename, | |
| 1193 u.release, | |
| 1194 u.version, | |
| 1195 u.machine); | |
|
658
5b521fe4d1f6
Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents:
643
diff
changeset
|
1196 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1197 #endif /* HAVE_UNAME */ |
|
199
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
1198 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1199 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1200 static char posix_utime__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1201 "utime(path, (atime, utime)) -> None\n\ |
|
12533
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1202 utime(path, None) -> None\n\ |
|
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1203 Set the access and modified time of the file to the given values. If the\n\ |
|
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1204 second form is used, set the access and modified times to the current time."; |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1205 |
| 4672 | 1206 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1207 posix_utime(PyObject *self, PyObject *args) |
| 6 | 1208 { |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
1209 char *path; |
| 2236 | 1210 long atime, mtime; |
| 926 | 1211 int res; |
|
12533
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1212 PyObject* arg; |
|
199
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
1213 |
|
6027
494e550cb18d
Added a bunch of XXX comments about things I'd like to see changed...
Guido van Rossum <guido@python.org>
parents:
5967
diff
changeset
|
1214 /* XXX should define struct utimbuf instead, above */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1215 #ifdef HAVE_UTIME_H |
|
199
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
1216 struct utimbuf buf; |
|
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
1217 #define ATIME buf.actime |
|
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
1218 #define MTIME buf.modtime |
|
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
1219 #define UTIME_ARG &buf |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1220 #else /* HAVE_UTIME_H */ |
|
199
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
1221 time_t buf[2]; |
|
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
1222 #define ATIME buf[0] |
|
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
1223 #define MTIME buf[1] |
|
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
1224 #define UTIME_ARG buf |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1225 #endif /* HAVE_UTIME_H */ |
|
199
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
1226 |
|
12533
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1227 if (!PyArg_ParseTuple(args, "sO:utime", &path, &arg)) |
| 6 | 1228 return NULL; |
|
12533
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1229 if (arg == Py_None) { |
|
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1230 /* optional time values not given */ |
|
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1231 Py_BEGIN_ALLOW_THREADS |
|
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1232 res = utime(path, NULL); |
|
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1233 Py_END_ALLOW_THREADS |
|
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1234 } |
|
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1235 else if (!PyArg_Parse(arg, "(ll)", &atime, &mtime)) { |
|
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1236 PyErr_SetString(PyExc_TypeError, |
| 15318 | 1237 "utime() arg 2 must be a tuple (atime, mtime)"); |
|
12533
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1238 return NULL; |
|
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1239 } |
|
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1240 else { |
|
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1241 ATIME = atime; |
|
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1242 MTIME = mtime; |
|
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1243 Py_BEGIN_ALLOW_THREADS |
|
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1244 res = utime(path, UTIME_ARG); |
|
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1245 Py_END_ALLOW_THREADS |
|
5235656f9d0f
posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents:
12503
diff
changeset
|
1246 } |
| 926 | 1247 if (res < 0) |
|
8708
acf49c9def7d
Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents:
8497
diff
changeset
|
1248 return posix_error_with_filename(path); |
| 4672 | 1249 Py_INCREF(Py_None); |
| 1250 return Py_None; | |
|
199
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
1251 #undef UTIME_ARG |
|
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
1252 #undef ATIME |
|
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
1253 #undef MTIME |
| 6 | 1254 } |
| 1255 | |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1256 |
| 264 | 1257 /* Process operations */ |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1258 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1259 static char posix__exit__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1260 "_exit(status)\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1261 Exit to the system with specified status, without normal exit processing."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1262 |
| 4672 | 1263 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1264 posix__exit(PyObject *self, PyObject *args) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1265 { |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1266 int sts; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1267 if (!PyArg_ParseTuple(args, "i:_exit", &sts)) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1268 return NULL; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1269 _exit(sts); |
| 4600 | 1270 return NULL; /* Make gcc -Wall happy */ |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1271 } |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1272 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1273 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1274 #ifdef HAVE_EXECV |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1275 static char posix_execv__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1276 "execv(path, args)\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1277 Execute an executable path with arguments, replacing current process.\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1278 \n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1279 path: path of executable file\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1280 args: tuple or list of strings"; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1281 |
| 4672 | 1282 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1283 posix_execv(PyObject *self, PyObject *args) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1284 { |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
1285 char *path; |
| 4672 | 1286 PyObject *argv; |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1287 char **argvlist; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1288 int i, argc; |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1289 PyObject *(*getitem)(PyObject *, int); |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1290 |
|
1360
1808ca5d8883
* import.c (MAGIC): Changed magic word to avoid confusion about exec
Guido van Rossum <guido@python.org>
parents:
1329
diff
changeset
|
1291 /* execv has two arguments: (path, argv), where |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1292 argv is a list or tuple of strings. */ |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1293 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1294 if (!PyArg_ParseTuple(args, "sO:execv", &path, &argv)) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1295 return NULL; |
| 4672 | 1296 if (PyList_Check(argv)) { |
| 1297 argc = PyList_Size(argv); | |
| 1298 getitem = PyList_GetItem; | |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1299 } |
| 4672 | 1300 else if (PyTuple_Check(argv)) { |
| 1301 argc = PyTuple_Size(argv); | |
| 1302 getitem = PyTuple_GetItem; | |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1303 } |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
1304 else { |
| 15318 | 1305 PyErr_SetString(PyExc_TypeError, "execv() arg 2 must be a tuple or list"); |
| 12503 | 1306 return NULL; |
| 1307 } | |
| 1308 | |
| 1309 if (argc == 0) { | |
| 15318 | 1310 PyErr_SetString(PyExc_ValueError, "execv() arg 2 must not be empty"); |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
1311 return NULL; |
|
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
1312 } |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1313 |
| 4672 | 1314 argvlist = PyMem_NEW(char *, argc+1); |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1315 if (argvlist == NULL) |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1316 return NULL; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1317 for (i = 0; i < argc; i++) { |
| 4672 | 1318 if (!PyArg_Parse((*getitem)(argv, i), "s", &argvlist[i])) { |
| 1319 PyMem_DEL(argvlist); | |
| 12503 | 1320 PyErr_SetString(PyExc_TypeError, |
| 15318 | 1321 "execv() arg 2 must contain only strings"); |
| 12503 | 1322 return NULL; |
| 1323 | |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1324 } |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1325 } |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1326 argvlist[argc] = NULL; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1327 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1328 #ifdef BAD_EXEC_PROTOTYPES |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1329 execv(path, (const char **) argvlist); |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1330 #else /* BAD_EXEC_PROTOTYPES */ |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
1331 execv(path, argvlist); |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1332 #endif /* BAD_EXEC_PROTOTYPES */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1333 |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1334 /* If we get here it's definitely an error */ |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1335 |
| 4672 | 1336 PyMem_DEL(argvlist); |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1337 return posix_error(); |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1338 } |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1339 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1340 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1341 static char posix_execve__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1342 "execve(path, args, env)\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1343 Execute a path with arguments and environment, replacing current process.\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1344 \n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1345 path: path of executable file\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1346 args: tuple or list of arguments\n\ |
|
13620
5b727ab37092
Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
Thomas Wouters <thomas@python.org>
parents:
13601
diff
changeset
|
1347 env: dictionary of strings mapping to strings"; |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1348 |
| 4672 | 1349 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1350 posix_execve(PyObject *self, PyObject *args) |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1351 { |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1352 char *path; |
| 4672 | 1353 PyObject *argv, *env; |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1354 char **argvlist; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1355 char **envlist; |
|
5058
371464f6666b
posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents:
4789
diff
changeset
|
1356 PyObject *key, *val, *keys=NULL, *vals=NULL; |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1357 int i, pos, argc, envc; |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1358 PyObject *(*getitem)(PyObject *, int); |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1359 |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1360 /* execve has three arguments: (path, argv, env), where |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1361 argv is a list or tuple of strings and env is a dictionary |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1362 like posix.environ. */ |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1363 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1364 if (!PyArg_ParseTuple(args, "sOO:execve", &path, &argv, &env)) |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1365 return NULL; |
| 4672 | 1366 if (PyList_Check(argv)) { |
| 1367 argc = PyList_Size(argv); | |
| 1368 getitem = PyList_GetItem; | |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1369 } |
| 4672 | 1370 else if (PyTuple_Check(argv)) { |
| 1371 argc = PyTuple_Size(argv); | |
| 1372 getitem = PyTuple_GetItem; | |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1373 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1374 else { |
| 15318 | 1375 PyErr_SetString(PyExc_TypeError, "execve() arg 2 must be a tuple or list"); |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1376 return NULL; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1377 } |
|
5058
371464f6666b
posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents:
4789
diff
changeset
|
1378 if (!PyMapping_Check(env)) { |
| 15318 | 1379 PyErr_SetString(PyExc_TypeError, "execve() arg 3 must be a mapping object"); |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1380 return NULL; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1381 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1382 |
| 12503 | 1383 if (argc == 0) { |
| 1384 PyErr_SetString(PyExc_ValueError, | |
| 15318 | 1385 "execve() arg 2 must not be empty"); |
| 12503 | 1386 return NULL; |
| 1387 } | |
| 1388 | |
| 4672 | 1389 argvlist = PyMem_NEW(char *, argc+1); |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1390 if (argvlist == NULL) { |
| 4672 | 1391 PyErr_NoMemory(); |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1392 return NULL; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1393 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1394 for (i = 0; i < argc; i++) { |
| 4672 | 1395 if (!PyArg_Parse((*getitem)(argv, i), |
| 15318 | 1396 "s;execve() arg 2 must contain only strings", |
| 4785 | 1397 &argvlist[i])) |
| 1398 { | |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1399 goto fail_1; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1400 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1401 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1402 argvlist[argc] = NULL; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1403 |
|
13576
61e4c29d53d8
replace PyXXX_Length calls with PyXXX_Size calls
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13513
diff
changeset
|
1404 i = PyMapping_Size(env); |
| 4672 | 1405 envlist = PyMem_NEW(char *, i + 1); |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1406 if (envlist == NULL) { |
| 4672 | 1407 PyErr_NoMemory(); |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1408 goto fail_1; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1409 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1410 envc = 0; |
|
5058
371464f6666b
posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents:
4789
diff
changeset
|
1411 keys = PyMapping_Keys(env); |
|
371464f6666b
posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents:
4789
diff
changeset
|
1412 vals = PyMapping_Values(env); |
|
371464f6666b
posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents:
4789
diff
changeset
|
1413 if (!keys || !vals) |
|
371464f6666b
posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents:
4789
diff
changeset
|
1414 goto fail_2; |
|
371464f6666b
posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents:
4789
diff
changeset
|
1415 |
|
371464f6666b
posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents:
4789
diff
changeset
|
1416 for (pos = 0; pos < i; pos++) { |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1417 char *p, *k, *v; |
|
5058
371464f6666b
posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents:
4789
diff
changeset
|
1418 |
|
371464f6666b
posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents:
4789
diff
changeset
|
1419 key = PyList_GetItem(keys, pos); |
|
371464f6666b
posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents:
4789
diff
changeset
|
1420 val = PyList_GetItem(vals, pos); |
|
371464f6666b
posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents:
4789
diff
changeset
|
1421 if (!key || !val) |
|
371464f6666b
posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents:
4789
diff
changeset
|
1422 goto fail_2; |
|
371464f6666b
posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents:
4789
diff
changeset
|
1423 |
| 15318 | 1424 if (!PyArg_Parse(key, "s;execve() arg 3 contains a non-string key", &k) || |
| 1425 !PyArg_Parse(val, "s;execve() arg 3 contains a non-string value", &v)) | |
| 4785 | 1426 { |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1427 goto fail_2; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1428 } |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
1429 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
1430 #if defined(PYOS_OS2) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
1431 /* Omit Pseudo-Env Vars that Would Confuse Programs if Passed On */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
1432 if (stricmp(k, "BEGINLIBPATH") != 0 && stricmp(k, "ENDLIBPATH") != 0) { |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
1433 #endif |
| 4672 | 1434 p = PyMem_NEW(char, PyString_Size(key)+PyString_Size(val) + 2); |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1435 if (p == NULL) { |
| 4672 | 1436 PyErr_NoMemory(); |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1437 goto fail_2; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1438 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1439 sprintf(p, "%s=%s", k, v); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1440 envlist[envc++] = p; |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
1441 #if defined(PYOS_OS2) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
1442 } |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
1443 #endif |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1444 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1445 envlist[envc] = 0; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1446 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1447 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1448 #ifdef BAD_EXEC_PROTOTYPES |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1449 execve(path, (const char **)argvlist, envlist); |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1450 #else /* BAD_EXEC_PROTOTYPES */ |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1451 execve(path, argvlist, envlist); |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1452 #endif /* BAD_EXEC_PROTOTYPES */ |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1453 |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1454 /* If we get here it's definitely an error */ |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1455 |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1456 (void) posix_error(); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1457 |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1458 fail_2: |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1459 while (--envc >= 0) |
| 4672 | 1460 PyMem_DEL(envlist[envc]); |
| 1461 PyMem_DEL(envlist); | |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1462 fail_1: |
| 4672 | 1463 PyMem_DEL(argvlist); |
|
5058
371464f6666b
posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents:
4789
diff
changeset
|
1464 Py_XDECREF(vals); |
|
371464f6666b
posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents:
4789
diff
changeset
|
1465 Py_XDECREF(keys); |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1466 return NULL; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1467 } |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1468 #endif /* HAVE_EXECV */ |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1469 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1470 |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1471 #ifdef HAVE_SPAWNV |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1472 static char posix_spawnv__doc__[] = |
|
10066
d7f434d784bf
spawnv, spawnve docstrings: added mode parameter; this is required!
Fred Drake <fdrake@acm.org>
parents:
10056
diff
changeset
|
1473 "spawnv(mode, path, args)\n\ |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1474 Execute an executable path with arguments, replacing current process.\n\ |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1475 \n\ |
|
10066
d7f434d784bf
spawnv, spawnve docstrings: added mode parameter; this is required!
Fred Drake <fdrake@acm.org>
parents:
10056
diff
changeset
|
1476 mode: mode of process creation\n\ |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1477 path: path of executable file\n\ |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1478 args: tuple or list of strings"; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1479 |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1480 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1481 posix_spawnv(PyObject *self, PyObject *args) |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1482 { |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1483 char *path; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1484 PyObject *argv; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1485 char **argvlist; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1486 int mode, i, argc; |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
1487 intptr_t spawnval; |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1488 PyObject *(*getitem)(PyObject *, int); |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1489 |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1490 /* spawnv has three arguments: (mode, path, argv), where |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1491 argv is a list or tuple of strings. */ |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1492 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1493 if (!PyArg_ParseTuple(args, "isO:spawnv", &mode, &path, &argv)) |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1494 return NULL; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1495 if (PyList_Check(argv)) { |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1496 argc = PyList_Size(argv); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1497 getitem = PyList_GetItem; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1498 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1499 else if (PyTuple_Check(argv)) { |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1500 argc = PyTuple_Size(argv); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1501 getitem = PyTuple_GetItem; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1502 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1503 else { |
| 15318 | 1504 PyErr_SetString(PyExc_TypeError, "spawmv() arg 2 must be a tuple or list"); |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1505 return NULL; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1506 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1507 |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1508 argvlist = PyMem_NEW(char *, argc+1); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1509 if (argvlist == NULL) |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1510 return NULL; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1511 for (i = 0; i < argc; i++) { |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1512 if (!PyArg_Parse((*getitem)(argv, i), "s", &argvlist[i])) { |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1513 PyMem_DEL(argvlist); |
|
12814
b1b260a2de98
Michael Hudson <mwh21@cam.ac.uk>:
Fred Drake <fdrake@acm.org>
parents:
12564
diff
changeset
|
1514 PyErr_SetString(PyExc_TypeError, |
| 15318 | 1515 "spawnv() arg 2 must contain only strings"); |
|
12814
b1b260a2de98
Michael Hudson <mwh21@cam.ac.uk>:
Fred Drake <fdrake@acm.org>
parents:
12564
diff
changeset
|
1516 return NULL; |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1517 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1518 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1519 argvlist[argc] = NULL; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1520 |
|
10069
5e01645ee41b
Add _P_WAIT etc. for NT.
Guido van Rossum <guido@python.org>
parents:
10066
diff
changeset
|
1521 if (mode == _OLD_P_OVERLAY) |
|
5e01645ee41b
Add _P_WAIT etc. for NT.
Guido van Rossum <guido@python.org>
parents:
10066
diff
changeset
|
1522 mode = _P_OVERLAY; |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
1523 spawnval = _spawnv(mode, path, argvlist); |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1524 |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1525 PyMem_DEL(argvlist); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1526 |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
1527 if (spawnval == -1) |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1528 return posix_error(); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1529 else |
|
13462
4cf0de29c08c
- fixed pointer size test in spawn functions. also added
Fredrik Lundh <fredrik@pythonware.com>
parents:
13442
diff
changeset
|
1530 #if SIZEOF_LONG == SIZEOF_VOID_P |
|
4cf0de29c08c
- fixed pointer size test in spawn functions. also added
Fredrik Lundh <fredrik@pythonware.com>
parents:
13442
diff
changeset
|
1531 return Py_BuildValue("l", (long) spawnval); |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
1532 #else |
|
13462
4cf0de29c08c
- fixed pointer size test in spawn functions. also added
Fredrik Lundh <fredrik@pythonware.com>
parents:
13442
diff
changeset
|
1533 return Py_BuildValue("L", (LONG_LONG) spawnval); |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
1534 #endif |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1535 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1536 |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1537 |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1538 static char posix_spawnve__doc__[] = |
|
10066
d7f434d784bf
spawnv, spawnve docstrings: added mode parameter; this is required!
Fred Drake <fdrake@acm.org>
parents:
10056
diff
changeset
|
1539 "spawnve(mode, path, args, env)\n\ |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1540 Execute a path with arguments and environment, replacing current process.\n\ |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1541 \n\ |
|
10066
d7f434d784bf
spawnv, spawnve docstrings: added mode parameter; this is required!
Fred Drake <fdrake@acm.org>
parents:
10056
diff
changeset
|
1542 mode: mode of process creation\n\ |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1543 path: path of executable file\n\ |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1544 args: tuple or list of arguments\n\ |
|
13620
5b727ab37092
Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
Thomas Wouters <thomas@python.org>
parents:
13601
diff
changeset
|
1545 env: dictionary of strings mapping to strings"; |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1546 |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1547 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1548 posix_spawnve(PyObject *self, PyObject *args) |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1549 { |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1550 char *path; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1551 PyObject *argv, *env; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1552 char **argvlist; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1553 char **envlist; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1554 PyObject *key, *val, *keys=NULL, *vals=NULL, *res=NULL; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1555 int mode, i, pos, argc, envc; |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
1556 intptr_t spawnval; |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1557 PyObject *(*getitem)(PyObject *, int); |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1558 |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1559 /* spawnve has four arguments: (mode, path, argv, env), where |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1560 argv is a list or tuple of strings and env is a dictionary |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1561 like posix.environ. */ |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1562 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1563 if (!PyArg_ParseTuple(args, "isOO:spawnve", &mode, &path, &argv, &env)) |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1564 return NULL; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1565 if (PyList_Check(argv)) { |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1566 argc = PyList_Size(argv); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1567 getitem = PyList_GetItem; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1568 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1569 else if (PyTuple_Check(argv)) { |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1570 argc = PyTuple_Size(argv); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1571 getitem = PyTuple_GetItem; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1572 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1573 else { |
| 15318 | 1574 PyErr_SetString(PyExc_TypeError, "spawnve() arg 2 must be a tuple or list"); |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1575 return NULL; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1576 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1577 if (!PyMapping_Check(env)) { |
| 15318 | 1578 PyErr_SetString(PyExc_TypeError, "spawnve() arg 3 must be a mapping object"); |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1579 return NULL; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1580 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1581 |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1582 argvlist = PyMem_NEW(char *, argc+1); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1583 if (argvlist == NULL) { |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1584 PyErr_NoMemory(); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1585 return NULL; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1586 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1587 for (i = 0; i < argc; i++) { |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1588 if (!PyArg_Parse((*getitem)(argv, i), |
| 15318 | 1589 "s;spawnve() arg 2 must contain only strings", |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1590 &argvlist[i])) |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1591 { |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1592 goto fail_1; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1593 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1594 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1595 argvlist[argc] = NULL; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1596 |
|
13576
61e4c29d53d8
replace PyXXX_Length calls with PyXXX_Size calls
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13513
diff
changeset
|
1597 i = PyMapping_Size(env); |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1598 envlist = PyMem_NEW(char *, i + 1); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1599 if (envlist == NULL) { |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1600 PyErr_NoMemory(); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1601 goto fail_1; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1602 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1603 envc = 0; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1604 keys = PyMapping_Keys(env); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1605 vals = PyMapping_Values(env); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1606 if (!keys || !vals) |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1607 goto fail_2; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1608 |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1609 for (pos = 0; pos < i; pos++) { |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1610 char *p, *k, *v; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1611 |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1612 key = PyList_GetItem(keys, pos); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1613 val = PyList_GetItem(vals, pos); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1614 if (!key || !val) |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1615 goto fail_2; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1616 |
| 15318 | 1617 if (!PyArg_Parse(key, "s;spawnve() arg 3 contains a non-string key", &k) || |
| 1618 !PyArg_Parse(val, "s;spawnve() arg 3 contains a non-string value", &v)) | |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1619 { |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1620 goto fail_2; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1621 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1622 p = PyMem_NEW(char, PyString_Size(key)+PyString_Size(val) + 2); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1623 if (p == NULL) { |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1624 PyErr_NoMemory(); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1625 goto fail_2; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1626 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1627 sprintf(p, "%s=%s", k, v); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1628 envlist[envc++] = p; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1629 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1630 envlist[envc] = 0; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1631 |
|
10069
5e01645ee41b
Add _P_WAIT etc. for NT.
Guido van Rossum <guido@python.org>
parents:
10066
diff
changeset
|
1632 if (mode == _OLD_P_OVERLAY) |
|
5e01645ee41b
Add _P_WAIT etc. for NT.
Guido van Rossum <guido@python.org>
parents:
10066
diff
changeset
|
1633 mode = _P_OVERLAY; |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
1634 spawnval = _spawnve(mode, path, argvlist, envlist); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
1635 if (spawnval == -1) |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1636 (void) posix_error(); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1637 else |
|
13462
4cf0de29c08c
- fixed pointer size test in spawn functions. also added
Fredrik Lundh <fredrik@pythonware.com>
parents:
13442
diff
changeset
|
1638 #if SIZEOF_LONG == SIZEOF_VOID_P |
|
4cf0de29c08c
- fixed pointer size test in spawn functions. also added
Fredrik Lundh <fredrik@pythonware.com>
parents:
13442
diff
changeset
|
1639 res = Py_BuildValue("l", (long) spawnval); |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
1640 #else |
|
13462
4cf0de29c08c
- fixed pointer size test in spawn functions. also added
Fredrik Lundh <fredrik@pythonware.com>
parents:
13442
diff
changeset
|
1641 res = Py_BuildValue("L", (LONG_LONG) spawnval); |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
1642 #endif |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1643 |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1644 fail_2: |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1645 while (--envc >= 0) |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1646 PyMem_DEL(envlist[envc]); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1647 PyMem_DEL(envlist); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1648 fail_1: |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1649 PyMem_DEL(argvlist); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1650 Py_XDECREF(vals); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1651 Py_XDECREF(keys); |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1652 return res; |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1653 } |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1654 #endif /* HAVE_SPAWNV */ |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1655 |
|
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
1656 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1657 #ifdef HAVE_FORK |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1658 static char posix_fork__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1659 "fork() -> pid\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1660 Fork a child process.\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1661 \n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1662 Return 0 to child process and PID of child to parent process."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1663 |
| 4672 | 1664 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1665 posix_fork(PyObject *self, PyObject *args) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1666 { |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1667 int pid; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1668 if (!PyArg_ParseTuple(args, ":fork")) |
|
731
c65fc172f16d
Check empty argument lists.
Guido van Rossum <guido@python.org>
parents:
658
diff
changeset
|
1669 return NULL; |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1670 pid = fork(); |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1671 if (pid == -1) |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1672 return posix_error(); |
|
13389
1c0d35ba16b1
Fix bug #392, reported by Jonathan Giddy <jon@dstc.edu.au>:
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
1673 if (pid == 0) |
|
1c0d35ba16b1
Fix bug #392, reported by Jonathan Giddy <jon@dstc.edu.au>:
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
1674 PyOS_AfterFork(); |
| 4672 | 1675 return PyInt_FromLong((long)pid); |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1676 } |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1677 #endif |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1678 |
|
13058
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1679 #if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1680 #ifdef HAVE_PTY_H |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1681 #include <pty.h> |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1682 #else |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1683 #ifdef HAVE_LIBUTIL_H |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1684 #include <libutil.h> |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1685 #endif /* HAVE_LIBUTIL_H */ |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1686 #endif /* HAVE_PTY_H */ |
|
13601
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1687 #endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */ |
|
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1688 |
|
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1689 #if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) |
|
13058
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1690 static char posix_openpty__doc__[] = |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1691 "openpty() -> (master_fd, slave_fd)\n\ |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1692 Open a pseudo-terminal, returning open fd's for both master and slave end.\n"; |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1693 |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1694 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1695 posix_openpty(PyObject *self, PyObject *args) |
|
13058
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1696 { |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1697 int master_fd, slave_fd; |
|
13601
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1698 #ifndef HAVE_OPENPTY |
|
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1699 char * slave_name; |
|
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1700 #endif |
|
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1701 |
|
13058
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1702 if (!PyArg_ParseTuple(args, ":openpty")) |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1703 return NULL; |
|
13601
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1704 |
|
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1705 #ifdef HAVE_OPENPTY |
|
13058
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1706 if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) != 0) |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1707 return posix_error(); |
|
13601
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1708 #else |
|
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1709 slave_name = _getpty(&master_fd, O_RDWR, 0666, 0); |
|
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1710 if (slave_name == NULL) |
|
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1711 return posix_error(); |
|
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1712 |
|
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1713 slave_fd = open(slave_name, O_RDWR); |
|
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1714 if (slave_fd < 0) |
|
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1715 return posix_error(); |
|
13694
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13675
diff
changeset
|
1716 #endif /* HAVE_OPENPTY */ |
|
13601
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1717 |
|
13058
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1718 return Py_BuildValue("(ii)", master_fd, slave_fd); |
|
13601
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1719 |
|
13058
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1720 } |
|
13601
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
1721 #endif /* defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) */ |
|
13058
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1722 |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1723 #ifdef HAVE_FORKPTY |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1724 static char posix_forkpty__doc__[] = |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1725 "forkpty() -> (pid, master_fd)\n\ |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1726 Fork a new process with a new pseudo-terminal as controlling tty.\n\n\ |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1727 Like fork(), return 0 as pid to child process, and PID of child to parent.\n\ |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1728 To both, return fd of newly opened pseudo-terminal.\n"; |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1729 |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1730 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1731 posix_forkpty(PyObject *self, PyObject *args) |
|
13058
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1732 { |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1733 int master_fd, pid; |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1734 |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1735 if (!PyArg_ParseTuple(args, ":forkpty")) |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1736 return NULL; |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1737 pid = forkpty(&master_fd, NULL, NULL, NULL); |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1738 if (pid == -1) |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1739 return posix_error(); |
|
13389
1c0d35ba16b1
Fix bug #392, reported by Jonathan Giddy <jon@dstc.edu.au>:
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
1740 if (pid == 0) |
|
1c0d35ba16b1
Fix bug #392, reported by Jonathan Giddy <jon@dstc.edu.au>:
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
1741 PyOS_AfterFork(); |
|
13058
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1742 return Py_BuildValue("(ii)", pid, master_fd); |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1743 } |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
1744 #endif |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1745 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1746 #ifdef HAVE_GETEGID |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1747 static char posix_getegid__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1748 "getegid() -> egid\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1749 Return the current process's effective group id."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1750 |
| 4672 | 1751 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1752 posix_getegid(PyObject *self, PyObject *args) |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1753 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1754 if (!PyArg_ParseTuple(args, ":getegid")) |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1755 return NULL; |
| 4672 | 1756 return PyInt_FromLong((long)getegid()); |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1757 } |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1758 #endif |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1759 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1760 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1761 #ifdef HAVE_GETEUID |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1762 static char posix_geteuid__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1763 "geteuid() -> euid\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1764 Return the current process's effective user id."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1765 |
| 4672 | 1766 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1767 posix_geteuid(PyObject *self, PyObject *args) |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1768 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1769 if (!PyArg_ParseTuple(args, ":geteuid")) |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1770 return NULL; |
| 4672 | 1771 return PyInt_FromLong((long)geteuid()); |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1772 } |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1773 #endif |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1774 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1775 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1776 #ifdef HAVE_GETGID |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1777 static char posix_getgid__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1778 "getgid() -> gid\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1779 Return the current process's group id."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1780 |
| 4672 | 1781 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1782 posix_getgid(PyObject *self, PyObject *args) |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1783 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1784 if (!PyArg_ParseTuple(args, ":getgid")) |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1785 return NULL; |
| 4672 | 1786 return PyInt_FromLong((long)getgid()); |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1787 } |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1788 #endif |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1789 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1790 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1791 static char posix_getpid__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1792 "getpid() -> pid\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1793 Return the current process id"; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1794 |
| 4672 | 1795 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1796 posix_getpid(PyObject *self, PyObject *args) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1797 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1798 if (!PyArg_ParseTuple(args, ":getpid")) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1799 return NULL; |
| 4672 | 1800 return PyInt_FromLong((long)getpid()); |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1801 } |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1802 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1803 |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1804 #ifdef HAVE_GETGROUPS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1805 static char posix_getgroups__doc__[] = "\ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1806 getgroups() -> list of group IDs\n\ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1807 Return list of supplemental group IDs for the process."; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1808 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1809 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1810 posix_getgroups(PyObject *self, PyObject *args) |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1811 { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1812 PyObject *result = NULL; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1813 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1814 if (PyArg_ParseTuple(args, ":getgroups")) { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1815 #ifdef NGROUPS_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1816 #define MAX_GROUPS NGROUPS_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1817 #else |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1818 /* defined to be 16 on Solaris7, so this should be a small number */ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1819 #define MAX_GROUPS 64 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1820 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1821 gid_t grouplist[MAX_GROUPS]; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1822 int n; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1823 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1824 n = getgroups(MAX_GROUPS, grouplist); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1825 if (n < 0) |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1826 posix_error(); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1827 else { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1828 result = PyList_New(n); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1829 if (result != NULL) { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1830 PyObject *o; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1831 int i; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1832 for (i = 0; i < n; ++i) { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1833 o = PyInt_FromLong((long)grouplist[i]); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1834 if (o == NULL) { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1835 Py_DECREF(result); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1836 result = NULL; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1837 break; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1838 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1839 PyList_SET_ITEM(result, i, o); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1840 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1841 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1842 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1843 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1844 return result; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1845 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1846 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
1847 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1848 #ifdef HAVE_GETPGRP |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1849 static char posix_getpgrp__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1850 "getpgrp() -> pgrp\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1851 Return the current process group id."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1852 |
| 4672 | 1853 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1854 posix_getpgrp(PyObject *self, PyObject *args) |
|
273
af1c8f5d0b37
Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents:
264
diff
changeset
|
1855 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1856 if (!PyArg_ParseTuple(args, ":getpgrp")) |
|
273
af1c8f5d0b37
Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents:
264
diff
changeset
|
1857 return NULL; |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1858 #ifdef GETPGRP_HAVE_ARG |
| 4672 | 1859 return PyInt_FromLong((long)getpgrp(0)); |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1860 #else /* GETPGRP_HAVE_ARG */ |
| 4672 | 1861 return PyInt_FromLong((long)getpgrp()); |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1862 #endif /* GETPGRP_HAVE_ARG */ |
|
273
af1c8f5d0b37
Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents:
264
diff
changeset
|
1863 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1864 #endif /* HAVE_GETPGRP */ |
|
273
af1c8f5d0b37
Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents:
264
diff
changeset
|
1865 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1866 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1867 #ifdef HAVE_SETPGRP |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1868 static char posix_setpgrp__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1869 "setpgrp() -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1870 Make this process a session leader."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1871 |
| 4672 | 1872 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1873 posix_setpgrp(PyObject *self, PyObject *args) |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1874 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1875 if (!PyArg_ParseTuple(args, ":setpgrp")) |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1876 return NULL; |
|
1983
80bd7af73201
distinguish between getpgrp and setpgrp arg requirements
Guido van Rossum <guido@python.org>
parents:
1915
diff
changeset
|
1877 #ifdef SETPGRP_HAVE_ARG |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1878 if (setpgrp(0, 0) < 0) |
|
1983
80bd7af73201
distinguish between getpgrp and setpgrp arg requirements
Guido van Rossum <guido@python.org>
parents:
1915
diff
changeset
|
1879 #else /* SETPGRP_HAVE_ARG */ |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1880 if (setpgrp() < 0) |
|
1983
80bd7af73201
distinguish between getpgrp and setpgrp arg requirements
Guido van Rossum <guido@python.org>
parents:
1915
diff
changeset
|
1881 #endif /* SETPGRP_HAVE_ARG */ |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1882 return posix_error(); |
| 4672 | 1883 Py_INCREF(Py_None); |
| 1884 return Py_None; | |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1885 } |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1886 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1887 #endif /* HAVE_SETPGRP */ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1888 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1889 #ifdef HAVE_GETPPID |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1890 static char posix_getppid__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1891 "getppid() -> ppid\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1892 Return the parent's process id."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1893 |
| 4672 | 1894 static PyObject * |
|
13651
8a063423e0b7
Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents:
13642
diff
changeset
|
1895 posix_getppid(PyObject *self, PyObject *args) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1896 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1897 if (!PyArg_ParseTuple(args, ":getppid")) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1898 return NULL; |
| 4672 | 1899 return PyInt_FromLong((long)getppid()); |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1900 } |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1901 #endif |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1902 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1903 |
|
11570
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
1904 #ifdef HAVE_GETLOGIN |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
1905 static char posix_getlogin__doc__[] = "\ |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
1906 getlogin() -> string\n\ |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
1907 Return the actual login name."; |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
1908 |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
1909 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1910 posix_getlogin(PyObject *self, PyObject *args) |
|
11570
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
1911 { |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
1912 PyObject *result = NULL; |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
1913 |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
1914 if (PyArg_ParseTuple(args, ":getlogin")) { |
|
15485
1091ad9a0303
posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents:
15318
diff
changeset
|
1915 char *name; |
|
1091ad9a0303
posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents:
15318
diff
changeset
|
1916 int old_errno = errno; |
|
1091ad9a0303
posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents:
15318
diff
changeset
|
1917 |
|
1091ad9a0303
posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents:
15318
diff
changeset
|
1918 errno = 0; |
|
1091ad9a0303
posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents:
15318
diff
changeset
|
1919 name = getlogin(); |
|
1091ad9a0303
posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents:
15318
diff
changeset
|
1920 if (name == NULL) { |
|
1091ad9a0303
posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents:
15318
diff
changeset
|
1921 if (errno) |
|
1091ad9a0303
posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents:
15318
diff
changeset
|
1922 posix_error(); |
|
1091ad9a0303
posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents:
15318
diff
changeset
|
1923 else |
|
1091ad9a0303
posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents:
15318
diff
changeset
|
1924 PyErr_SetString(PyExc_OSError, |
|
15486
b3398c452d95
posix_getlogin(): Be more cautious about interpreting a NULL from
Fred Drake <fdrake@acm.org>
parents:
15485
diff
changeset
|
1925 "unable to determine login name"); |
|
15485
1091ad9a0303
posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents:
15318
diff
changeset
|
1926 } |
|
11570
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
1927 else |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
1928 result = PyString_FromString(name); |
|
15485
1091ad9a0303
posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents:
15318
diff
changeset
|
1929 errno = old_errno; |
|
11570
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
1930 } |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
1931 return result; |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
1932 } |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
1933 #endif |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
1934 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1935 #ifdef HAVE_GETUID |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1936 static char posix_getuid__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1937 "getuid() -> uid\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1938 Return the current process's user id."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1939 |
| 4672 | 1940 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1941 posix_getuid(PyObject *self, PyObject *args) |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1942 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1943 if (!PyArg_ParseTuple(args, ":getuid")) |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1944 return NULL; |
| 4672 | 1945 return PyInt_FromLong((long)getuid()); |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1946 } |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1947 #endif |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1948 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1949 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1950 #ifdef HAVE_KILL |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1951 static char posix_kill__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1952 "kill(pid, sig) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1953 Kill a process with a signal."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1954 |
| 4672 | 1955 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1956 posix_kill(PyObject *self, PyObject *args) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1957 { |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1958 int pid, sig; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1959 if (!PyArg_ParseTuple(args, "ii:kill", &pid, &sig)) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1960 return NULL; |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
1961 #if defined(PYOS_OS2) |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
1962 if (sig == XCPT_SIGNAL_INTR || sig == XCPT_SIGNAL_BREAK) { |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
1963 APIRET rc; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
1964 if ((rc = DosSendSignalException(pid, sig)) != NO_ERROR) |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
1965 return os2_error(rc); |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
1966 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
1967 } else if (sig == XCPT_SIGNAL_KILLPROC) { |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
1968 APIRET rc; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
1969 if ((rc = DosKillProcess(DKP_PROCESS, pid)) != NO_ERROR) |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
1970 return os2_error(rc); |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
1971 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
1972 } else |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
1973 return NULL; /* Unrecognized Signal Requested */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
1974 #else |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1975 if (kill(pid, sig) == -1) |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1976 return posix_error(); |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
1977 #endif |
| 4672 | 1978 Py_INCREF(Py_None); |
| 1979 return Py_None; | |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1980 } |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1981 #endif |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1982 |
|
3735
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1983 #ifdef HAVE_PLOCK |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1984 |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1985 #ifdef HAVE_SYS_LOCK_H |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1986 #include <sys/lock.h> |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1987 #endif |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1988 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1989 static char posix_plock__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1990 "plock(op) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1991 Lock program segments into memory."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
1992 |
| 4672 | 1993 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
1994 posix_plock(PyObject *self, PyObject *args) |
|
3735
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1995 { |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1996 int op; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
1997 if (!PyArg_ParseTuple(args, "i:plock", &op)) |
|
3735
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1998 return NULL; |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1999 if (plock(op) == -1) |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
2000 return posix_error(); |
| 4672 | 2001 Py_INCREF(Py_None); |
| 2002 return Py_None; | |
|
3735
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
2003 } |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
2004 #endif |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
2005 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
2006 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
2007 #ifdef HAVE_POPEN |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
2008 static char posix_popen__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
2009 "popen(command [, mode='r' [, bufsize]]) -> pipe\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
2010 Open a pipe to/from a command returning a file object."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
2011 |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2012 #if defined(PYOS_OS2) |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
2013 static int |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2014 async_system(const char *command) |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2015 { |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2016 char *p, errormsg[256], args[1024]; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2017 RESULTCODES rcodes; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2018 APIRET rc; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2019 char *shell = getenv("COMSPEC"); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2020 if (!shell) |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2021 shell = "cmd"; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2022 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2023 strcpy(args, shell); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2024 p = &args[ strlen(args)+1 ]; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2025 strcpy(p, "/c "); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2026 strcat(p, command); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2027 p += strlen(p) + 1; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2028 *p = '\0'; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2029 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2030 rc = DosExecPgm(errormsg, sizeof(errormsg), |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2031 EXEC_ASYNC, /* Execute Async w/o Wait for Results */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2032 args, |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2033 NULL, /* Inherit Parent's Environment */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2034 &rcodes, shell); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2035 return rc; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2036 } |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2037 |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
2038 static FILE * |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
2039 popen(const char *command, const char *mode, int pipesize, int *err) |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2040 { |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2041 HFILE rhan, whan; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2042 FILE *retfd = NULL; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2043 APIRET rc = DosCreatePipe(&rhan, &whan, pipesize); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2044 |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
2045 if (rc != NO_ERROR) { |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
2046 *err = rc; |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2047 return NULL; /* ERROR - Unable to Create Anon Pipe */ |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
2048 } |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2049 |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2050 if (strchr(mode, 'r') != NULL) { /* Treat Command as a Data Source */ |
|
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2051 int oldfd = dup(1); /* Save STDOUT Handle in Another Handle */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2052 |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2053 DosEnterCritSec(); /* Stop Other Threads While Changing Handles */ |
|
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2054 close(1); /* Make STDOUT Available for Reallocation */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2055 |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2056 if (dup2(whan, 1) == 0) { /* Connect STDOUT to Pipe Write Side */ |
|
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2057 DosClose(whan); /* Close Now-Unused Pipe Write Handle */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2058 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2059 if (async_system(command) == NO_ERROR) |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
2060 retfd = fdopen(rhan, mode); /* And Return Pipe Read Handle */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2061 } |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2062 |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2063 dup2(oldfd, 1); /* Reconnect STDOUT to Original Handle */ |
|
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2064 DosExitCritSec(); /* Now Allow Other Threads to Run */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2065 |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2066 close(oldfd); /* And Close Saved STDOUT Handle */ |
|
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2067 return retfd; /* Return fd of Pipe or NULL if Error */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2068 |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2069 } else if (strchr(mode, 'w')) { /* Treat Command as a Data Sink */ |
|
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2070 int oldfd = dup(0); /* Save STDIN Handle in Another Handle */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2071 |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2072 DosEnterCritSec(); /* Stop Other Threads While Changing Handles */ |
|
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2073 close(0); /* Make STDIN Available for Reallocation */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2074 |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2075 if (dup2(rhan, 0) == 0) { /* Connect STDIN to Pipe Read Side */ |
|
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2076 DosClose(rhan); /* Close Now-Unused Pipe Read Handle */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2077 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2078 if (async_system(command) == NO_ERROR) |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
2079 retfd = fdopen(whan, mode); /* And Return Pipe Write Handle */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2080 } |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2081 |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2082 dup2(oldfd, 0); /* Reconnect STDIN to Original Handle */ |
|
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2083 DosExitCritSec(); /* Now Allow Other Threads to Run */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2084 |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2085 close(oldfd); /* And Close Saved STDIN Handle */ |
|
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2086 return retfd; /* Return fd of Pipe or NULL if Error */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2087 |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
2088 } else { |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
2089 *err = ERROR_INVALID_ACCESS; |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
2090 return NULL; /* ERROR - Invalid Mode (Neither Read nor Write) */ |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
2091 } |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2092 } |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2093 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2094 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
2095 posix_popen(PyObject *self, PyObject *args) |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2096 { |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2097 char *name; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2098 char *mode = "r"; |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
2099 int err, bufsize = -1; |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2100 FILE *fp; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2101 PyObject *f; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
2102 if (!PyArg_ParseTuple(args, "s|si:popen", &name, &mode, &bufsize)) |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2103 return NULL; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2104 Py_BEGIN_ALLOW_THREADS |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
2105 fp = popen(name, mode, (bufsize > 0) ? bufsize : 4096, &err); |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2106 Py_END_ALLOW_THREADS |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2107 if (fp == NULL) |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
2108 return os2_error(err); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
2109 |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2110 f = PyFile_FromFile(fp, name, mode, fclose); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2111 if (f != NULL) |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2112 PyFile_SetBufSize(f, bufsize); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2113 return f; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2114 } |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2115 |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2116 #elif defined(MS_WIN32) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2117 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2118 /* |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2119 * Portable 'popen' replacement for Win32. |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2120 * |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2121 * Written by Bill Tutt <billtut@microsoft.com>. Minor tweaks |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2122 * and 2.0 integration by Fredrik Lundh <fredrik@pythonware.com> |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2123 * Return code handling by David Bolen <db3l@fitlinxx.com>. |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2124 */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2125 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2126 #include <malloc.h> |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2127 #include <io.h> |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2128 #include <fcntl.h> |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2129 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2130 /* These tell _PyPopen() wether to return 1, 2, or 3 file objects. */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2131 #define POPEN_1 1 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2132 #define POPEN_2 2 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2133 #define POPEN_3 3 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2134 #define POPEN_4 4 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2135 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2136 static PyObject *_PyPopen(char *, int, int); |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2137 static int _PyPclose(FILE *file); |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2138 |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2139 /* |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2140 * Internal dictionary mapping popen* file pointers to process handles, |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2141 * for use when retrieving the process exit code. See _PyPclose() below |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2142 * for more information on this dictionary's use. |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2143 */ |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2144 static PyObject *_PyPopenProcs = NULL; |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2145 |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2146 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2147 /* popen that works from a GUI. |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2148 * |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2149 * The result of this function is a pipe (file) connected to the |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2150 * processes stdin or stdout, depending on the requested mode. |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2151 */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2152 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2153 static PyObject * |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2154 posix_popen(PyObject *self, PyObject *args) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2155 { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2156 PyObject *f, *s; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2157 int tm = 0; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2158 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2159 char *cmdstring; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2160 char *mode = "r"; |
|
13479
93ae34aa20ab
- added popen.popen2/popen3/popen4 support for
Fredrik Lundh <fredrik@pythonware.com>
parents:
13478
diff
changeset
|
2161 int bufsize = -1; |
|
13478
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2162 if (!PyArg_ParseTuple(args, "s|si:popen", &cmdstring, &mode, &bufsize)) |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2163 return NULL; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2164 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2165 s = PyTuple_New(0); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2166 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2167 if (*mode == 'r') |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2168 tm = _O_RDONLY; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2169 else if (*mode != 'w') { |
| 15318 | 2170 PyErr_SetString(PyExc_ValueError, "popen() arg 2 must be 'r' or 'w'"); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2171 return NULL; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2172 } else |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2173 tm = _O_WRONLY; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2174 |
|
13478
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2175 if (bufsize != -1) { |
| 15318 | 2176 PyErr_SetString(PyExc_ValueError, "popen() arg 3 must be -1"); |
|
13478
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2177 return NULL; |
|
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2178 } |
|
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2179 |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2180 if (*(mode+1) == 't') |
|
13479
93ae34aa20ab
- added popen.popen2/popen3/popen4 support for
Fredrik Lundh <fredrik@pythonware.com>
parents:
13478
diff
changeset
|
2181 f = _PyPopen(cmdstring, tm | _O_TEXT, POPEN_1); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2182 else if (*(mode+1) == 'b') |
|
13479
93ae34aa20ab
- added popen.popen2/popen3/popen4 support for
Fredrik Lundh <fredrik@pythonware.com>
parents:
13478
diff
changeset
|
2183 f = _PyPopen(cmdstring, tm | _O_BINARY, POPEN_1); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2184 else |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2185 f = _PyPopen(cmdstring, tm | _O_TEXT, POPEN_1); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2186 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2187 return f; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2188 } |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2189 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2190 /* Variation on win32pipe.popen |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2191 * |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2192 * The result of this function is a pipe (file) connected to the |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2193 * process's stdin, and a pipe connected to the process's stdout. |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2194 */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2195 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2196 static PyObject * |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2197 win32_popen2(PyObject *self, PyObject *args) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2198 { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2199 PyObject *f; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2200 int tm=0; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2201 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2202 char *cmdstring; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2203 char *mode = "t"; |
|
13478
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2204 int bufsize = -1; |
|
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2205 if (!PyArg_ParseTuple(args, "s|si:popen2", &cmdstring, &mode, &bufsize)) |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2206 return NULL; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2207 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2208 if (*mode == 't') |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2209 tm = _O_TEXT; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2210 else if (*mode != 'b') { |
| 15318 | 2211 PyErr_SetString(PyExc_ValueError, "popen2() arg 2 must be 't' or 'b'"); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2212 return NULL; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2213 } else |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2214 tm = _O_BINARY; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2215 |
|
13478
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2216 if (bufsize != -1) { |
| 15318 | 2217 PyErr_SetString(PyExc_ValueError, "popen2() arg 3 must be -1"); |
|
13478
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2218 return NULL; |
|
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2219 } |
|
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2220 |
|
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2221 f = _PyPopen(cmdstring, tm, POPEN_2); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2222 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2223 return f; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2224 } |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2225 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2226 /* |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2227 * Variation on <om win32pipe.popen> |
|
13479
93ae34aa20ab
- added popen.popen2/popen3/popen4 support for
Fredrik Lundh <fredrik@pythonware.com>
parents:
13478
diff
changeset
|
2228 * |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2229 * The result of this function is 3 pipes - the process's stdin, |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2230 * stdout and stderr |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2231 */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2232 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2233 static PyObject * |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2234 win32_popen3(PyObject *self, PyObject *args) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2235 { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2236 PyObject *f; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2237 int tm = 0; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2238 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2239 char *cmdstring; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2240 char *mode = "t"; |
|
13478
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2241 int bufsize = -1; |
|
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2242 if (!PyArg_ParseTuple(args, "s|si:popen3", &cmdstring, &mode, &bufsize)) |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2243 return NULL; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2244 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2245 if (*mode == 't') |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2246 tm = _O_TEXT; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2247 else if (*mode != 'b') { |
| 15318 | 2248 PyErr_SetString(PyExc_ValueError, "popen3() arg 2 must be 't' or 'b'"); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2249 return NULL; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2250 } else |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2251 tm = _O_BINARY; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2252 |
|
13478
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2253 if (bufsize != -1) { |
| 15318 | 2254 PyErr_SetString(PyExc_ValueError, "popen3() arg 3 must be -1"); |
|
13478
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2255 return NULL; |
|
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2256 } |
|
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2257 |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2258 f = _PyPopen(cmdstring, tm, POPEN_3); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2259 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2260 return f; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2261 } |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2262 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2263 /* |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2264 * Variation on win32pipe.popen |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2265 * |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2266 * The result of this function is 2 pipes - the processes stdin, |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2267 * and stdout+stderr combined as a single pipe. |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2268 */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2269 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2270 static PyObject * |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2271 win32_popen4(PyObject *self, PyObject *args) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2272 { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2273 PyObject *f; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2274 int tm = 0; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2275 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2276 char *cmdstring; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2277 char *mode = "t"; |
|
13478
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2278 int bufsize = -1; |
|
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2279 if (!PyArg_ParseTuple(args, "s|si:popen4", &cmdstring, &mode, &bufsize)) |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2280 return NULL; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2281 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2282 if (*mode == 't') |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2283 tm = _O_TEXT; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2284 else if (*mode != 'b') { |
| 15318 | 2285 PyErr_SetString(PyExc_ValueError, "popen4() arg 2 must be 't' or 'b'"); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2286 return NULL; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2287 } else |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2288 tm = _O_BINARY; |
|
13478
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2289 |
|
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2290 if (bufsize != -1) { |
| 15318 | 2291 PyErr_SetString(PyExc_ValueError, "popen4() arg 3 must be -1"); |
|
13478
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2292 return NULL; |
|
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2293 } |
|
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2294 |
|
13479
93ae34aa20ab
- added popen.popen2/popen3/popen4 support for
Fredrik Lundh <fredrik@pythonware.com>
parents:
13478
diff
changeset
|
2295 f = _PyPopen(cmdstring, tm, POPEN_4); |
|
13478
70d351fcb8d5
- added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents:
13468
diff
changeset
|
2296 |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2297 return f; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2298 } |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2299 |
|
16367
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2300 static BOOL |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2301 _PyPopenCreateProcess(char *cmdstring, |
|
13486
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2302 HANDLE hStdin, |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2303 HANDLE hStdout, |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2304 HANDLE hStderr, |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2305 HANDLE *hProcess) |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2306 { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2307 PROCESS_INFORMATION piProcInfo; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2308 STARTUPINFO siStartInfo; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2309 char *s1,*s2, *s3 = " /c "; |
|
16367
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2310 const char *szConsoleSpawn = "w9xpopen.exe"; |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2311 int i; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2312 int x; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2313 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2314 if (i = GetEnvironmentVariable("COMSPEC",NULL,0)) { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2315 s1 = (char *)_alloca(i); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2316 if (!(x = GetEnvironmentVariable("COMSPEC", s1, i))) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2317 return x; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2318 if (GetVersion() < 0x80000000) { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2319 /* |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2320 * NT/2000 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2321 */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2322 x = i + strlen(s3) + strlen(cmdstring) + 1; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2323 s2 = (char *)_alloca(x); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2324 ZeroMemory(s2, x); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2325 sprintf(s2, "%s%s%s", s1, s3, cmdstring); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2326 } |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2327 else { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2328 /* |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2329 * Oh gag, we're on Win9x. Use the workaround listed in |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2330 * KB: Q150956 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2331 */ |
|
16367
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2332 char modulepath[_MAX_PATH]; |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2333 struct stat statinfo; |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2334 GetModuleFileName(NULL, modulepath, sizeof(modulepath)); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2335 for (i = x = 0; modulepath[i]; i++) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2336 if (modulepath[i] == '\\') |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2337 x = i+1; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2338 modulepath[x] = '\0'; |
|
16367
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2339 /* Create the full-name to w9xpopen, so we can test it exists */ |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2340 strncat(modulepath, |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2341 szConsoleSpawn, |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2342 (sizeof(modulepath)/sizeof(modulepath[0])) |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2343 -strlen(modulepath)); |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2344 if (stat(modulepath, &statinfo) != 0) { |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2345 /* Eeek - file-not-found - possibly an embedding |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2346 situation - see if we can locate it in sys.prefix |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2347 */ |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2348 strncpy(modulepath, |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2349 Py_GetExecPrefix(), |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2350 sizeof(modulepath)/sizeof(modulepath[0])); |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2351 if (modulepath[strlen(modulepath)-1] != '\\') |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2352 strcat(modulepath, "\\"); |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2353 strncat(modulepath, |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2354 szConsoleSpawn, |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2355 (sizeof(modulepath)/sizeof(modulepath[0])) |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2356 -strlen(modulepath)); |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2357 /* No where else to look - raise an easily identifiable |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2358 error, rather than leaving Windows to report |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2359 "file not found" - as the user is probably blissfully |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2360 unaware this shim EXE is used, and it will confuse them. |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2361 (well, it confused me for a while ;-) |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2362 */ |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2363 if (stat(modulepath, &statinfo) != 0) { |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2364 PyErr_Format(PyExc_RuntimeError, |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2365 "Can not locate '%s' which is needed " |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2366 "for popen to work on this platform.", |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2367 szConsoleSpawn); |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2368 return FALSE; |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2369 } |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2370 } |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2371 x = i + strlen(s3) + strlen(cmdstring) + 1 + |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2372 strlen(modulepath) + |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2373 strlen(szConsoleSpawn) + 1; |
|
16367
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2374 |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2375 s2 = (char *)_alloca(x); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2376 ZeroMemory(s2, x); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2377 sprintf( |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2378 s2, |
|
16367
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2379 "%s \"%s%s%s\"", |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2380 modulepath, |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2381 s1, |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2382 s3, |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2383 cmdstring); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2384 } |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2385 } |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2386 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2387 /* Could be an else here to try cmd.exe / command.com in the path |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2388 Now we'll just error out.. */ |
|
16367
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2389 else { |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2390 PyErr_SetString(PyExc_RuntimeError, "Can not locate a COMSPEC environment variable to use as the shell"); |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2391 return FALSE; |
|
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2392 } |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2393 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2394 ZeroMemory(&siStartInfo, sizeof(STARTUPINFO)); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2395 siStartInfo.cb = sizeof(STARTUPINFO); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2396 siStartInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2397 siStartInfo.hStdInput = hStdin; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2398 siStartInfo.hStdOutput = hStdout; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2399 siStartInfo.hStdError = hStderr; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2400 siStartInfo.wShowWindow = SW_HIDE; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2401 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2402 if (CreateProcess(NULL, |
|
13486
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2403 s2, |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2404 NULL, |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2405 NULL, |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2406 TRUE, |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2407 CREATE_NEW_CONSOLE, |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2408 NULL, |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2409 NULL, |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2410 &siStartInfo, |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2411 &piProcInfo) ) { |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2412 /* Close the handles now so anyone waiting is woken. */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2413 CloseHandle(piProcInfo.hThread); |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2414 |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2415 /* Return process handle */ |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2416 *hProcess = piProcInfo.hProcess; |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2417 return TRUE; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2418 } |
|
16367
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2419 win32_error("CreateProcess", NULL); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2420 return FALSE; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2421 } |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2422 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2423 /* The following code is based off of KB: Q190351 */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2424 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2425 static PyObject * |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2426 _PyPopen(char *cmdstring, int mode, int n) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2427 { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2428 HANDLE hChildStdinRd, hChildStdinWr, hChildStdoutRd, hChildStdoutWr, |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2429 hChildStderrRd, hChildStderrWr, hChildStdinWrDup, hChildStdoutRdDup, |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2430 hChildStderrRdDup, hProcess; /* hChildStdoutWrDup; */ |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2431 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2432 SECURITY_ATTRIBUTES saAttr; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2433 BOOL fSuccess; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2434 int fd1, fd2, fd3; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2435 FILE *f1, *f2, *f3; |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2436 long file_count; |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2437 PyObject *f; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2438 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2439 saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2440 saAttr.bInheritHandle = TRUE; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2441 saAttr.lpSecurityDescriptor = NULL; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2442 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2443 if (!CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0)) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2444 return win32_error("CreatePipe", NULL); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2445 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2446 /* Create new output read handle and the input write handle. Set |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2447 * the inheritance properties to FALSE. Otherwise, the child inherits |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2448 * the these handles; resulting in non-closeable handles to the pipes |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2449 * being created. */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2450 fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdinWr, |
|
13486
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2451 GetCurrentProcess(), &hChildStdinWrDup, 0, |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2452 FALSE, |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2453 DUPLICATE_SAME_ACCESS); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2454 if (!fSuccess) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2455 return win32_error("DuplicateHandle", NULL); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2456 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2457 /* Close the inheritable version of ChildStdin |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2458 that we're using. */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2459 CloseHandle(hChildStdinWr); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2460 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2461 if (!CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0)) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2462 return win32_error("CreatePipe", NULL); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2463 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2464 fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdoutRd, |
|
13486
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2465 GetCurrentProcess(), &hChildStdoutRdDup, 0, |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2466 FALSE, DUPLICATE_SAME_ACCESS); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2467 if (!fSuccess) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2468 return win32_error("DuplicateHandle", NULL); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2469 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2470 /* Close the inheritable version of ChildStdout |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2471 that we're using. */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2472 CloseHandle(hChildStdoutRd); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2473 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2474 if (n != POPEN_4) { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2475 if (!CreatePipe(&hChildStderrRd, &hChildStderrWr, &saAttr, 0)) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2476 return win32_error("CreatePipe", NULL); |
|
13486
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2477 fSuccess = DuplicateHandle(GetCurrentProcess(), |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2478 hChildStderrRd, |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2479 GetCurrentProcess(), |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2480 &hChildStderrRdDup, 0, |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2481 FALSE, DUPLICATE_SAME_ACCESS); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2482 if (!fSuccess) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2483 return win32_error("DuplicateHandle", NULL); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2484 /* Close the inheritable version of ChildStdErr that we're using. */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2485 CloseHandle(hChildStderrRd); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2486 } |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2487 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2488 switch (n) { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2489 case POPEN_1: |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2490 switch (mode & (_O_RDONLY | _O_TEXT | _O_BINARY | _O_WRONLY)) { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2491 case _O_WRONLY | _O_TEXT: |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2492 /* Case for writing to child Stdin in text mode. */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2493 fd1 = _open_osfhandle((long)hChildStdinWrDup, mode); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2494 f1 = _fdopen(fd1, "w"); |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2495 f = PyFile_FromFile(f1, cmdstring, "w", _PyPclose); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2496 PyFile_SetBufSize(f, 0); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2497 /* We don't care about these pipes anymore, so close them. */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2498 CloseHandle(hChildStdoutRdDup); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2499 CloseHandle(hChildStderrRdDup); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2500 break; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2501 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2502 case _O_RDONLY | _O_TEXT: |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2503 /* Case for reading from child Stdout in text mode. */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2504 fd1 = _open_osfhandle((long)hChildStdoutRdDup, mode); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2505 f1 = _fdopen(fd1, "r"); |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2506 f = PyFile_FromFile(f1, cmdstring, "r", _PyPclose); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2507 PyFile_SetBufSize(f, 0); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2508 /* We don't care about these pipes anymore, so close them. */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2509 CloseHandle(hChildStdinWrDup); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2510 CloseHandle(hChildStderrRdDup); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2511 break; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2512 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2513 case _O_RDONLY | _O_BINARY: |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2514 /* Case for readinig from child Stdout in binary mode. */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2515 fd1 = _open_osfhandle((long)hChildStdoutRdDup, mode); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2516 f1 = _fdopen(fd1, "rb"); |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2517 f = PyFile_FromFile(f1, cmdstring, "rb", _PyPclose); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2518 PyFile_SetBufSize(f, 0); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2519 /* We don't care about these pipes anymore, so close them. */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2520 CloseHandle(hChildStdinWrDup); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2521 CloseHandle(hChildStderrRdDup); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2522 break; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2523 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2524 case _O_WRONLY | _O_BINARY: |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2525 /* Case for writing to child Stdin in binary mode. */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2526 fd1 = _open_osfhandle((long)hChildStdinWrDup, mode); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2527 f1 = _fdopen(fd1, "wb"); |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2528 f = PyFile_FromFile(f1, cmdstring, "wb", _PyPclose); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2529 PyFile_SetBufSize(f, 0); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2530 /* We don't care about these pipes anymore, so close them. */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2531 CloseHandle(hChildStdoutRdDup); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2532 CloseHandle(hChildStderrRdDup); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2533 break; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2534 } |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2535 file_count = 1; |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2536 break; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2537 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2538 case POPEN_2: |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2539 case POPEN_4: |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2540 { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2541 char *m1, *m2; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2542 PyObject *p1, *p2; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2543 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2544 if (mode && _O_TEXT) { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2545 m1 = "r"; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2546 m2 = "w"; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2547 } else { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2548 m1 = "rb"; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2549 m2 = "wb"; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2550 } |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2551 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2552 fd1 = _open_osfhandle((long)hChildStdinWrDup, mode); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2553 f1 = _fdopen(fd1, m2); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2554 fd2 = _open_osfhandle((long)hChildStdoutRdDup, mode); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2555 f2 = _fdopen(fd2, m1); |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2556 p1 = PyFile_FromFile(f1, cmdstring, m2, _PyPclose); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2557 PyFile_SetBufSize(p1, 0); |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2558 p2 = PyFile_FromFile(f2, cmdstring, m1, _PyPclose); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2559 PyFile_SetBufSize(p2, 0); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2560 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2561 if (n != 4) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2562 CloseHandle(hChildStderrRdDup); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2563 |
|
13486
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2564 f = Py_BuildValue("OO",p1,p2); |
|
16366
38ca9cc9fc48
Fix Bug #125891 - os.popen2,3 and 4 leaked file objects on Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
15904
diff
changeset
|
2565 Py_XDECREF(p1); |
|
38ca9cc9fc48
Fix Bug #125891 - os.popen2,3 and 4 leaked file objects on Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
15904
diff
changeset
|
2566 Py_XDECREF(p2); |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2567 file_count = 2; |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2568 break; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2569 } |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2570 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2571 case POPEN_3: |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2572 { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2573 char *m1, *m2; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2574 PyObject *p1, *p2, *p3; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2575 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2576 if (mode && _O_TEXT) { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2577 m1 = "r"; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2578 m2 = "w"; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2579 } else { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2580 m1 = "rb"; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2581 m2 = "wb"; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2582 } |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2583 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2584 fd1 = _open_osfhandle((long)hChildStdinWrDup, mode); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2585 f1 = _fdopen(fd1, m2); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2586 fd2 = _open_osfhandle((long)hChildStdoutRdDup, mode); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2587 f2 = _fdopen(fd2, m1); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2588 fd3 = _open_osfhandle((long)hChildStderrRdDup, mode); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2589 f3 = _fdopen(fd3, m1); |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2590 p1 = PyFile_FromFile(f1, cmdstring, m2, _PyPclose); |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2591 p2 = PyFile_FromFile(f2, cmdstring, m1, _PyPclose); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2592 p3 = PyFile_FromFile(f3, cmdstring, m1, _PyPclose); |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2593 PyFile_SetBufSize(p1, 0); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2594 PyFile_SetBufSize(p2, 0); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2595 PyFile_SetBufSize(p3, 0); |
|
13486
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2596 f = Py_BuildValue("OOO",p1,p2,p3); |
|
16366
38ca9cc9fc48
Fix Bug #125891 - os.popen2,3 and 4 leaked file objects on Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
15904
diff
changeset
|
2597 Py_XDECREF(p1); |
|
38ca9cc9fc48
Fix Bug #125891 - os.popen2,3 and 4 leaked file objects on Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
15904
diff
changeset
|
2598 Py_XDECREF(p2); |
|
38ca9cc9fc48
Fix Bug #125891 - os.popen2,3 and 4 leaked file objects on Windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
15904
diff
changeset
|
2599 Py_XDECREF(p3); |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2600 file_count = 3; |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2601 break; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2602 } |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2603 } |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2604 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2605 if (n == POPEN_4) { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2606 if (!_PyPopenCreateProcess(cmdstring, |
|
13486
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2607 hChildStdinRd, |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2608 hChildStdoutWr, |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2609 hChildStdoutWr, |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2610 &hProcess)) |
|
16367
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2611 return NULL; |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2612 } |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2613 else { |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2614 if (!_PyPopenCreateProcess(cmdstring, |
|
13486
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2615 hChildStdinRd, |
|
32b686da3e51
- changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents:
13479
diff
changeset
|
2616 hChildStdoutWr, |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2617 hChildStderrWr, |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2618 &hProcess)) |
|
16367
3c1b426b3ff4
Partial fix to [ Bug #128685 ] popen on Win9x isnt smart enough about finding w9xpopen.exe.
Mark Hammond <mhammond@skippinet.com.au>
parents:
16366
diff
changeset
|
2619 return NULL; |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2620 } |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2621 |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2622 /* |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2623 * Insert the files we've created into the process dictionary |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2624 * all referencing the list with the process handle and the |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2625 * initial number of files (see description below in _PyPclose). |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2626 * Since if _PyPclose later tried to wait on a process when all |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2627 * handles weren't closed, it could create a deadlock with the |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2628 * child, we spend some energy here to try to ensure that we |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2629 * either insert all file handles into the dictionary or none |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2630 * at all. It's a little clumsy with the various popen modes |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2631 * and variable number of files involved. |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2632 */ |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2633 if (!_PyPopenProcs) { |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2634 _PyPopenProcs = PyDict_New(); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2635 } |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2636 |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2637 if (_PyPopenProcs) { |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2638 PyObject *procObj, *hProcessObj, *intObj, *fileObj[3]; |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2639 int ins_rc[3]; |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2640 |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2641 fileObj[0] = fileObj[1] = fileObj[2] = NULL; |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2642 ins_rc[0] = ins_rc[1] = ins_rc[2] = 0; |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2643 |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2644 procObj = PyList_New(2); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2645 hProcessObj = PyLong_FromVoidPtr(hProcess); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2646 intObj = PyInt_FromLong(file_count); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2647 |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2648 if (procObj && hProcessObj && intObj) { |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2649 PyList_SetItem(procObj,0,hProcessObj); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2650 PyList_SetItem(procObj,1,intObj); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2651 |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2652 fileObj[0] = PyLong_FromVoidPtr(f1); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2653 if (fileObj[0]) { |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2654 ins_rc[0] = PyDict_SetItem(_PyPopenProcs, |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2655 fileObj[0], |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2656 procObj); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2657 } |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2658 if (file_count >= 2) { |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2659 fileObj[1] = PyLong_FromVoidPtr(f2); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2660 if (fileObj[1]) { |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2661 ins_rc[1] = PyDict_SetItem(_PyPopenProcs, |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2662 fileObj[1], |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2663 procObj); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2664 } |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2665 } |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2666 if (file_count >= 3) { |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2667 fileObj[2] = PyLong_FromVoidPtr(f3); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2668 if (fileObj[2]) { |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2669 ins_rc[2] = PyDict_SetItem(_PyPopenProcs, |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2670 fileObj[2], |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2671 procObj); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2672 } |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2673 } |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2674 |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2675 if (ins_rc[0] < 0 || !fileObj[0] || |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2676 ins_rc[1] < 0 || (file_count > 1 && !fileObj[1]) || |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2677 ins_rc[2] < 0 || (file_count > 2 && !fileObj[2])) { |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2678 /* Something failed - remove any dictionary |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2679 * entries that did make it. |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2680 */ |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2681 if (!ins_rc[0] && fileObj[0]) { |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2682 PyDict_DelItem(_PyPopenProcs, |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2683 fileObj[0]); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2684 } |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2685 if (!ins_rc[1] && fileObj[1]) { |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2686 PyDict_DelItem(_PyPopenProcs, |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2687 fileObj[1]); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2688 } |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2689 if (!ins_rc[2] && fileObj[2]) { |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2690 PyDict_DelItem(_PyPopenProcs, |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2691 fileObj[2]); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2692 } |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2693 } |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2694 } |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2695 |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2696 /* |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2697 * Clean up our localized references for the dictionary keys |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2698 * and value since PyDict_SetItem will Py_INCREF any copies |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2699 * that got placed in the dictionary. |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2700 */ |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2701 Py_XDECREF(procObj); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2702 Py_XDECREF(fileObj[0]); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2703 Py_XDECREF(fileObj[1]); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2704 Py_XDECREF(fileObj[2]); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2705 } |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2706 |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2707 /* Child is launched. Close the parents copy of those pipe |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2708 * handles that only the child should have open. You need to |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2709 * make sure that no handles to the write end of the output pipe |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2710 * are maintained in this process or else the pipe will not close |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2711 * when the child process exits and the ReadFile will hang. */ |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2712 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2713 if (!CloseHandle(hChildStdinRd)) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2714 return win32_error("CloseHandle", NULL); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2715 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2716 if (!CloseHandle(hChildStdoutWr)) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2717 return win32_error("CloseHandle", NULL); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2718 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2719 if ((n != 4) && (!CloseHandle(hChildStderrWr))) |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2720 return win32_error("CloseHandle", NULL); |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2721 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2722 return f; |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
2723 } |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2724 |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2725 /* |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2726 * Wrapper for fclose() to use for popen* files, so we can retrieve the |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2727 * exit code for the child process and return as a result of the close. |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2728 * |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2729 * This function uses the _PyPopenProcs dictionary in order to map the |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2730 * input file pointer to information about the process that was |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2731 * originally created by the popen* call that created the file pointer. |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2732 * The dictionary uses the file pointer as a key (with one entry |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2733 * inserted for each file returned by the original popen* call) and a |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2734 * single list object as the value for all files from a single call. |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2735 * The list object contains the Win32 process handle at [0], and a file |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2736 * count at [1], which is initialized to the total number of file |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2737 * handles using that list. |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2738 * |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2739 * This function closes whichever handle it is passed, and decrements |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2740 * the file count in the dictionary for the process handle pointed to |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2741 * by this file. On the last close (when the file count reaches zero), |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2742 * this function will wait for the child process and then return its |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2743 * exit code as the result of the close() operation. This permits the |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2744 * files to be closed in any order - it is always the close() of the |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2745 * final handle that will return the exit code. |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2746 */ |
|
14341
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2747 |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2748 /* RED_FLAG 31-Aug-2000 Tim |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2749 * This is always called (today!) between a pair of |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2750 * Py_BEGIN_ALLOW_THREADS/ Py_END_ALLOW_THREADS |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2751 * macros. So the thread running this has no valid thread state, as |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2752 * far as Python is concerned. However, this calls some Python API |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2753 * functions that cannot be called safely without a valid thread |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2754 * state, in particular PyDict_GetItem. |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2755 * As a temporary hack (although it may last for years ...), we |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2756 * *rely* on not having a valid thread state in this function, in |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2757 * order to create our own "from scratch". |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2758 * This will deadlock if _PyPclose is ever called by a thread |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2759 * holding the global lock. |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2760 */ |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2761 |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2762 static int _PyPclose(FILE *file) |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2763 { |
|
13720
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2764 int result; |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2765 DWORD exit_code; |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2766 HANDLE hProcess; |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2767 PyObject *procObj, *hProcessObj, *intObj, *fileObj; |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2768 long file_count; |
|
14341
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2769 #ifdef WITH_THREAD |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2770 PyInterpreterState* pInterpreterState; |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2771 PyThreadState* pThreadState; |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2772 #endif |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2773 |
|
13720
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2774 /* Close the file handle first, to ensure it can't block the |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2775 * child from exiting if it's the last handle. |
|
13720
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2776 */ |
|
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2777 result = fclose(file); |
|
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2778 |
|
14341
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2779 #ifdef WITH_THREAD |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2780 /* Bootstrap a valid thread state into existence. */ |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2781 pInterpreterState = PyInterpreterState_New(); |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2782 if (!pInterpreterState) { |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2783 /* Well, we're hosed now! We don't have a thread |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2784 * state, so can't call a nice error routine, or raise |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2785 * an exception. Just die. |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2786 */ |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2787 Py_FatalError("unable to allocate interpreter state " |
| 15318 | 2788 "when closing popen object"); |
|
14341
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2789 return -1; /* unreachable */ |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2790 } |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2791 pThreadState = PyThreadState_New(pInterpreterState); |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2792 if (!pThreadState) { |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2793 Py_FatalError("unable to allocate thread state " |
| 15318 | 2794 "when closing popen object"); |
|
14341
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2795 return -1; /* unreachable */ |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2796 } |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2797 /* Grab the global lock. Note that this will deadlock if the |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2798 * current thread already has the lock! (see RED_FLAG comments |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2799 * before this function) |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2800 */ |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2801 PyEval_RestoreThread(pThreadState); |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2802 #endif |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2803 |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2804 if (_PyPopenProcs) { |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2805 if ((fileObj = PyLong_FromVoidPtr(file)) != NULL && |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2806 (procObj = PyDict_GetItem(_PyPopenProcs, |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2807 fileObj)) != NULL && |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2808 (hProcessObj = PyList_GetItem(procObj,0)) != NULL && |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2809 (intObj = PyList_GetItem(procObj,1)) != NULL) { |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2810 |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2811 hProcess = PyLong_AsVoidPtr(hProcessObj); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2812 file_count = PyInt_AsLong(intObj); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2813 |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2814 if (file_count > 1) { |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2815 /* Still other files referencing process */ |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2816 file_count--; |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2817 PyList_SetItem(procObj,1, |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2818 PyInt_FromLong(file_count)); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2819 } else { |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2820 /* Last file for this process */ |
|
13720
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2821 if (result != EOF && |
|
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2822 WaitForSingleObject(hProcess, INFINITE) != WAIT_FAILED && |
|
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2823 GetExitCodeProcess(hProcess, &exit_code)) { |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2824 /* Possible truncation here in 16-bit environments, but |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2825 * real exit codes are just the lower byte in any event. |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2826 */ |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2827 result = exit_code; |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2828 } else { |
|
13720
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2829 /* Indicate failure - this will cause the file object |
|
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2830 * to raise an I/O error and translate the last Win32 |
|
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2831 * error code from errno. We do have a problem with |
|
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2832 * last errors that overlap the normal errno table, |
|
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2833 * but that's a consistent problem with the file object. |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2834 */ |
|
13720
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2835 if (result != EOF) { |
|
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2836 /* If the error wasn't from the fclose(), then |
|
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2837 * set errno for the file object error handling. |
|
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2838 */ |
|
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2839 errno = GetLastError(); |
|
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2840 } |
|
d3f694023642
- changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents:
13694
diff
changeset
|
2841 result = -1; |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2842 } |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2843 |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2844 /* Free up the native handle at this point */ |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2845 CloseHandle(hProcess); |
|
13960
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2846 } |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2847 |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2848 /* Remove this file pointer from dictionary */ |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2849 PyDict_DelItem(_PyPopenProcs, fileObj); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2850 |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2851 if (PyDict_Size(_PyPopenProcs) == 0) { |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2852 Py_DECREF(_PyPopenProcs); |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2853 _PyPopenProcs = NULL; |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2854 } |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2855 |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2856 } /* if object retrieval ok */ |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2857 |
|
7dde74c1ebbe
Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents:
13761
diff
changeset
|
2858 Py_XDECREF(fileObj); |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2859 } /* if _PyPopenProcs */ |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2860 |
|
14341
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2861 #ifdef WITH_THREAD |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2862 /* Tear down the thread & interpreter states. |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2863 * Note that interpreter state clear & delete functions automatically |
|
14354
0f6809eba50a
Repaired damaged comments, and extra spaces in fatal error msgs we'd better
Tim Peters <tim.peters@gmail.com>
parents:
14341
diff
changeset
|
2864 * call the thread clear & delete functions, and indeed insist on |
|
0f6809eba50a
Repaired damaged comments, and extra spaces in fatal error msgs we'd better
Tim Peters <tim.peters@gmail.com>
parents:
14341
diff
changeset
|
2865 * doing that themselves. The lock must be held during the clear, but |
|
0f6809eba50a
Repaired damaged comments, and extra spaces in fatal error msgs we'd better
Tim Peters <tim.peters@gmail.com>
parents:
14341
diff
changeset
|
2866 * need not be held during the delete. |
|
14341
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2867 */ |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2868 PyInterpreterState_Clear(pInterpreterState); |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2869 PyEval_ReleaseThread(pThreadState); |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2870 PyInterpreterState_Delete(pInterpreterState); |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2871 #endif |
|
ab61c335a04d
Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents:
14001
diff
changeset
|
2872 |
|
13675
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2873 return result; |
|
b1959f006566
-- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents:
13667
diff
changeset
|
2874 } |
|
14354
0f6809eba50a
Repaired damaged comments, and extra spaces in fatal error msgs we'd better
Tim Peters <tim.peters@gmail.com>
parents:
14341
diff
changeset
|
2875 |
|
0f6809eba50a
Repaired damaged comments, and extra spaces in fatal error msgs we'd better
Tim Peters <tim.peters@gmail.com>
parents:
14341
diff
changeset
|
2876 #else /* which OS? */ |
| 4672 | 2877 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
2878 posix_popen(PyObject *self, PyObject *args) |
| 264 | 2879 { |
|
2114
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
2880 char *name; |
|
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
2881 char *mode = "r"; |
|
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
2882 int bufsize = -1; |
| 264 | 2883 FILE *fp; |
| 4672 | 2884 PyObject *f; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
2885 if (!PyArg_ParseTuple(args, "s|si:popen", &name, &mode, &bufsize)) |
| 264 | 2886 return NULL; |
| 4672 | 2887 Py_BEGIN_ALLOW_THREADS |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
2888 fp = popen(name, mode); |
| 4672 | 2889 Py_END_ALLOW_THREADS |
| 264 | 2890 if (fp == NULL) |
| 2891 return posix_error(); | |
| 4672 | 2892 f = PyFile_FromFile(fp, name, mode, pclose); |
|
2114
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
2893 if (f != NULL) |
| 4672 | 2894 PyFile_SetBufSize(f, bufsize); |
|
2114
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
2895 return f; |
| 264 | 2896 } |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2897 #endif |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
2898 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
2899 #endif /* HAVE_POPEN */ |
| 264 | 2900 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
2901 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
2902 #ifdef HAVE_SETUID |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
2903 static char posix_setuid__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
2904 "setuid(uid) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
2905 Set the current process's user id."; |
| 4672 | 2906 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
2907 posix_setuid(PyObject *self, PyObject *args) |
|
1405
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
2908 { |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
2909 int uid; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
2910 if (!PyArg_ParseTuple(args, "i:setuid", &uid)) |
|
1405
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
2911 return NULL; |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
2912 if (setuid(uid) < 0) |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
2913 return posix_error(); |
| 4672 | 2914 Py_INCREF(Py_None); |
| 2915 return Py_None; | |
|
1405
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
2916 } |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
2917 #endif /* HAVE_SETUID */ |
|
1405
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
2918 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
2919 |
|
13582
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2920 #ifdef HAVE_SETEUID |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2921 static char posix_seteuid__doc__[] = |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2922 "seteuid(uid) -> None\n\ |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2923 Set the current process's effective user id."; |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2924 static PyObject * |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2925 posix_seteuid (PyObject *self, PyObject *args) |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2926 { |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2927 int euid; |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2928 if (!PyArg_ParseTuple(args, "i", &euid)) { |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2929 return NULL; |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2930 } else if (seteuid(euid) < 0) { |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2931 return posix_error(); |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2932 } else { |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2933 Py_INCREF(Py_None); |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2934 return Py_None; |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2935 } |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2936 } |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2937 #endif /* HAVE_SETEUID */ |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2938 |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2939 #ifdef HAVE_SETEGID |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2940 static char posix_setegid__doc__[] = |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2941 "setegid(gid) -> None\n\ |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2942 Set the current process's effective group id."; |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2943 static PyObject * |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2944 posix_setegid (PyObject *self, PyObject *args) |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2945 { |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2946 int egid; |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2947 if (!PyArg_ParseTuple(args, "i", &egid)) { |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2948 return NULL; |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2949 } else if (setegid(egid) < 0) { |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2950 return posix_error(); |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2951 } else { |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2952 Py_INCREF(Py_None); |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2953 return Py_None; |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2954 } |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2955 } |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2956 #endif /* HAVE_SETEGID */ |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2957 |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2958 #ifdef HAVE_SETREUID |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2959 static char posix_setreuid__doc__[] = |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2960 "seteuid(ruid, euid) -> None\n\ |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2961 Set the current process's real and effective user ids."; |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2962 static PyObject * |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2963 posix_setreuid (PyObject *self, PyObject *args) |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2964 { |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2965 int ruid, euid; |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2966 if (!PyArg_ParseTuple(args, "ii", &ruid, &euid)) { |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2967 return NULL; |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2968 } else if (setreuid(ruid, euid) < 0) { |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2969 return posix_error(); |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2970 } else { |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2971 Py_INCREF(Py_None); |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2972 return Py_None; |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2973 } |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2974 } |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2975 #endif /* HAVE_SETREUID */ |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2976 |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2977 #ifdef HAVE_SETREGID |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2978 static char posix_setregid__doc__[] = |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2979 "setegid(rgid, egid) -> None\n\ |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2980 Set the current process's real and effective group ids."; |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2981 static PyObject * |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2982 posix_setregid (PyObject *self, PyObject *args) |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2983 { |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2984 int rgid, egid; |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2985 if (!PyArg_ParseTuple(args, "ii", &rgid, &egid)) { |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2986 return NULL; |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2987 } else if (setregid(rgid, egid) < 0) { |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2988 return posix_error(); |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2989 } else { |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2990 Py_INCREF(Py_None); |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2991 return Py_None; |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2992 } |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2993 } |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2994 #endif /* HAVE_SETREGID */ |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
2995 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
2996 #ifdef HAVE_SETGID |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
2997 static char posix_setgid__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
2998 "setgid(gid) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
2999 Set the current process's group id."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3000 |
| 4672 | 3001 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3002 posix_setgid(PyObject *self, PyObject *args) |
|
1405
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
3003 { |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
3004 int gid; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3005 if (!PyArg_ParseTuple(args, "i:setgid", &gid)) |
|
1405
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
3006 return NULL; |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
3007 if (setgid(gid) < 0) |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
3008 return posix_error(); |
| 4672 | 3009 Py_INCREF(Py_None); |
| 3010 return Py_None; | |
|
1405
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
3011 } |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
3012 #endif /* HAVE_SETGID */ |
|
1405
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
3013 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3014 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3015 #ifdef HAVE_WAITPID |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3016 static char posix_waitpid__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3017 "waitpid(pid, options) -> (pid, status)\n\ |
|
15511
3480e83e17ab
Trivial typo fix, submitted by Charles Waldman (SF patch #102794).
Guido van Rossum <guido@python.org>
parents:
15486
diff
changeset
|
3018 Wait for completion of a given child process."; |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3019 |
| 4672 | 3020 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3021 posix_waitpid(PyObject *self, PyObject *args) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
3022 { |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3023 int pid, options; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3024 #ifdef UNION_WAIT |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3025 union wait status; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3026 #define status_i (status.w_status) |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3027 #else |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3028 int status; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3029 #define status_i status |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3030 #endif |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3031 status_i = 0; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3032 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3033 if (!PyArg_ParseTuple(args, "ii:waitpid", &pid, &options)) |
|
931
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
3034 return NULL; |
| 4672 | 3035 Py_BEGIN_ALLOW_THREADS |
|
10056
b82a61a884cf
Oops, the patch for NeXT always replaced waitpid() with wait4() --
Guido van Rossum <guido@python.org>
parents:
9970
diff
changeset
|
3036 #ifdef NeXT |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3037 pid = wait4(pid, &status, options, NULL); |
|
10056
b82a61a884cf
Oops, the patch for NeXT always replaced waitpid() with wait4() --
Guido van Rossum <guido@python.org>
parents:
9970
diff
changeset
|
3038 #else |
|
b82a61a884cf
Oops, the patch for NeXT always replaced waitpid() with wait4() --
Guido van Rossum <guido@python.org>
parents:
9970
diff
changeset
|
3039 pid = waitpid(pid, &status, options); |
|
b82a61a884cf
Oops, the patch for NeXT always replaced waitpid() with wait4() --
Guido van Rossum <guido@python.org>
parents:
9970
diff
changeset
|
3040 #endif |
| 4672 | 3041 Py_END_ALLOW_THREADS |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
3042 if (pid == -1) |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
3043 return posix_error(); |
|
931
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
3044 else |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3045 return Py_BuildValue("ii", pid, status_i); |
|
931
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
3046 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3047 #endif /* HAVE_WAITPID */ |
|
931
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
3048 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3049 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
3050 #ifdef HAVE_WAIT |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3051 static char posix_wait__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3052 "wait() -> (pid, status)\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3053 Wait for completion of a child process."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3054 |
| 4672 | 3055 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3056 posix_wait(PyObject *self, PyObject *args) |
|
931
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
3057 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3058 int pid; |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3059 #ifdef UNION_WAIT |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3060 union wait status; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3061 #define status_i (status.w_status) |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3062 #else |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3063 int status; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3064 #define status_i status |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3065 #endif |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3066 if (!PyArg_ParseTuple(args, ":wait")) |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3067 return NULL; |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3068 status_i = 0; |
| 4672 | 3069 Py_BEGIN_ALLOW_THREADS |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3070 pid = wait(&status); |
| 4672 | 3071 Py_END_ALLOW_THREADS |
|
931
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
3072 if (pid == -1) |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
3073 return posix_error(); |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
3074 else |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3075 return Py_BuildValue("ii", pid, status_i); |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3076 #undef status_i |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
3077 } |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
3078 #endif |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
3079 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3080 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3081 static char posix_lstat__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3082 "lstat(path) -> (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3083 Like stat(path), but do not follow symbolic links."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3084 |
| 4672 | 3085 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3086 posix_lstat(PyObject *self, PyObject *args) |
| 6 | 3087 { |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3088 #ifdef HAVE_LSTAT |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3089 return posix_do_stat(self, args, "s:lstat", lstat); |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3090 #else /* !HAVE_LSTAT */ |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
3091 return posix_do_stat(self, args, "s:lstat", STAT); |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3092 #endif /* !HAVE_LSTAT */ |
| 6 | 3093 } |
| 3094 | |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3095 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3096 #ifdef HAVE_READLINK |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3097 static char posix_readlink__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3098 "readlink(path) -> path\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3099 Return a string representing the path to which the symbolic link points."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3100 |
| 4672 | 3101 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3102 posix_readlink(PyObject *self, PyObject *args) |
| 6 | 3103 { |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3104 char buf[MAXPATHLEN]; |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
3105 char *path; |
| 6 | 3106 int n; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3107 if (!PyArg_ParseTuple(args, "s:readlink", &path)) |
| 6 | 3108 return NULL; |
| 4672 | 3109 Py_BEGIN_ALLOW_THREADS |
|
731
c65fc172f16d
Check empty argument lists.
Guido van Rossum <guido@python.org>
parents:
658
diff
changeset
|
3110 n = readlink(path, buf, (int) sizeof buf); |
| 4672 | 3111 Py_END_ALLOW_THREADS |
| 6 | 3112 if (n < 0) |
|
8708
acf49c9def7d
Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents:
8497
diff
changeset
|
3113 return posix_error_with_filename(path); |
| 4672 | 3114 return PyString_FromStringAndSize(buf, n); |
| 6 | 3115 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3116 #endif /* HAVE_READLINK */ |
| 6 | 3117 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3118 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3119 #ifdef HAVE_SYMLINK |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3120 static char posix_symlink__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3121 "symlink(src, dst) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3122 Create a symbolic link."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3123 |
|
6971
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3124 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3125 posix_symlink(PyObject *self, PyObject *args) |
|
6971
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3126 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3127 return posix_2str(args, "ss:symlink", symlink); |
|
6971
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3128 } |
|
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3129 #endif /* HAVE_SYMLINK */ |
|
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3130 |
|
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3131 |
|
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3132 #ifdef HAVE_TIMES |
|
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3133 #ifndef HZ |
|
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3134 #define HZ 60 /* Universal constant :-) */ |
|
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3135 #endif /* HZ */ |
|
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3136 |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3137 #if defined(PYCC_VACPP) && defined(PYOS_OS2) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3138 static long |
|
13651
8a063423e0b7
Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents:
13642
diff
changeset
|
3139 system_uptime(void) |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3140 { |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3141 ULONG value = 0; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3142 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3143 Py_BEGIN_ALLOW_THREADS |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3144 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &value, sizeof(value)); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3145 Py_END_ALLOW_THREADS |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3146 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3147 return value; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3148 } |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3149 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3150 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3151 posix_times(PyObject *self, PyObject *args) |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3152 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3153 if (!PyArg_ParseTuple(args, ":times")) |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3154 return NULL; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3155 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3156 /* Currently Only Uptime is Provided -- Others Later */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3157 return Py_BuildValue("ddddd", |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3158 (double)0 /* t.tms_utime / HZ */, |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3159 (double)0 /* t.tms_stime / HZ */, |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3160 (double)0 /* t.tms_cutime / HZ */, |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3161 (double)0 /* t.tms_cstime / HZ */, |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3162 (double)system_uptime() / 1000); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3163 } |
|
6971
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3164 #else /* not OS2 */ |
| 4672 | 3165 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3166 posix_times(PyObject *self, PyObject *args) |
|
793
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
3167 { |
|
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
3168 struct tms t; |
|
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
3169 clock_t c; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3170 if (!PyArg_ParseTuple(args, ":times")) |
|
793
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
3171 return NULL; |
|
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
3172 errno = 0; |
|
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
3173 c = times(&t); |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3174 if (c == (clock_t) -1) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3175 return posix_error(); |
| 4672 | 3176 return Py_BuildValue("ddddd", |
| 4785 | 3177 (double)t.tms_utime / HZ, |
| 3178 (double)t.tms_stime / HZ, | |
| 3179 (double)t.tms_cutime / HZ, | |
| 3180 (double)t.tms_cstime / HZ, | |
| 3181 (double)c / HZ); | |
|
793
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
3182 } |
|
6971
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3183 #endif /* not OS2 */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3184 #endif /* HAVE_TIMES */ |
|
6971
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3185 |
|
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3186 |
|
4233
1099159ec821
Use #ifdef MS_WIN32 instead of _MSC_VER > 850.
Guido van Rossum <guido@python.org>
parents:
3801
diff
changeset
|
3187 #ifdef MS_WIN32 |
|
1915
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
3188 #define HAVE_TIMES /* so the method table will pick it up */ |
| 4672 | 3189 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3190 posix_times(PyObject *self, PyObject *args) |
|
1915
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
3191 { |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
3192 FILETIME create, exit, kernel, user; |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
3193 HANDLE hProc; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3194 if (!PyArg_ParseTuple(args, ":times")) |
|
1915
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
3195 return NULL; |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
3196 hProc = GetCurrentProcess(); |
|
10178
f0a57ccf233c
Fixed totally bogus conversion factors used in the Win32 version of
Guido van Rossum <guido@python.org>
parents:
10133
diff
changeset
|
3197 GetProcessTimes(hProc, &create, &exit, &kernel, &user); |
|
f0a57ccf233c
Fixed totally bogus conversion factors used in the Win32 version of
Guido van Rossum <guido@python.org>
parents:
10133
diff
changeset
|
3198 /* The fields of a FILETIME structure are the hi and lo part |
|
f0a57ccf233c
Fixed totally bogus conversion factors used in the Win32 version of
Guido van Rossum <guido@python.org>
parents:
10133
diff
changeset
|
3199 of a 64-bit value expressed in 100 nanosecond units. |
|
f0a57ccf233c
Fixed totally bogus conversion factors used in the Win32 version of
Guido van Rossum <guido@python.org>
parents:
10133
diff
changeset
|
3200 1e7 is one second in such units; 1e-7 the inverse. |
|
f0a57ccf233c
Fixed totally bogus conversion factors used in the Win32 version of
Guido van Rossum <guido@python.org>
parents:
10133
diff
changeset
|
3201 429.4967296 is 2**32 / 1e7 or 2**32 * 1e-7. |
|
f0a57ccf233c
Fixed totally bogus conversion factors used in the Win32 version of
Guido van Rossum <guido@python.org>
parents:
10133
diff
changeset
|
3202 */ |
| 4672 | 3203 return Py_BuildValue( |
| 3204 "ddddd", | |
|
10178
f0a57ccf233c
Fixed totally bogus conversion factors used in the Win32 version of
Guido van Rossum <guido@python.org>
parents:
10133
diff
changeset
|
3205 (double)(kernel.dwHighDateTime*429.4967296 + |
|
f0a57ccf233c
Fixed totally bogus conversion factors used in the Win32 version of
Guido van Rossum <guido@python.org>
parents:
10133
diff
changeset
|
3206 kernel.dwLowDateTime*1e-7), |
|
f0a57ccf233c
Fixed totally bogus conversion factors used in the Win32 version of
Guido van Rossum <guido@python.org>
parents:
10133
diff
changeset
|
3207 (double)(user.dwHighDateTime*429.4967296 + |
|
f0a57ccf233c
Fixed totally bogus conversion factors used in the Win32 version of
Guido van Rossum <guido@python.org>
parents:
10133
diff
changeset
|
3208 user.dwLowDateTime*1e-7), |
| 4672 | 3209 (double)0, |
| 3210 (double)0, | |
| 3211 (double)0); | |
|
1915
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
3212 } |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
3213 #endif /* MS_WIN32 */ |
|
6971
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3214 |
|
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3215 #ifdef HAVE_TIMES |
|
5725
9a3b115aa491
Moved the definition of posix_times__doc__ to outside of #ifdef HAVE_TIMES
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
5699
diff
changeset
|
3216 static char posix_times__doc__[] = |
|
9a3b115aa491
Moved the definition of posix_times__doc__ to outside of #ifdef HAVE_TIMES
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
5699
diff
changeset
|
3217 "times() -> (utime, stime, cutime, cstime, elapsed_time)\n\ |
|
9a3b115aa491
Moved the definition of posix_times__doc__ to outside of #ifdef HAVE_TIMES
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
5699
diff
changeset
|
3218 Return a tuple of floating point numbers indicating process times."; |
|
6971
bc125f0d2c5d
Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents:
6766
diff
changeset
|
3219 #endif |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
3220 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3221 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3222 #ifdef HAVE_SETSID |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3223 static char posix_setsid__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3224 "setsid() -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3225 Call the system call setsid()."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3226 |
| 4672 | 3227 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3228 posix_setsid(PyObject *self, PyObject *args) |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
3229 { |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3230 if (!PyArg_ParseTuple(args, ":setsid")) |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
3231 return NULL; |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3232 if (setsid() < 0) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3233 return posix_error(); |
| 4672 | 3234 Py_INCREF(Py_None); |
| 3235 return Py_None; | |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
3236 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3237 #endif /* HAVE_SETSID */ |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
3238 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3239 #ifdef HAVE_SETPGID |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3240 static char posix_setpgid__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3241 "setpgid(pid, pgrp) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3242 Call the system call setpgid()."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3243 |
| 4672 | 3244 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3245 posix_setpgid(PyObject *self, PyObject *args) |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
3246 { |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
3247 int pid, pgrp; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3248 if (!PyArg_ParseTuple(args, "ii:setpgid", &pid, &pgrp)) |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
3249 return NULL; |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3250 if (setpgid(pid, pgrp) < 0) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3251 return posix_error(); |
| 4672 | 3252 Py_INCREF(Py_None); |
| 3253 return Py_None; | |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
3254 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3255 #endif /* HAVE_SETPGID */ |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
3256 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3257 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3258 #ifdef HAVE_TCGETPGRP |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3259 static char posix_tcgetpgrp__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3260 "tcgetpgrp(fd) -> pgid\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3261 Return the process group associated with the terminal given by a fd."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3262 |
| 4672 | 3263 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3264 posix_tcgetpgrp(PyObject *self, PyObject *args) |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
3265 { |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
3266 int fd, pgid; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3267 if (!PyArg_ParseTuple(args, "i:tcgetpgrp", &fd)) |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
3268 return NULL; |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
3269 pgid = tcgetpgrp(fd); |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3270 if (pgid < 0) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3271 return posix_error(); |
| 4672 | 3272 return PyInt_FromLong((long)pgid); |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
3273 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3274 #endif /* HAVE_TCGETPGRP */ |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
3275 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3276 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3277 #ifdef HAVE_TCSETPGRP |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3278 static char posix_tcsetpgrp__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3279 "tcsetpgrp(fd, pgid) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3280 Set the process group associated with the terminal given by a fd."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3281 |
| 4672 | 3282 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3283 posix_tcsetpgrp(PyObject *self, PyObject *args) |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
3284 { |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
3285 int fd, pgid; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3286 if (!PyArg_ParseTuple(args, "ii:tcsetpgrp", &fd, &pgid)) |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
3287 return NULL; |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3288 if (tcsetpgrp(fd, pgid) < 0) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3289 return posix_error(); |
| 4785 | 3290 Py_INCREF(Py_None); |
| 4672 | 3291 return Py_None; |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
3292 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
3293 #endif /* HAVE_TCSETPGRP */ |
|
793
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
3294 |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3295 /* Functions acting on file descriptors */ |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3296 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3297 static char posix_open__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3298 "open(filename, flag [, mode=0777]) -> fd\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3299 Open a file (for low level IO)."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3300 |
| 4672 | 3301 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3302 posix_open(PyObject *self, PyObject *args) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3303 { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3304 char *file; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3305 int flag; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3306 int mode = 0777; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3307 int fd; |
| 4785 | 3308 if (!PyArg_ParseTuple(args, "si|i", &file, &flag, &mode)) |
| 3309 return NULL; | |
| 3310 | |
| 4672 | 3311 Py_BEGIN_ALLOW_THREADS |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3312 fd = open(file, flag, mode); |
| 4672 | 3313 Py_END_ALLOW_THREADS |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3314 if (fd < 0) |
|
8708
acf49c9def7d
Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents:
8497
diff
changeset
|
3315 return posix_error_with_filename(file); |
| 4672 | 3316 return PyInt_FromLong((long)fd); |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3317 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3318 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3319 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3320 static char posix_close__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3321 "close(fd) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3322 Close a file descriptor (for low level IO)."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3323 |
| 4672 | 3324 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3325 posix_close(PyObject *self, PyObject *args) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3326 { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3327 int fd, res; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3328 if (!PyArg_ParseTuple(args, "i:close", &fd)) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3329 return NULL; |
| 4672 | 3330 Py_BEGIN_ALLOW_THREADS |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3331 res = close(fd); |
| 4672 | 3332 Py_END_ALLOW_THREADS |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3333 if (res < 0) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3334 return posix_error(); |
| 4672 | 3335 Py_INCREF(Py_None); |
| 3336 return Py_None; | |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3337 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3338 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3339 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3340 static char posix_dup__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3341 "dup(fd) -> fd2\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3342 Return a duplicate of a file descriptor."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3343 |
| 4672 | 3344 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3345 posix_dup(PyObject *self, PyObject *args) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3346 { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3347 int fd; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3348 if (!PyArg_ParseTuple(args, "i:dup", &fd)) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3349 return NULL; |
| 4672 | 3350 Py_BEGIN_ALLOW_THREADS |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3351 fd = dup(fd); |
| 4672 | 3352 Py_END_ALLOW_THREADS |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3353 if (fd < 0) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3354 return posix_error(); |
| 4672 | 3355 return PyInt_FromLong((long)fd); |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3356 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3357 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3358 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3359 static char posix_dup2__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3360 "dup2(fd, fd2) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3361 Duplicate file descriptor."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3362 |
| 4672 | 3363 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3364 posix_dup2(PyObject *self, PyObject *args) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3365 { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3366 int fd, fd2, res; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3367 if (!PyArg_ParseTuple(args, "ii:dup2", &fd, &fd2)) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3368 return NULL; |
| 4672 | 3369 Py_BEGIN_ALLOW_THREADS |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3370 res = dup2(fd, fd2); |
| 4672 | 3371 Py_END_ALLOW_THREADS |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3372 if (res < 0) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3373 return posix_error(); |
| 4672 | 3374 Py_INCREF(Py_None); |
| 3375 return Py_None; | |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3376 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3377 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3378 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3379 static char posix_lseek__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3380 "lseek(fd, pos, how) -> newpos\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3381 Set the current position of a file descriptor."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3382 |
| 4672 | 3383 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3384 posix_lseek(PyObject *self, PyObject *args) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3385 { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3386 int fd, how; |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
3387 #ifdef MS_WIN64 |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
3388 LONG_LONG pos, res; |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
3389 #else |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3390 off_t pos, res; |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
3391 #endif |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3392 PyObject *posobj; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3393 if (!PyArg_ParseTuple(args, "iOi:lseek", &fd, &posobj, &how)) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3394 return NULL; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3395 #ifdef SEEK_SET |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3396 /* Turn 0, 1, 2 into SEEK_{SET,CUR,END} */ |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3397 switch (how) { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3398 case 0: how = SEEK_SET; break; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3399 case 1: how = SEEK_CUR; break; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3400 case 2: how = SEEK_END; break; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3401 } |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
3402 #endif /* SEEK_END */ |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3403 |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3404 #if !defined(HAVE_LARGEFILE_SUPPORT) |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3405 pos = PyInt_AsLong(posobj); |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3406 #else |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3407 pos = PyLong_Check(posobj) ? |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3408 PyLong_AsLongLong(posobj) : PyInt_AsLong(posobj); |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3409 #endif |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3410 if (PyErr_Occurred()) |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3411 return NULL; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3412 |
| 4672 | 3413 Py_BEGIN_ALLOW_THREADS |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
3414 #ifdef MS_WIN64 |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
3415 res = _lseeki64(fd, pos, how); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
3416 #else |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3417 res = lseek(fd, pos, how); |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
3418 #endif |
| 4672 | 3419 Py_END_ALLOW_THREADS |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3420 if (res < 0) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3421 return posix_error(); |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3422 |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3423 #if !defined(HAVE_LARGEFILE_SUPPORT) |
| 4672 | 3424 return PyInt_FromLong(res); |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3425 #else |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3426 return PyLong_FromLongLong(res); |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3427 #endif |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3428 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3429 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3430 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3431 static char posix_read__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3432 "read(fd, buffersize) -> string\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3433 Read a file descriptor."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3434 |
| 4672 | 3435 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3436 posix_read(PyObject *self, PyObject *args) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3437 { |
|
3667
eabbb3c1818f
Avoid core dump in resizestring() on read() with 0 bytes.
Guido van Rossum <guido@python.org>
parents:
3622
diff
changeset
|
3438 int fd, size, n; |
| 4672 | 3439 PyObject *buffer; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3440 if (!PyArg_ParseTuple(args, "ii:read", &fd, &size)) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3441 return NULL; |
| 4672 | 3442 buffer = PyString_FromStringAndSize((char *)NULL, size); |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3443 if (buffer == NULL) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3444 return NULL; |
| 4672 | 3445 Py_BEGIN_ALLOW_THREADS |
| 3446 n = read(fd, PyString_AsString(buffer), size); | |
| 3447 Py_END_ALLOW_THREADS | |
|
3667
eabbb3c1818f
Avoid core dump in resizestring() on read() with 0 bytes.
Guido van Rossum <guido@python.org>
parents:
3622
diff
changeset
|
3448 if (n < 0) { |
| 4672 | 3449 Py_DECREF(buffer); |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3450 return posix_error(); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3451 } |
|
3667
eabbb3c1818f
Avoid core dump in resizestring() on read() with 0 bytes.
Guido van Rossum <guido@python.org>
parents:
3622
diff
changeset
|
3452 if (n != size) |
| 4672 | 3453 _PyString_Resize(&buffer, n); |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3454 return buffer; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3455 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3456 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3457 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3458 static char posix_write__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3459 "write(fd, string) -> byteswritten\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3460 Write a string to a file descriptor."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3461 |
| 4672 | 3462 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3463 posix_write(PyObject *self, PyObject *args) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3464 { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3465 int fd, size; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3466 char *buffer; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3467 if (!PyArg_ParseTuple(args, "is#:write", &fd, &buffer, &size)) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3468 return NULL; |
| 4672 | 3469 Py_BEGIN_ALLOW_THREADS |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3470 size = write(fd, buffer, size); |
| 4672 | 3471 Py_END_ALLOW_THREADS |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3472 if (size < 0) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3473 return posix_error(); |
| 4672 | 3474 return PyInt_FromLong((long)size); |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3475 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3476 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3477 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3478 static char posix_fstat__doc__[]= |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3479 "fstat(fd) -> (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime)\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3480 Like stat(), but for an open file descriptor."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3481 |
| 4672 | 3482 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3483 posix_fstat(PyObject *self, PyObject *args) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3484 { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3485 int fd; |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
3486 STRUCT_STAT st; |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3487 int res; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3488 if (!PyArg_ParseTuple(args, "i:fstat", &fd)) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3489 return NULL; |
| 4672 | 3490 Py_BEGIN_ALLOW_THREADS |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
3491 res = FSTAT(fd, &st); |
| 4672 | 3492 Py_END_ALLOW_THREADS |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3493 if (res != 0) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3494 return posix_error(); |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
3495 |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
3496 return _pystat_fromstructstat(st); |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3497 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3498 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3499 |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3500 static char posix_fdopen__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3501 "fdopen(fd, [, mode='r' [, bufsize]]) -> file_object\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3502 Return an open file object connected to a file descriptor."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3503 |
| 4672 | 3504 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3505 posix_fdopen(PyObject *self, PyObject *args) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3506 { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3507 int fd; |
|
2114
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
3508 char *mode = "r"; |
|
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
3509 int bufsize = -1; |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3510 FILE *fp; |
| 4672 | 3511 PyObject *f; |
| 3512 if (!PyArg_ParseTuple(args, "i|si", &fd, &mode, &bufsize)) | |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3513 return NULL; |
| 4785 | 3514 |
| 4672 | 3515 Py_BEGIN_ALLOW_THREADS |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3516 fp = fdopen(fd, mode); |
| 4672 | 3517 Py_END_ALLOW_THREADS |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3518 if (fp == NULL) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3519 return posix_error(); |
| 4672 | 3520 f = PyFile_FromFile(fp, "(fdopen)", mode, fclose); |
|
2114
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
3521 if (f != NULL) |
| 4672 | 3522 PyFile_SetBufSize(f, bufsize); |
|
2114
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
3523 return f; |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3524 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3525 |
|
13641
38ea27455cbb
new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents:
13620
diff
changeset
|
3526 static char posix_isatty__doc__[] = |
|
38ea27455cbb
new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents:
13620
diff
changeset
|
3527 "isatty(fd) -> Boolean\n\ |
|
38ea27455cbb
new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents:
13620
diff
changeset
|
3528 Return true if the file descriptor 'fd' is an open file descriptor\n\ |
|
14995
eec2eb121dae
Clarify that isatty is only guaranteed to return true for slave ends of
Thomas Wouters <thomas@python.org>
parents:
14837
diff
changeset
|
3529 connected to the slave end of a terminal."; |
|
13641
38ea27455cbb
new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents:
13620
diff
changeset
|
3530 |
|
38ea27455cbb
new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents:
13620
diff
changeset
|
3531 static PyObject * |
|
13642
dacc9f167e95
ANSIfy the just-checked-in isatty() wrapper.
Thomas Wouters <thomas@python.org>
parents:
13641
diff
changeset
|
3532 posix_isatty(PyObject *self, PyObject *args) |
|
13641
38ea27455cbb
new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents:
13620
diff
changeset
|
3533 { |
|
38ea27455cbb
new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents:
13620
diff
changeset
|
3534 int fd; |
|
38ea27455cbb
new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents:
13620
diff
changeset
|
3535 if (!PyArg_ParseTuple(args, "i:isatty", &fd)) |
|
38ea27455cbb
new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents:
13620
diff
changeset
|
3536 return NULL; |
|
38ea27455cbb
new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents:
13620
diff
changeset
|
3537 return Py_BuildValue("i", isatty(fd)); |
|
38ea27455cbb
new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents:
13620
diff
changeset
|
3538 } |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3539 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3540 #ifdef HAVE_PIPE |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3541 static char posix_pipe__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3542 "pipe() -> (read_end, write_end)\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3543 Create a pipe."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3544 |
| 4672 | 3545 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3546 posix_pipe(PyObject *self, PyObject *args) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3547 { |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
3548 #if defined(PYOS_OS2) |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
3549 HFILE read, write; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
3550 APIRET rc; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
3551 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3552 if (!PyArg_ParseTuple(args, ":pipe")) |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
3553 return NULL; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
3554 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
3555 Py_BEGIN_ALLOW_THREADS |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
3556 rc = DosCreatePipe( &read, &write, 4096); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
3557 Py_END_ALLOW_THREADS |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
3558 if (rc != NO_ERROR) |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3559 return os2_error(rc); |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
3560 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
3561 return Py_BuildValue("(ii)", read, write); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
3562 #else |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
3563 #if !defined(MS_WIN32) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3564 int fds[2]; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3565 int res; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3566 if (!PyArg_ParseTuple(args, ":pipe")) |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3567 return NULL; |
| 4672 | 3568 Py_BEGIN_ALLOW_THREADS |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3569 res = pipe(fds); |
| 4672 | 3570 Py_END_ALLOW_THREADS |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3571 if (res != 0) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3572 return posix_error(); |
| 4672 | 3573 return Py_BuildValue("(ii)", fds[0], fds[1]); |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
3574 #else /* MS_WIN32 */ |
|
1815
6353fe25cdce
* Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents:
1792
diff
changeset
|
3575 HANDLE read, write; |
|
8497
0f91c0bbacc5
On Windows, make the pipe() call return Unix file descriptors instead
Guido van Rossum <guido@python.org>
parents:
6971
diff
changeset
|
3576 int read_fd, write_fd; |
|
1815
6353fe25cdce
* Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents:
1792
diff
changeset
|
3577 BOOL ok; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3578 if (!PyArg_ParseTuple(args, ":pipe")) |
|
1815
6353fe25cdce
* Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents:
1792
diff
changeset
|
3579 return NULL; |
| 4672 | 3580 Py_BEGIN_ALLOW_THREADS |
|
8497
0f91c0bbacc5
On Windows, make the pipe() call return Unix file descriptors instead
Guido van Rossum <guido@python.org>
parents:
6971
diff
changeset
|
3581 ok = CreatePipe(&read, &write, NULL, 0); |
| 4672 | 3582 Py_END_ALLOW_THREADS |
|
1815
6353fe25cdce
* Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents:
1792
diff
changeset
|
3583 if (!ok) |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
3584 return win32_error("CreatePipe", NULL); |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
3585 read_fd = _open_osfhandle((intptr_t)read, 0); |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
3586 write_fd = _open_osfhandle((intptr_t)write, 1); |
|
8497
0f91c0bbacc5
On Windows, make the pipe() call return Unix file descriptors instead
Guido van Rossum <guido@python.org>
parents:
6971
diff
changeset
|
3587 return Py_BuildValue("(ii)", read_fd, write_fd); |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
3588 #endif /* MS_WIN32 */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
3589 #endif |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
3590 } |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3591 #endif /* HAVE_PIPE */ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3592 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3593 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3594 #ifdef HAVE_MKFIFO |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3595 static char posix_mkfifo__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3596 "mkfifo(file, [, mode=0666]) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3597 Create a FIFO (a POSIX named pipe)."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3598 |
| 4672 | 3599 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3600 posix_mkfifo(PyObject *self, PyObject *args) |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3601 { |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3602 char *file; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3603 int mode = 0666; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3604 int res; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3605 if (!PyArg_ParseTuple(args, "s|i:mkfifo", &file, &mode)) |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3606 return NULL; |
| 4672 | 3607 Py_BEGIN_ALLOW_THREADS |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3608 res = mkfifo(file, mode); |
| 4672 | 3609 Py_END_ALLOW_THREADS |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3610 if (res < 0) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3611 return posix_error(); |
| 4672 | 3612 Py_INCREF(Py_None); |
| 3613 return Py_None; | |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3614 } |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3615 #endif |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3616 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3617 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3618 #ifdef HAVE_FTRUNCATE |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3619 static char posix_ftruncate__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3620 "ftruncate(fd, length) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3621 Truncate a file to a specified length."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3622 |
| 4672 | 3623 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3624 posix_ftruncate(PyObject *self, PyObject *args) |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3625 { |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3626 int fd; |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3627 off_t length; |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3628 int res; |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3629 PyObject *lenobj; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3630 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3631 if (!PyArg_ParseTuple(args, "iO:ftruncate", &fd, &lenobj)) |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3632 return NULL; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3633 |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3634 #if !defined(HAVE_LARGEFILE_SUPPORT) |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3635 length = PyInt_AsLong(lenobj); |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3636 #else |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3637 length = PyLong_Check(lenobj) ? |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3638 PyLong_AsLongLong(lenobj) : PyInt_AsLong(lenobj); |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3639 #endif |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3640 if (PyErr_Occurred()) |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3641 return NULL; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3642 |
| 4672 | 3643 Py_BEGIN_ALLOW_THREADS |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3644 res = ftruncate(fd, length); |
| 4672 | 3645 Py_END_ALLOW_THREADS |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3646 if (res < 0) { |
| 4672 | 3647 PyErr_SetFromErrno(PyExc_IOError); |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3648 return NULL; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3649 } |
| 4672 | 3650 Py_INCREF(Py_None); |
| 3651 return Py_None; | |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3652 } |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
3653 #endif |
|
793
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
3654 |
|
5584
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3655 #ifdef NeXT |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3656 #define HAVE_PUTENV |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3657 /* Steve Spicklemire got this putenv from NeXTAnswers */ |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3658 static int |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3659 putenv(char *newval) |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3660 { |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3661 extern char **environ; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3662 |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3663 static int firstTime = 1; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3664 char **ep; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3665 char *cp; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3666 int esiz; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3667 char *np; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3668 |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3669 if (!(np = strchr(newval, '='))) |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3670 return 1; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3671 *np = '\0'; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3672 |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3673 /* look it up */ |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3674 for (ep=environ ; *ep ; ep++) |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3675 { |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3676 /* this should always be true... */ |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3677 if (cp = strchr(*ep, '=')) |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3678 { |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3679 *cp = '\0'; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3680 if (!strcmp(*ep, newval)) |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3681 { |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3682 /* got it! */ |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3683 *cp = '='; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3684 break; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3685 } |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3686 *cp = '='; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3687 } |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3688 else |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3689 { |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3690 *np = '='; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3691 return 1; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3692 } |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3693 } |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3694 |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3695 *np = '='; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3696 if (*ep) |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3697 { |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3698 /* the string was already there: |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3699 just replace it with the new one */ |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3700 *ep = newval; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3701 return 0; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3702 } |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3703 |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3704 /* expand environ by one */ |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3705 for (esiz=2, ep=environ ; *ep ; ep++) |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3706 esiz++; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3707 if (firstTime) |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3708 { |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3709 char **epp; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3710 char **newenv; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3711 if (!(newenv = malloc(esiz * sizeof(char *)))) |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3712 return 1; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3713 |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3714 for (ep=environ, epp=newenv ; *ep ;) |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3715 *epp++ = *ep++; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3716 *epp++ = newval; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3717 *epp = (char *) 0; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3718 environ = newenv; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3719 } |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3720 else |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3721 { |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3722 if (!(environ = realloc(environ, esiz * sizeof(char *)))) |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3723 return 1; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3724 environ[esiz - 2] = newval; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3725 environ[esiz - 1] = (char *) 0; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3726 firstTime = 0; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3727 } |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3728 |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3729 return 0; |
|
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3730 } |
|
6130
2d9582eee112
Added /**/ around #end tags
Guido van Rossum <guido@python.org>
parents:
6027
diff
changeset
|
3731 #endif /* NeXT */ |
|
5584
85c5043c9316
Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents:
5361
diff
changeset
|
3732 |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3733 |
|
3801
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
3734 #ifdef HAVE_PUTENV |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3735 static char posix_putenv__doc__[] = |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3736 "putenv(key, value) -> None\n\ |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3737 Change or add an environment variable."; |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
3738 |
|
11230
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3739 /* Save putenv() parameters as values here, so we can collect them when they |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3740 * get re-set with another call for the same key. */ |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3741 static PyObject *posix_putenv_garbage; |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3742 |
| 4672 | 3743 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3744 posix_putenv(PyObject *self, PyObject *args) |
|
3801
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
3745 { |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
3746 char *s1, *s2; |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
3747 char *new; |
|
11230
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3748 PyObject *newstr; |
|
3801
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
3749 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3750 if (!PyArg_ParseTuple(args, "ss:putenv", &s1, &s2)) |
|
3801
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
3751 return NULL; |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3752 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3753 #if defined(PYOS_OS2) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3754 if (stricmp(s1, "BEGINLIBPATH") == 0) { |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3755 APIRET rc; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3756 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3757 if (strlen(s2) == 0) /* If New Value is an Empty String */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3758 s2 = NULL; /* Then OS/2 API Wants a NULL to Undefine It */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3759 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3760 rc = DosSetExtLIBPATH(s2, BEGIN_LIBPATH); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3761 if (rc != NO_ERROR) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3762 return os2_error(rc); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3763 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3764 } else if (stricmp(s1, "ENDLIBPATH") == 0) { |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3765 APIRET rc; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3766 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3767 if (strlen(s2) == 0) /* If New Value is an Empty String */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3768 s2 = NULL; /* Then OS/2 API Wants a NULL to Undefine It */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3769 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3770 rc = DosSetExtLIBPATH(s2, END_LIBPATH); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3771 if (rc != NO_ERROR) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3772 return os2_error(rc); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3773 } else { |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3774 #endif |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3775 |
|
11230
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3776 /* XXX This can leak memory -- not easy to fix :-( */ |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3777 newstr = PyString_FromStringAndSize(NULL, strlen(s1) + strlen(s2) + 2); |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3778 if (newstr == NULL) |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3779 return PyErr_NoMemory(); |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3780 new = PyString_AS_STRING(newstr); |
|
3801
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
3781 (void) sprintf(new, "%s=%s", s1, s2); |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
3782 if (putenv(new)) { |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
3783 posix_error(); |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
3784 return NULL; |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
3785 } |
|
11230
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3786 /* Install the first arg and newstr in posix_putenv_garbage; |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3787 * this will cause previous value to be collected. This has to |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3788 * happen after the real putenv() call because the old value |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3789 * was still accessible until then. */ |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3790 if (PyDict_SetItem(posix_putenv_garbage, |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3791 PyTuple_GET_ITEM(args, 0), newstr)) { |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3792 /* really not much we can do; just leak */ |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3793 PyErr_Clear(); |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3794 } |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3795 else { |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3796 Py_DECREF(newstr); |
|
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
3797 } |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3798 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3799 #if defined(PYOS_OS2) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3800 } |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
3801 #endif |
| 4672 | 3802 Py_INCREF(Py_None); |
| 3803 return Py_None; | |
|
3801
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
3804 } |
|
6315
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3805 #endif /* putenv */ |
|
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3806 |
|
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3807 #ifdef HAVE_STRERROR |
|
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3808 static char posix_strerror__doc__[] = |
|
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3809 "strerror(code) -> string\n\ |
|
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3810 Translate an error code to a message string."; |
|
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3811 |
|
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3812 PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3813 posix_strerror(PyObject *self, PyObject *args) |
|
6315
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3814 { |
|
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3815 int code; |
|
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3816 char *message; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3817 if (!PyArg_ParseTuple(args, "i:strerror", &code)) |
|
6315
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3818 return NULL; |
|
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3819 message = strerror(code); |
|
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3820 if (message == NULL) { |
|
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3821 PyErr_SetString(PyExc_ValueError, |
| 15318 | 3822 "strerror() argument out of range"); |
|
6315
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3823 return NULL; |
|
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3824 } |
|
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3825 return PyString_FromString(message); |
|
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3826 } |
|
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3827 #endif /* strerror */ |
|
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
3828 |
|
3801
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
3829 |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3830 #ifdef HAVE_SYS_WAIT_H |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3831 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3832 #ifdef WIFSTOPPED |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3833 static char posix_WIFSTOPPED__doc__[] = |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3834 "WIFSTOPPED(status) -> Boolean\n\ |
|
10073
1e21e22453dc
Added documentation to the docstrings for the W*() functions that take
Fred Drake <fdrake@acm.org>
parents:
10069
diff
changeset
|
3835 Return true if the process returning 'status' was stopped."; |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3836 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3837 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3838 posix_WIFSTOPPED(PyObject *self, PyObject *args) |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3839 { |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3840 #ifdef UNION_WAIT |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3841 union wait status; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3842 #define status_i (status.w_status) |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3843 #else |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3844 int status; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3845 #define status_i status |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3846 #endif |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3847 status_i = 0; |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3848 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3849 if (!PyArg_ParseTuple(args, "i:WIFSTOPPED", &status_i)) |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3850 { |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3851 return NULL; |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3852 } |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3853 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3854 return Py_BuildValue("i", WIFSTOPPED(status)); |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3855 #undef status_i |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3856 } |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3857 #endif /* WIFSTOPPED */ |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3858 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3859 #ifdef WIFSIGNALED |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3860 static char posix_WIFSIGNALED__doc__[] = |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3861 "WIFSIGNALED(status) -> Boolean\n\ |
|
10286
3b81a7d418cb
# Typo in docstring (Retrun -> Return).
Guido van Rossum <guido@python.org>
parents:
10263
diff
changeset
|
3862 Return true if the process returning 'status' was terminated by a signal."; |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3863 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3864 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3865 posix_WIFSIGNALED(PyObject *self, PyObject *args) |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3866 { |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3867 #ifdef UNION_WAIT |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3868 union wait status; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3869 #define status_i (status.w_status) |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3870 #else |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3871 int status; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3872 #define status_i status |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3873 #endif |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3874 status_i = 0; |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3875 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3876 if (!PyArg_ParseTuple(args, "i:WIFSIGNALED", &status_i)) |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3877 { |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3878 return NULL; |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3879 } |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3880 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3881 return Py_BuildValue("i", WIFSIGNALED(status)); |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3882 #undef status_i |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3883 } |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3884 #endif /* WIFSIGNALED */ |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3885 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3886 #ifdef WIFEXITED |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3887 static char posix_WIFEXITED__doc__[] = |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3888 "WIFEXITED(status) -> Boolean\n\ |
|
10073
1e21e22453dc
Added documentation to the docstrings for the W*() functions that take
Fred Drake <fdrake@acm.org>
parents:
10069
diff
changeset
|
3889 Return true if the process returning 'status' exited using the exit()\n\ |
|
1e21e22453dc
Added documentation to the docstrings for the W*() functions that take
Fred Drake <fdrake@acm.org>
parents:
10069
diff
changeset
|
3890 system call."; |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3891 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3892 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3893 posix_WIFEXITED(PyObject *self, PyObject *args) |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3894 { |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3895 #ifdef UNION_WAIT |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3896 union wait status; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3897 #define status_i (status.w_status) |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3898 #else |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3899 int status; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3900 #define status_i status |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3901 #endif |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3902 status_i = 0; |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3903 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3904 if (!PyArg_ParseTuple(args, "i:WIFEXITED", &status_i)) |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3905 { |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3906 return NULL; |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3907 } |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3908 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3909 return Py_BuildValue("i", WIFEXITED(status)); |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3910 #undef status_i |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3911 } |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3912 #endif /* WIFEXITED */ |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3913 |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3914 #ifdef WEXITSTATUS |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3915 static char posix_WEXITSTATUS__doc__[] = |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3916 "WEXITSTATUS(status) -> integer\n\ |
|
10073
1e21e22453dc
Added documentation to the docstrings for the W*() functions that take
Fred Drake <fdrake@acm.org>
parents:
10069
diff
changeset
|
3917 Return the process return code from 'status'."; |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3918 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3919 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3920 posix_WEXITSTATUS(PyObject *self, PyObject *args) |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3921 { |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3922 #ifdef UNION_WAIT |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3923 union wait status; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3924 #define status_i (status.w_status) |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3925 #else |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3926 int status; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3927 #define status_i status |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3928 #endif |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3929 status_i = 0; |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3930 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3931 if (!PyArg_ParseTuple(args, "i:WEXITSTATUS", &status_i)) |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3932 { |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3933 return NULL; |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3934 } |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3935 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3936 return Py_BuildValue("i", WEXITSTATUS(status)); |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3937 #undef status_i |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3938 } |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3939 #endif /* WEXITSTATUS */ |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3940 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3941 #ifdef WTERMSIG |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3942 static char posix_WTERMSIG__doc__[] = |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3943 "WTERMSIG(status) -> integer\n\ |
|
10073
1e21e22453dc
Added documentation to the docstrings for the W*() functions that take
Fred Drake <fdrake@acm.org>
parents:
10069
diff
changeset
|
3944 Return the signal that terminated the process that provided the 'status'\n\ |
|
1e21e22453dc
Added documentation to the docstrings for the W*() functions that take
Fred Drake <fdrake@acm.org>
parents:
10069
diff
changeset
|
3945 value."; |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3946 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3947 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3948 posix_WTERMSIG(PyObject *self, PyObject *args) |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3949 { |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3950 #ifdef UNION_WAIT |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3951 union wait status; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3952 #define status_i (status.w_status) |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3953 #else |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3954 int status; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3955 #define status_i status |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3956 #endif |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3957 status_i = 0; |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3958 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3959 if (!PyArg_ParseTuple(args, "i:WTERMSIG", &status_i)) |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3960 { |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3961 return NULL; |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3962 } |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3963 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3964 return Py_BuildValue("i", WTERMSIG(status)); |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3965 #undef status_i |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3966 } |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3967 #endif /* WTERMSIG */ |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3968 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3969 #ifdef WSTOPSIG |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3970 static char posix_WSTOPSIG__doc__[] = |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3971 "WSTOPSIG(status) -> integer\n\ |
|
10073
1e21e22453dc
Added documentation to the docstrings for the W*() functions that take
Fred Drake <fdrake@acm.org>
parents:
10069
diff
changeset
|
3972 Return the signal that stopped the process that provided the 'status' value."; |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3973 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3974 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
3975 posix_WSTOPSIG(PyObject *self, PyObject *args) |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3976 { |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3977 #ifdef UNION_WAIT |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3978 union wait status; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3979 #define status_i (status.w_status) |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3980 #else |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3981 int status; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3982 #define status_i status |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3983 #endif |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9954
diff
changeset
|
3984 status_i = 0; |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3985 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3986 if (!PyArg_ParseTuple(args, "i:WSTOPSIG", &status_i)) |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3987 { |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3988 return NULL; |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3989 } |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3990 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3991 return Py_BuildValue("i", WSTOPSIG(status)); |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
3992 #undef status_i |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3993 } |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3994 #endif /* WSTOPSIG */ |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3995 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3996 #endif /* HAVE_SYS_WAIT_H */ |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3997 |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
3998 |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3999 #if defined(HAVE_FSTATVFS) |
|
11391
5486dcf13d77
John DuBois tells us that SCO OpenServer 5.0 and later requires _SVID3
Guido van Rossum <guido@python.org>
parents:
11230
diff
changeset
|
4000 #ifdef _SCO_DS |
|
5486dcf13d77
John DuBois tells us that SCO OpenServer 5.0 and later requires _SVID3
Guido van Rossum <guido@python.org>
parents:
11230
diff
changeset
|
4001 /* SCO OpenServer 5.0 and later requires _SVID3 before it reveals the |
|
5486dcf13d77
John DuBois tells us that SCO OpenServer 5.0 and later requires _SVID3
Guido van Rossum <guido@python.org>
parents:
11230
diff
changeset
|
4002 needed definitions in sys/statvfs.h */ |
|
5486dcf13d77
John DuBois tells us that SCO OpenServer 5.0 and later requires _SVID3
Guido van Rossum <guido@python.org>
parents:
11230
diff
changeset
|
4003 #define _SVID3 |
|
5486dcf13d77
John DuBois tells us that SCO OpenServer 5.0 and later requires _SVID3
Guido van Rossum <guido@python.org>
parents:
11230
diff
changeset
|
4004 #endif |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4005 #include <sys/statvfs.h> |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4006 |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4007 static char posix_fstatvfs__doc__[] = |
|
10092
574075e9a25f
Portability fix for [f]statvfs() return tuple: no longer return the
Guido van Rossum <guido@python.org>
parents:
10073
diff
changeset
|
4008 "fstatvfs(fd) -> \n\ |
|
574075e9a25f
Portability fix for [f]statvfs() return tuple: no longer return the
Guido van Rossum <guido@python.org>
parents:
10073
diff
changeset
|
4009 (bsize, frsize, blocks, bfree, bavail, files, ffree, favail, flag, namemax)\n\ |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4010 Perform an fstatvfs system call on the given fd."; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4011 |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4012 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
4013 posix_fstatvfs(PyObject *self, PyObject *args) |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4014 { |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4015 int fd, res; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4016 struct statvfs st; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4017 if (!PyArg_ParseTuple(args, "i:fstatvfs", &fd)) |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4018 return NULL; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4019 Py_BEGIN_ALLOW_THREADS |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4020 res = fstatvfs(fd, &st); |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4021 Py_END_ALLOW_THREADS |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4022 if (res != 0) |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4023 return posix_error(); |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4024 #if !defined(HAVE_LARGEFILE_SUPPORT) |
|
10092
574075e9a25f
Portability fix for [f]statvfs() return tuple: no longer return the
Guido van Rossum <guido@python.org>
parents:
10073
diff
changeset
|
4025 return Py_BuildValue("(llllllllll)", |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4026 (long) st.f_bsize, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4027 (long) st.f_frsize, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4028 (long) st.f_blocks, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4029 (long) st.f_bfree, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4030 (long) st.f_bavail, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4031 (long) st.f_files, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4032 (long) st.f_ffree, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4033 (long) st.f_favail, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4034 (long) st.f_flag, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4035 (long) st.f_namemax); |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4036 #else |
|
10092
574075e9a25f
Portability fix for [f]statvfs() return tuple: no longer return the
Guido van Rossum <guido@python.org>
parents:
10073
diff
changeset
|
4037 return Py_BuildValue("(llLLLLLLll)", |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4038 (long) st.f_bsize, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4039 (long) st.f_frsize, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4040 (LONG_LONG) st.f_blocks, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4041 (LONG_LONG) st.f_bfree, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4042 (LONG_LONG) st.f_bavail, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4043 (LONG_LONG) st.f_files, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4044 (LONG_LONG) st.f_ffree, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4045 (LONG_LONG) st.f_favail, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4046 (long) st.f_flag, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4047 (long) st.f_namemax); |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4048 #endif |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4049 } |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4050 #endif /* HAVE_FSTATVFS */ |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4051 |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4052 |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4053 #if defined(HAVE_STATVFS) |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4054 #include <sys/statvfs.h> |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4055 |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4056 static char posix_statvfs__doc__[] = |
|
10092
574075e9a25f
Portability fix for [f]statvfs() return tuple: no longer return the
Guido van Rossum <guido@python.org>
parents:
10073
diff
changeset
|
4057 "statvfs(path) -> \n\ |
|
574075e9a25f
Portability fix for [f]statvfs() return tuple: no longer return the
Guido van Rossum <guido@python.org>
parents:
10073
diff
changeset
|
4058 (bsize, frsize, blocks, bfree, bavail, files, ffree, favail, flag, namemax)\n\ |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4059 Perform a statvfs system call on the given path."; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4060 |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4061 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
4062 posix_statvfs(PyObject *self, PyObject *args) |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4063 { |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4064 char *path; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4065 int res; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4066 struct statvfs st; |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4067 if (!PyArg_ParseTuple(args, "s:statvfs", &path)) |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4068 return NULL; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4069 Py_BEGIN_ALLOW_THREADS |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4070 res = statvfs(path, &st); |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4071 Py_END_ALLOW_THREADS |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4072 if (res != 0) |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4073 return posix_error_with_filename(path); |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4074 #if !defined(HAVE_LARGEFILE_SUPPORT) |
|
10092
574075e9a25f
Portability fix for [f]statvfs() return tuple: no longer return the
Guido van Rossum <guido@python.org>
parents:
10073
diff
changeset
|
4075 return Py_BuildValue("(llllllllll)", |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4076 (long) st.f_bsize, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4077 (long) st.f_frsize, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4078 (long) st.f_blocks, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4079 (long) st.f_bfree, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4080 (long) st.f_bavail, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4081 (long) st.f_files, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4082 (long) st.f_ffree, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4083 (long) st.f_favail, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4084 (long) st.f_flag, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4085 (long) st.f_namemax); |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4086 #else /* HAVE_LARGEFILE_SUPPORT */ |
|
10092
574075e9a25f
Portability fix for [f]statvfs() return tuple: no longer return the
Guido van Rossum <guido@python.org>
parents:
10073
diff
changeset
|
4087 return Py_BuildValue("(llLLLLLLll)", |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4088 (long) st.f_bsize, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4089 (long) st.f_frsize, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4090 (LONG_LONG) st.f_blocks, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4091 (LONG_LONG) st.f_bfree, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4092 (LONG_LONG) st.f_bavail, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4093 (LONG_LONG) st.f_files, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4094 (LONG_LONG) st.f_ffree, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4095 (LONG_LONG) st.f_favail, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4096 (long) st.f_flag, |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4097 (long) st.f_namemax); |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4098 #endif |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4099 } |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4100 #endif /* HAVE_STATVFS */ |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4101 |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
4102 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4103 #ifdef HAVE_TEMPNAM |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4104 static char posix_tempnam__doc__[] = "\ |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4105 tempnam([dir[, prefix]]) -> string\n\ |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4106 Return a unique name for a temporary file.\n\ |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4107 The directory and a short may be specified as strings; they may be omitted\n\ |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4108 or None if not needed."; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4109 |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4110 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
4111 posix_tempnam(PyObject *self, PyObject *args) |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4112 { |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4113 PyObject *result = NULL; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4114 char *dir = NULL; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4115 char *pfx = NULL; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4116 char *name; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4117 |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4118 if (!PyArg_ParseTuple(args, "|zz:tempnam", &dir, &pfx)) |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4119 return NULL; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4120 name = tempnam(dir, pfx); |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4121 if (name == NULL) |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4122 return PyErr_NoMemory(); |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4123 result = PyString_FromString(name); |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4124 free(name); |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4125 return result; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4126 } |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4127 #endif |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4128 |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4129 |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4130 #ifdef HAVE_TMPFILE |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4131 static char posix_tmpfile__doc__[] = "\ |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4132 tmpfile() -> file object\n\ |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4133 Create a temporary file with no directory entries."; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4134 |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4135 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
4136 posix_tmpfile(PyObject *self, PyObject *args) |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4137 { |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4138 FILE *fp; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4139 |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4140 if (!PyArg_ParseTuple(args, ":tmpfile")) |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4141 return NULL; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4142 fp = tmpfile(); |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4143 if (fp == NULL) |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4144 return posix_error(); |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4145 return PyFile_FromFile(fp, "<tmpfile>", "w+", fclose); |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4146 } |
|
9939
faf351e31571
Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents:
9824
diff
changeset
|
4147 #endif |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4148 |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4149 |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4150 #ifdef HAVE_TMPNAM |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4151 static char posix_tmpnam__doc__[] = "\ |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4152 tmpnam() -> string\n\ |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4153 Return a unique name for a temporary file."; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4154 |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4155 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
4156 posix_tmpnam(PyObject *self, PyObject *args) |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4157 { |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4158 char buffer[L_tmpnam]; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4159 char *name; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4160 |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4161 if (!PyArg_ParseTuple(args, ":tmpnam")) |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4162 return NULL; |
|
11893
610d7d642917
Second attempt to fix the ctermid_r/tmpnam_r warnings: define USE_CTERMID_R
Greg Ward <gward@python.net>
parents:
11892
diff
changeset
|
4163 #ifdef USE_TMPNAM_R |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4164 name = tmpnam_r(buffer); |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4165 #else |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4166 name = tmpnam(buffer); |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4167 #endif |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4168 if (name == NULL) { |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4169 PyErr_SetObject(PyExc_OSError, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4170 Py_BuildValue("is", 0, |
|
11893
610d7d642917
Second attempt to fix the ctermid_r/tmpnam_r warnings: define USE_CTERMID_R
Greg Ward <gward@python.net>
parents:
11892
diff
changeset
|
4171 #ifdef USE_TMPNAM_R |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4172 "unexpected NULL from tmpnam_r" |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4173 #else |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4174 "unexpected NULL from tmpnam" |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4175 #endif |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4176 )); |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4177 return NULL; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4178 } |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4179 return PyString_FromString(buffer); |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4180 } |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4181 #endif |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4182 |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
4183 |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4184 /* This is used for fpathconf(), pathconf(), confstr() and sysconf(). |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4185 * It maps strings representing configuration variable names to |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4186 * integer values, allowing those functions to be called with the |
|
13620
5b727ab37092
Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
Thomas Wouters <thomas@python.org>
parents:
13601
diff
changeset
|
4187 * magic names instead of polluting the module's namespace with tons of |
|
11570
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4188 * rarely-used constants. There are three separate tables that use |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4189 * these definitions. |
|
11577
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
4190 * |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
4191 * This code is always included, even if none of the interfaces that |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
4192 * need it are included. The #if hackery needed to avoid it would be |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
4193 * sufficiently pervasive that it's not worth the loss of readability. |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4194 */ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4195 struct constdef { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4196 char *name; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4197 long value; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4198 }; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4199 |
|
11570
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4200 static int |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
4201 conv_confname(PyObject *arg, int *valuep, struct constdef *table, |
|
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
4202 size_t tablesize) |
|
11570
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4203 { |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4204 if (PyInt_Check(arg)) { |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4205 *valuep = PyInt_AS_LONG(arg); |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4206 return 1; |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4207 } |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4208 if (PyString_Check(arg)) { |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4209 /* look up the value in the table using a binary search */ |
|
13153
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
4210 size_t lo = 0; |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
4211 size_t mid; |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
4212 size_t hi = tablesize; |
|
32816ce60a49
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
13058
diff
changeset
|
4213 int cmp; |
|
11570
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4214 char *confname = PyString_AS_STRING(arg); |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4215 while (lo < hi) { |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4216 mid = (lo + hi) / 2; |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4217 cmp = strcmp(confname, table[mid].name); |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4218 if (cmp < 0) |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4219 hi = mid; |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4220 else if (cmp > 0) |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4221 lo = mid + 1; |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4222 else { |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4223 *valuep = table[mid].value; |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4224 return 1; |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4225 } |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4226 } |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4227 PyErr_SetString(PyExc_ValueError, "unrecognized configuration name"); |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4228 } |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4229 else |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4230 PyErr_SetString(PyExc_TypeError, |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4231 "configuration names must be strings or integers"); |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4232 return 0; |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4233 } |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4234 |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4235 |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4236 #if defined(HAVE_FPATHCONF) || defined(HAVE_PATHCONF) |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4237 static struct constdef posix_constants_pathconf[] = { |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4238 #ifdef _PC_ABI_AIO_XFER_MAX |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4239 {"PC_ABI_AIO_XFER_MAX", _PC_ABI_AIO_XFER_MAX}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4240 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4241 #ifdef _PC_ABI_ASYNC_IO |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4242 {"PC_ABI_ASYNC_IO", _PC_ABI_ASYNC_IO}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4243 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4244 #ifdef _PC_ASYNC_IO |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4245 {"PC_ASYNC_IO", _PC_ASYNC_IO}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4246 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4247 #ifdef _PC_CHOWN_RESTRICTED |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4248 {"PC_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4249 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4250 #ifdef _PC_FILESIZEBITS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4251 {"PC_FILESIZEBITS", _PC_FILESIZEBITS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4252 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4253 #ifdef _PC_LAST |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4254 {"PC_LAST", _PC_LAST}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4255 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4256 #ifdef _PC_LINK_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4257 {"PC_LINK_MAX", _PC_LINK_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4258 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4259 #ifdef _PC_MAX_CANON |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4260 {"PC_MAX_CANON", _PC_MAX_CANON}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4261 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4262 #ifdef _PC_MAX_INPUT |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4263 {"PC_MAX_INPUT", _PC_MAX_INPUT}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4264 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4265 #ifdef _PC_NAME_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4266 {"PC_NAME_MAX", _PC_NAME_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4267 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4268 #ifdef _PC_NO_TRUNC |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4269 {"PC_NO_TRUNC", _PC_NO_TRUNC}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4270 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4271 #ifdef _PC_PATH_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4272 {"PC_PATH_MAX", _PC_PATH_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4273 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4274 #ifdef _PC_PIPE_BUF |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4275 {"PC_PIPE_BUF", _PC_PIPE_BUF}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4276 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4277 #ifdef _PC_PRIO_IO |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4278 {"PC_PRIO_IO", _PC_PRIO_IO}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4279 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4280 #ifdef _PC_SOCK_MAXBUF |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4281 {"PC_SOCK_MAXBUF", _PC_SOCK_MAXBUF}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4282 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4283 #ifdef _PC_SYNC_IO |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4284 {"PC_SYNC_IO", _PC_SYNC_IO}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4285 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4286 #ifdef _PC_VDISABLE |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4287 {"PC_VDISABLE", _PC_VDISABLE}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4288 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4289 }; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4290 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4291 static int |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
4292 conv_path_confname(PyObject *arg, int *valuep) |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4293 { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4294 return conv_confname(arg, valuep, posix_constants_pathconf, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4295 sizeof(posix_constants_pathconf) |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4296 / sizeof(struct constdef)); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4297 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4298 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4299 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4300 #ifdef HAVE_FPATHCONF |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4301 static char posix_fpathconf__doc__[] = "\ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4302 fpathconf(fd, name) -> integer\n\ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4303 Return the configuration limit name for the file descriptor fd.\n\ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4304 If there is no limit, return -1."; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4305 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4306 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
4307 posix_fpathconf(PyObject *self, PyObject *args) |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4308 { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4309 PyObject *result = NULL; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4310 int name, fd; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4311 |
|
11570
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4312 if (PyArg_ParseTuple(args, "iO&:fpathconf", &fd, |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4313 conv_path_confname, &name)) { |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4314 long limit; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4315 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4316 errno = 0; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4317 limit = fpathconf(fd, name); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4318 if (limit == -1 && errno != 0) |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4319 posix_error(); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4320 else |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4321 result = PyInt_FromLong(limit); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4322 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4323 return result; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4324 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4325 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4326 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4327 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4328 #ifdef HAVE_PATHCONF |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4329 static char posix_pathconf__doc__[] = "\ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4330 pathconf(path, name) -> integer\n\ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4331 Return the configuration limit name for the file or directory path.\n\ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4332 If there is no limit, return -1."; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4333 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4334 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
4335 posix_pathconf(PyObject *self, PyObject *args) |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4336 { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4337 PyObject *result = NULL; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4338 int name; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4339 char *path; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4340 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4341 if (PyArg_ParseTuple(args, "sO&:pathconf", &path, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4342 conv_path_confname, &name)) { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4343 long limit; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4344 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4345 errno = 0; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4346 limit = pathconf(path, name); |
|
11570
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4347 if (limit == -1 && errno != 0) { |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4348 if (errno == EINVAL) |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4349 /* could be a path or name problem */ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4350 posix_error(); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4351 else |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4352 posix_error_with_filename(path); |
|
11570
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
4353 } |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4354 else |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4355 result = PyInt_FromLong(limit); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4356 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4357 return result; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4358 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4359 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4360 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4361 #ifdef HAVE_CONFSTR |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4362 static struct constdef posix_constants_confstr[] = { |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4363 #ifdef _CS_ARCHITECTURE |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4364 {"CS_ARCHITECTURE", _CS_ARCHITECTURE}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4365 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4366 #ifdef _CS_HOSTNAME |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4367 {"CS_HOSTNAME", _CS_HOSTNAME}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4368 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4369 #ifdef _CS_HW_PROVIDER |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4370 {"CS_HW_PROVIDER", _CS_HW_PROVIDER}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4371 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4372 #ifdef _CS_HW_SERIAL |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4373 {"CS_HW_SERIAL", _CS_HW_SERIAL}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4374 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4375 #ifdef _CS_INITTAB_NAME |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4376 {"CS_INITTAB_NAME", _CS_INITTAB_NAME}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4377 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4378 #ifdef _CS_LFS64_CFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4379 {"CS_LFS64_CFLAGS", _CS_LFS64_CFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4380 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4381 #ifdef _CS_LFS64_LDFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4382 {"CS_LFS64_LDFLAGS", _CS_LFS64_LDFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4383 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4384 #ifdef _CS_LFS64_LIBS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4385 {"CS_LFS64_LIBS", _CS_LFS64_LIBS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4386 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4387 #ifdef _CS_LFS64_LINTFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4388 {"CS_LFS64_LINTFLAGS", _CS_LFS64_LINTFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4389 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4390 #ifdef _CS_LFS_CFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4391 {"CS_LFS_CFLAGS", _CS_LFS_CFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4392 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4393 #ifdef _CS_LFS_LDFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4394 {"CS_LFS_LDFLAGS", _CS_LFS_LDFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4395 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4396 #ifdef _CS_LFS_LIBS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4397 {"CS_LFS_LIBS", _CS_LFS_LIBS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4398 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4399 #ifdef _CS_LFS_LINTFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4400 {"CS_LFS_LINTFLAGS", _CS_LFS_LINTFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4401 #endif |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4402 #ifdef _CS_MACHINE |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4403 {"CS_MACHINE", _CS_MACHINE}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4404 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4405 #ifdef _CS_PATH |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4406 {"CS_PATH", _CS_PATH}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4407 #endif |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4408 #ifdef _CS_RELEASE |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4409 {"CS_RELEASE", _CS_RELEASE}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4410 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4411 #ifdef _CS_SRPC_DOMAIN |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4412 {"CS_SRPC_DOMAIN", _CS_SRPC_DOMAIN}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4413 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4414 #ifdef _CS_SYSNAME |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4415 {"CS_SYSNAME", _CS_SYSNAME}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4416 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4417 #ifdef _CS_VERSION |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4418 {"CS_VERSION", _CS_VERSION}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4419 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4420 #ifdef _CS_XBS5_ILP32_OFF32_CFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4421 {"CS_XBS5_ILP32_OFF32_CFLAGS", _CS_XBS5_ILP32_OFF32_CFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4422 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4423 #ifdef _CS_XBS5_ILP32_OFF32_LDFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4424 {"CS_XBS5_ILP32_OFF32_LDFLAGS", _CS_XBS5_ILP32_OFF32_LDFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4425 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4426 #ifdef _CS_XBS5_ILP32_OFF32_LIBS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4427 {"CS_XBS5_ILP32_OFF32_LIBS", _CS_XBS5_ILP32_OFF32_LIBS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4428 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4429 #ifdef _CS_XBS5_ILP32_OFF32_LINTFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4430 {"CS_XBS5_ILP32_OFF32_LINTFLAGS", _CS_XBS5_ILP32_OFF32_LINTFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4431 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4432 #ifdef _CS_XBS5_ILP32_OFFBIG_CFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4433 {"CS_XBS5_ILP32_OFFBIG_CFLAGS", _CS_XBS5_ILP32_OFFBIG_CFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4434 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4435 #ifdef _CS_XBS5_ILP32_OFFBIG_LDFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4436 {"CS_XBS5_ILP32_OFFBIG_LDFLAGS", _CS_XBS5_ILP32_OFFBIG_LDFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4437 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4438 #ifdef _CS_XBS5_ILP32_OFFBIG_LIBS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4439 {"CS_XBS5_ILP32_OFFBIG_LIBS", _CS_XBS5_ILP32_OFFBIG_LIBS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4440 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4441 #ifdef _CS_XBS5_ILP32_OFFBIG_LINTFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4442 {"CS_XBS5_ILP32_OFFBIG_LINTFLAGS", _CS_XBS5_ILP32_OFFBIG_LINTFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4443 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4444 #ifdef _CS_XBS5_LP64_OFF64_CFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4445 {"CS_XBS5_LP64_OFF64_CFLAGS", _CS_XBS5_LP64_OFF64_CFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4446 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4447 #ifdef _CS_XBS5_LP64_OFF64_LDFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4448 {"CS_XBS5_LP64_OFF64_LDFLAGS", _CS_XBS5_LP64_OFF64_LDFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4449 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4450 #ifdef _CS_XBS5_LP64_OFF64_LIBS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4451 {"CS_XBS5_LP64_OFF64_LIBS", _CS_XBS5_LP64_OFF64_LIBS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4452 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4453 #ifdef _CS_XBS5_LP64_OFF64_LINTFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4454 {"CS_XBS5_LP64_OFF64_LINTFLAGS", _CS_XBS5_LP64_OFF64_LINTFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4455 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4456 #ifdef _CS_XBS5_LPBIG_OFFBIG_CFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4457 {"CS_XBS5_LPBIG_OFFBIG_CFLAGS", _CS_XBS5_LPBIG_OFFBIG_CFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4458 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4459 #ifdef _CS_XBS5_LPBIG_OFFBIG_LDFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4460 {"CS_XBS5_LPBIG_OFFBIG_LDFLAGS", _CS_XBS5_LPBIG_OFFBIG_LDFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4461 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4462 #ifdef _CS_XBS5_LPBIG_OFFBIG_LIBS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4463 {"CS_XBS5_LPBIG_OFFBIG_LIBS", _CS_XBS5_LPBIG_OFFBIG_LIBS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4464 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4465 #ifdef _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4466 {"CS_XBS5_LPBIG_OFFBIG_LINTFLAGS", _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4467 #endif |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4468 #ifdef _MIPS_CS_AVAIL_PROCESSORS |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4469 {"MIPS_CS_AVAIL_PROCESSORS", _MIPS_CS_AVAIL_PROCESSORS}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4470 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4471 #ifdef _MIPS_CS_BASE |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4472 {"MIPS_CS_BASE", _MIPS_CS_BASE}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4473 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4474 #ifdef _MIPS_CS_HOSTID |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4475 {"MIPS_CS_HOSTID", _MIPS_CS_HOSTID}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4476 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4477 #ifdef _MIPS_CS_HW_NAME |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4478 {"MIPS_CS_HW_NAME", _MIPS_CS_HW_NAME}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4479 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4480 #ifdef _MIPS_CS_NUM_PROCESSORS |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4481 {"MIPS_CS_NUM_PROCESSORS", _MIPS_CS_NUM_PROCESSORS}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4482 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4483 #ifdef _MIPS_CS_OSREL_MAJ |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4484 {"MIPS_CS_OSREL_MAJ", _MIPS_CS_OSREL_MAJ}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4485 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4486 #ifdef _MIPS_CS_OSREL_MIN |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4487 {"MIPS_CS_OSREL_MIN", _MIPS_CS_OSREL_MIN}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4488 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4489 #ifdef _MIPS_CS_OSREL_PATCH |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4490 {"MIPS_CS_OSREL_PATCH", _MIPS_CS_OSREL_PATCH}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4491 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4492 #ifdef _MIPS_CS_OS_NAME |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4493 {"MIPS_CS_OS_NAME", _MIPS_CS_OS_NAME}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4494 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4495 #ifdef _MIPS_CS_OS_PROVIDER |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4496 {"MIPS_CS_OS_PROVIDER", _MIPS_CS_OS_PROVIDER}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4497 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4498 #ifdef _MIPS_CS_PROCESSORS |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4499 {"MIPS_CS_PROCESSORS", _MIPS_CS_PROCESSORS}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4500 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4501 #ifdef _MIPS_CS_SERIAL |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4502 {"MIPS_CS_SERIAL", _MIPS_CS_SERIAL}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4503 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4504 #ifdef _MIPS_CS_VENDOR |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4505 {"MIPS_CS_VENDOR", _MIPS_CS_VENDOR}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4506 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4507 }; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4508 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4509 static int |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
4510 conv_confstr_confname(PyObject *arg, int *valuep) |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4511 { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4512 return conv_confname(arg, valuep, posix_constants_confstr, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4513 sizeof(posix_constants_confstr) |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4514 / sizeof(struct constdef)); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4515 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4516 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4517 static char posix_confstr__doc__[] = "\ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4518 confstr(name) -> string\n\ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4519 Return a string-valued system configuration variable."; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4520 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4521 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
4522 posix_confstr(PyObject *self, PyObject *args) |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4523 { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4524 PyObject *result = NULL; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4525 int name; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4526 char buffer[64]; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4527 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4528 if (PyArg_ParseTuple(args, "O&:confstr", conv_confstr_confname, &name)) { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4529 int len = confstr(name, buffer, sizeof(buffer)); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4530 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4531 errno = 0; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4532 if (len == 0) { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4533 if (errno != 0) |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4534 posix_error(); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4535 else |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4536 result = PyString_FromString(""); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4537 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4538 else { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4539 if (len >= sizeof(buffer)) { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4540 result = PyString_FromStringAndSize(NULL, len); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4541 if (result != NULL) |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4542 confstr(name, PyString_AS_STRING(result), len+1); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4543 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4544 else |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4545 result = PyString_FromString(buffer); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4546 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4547 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4548 return result; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4549 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4550 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4551 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4552 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4553 #ifdef HAVE_SYSCONF |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4554 static struct constdef posix_constants_sysconf[] = { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4555 #ifdef _SC_2_CHAR_TERM |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4556 {"SC_2_CHAR_TERM", _SC_2_CHAR_TERM}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4557 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4558 #ifdef _SC_2_C_BIND |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4559 {"SC_2_C_BIND", _SC_2_C_BIND}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4560 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4561 #ifdef _SC_2_C_DEV |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4562 {"SC_2_C_DEV", _SC_2_C_DEV}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4563 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4564 #ifdef _SC_2_C_VERSION |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4565 {"SC_2_C_VERSION", _SC_2_C_VERSION}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4566 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4567 #ifdef _SC_2_FORT_DEV |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4568 {"SC_2_FORT_DEV", _SC_2_FORT_DEV}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4569 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4570 #ifdef _SC_2_FORT_RUN |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4571 {"SC_2_FORT_RUN", _SC_2_FORT_RUN}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4572 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4573 #ifdef _SC_2_LOCALEDEF |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4574 {"SC_2_LOCALEDEF", _SC_2_LOCALEDEF}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4575 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4576 #ifdef _SC_2_SW_DEV |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4577 {"SC_2_SW_DEV", _SC_2_SW_DEV}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4578 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4579 #ifdef _SC_2_UPE |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4580 {"SC_2_UPE", _SC_2_UPE}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4581 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4582 #ifdef _SC_2_VERSION |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4583 {"SC_2_VERSION", _SC_2_VERSION}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4584 #endif |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4585 #ifdef _SC_ABI_ASYNCHRONOUS_IO |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4586 {"SC_ABI_ASYNCHRONOUS_IO", _SC_ABI_ASYNCHRONOUS_IO}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4587 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4588 #ifdef _SC_ACL |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4589 {"SC_ACL", _SC_ACL}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4590 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4591 #ifdef _SC_AIO_LISTIO_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4592 {"SC_AIO_LISTIO_MAX", _SC_AIO_LISTIO_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4593 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4594 #ifdef _SC_AIO_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4595 {"SC_AIO_MAX", _SC_AIO_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4596 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4597 #ifdef _SC_AIO_PRIO_DELTA_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4598 {"SC_AIO_PRIO_DELTA_MAX", _SC_AIO_PRIO_DELTA_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4599 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4600 #ifdef _SC_ARG_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4601 {"SC_ARG_MAX", _SC_ARG_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4602 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4603 #ifdef _SC_ASYNCHRONOUS_IO |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4604 {"SC_ASYNCHRONOUS_IO", _SC_ASYNCHRONOUS_IO}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4605 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4606 #ifdef _SC_ATEXIT_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4607 {"SC_ATEXIT_MAX", _SC_ATEXIT_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4608 #endif |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4609 #ifdef _SC_AUDIT |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4610 {"SC_AUDIT", _SC_AUDIT}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4611 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4612 #ifdef _SC_AVPHYS_PAGES |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4613 {"SC_AVPHYS_PAGES", _SC_AVPHYS_PAGES}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4614 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4615 #ifdef _SC_BC_BASE_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4616 {"SC_BC_BASE_MAX", _SC_BC_BASE_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4617 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4618 #ifdef _SC_BC_DIM_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4619 {"SC_BC_DIM_MAX", _SC_BC_DIM_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4620 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4621 #ifdef _SC_BC_SCALE_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4622 {"SC_BC_SCALE_MAX", _SC_BC_SCALE_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4623 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4624 #ifdef _SC_BC_STRING_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4625 {"SC_BC_STRING_MAX", _SC_BC_STRING_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4626 #endif |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4627 #ifdef _SC_CAP |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4628 {"SC_CAP", _SC_CAP}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4629 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4630 #ifdef _SC_CHARCLASS_NAME_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4631 {"SC_CHARCLASS_NAME_MAX", _SC_CHARCLASS_NAME_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4632 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4633 #ifdef _SC_CHAR_BIT |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4634 {"SC_CHAR_BIT", _SC_CHAR_BIT}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4635 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4636 #ifdef _SC_CHAR_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4637 {"SC_CHAR_MAX", _SC_CHAR_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4638 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4639 #ifdef _SC_CHAR_MIN |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4640 {"SC_CHAR_MIN", _SC_CHAR_MIN}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4641 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4642 #ifdef _SC_CHILD_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4643 {"SC_CHILD_MAX", _SC_CHILD_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4644 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4645 #ifdef _SC_CLK_TCK |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4646 {"SC_CLK_TCK", _SC_CLK_TCK}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4647 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4648 #ifdef _SC_COHER_BLKSZ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4649 {"SC_COHER_BLKSZ", _SC_COHER_BLKSZ}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4650 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4651 #ifdef _SC_COLL_WEIGHTS_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4652 {"SC_COLL_WEIGHTS_MAX", _SC_COLL_WEIGHTS_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4653 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4654 #ifdef _SC_DCACHE_ASSOC |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4655 {"SC_DCACHE_ASSOC", _SC_DCACHE_ASSOC}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4656 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4657 #ifdef _SC_DCACHE_BLKSZ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4658 {"SC_DCACHE_BLKSZ", _SC_DCACHE_BLKSZ}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4659 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4660 #ifdef _SC_DCACHE_LINESZ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4661 {"SC_DCACHE_LINESZ", _SC_DCACHE_LINESZ}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4662 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4663 #ifdef _SC_DCACHE_SZ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4664 {"SC_DCACHE_SZ", _SC_DCACHE_SZ}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4665 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4666 #ifdef _SC_DCACHE_TBLKSZ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4667 {"SC_DCACHE_TBLKSZ", _SC_DCACHE_TBLKSZ}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4668 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4669 #ifdef _SC_DELAYTIMER_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4670 {"SC_DELAYTIMER_MAX", _SC_DELAYTIMER_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4671 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4672 #ifdef _SC_EQUIV_CLASS_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4673 {"SC_EQUIV_CLASS_MAX", _SC_EQUIV_CLASS_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4674 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4675 #ifdef _SC_EXPR_NEST_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4676 {"SC_EXPR_NEST_MAX", _SC_EXPR_NEST_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4677 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4678 #ifdef _SC_FSYNC |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4679 {"SC_FSYNC", _SC_FSYNC}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4680 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4681 #ifdef _SC_GETGR_R_SIZE_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4682 {"SC_GETGR_R_SIZE_MAX", _SC_GETGR_R_SIZE_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4683 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4684 #ifdef _SC_GETPW_R_SIZE_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4685 {"SC_GETPW_R_SIZE_MAX", _SC_GETPW_R_SIZE_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4686 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4687 #ifdef _SC_ICACHE_ASSOC |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4688 {"SC_ICACHE_ASSOC", _SC_ICACHE_ASSOC}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4689 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4690 #ifdef _SC_ICACHE_BLKSZ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4691 {"SC_ICACHE_BLKSZ", _SC_ICACHE_BLKSZ}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4692 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4693 #ifdef _SC_ICACHE_LINESZ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4694 {"SC_ICACHE_LINESZ", _SC_ICACHE_LINESZ}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4695 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4696 #ifdef _SC_ICACHE_SZ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4697 {"SC_ICACHE_SZ", _SC_ICACHE_SZ}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4698 #endif |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4699 #ifdef _SC_INF |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4700 {"SC_INF", _SC_INF}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4701 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4702 #ifdef _SC_INT_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4703 {"SC_INT_MAX", _SC_INT_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4704 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4705 #ifdef _SC_INT_MIN |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4706 {"SC_INT_MIN", _SC_INT_MIN}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4707 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4708 #ifdef _SC_IOV_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4709 {"SC_IOV_MAX", _SC_IOV_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4710 #endif |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4711 #ifdef _SC_IP_SECOPTS |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4712 {"SC_IP_SECOPTS", _SC_IP_SECOPTS}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4713 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4714 #ifdef _SC_JOB_CONTROL |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4715 {"SC_JOB_CONTROL", _SC_JOB_CONTROL}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4716 #endif |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4717 #ifdef _SC_KERN_POINTERS |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4718 {"SC_KERN_POINTERS", _SC_KERN_POINTERS}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4719 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4720 #ifdef _SC_KERN_SIM |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4721 {"SC_KERN_SIM", _SC_KERN_SIM}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4722 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4723 #ifdef _SC_LINE_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4724 {"SC_LINE_MAX", _SC_LINE_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4725 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4726 #ifdef _SC_LOGIN_NAME_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4727 {"SC_LOGIN_NAME_MAX", _SC_LOGIN_NAME_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4728 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4729 #ifdef _SC_LOGNAME_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4730 {"SC_LOGNAME_MAX", _SC_LOGNAME_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4731 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4732 #ifdef _SC_LONG_BIT |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4733 {"SC_LONG_BIT", _SC_LONG_BIT}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4734 #endif |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4735 #ifdef _SC_MAC |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4736 {"SC_MAC", _SC_MAC}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4737 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4738 #ifdef _SC_MAPPED_FILES |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4739 {"SC_MAPPED_FILES", _SC_MAPPED_FILES}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4740 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4741 #ifdef _SC_MAXPID |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4742 {"SC_MAXPID", _SC_MAXPID}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4743 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4744 #ifdef _SC_MB_LEN_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4745 {"SC_MB_LEN_MAX", _SC_MB_LEN_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4746 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4747 #ifdef _SC_MEMLOCK |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4748 {"SC_MEMLOCK", _SC_MEMLOCK}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4749 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4750 #ifdef _SC_MEMLOCK_RANGE |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4751 {"SC_MEMLOCK_RANGE", _SC_MEMLOCK_RANGE}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4752 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4753 #ifdef _SC_MEMORY_PROTECTION |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4754 {"SC_MEMORY_PROTECTION", _SC_MEMORY_PROTECTION}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4755 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4756 #ifdef _SC_MESSAGE_PASSING |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4757 {"SC_MESSAGE_PASSING", _SC_MESSAGE_PASSING}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4758 #endif |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4759 #ifdef _SC_MMAP_FIXED_ALIGNMENT |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4760 {"SC_MMAP_FIXED_ALIGNMENT", _SC_MMAP_FIXED_ALIGNMENT}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4761 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4762 #ifdef _SC_MQ_OPEN_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4763 {"SC_MQ_OPEN_MAX", _SC_MQ_OPEN_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4764 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4765 #ifdef _SC_MQ_PRIO_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4766 {"SC_MQ_PRIO_MAX", _SC_MQ_PRIO_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4767 #endif |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4768 #ifdef _SC_NACLS_MAX |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4769 {"SC_NACLS_MAX", _SC_NACLS_MAX}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4770 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4771 #ifdef _SC_NGROUPS_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4772 {"SC_NGROUPS_MAX", _SC_NGROUPS_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4773 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4774 #ifdef _SC_NL_ARGMAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4775 {"SC_NL_ARGMAX", _SC_NL_ARGMAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4776 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4777 #ifdef _SC_NL_LANGMAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4778 {"SC_NL_LANGMAX", _SC_NL_LANGMAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4779 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4780 #ifdef _SC_NL_MSGMAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4781 {"SC_NL_MSGMAX", _SC_NL_MSGMAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4782 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4783 #ifdef _SC_NL_NMAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4784 {"SC_NL_NMAX", _SC_NL_NMAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4785 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4786 #ifdef _SC_NL_SETMAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4787 {"SC_NL_SETMAX", _SC_NL_SETMAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4788 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4789 #ifdef _SC_NL_TEXTMAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4790 {"SC_NL_TEXTMAX", _SC_NL_TEXTMAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4791 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4792 #ifdef _SC_NPROCESSORS_CONF |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4793 {"SC_NPROCESSORS_CONF", _SC_NPROCESSORS_CONF}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4794 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4795 #ifdef _SC_NPROCESSORS_ONLN |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4796 {"SC_NPROCESSORS_ONLN", _SC_NPROCESSORS_ONLN}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4797 #endif |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4798 #ifdef _SC_NPROC_CONF |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4799 {"SC_NPROC_CONF", _SC_NPROC_CONF}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4800 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4801 #ifdef _SC_NPROC_ONLN |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4802 {"SC_NPROC_ONLN", _SC_NPROC_ONLN}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4803 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4804 #ifdef _SC_NZERO |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4805 {"SC_NZERO", _SC_NZERO}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4806 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4807 #ifdef _SC_OPEN_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4808 {"SC_OPEN_MAX", _SC_OPEN_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4809 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4810 #ifdef _SC_PAGESIZE |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4811 {"SC_PAGESIZE", _SC_PAGESIZE}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4812 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4813 #ifdef _SC_PAGE_SIZE |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4814 {"SC_PAGE_SIZE", _SC_PAGE_SIZE}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4815 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4816 #ifdef _SC_PASS_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4817 {"SC_PASS_MAX", _SC_PASS_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4818 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4819 #ifdef _SC_PHYS_PAGES |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4820 {"SC_PHYS_PAGES", _SC_PHYS_PAGES}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4821 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4822 #ifdef _SC_PII |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4823 {"SC_PII", _SC_PII}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4824 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4825 #ifdef _SC_PII_INTERNET |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4826 {"SC_PII_INTERNET", _SC_PII_INTERNET}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4827 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4828 #ifdef _SC_PII_INTERNET_DGRAM |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4829 {"SC_PII_INTERNET_DGRAM", _SC_PII_INTERNET_DGRAM}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4830 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4831 #ifdef _SC_PII_INTERNET_STREAM |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4832 {"SC_PII_INTERNET_STREAM", _SC_PII_INTERNET_STREAM}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4833 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4834 #ifdef _SC_PII_OSI |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4835 {"SC_PII_OSI", _SC_PII_OSI}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4836 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4837 #ifdef _SC_PII_OSI_CLTS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4838 {"SC_PII_OSI_CLTS", _SC_PII_OSI_CLTS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4839 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4840 #ifdef _SC_PII_OSI_COTS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4841 {"SC_PII_OSI_COTS", _SC_PII_OSI_COTS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4842 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4843 #ifdef _SC_PII_OSI_M |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4844 {"SC_PII_OSI_M", _SC_PII_OSI_M}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4845 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4846 #ifdef _SC_PII_SOCKET |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4847 {"SC_PII_SOCKET", _SC_PII_SOCKET}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4848 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4849 #ifdef _SC_PII_XTI |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4850 {"SC_PII_XTI", _SC_PII_XTI}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4851 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4852 #ifdef _SC_POLL |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4853 {"SC_POLL", _SC_POLL}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4854 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4855 #ifdef _SC_PRIORITIZED_IO |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4856 {"SC_PRIORITIZED_IO", _SC_PRIORITIZED_IO}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4857 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4858 #ifdef _SC_PRIORITY_SCHEDULING |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4859 {"SC_PRIORITY_SCHEDULING", _SC_PRIORITY_SCHEDULING}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4860 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4861 #ifdef _SC_REALTIME_SIGNALS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4862 {"SC_REALTIME_SIGNALS", _SC_REALTIME_SIGNALS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4863 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4864 #ifdef _SC_RE_DUP_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4865 {"SC_RE_DUP_MAX", _SC_RE_DUP_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4866 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4867 #ifdef _SC_RTSIG_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4868 {"SC_RTSIG_MAX", _SC_RTSIG_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4869 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4870 #ifdef _SC_SAVED_IDS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4871 {"SC_SAVED_IDS", _SC_SAVED_IDS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4872 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4873 #ifdef _SC_SCHAR_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4874 {"SC_SCHAR_MAX", _SC_SCHAR_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4875 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4876 #ifdef _SC_SCHAR_MIN |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4877 {"SC_SCHAR_MIN", _SC_SCHAR_MIN}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4878 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4879 #ifdef _SC_SELECT |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4880 {"SC_SELECT", _SC_SELECT}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4881 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4882 #ifdef _SC_SEMAPHORES |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4883 {"SC_SEMAPHORES", _SC_SEMAPHORES}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4884 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4885 #ifdef _SC_SEM_NSEMS_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4886 {"SC_SEM_NSEMS_MAX", _SC_SEM_NSEMS_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4887 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4888 #ifdef _SC_SEM_VALUE_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4889 {"SC_SEM_VALUE_MAX", _SC_SEM_VALUE_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4890 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4891 #ifdef _SC_SHARED_MEMORY_OBJECTS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4892 {"SC_SHARED_MEMORY_OBJECTS", _SC_SHARED_MEMORY_OBJECTS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4893 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4894 #ifdef _SC_SHRT_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4895 {"SC_SHRT_MAX", _SC_SHRT_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4896 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4897 #ifdef _SC_SHRT_MIN |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4898 {"SC_SHRT_MIN", _SC_SHRT_MIN}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4899 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4900 #ifdef _SC_SIGQUEUE_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4901 {"SC_SIGQUEUE_MAX", _SC_SIGQUEUE_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4902 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4903 #ifdef _SC_SIGRT_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4904 {"SC_SIGRT_MAX", _SC_SIGRT_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4905 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4906 #ifdef _SC_SIGRT_MIN |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4907 {"SC_SIGRT_MIN", _SC_SIGRT_MIN}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4908 #endif |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4909 #ifdef _SC_SOFTPOWER |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4910 {"SC_SOFTPOWER", _SC_SOFTPOWER}, |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
4911 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4912 #ifdef _SC_SPLIT_CACHE |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4913 {"SC_SPLIT_CACHE", _SC_SPLIT_CACHE}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4914 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4915 #ifdef _SC_SSIZE_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4916 {"SC_SSIZE_MAX", _SC_SSIZE_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4917 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4918 #ifdef _SC_STACK_PROT |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4919 {"SC_STACK_PROT", _SC_STACK_PROT}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4920 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4921 #ifdef _SC_STREAM_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4922 {"SC_STREAM_MAX", _SC_STREAM_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4923 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4924 #ifdef _SC_SYNCHRONIZED_IO |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4925 {"SC_SYNCHRONIZED_IO", _SC_SYNCHRONIZED_IO}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4926 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4927 #ifdef _SC_THREADS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4928 {"SC_THREADS", _SC_THREADS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4929 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4930 #ifdef _SC_THREAD_ATTR_STACKADDR |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4931 {"SC_THREAD_ATTR_STACKADDR", _SC_THREAD_ATTR_STACKADDR}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4932 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4933 #ifdef _SC_THREAD_ATTR_STACKSIZE |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4934 {"SC_THREAD_ATTR_STACKSIZE", _SC_THREAD_ATTR_STACKSIZE}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4935 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4936 #ifdef _SC_THREAD_DESTRUCTOR_ITERATIONS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4937 {"SC_THREAD_DESTRUCTOR_ITERATIONS", _SC_THREAD_DESTRUCTOR_ITERATIONS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4938 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4939 #ifdef _SC_THREAD_KEYS_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4940 {"SC_THREAD_KEYS_MAX", _SC_THREAD_KEYS_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4941 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4942 #ifdef _SC_THREAD_PRIORITY_SCHEDULING |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4943 {"SC_THREAD_PRIORITY_SCHEDULING", _SC_THREAD_PRIORITY_SCHEDULING}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4944 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4945 #ifdef _SC_THREAD_PRIO_INHERIT |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4946 {"SC_THREAD_PRIO_INHERIT", _SC_THREAD_PRIO_INHERIT}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4947 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4948 #ifdef _SC_THREAD_PRIO_PROTECT |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4949 {"SC_THREAD_PRIO_PROTECT", _SC_THREAD_PRIO_PROTECT}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4950 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4951 #ifdef _SC_THREAD_PROCESS_SHARED |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4952 {"SC_THREAD_PROCESS_SHARED", _SC_THREAD_PROCESS_SHARED}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4953 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4954 #ifdef _SC_THREAD_SAFE_FUNCTIONS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4955 {"SC_THREAD_SAFE_FUNCTIONS", _SC_THREAD_SAFE_FUNCTIONS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4956 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4957 #ifdef _SC_THREAD_STACK_MIN |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4958 {"SC_THREAD_STACK_MIN", _SC_THREAD_STACK_MIN}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4959 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4960 #ifdef _SC_THREAD_THREADS_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4961 {"SC_THREAD_THREADS_MAX", _SC_THREAD_THREADS_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4962 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4963 #ifdef _SC_TIMERS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4964 {"SC_TIMERS", _SC_TIMERS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4965 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4966 #ifdef _SC_TIMER_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4967 {"SC_TIMER_MAX", _SC_TIMER_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4968 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4969 #ifdef _SC_TTY_NAME_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4970 {"SC_TTY_NAME_MAX", _SC_TTY_NAME_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4971 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4972 #ifdef _SC_TZNAME_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4973 {"SC_TZNAME_MAX", _SC_TZNAME_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4974 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4975 #ifdef _SC_T_IOV_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4976 {"SC_T_IOV_MAX", _SC_T_IOV_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4977 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4978 #ifdef _SC_UCHAR_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4979 {"SC_UCHAR_MAX", _SC_UCHAR_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4980 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4981 #ifdef _SC_UINT_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4982 {"SC_UINT_MAX", _SC_UINT_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4983 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4984 #ifdef _SC_UIO_MAXIOV |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4985 {"SC_UIO_MAXIOV", _SC_UIO_MAXIOV}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4986 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4987 #ifdef _SC_ULONG_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4988 {"SC_ULONG_MAX", _SC_ULONG_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4989 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4990 #ifdef _SC_USHRT_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4991 {"SC_USHRT_MAX", _SC_USHRT_MAX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4992 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4993 #ifdef _SC_VERSION |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4994 {"SC_VERSION", _SC_VERSION}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4995 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4996 #ifdef _SC_WORD_BIT |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4997 {"SC_WORD_BIT", _SC_WORD_BIT}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4998 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
4999 #ifdef _SC_XBS5_ILP32_OFF32 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5000 {"SC_XBS5_ILP32_OFF32", _SC_XBS5_ILP32_OFF32}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5001 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5002 #ifdef _SC_XBS5_ILP32_OFFBIG |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5003 {"SC_XBS5_ILP32_OFFBIG", _SC_XBS5_ILP32_OFFBIG}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5004 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5005 #ifdef _SC_XBS5_LP64_OFF64 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5006 {"SC_XBS5_LP64_OFF64", _SC_XBS5_LP64_OFF64}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5007 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5008 #ifdef _SC_XBS5_LPBIG_OFFBIG |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5009 {"SC_XBS5_LPBIG_OFFBIG", _SC_XBS5_LPBIG_OFFBIG}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5010 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5011 #ifdef _SC_XOPEN_CRYPT |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5012 {"SC_XOPEN_CRYPT", _SC_XOPEN_CRYPT}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5013 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5014 #ifdef _SC_XOPEN_ENH_I18N |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5015 {"SC_XOPEN_ENH_I18N", _SC_XOPEN_ENH_I18N}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5016 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5017 #ifdef _SC_XOPEN_LEGACY |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5018 {"SC_XOPEN_LEGACY", _SC_XOPEN_LEGACY}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5019 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5020 #ifdef _SC_XOPEN_REALTIME |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5021 {"SC_XOPEN_REALTIME", _SC_XOPEN_REALTIME}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5022 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5023 #ifdef _SC_XOPEN_REALTIME_THREADS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5024 {"SC_XOPEN_REALTIME_THREADS", _SC_XOPEN_REALTIME_THREADS}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5025 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5026 #ifdef _SC_XOPEN_SHM |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5027 {"SC_XOPEN_SHM", _SC_XOPEN_SHM}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5028 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5029 #ifdef _SC_XOPEN_UNIX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5030 {"SC_XOPEN_UNIX", _SC_XOPEN_UNIX}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5031 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5032 #ifdef _SC_XOPEN_VERSION |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5033 {"SC_XOPEN_VERSION", _SC_XOPEN_VERSION}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5034 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5035 #ifdef _SC_XOPEN_XCU_VERSION |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5036 {"SC_XOPEN_XCU_VERSION", _SC_XOPEN_XCU_VERSION}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5037 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5038 #ifdef _SC_XOPEN_XPG2 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5039 {"SC_XOPEN_XPG2", _SC_XOPEN_XPG2}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5040 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5041 #ifdef _SC_XOPEN_XPG3 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5042 {"SC_XOPEN_XPG3", _SC_XOPEN_XPG3}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5043 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5044 #ifdef _SC_XOPEN_XPG4 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5045 {"SC_XOPEN_XPG4", _SC_XOPEN_XPG4}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5046 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5047 }; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5048 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5049 static int |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
5050 conv_sysconf_confname(PyObject *arg, int *valuep) |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5051 { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5052 return conv_confname(arg, valuep, posix_constants_sysconf, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5053 sizeof(posix_constants_sysconf) |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5054 / sizeof(struct constdef)); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5055 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5056 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5057 static char posix_sysconf__doc__[] = "\ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5058 sysconf(name) -> integer\n\ |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5059 Return an integer-valued system configuration variable."; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5060 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5061 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
5062 posix_sysconf(PyObject *self, PyObject *args) |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5063 { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5064 PyObject *result = NULL; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5065 int name; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5066 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5067 if (PyArg_ParseTuple(args, "O&:sysconf", conv_sysconf_confname, &name)) { |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5068 int value; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5069 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5070 errno = 0; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5071 value = sysconf(name); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5072 if (value == -1 && errno != 0) |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5073 posix_error(); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5074 else |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5075 result = PyInt_FromLong(value); |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5076 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5077 return result; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5078 } |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5079 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5080 |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5081 |
|
11577
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5082 /* This code is used to ensure that the tables of configuration value names |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5083 * are in sorted order as required by conv_confname(), and also to build the |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5084 * the exported dictionaries that are used to publish information about the |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5085 * names available on the host platform. |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5086 * |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5087 * Sorting the table at runtime ensures that the table is properly ordered |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5088 * when used, even for platforms we're not able to test on. It also makes |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5089 * it easier to add additional entries to the tables. |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5090 */ |
|
11577
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5091 |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5092 static int |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
5093 cmp_constdefs(const void *v1, const void *v2) |
|
11577
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5094 { |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5095 const struct constdef *c1 = |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5096 (const struct constdef *) v1; |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5097 const struct constdef *c2 = |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5098 (const struct constdef *) v2; |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5099 |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5100 return strcmp(c1->name, c2->name); |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5101 } |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5102 |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5103 static int |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
5104 setup_confname_table(struct constdef *table, size_t tablesize, |
|
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
5105 char *tablename, PyObject *moddict) |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5106 { |
|
11577
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5107 PyObject *d = NULL; |
|
12393
a0498b15244c
setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents:
12150
diff
changeset
|
5108 size_t i; |
|
a0498b15244c
setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents:
12150
diff
changeset
|
5109 int status; |
|
11577
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5110 |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5111 qsort(table, tablesize, sizeof(struct constdef), cmp_constdefs); |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5112 d = PyDict_New(); |
|
12393
a0498b15244c
setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents:
12150
diff
changeset
|
5113 if (d == NULL) |
|
a0498b15244c
setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents:
12150
diff
changeset
|
5114 return -1; |
|
a0498b15244c
setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents:
12150
diff
changeset
|
5115 |
|
a0498b15244c
setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents:
12150
diff
changeset
|
5116 for (i=0; i < tablesize; ++i) { |
|
a0498b15244c
setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents:
12150
diff
changeset
|
5117 PyObject *o = PyInt_FromLong(table[i].value); |
|
a0498b15244c
setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents:
12150
diff
changeset
|
5118 if (o == NULL || PyDict_SetItemString(d, table[i].name, o) == -1) { |
|
a0498b15244c
setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents:
12150
diff
changeset
|
5119 Py_XDECREF(o); |
|
a0498b15244c
setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents:
12150
diff
changeset
|
5120 Py_DECREF(d); |
|
a0498b15244c
setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents:
12150
diff
changeset
|
5121 return -1; |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5122 } |
|
12393
a0498b15244c
setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents:
12150
diff
changeset
|
5123 Py_DECREF(o); |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5124 } |
|
12393
a0498b15244c
setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents:
12150
diff
changeset
|
5125 status = PyDict_SetItemString(moddict, tablename, d); |
|
a0498b15244c
setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents:
12150
diff
changeset
|
5126 Py_DECREF(d); |
|
a0498b15244c
setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents:
12150
diff
changeset
|
5127 return status; |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5128 } |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5129 |
|
11577
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5130 /* Return -1 on failure, 0 on success. */ |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5131 static int |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
5132 setup_confname_tables(PyObject *moddict) |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5133 { |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5134 #if defined(HAVE_FPATHCONF) || defined(HAVE_PATHCONF) |
|
11577
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5135 if (setup_confname_table(posix_constants_pathconf, |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5136 sizeof(posix_constants_pathconf) |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5137 / sizeof(struct constdef), |
|
11577
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5138 "pathconf_names", moddict)) |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5139 return -1; |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5140 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5141 #ifdef HAVE_CONFSTR |
|
11577
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5142 if (setup_confname_table(posix_constants_confstr, |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5143 sizeof(posix_constants_confstr) |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5144 / sizeof(struct constdef), |
|
11577
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5145 "confstr_names", moddict)) |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5146 return -1; |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5147 #endif |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5148 #ifdef HAVE_SYSCONF |
|
11577
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5149 if (setup_confname_table(posix_constants_sysconf, |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5150 sizeof(posix_constants_sysconf) |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5151 / sizeof(struct constdef), |
|
11577
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5152 "sysconf_names", moddict)) |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5153 return -1; |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5154 #endif |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5155 return 0; |
|
11574
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5156 } |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5157 |
|
fd0d31c346b2
Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents:
11570
diff
changeset
|
5158 |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5159 static char posix_abort__doc__[] = "\ |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5160 abort() -> does not return!\n\ |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5161 Abort the interpreter immediately. This 'dumps core' or otherwise fails\n\ |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5162 in the hardest way possible on the hosting operating system."; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5163 |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5164 static PyObject * |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
5165 posix_abort(PyObject *self, PyObject *args) |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5166 { |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5167 if (!PyArg_ParseTuple(args, ":abort")) |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5168 return NULL; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5169 abort(); |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5170 /*NOTREACHED*/ |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5171 Py_FatalError("abort() called from Python code didn't abort!"); |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5172 return NULL; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5173 } |
|
11577
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5174 |
|
14752
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5175 #ifdef MS_WIN32 |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5176 static char win32_startfile__doc__[] = "\ |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5177 startfile(filepath) - Start a file with its associated application.\n\ |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5178 \n\ |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5179 This acts like double-clicking the file in Explorer, or giving the file\n\ |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5180 name as an argument to the DOS \"start\" command: the file is opened\n\ |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5181 with whatever application (if any) its extension is associated.\n\ |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5182 \n\ |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5183 startfile returns as soon as the associated application is launched.\n\ |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5184 There is no option to wait for the application to close, and no way\n\ |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5185 to retrieve the application's exit status.\n\ |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5186 \n\ |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5187 The filepath is relative to the current directory. If you want to use\n\ |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5188 an absolute path, make sure the first character is not a slash (\"/\");\n\ |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5189 the underlying Win32 ShellExecute function doesn't work if it is."; |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5190 |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5191 static PyObject * |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5192 win32_startfile(PyObject *self, PyObject *args) |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5193 { |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5194 char *filepath; |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5195 HINSTANCE rc; |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5196 if (!PyArg_ParseTuple(args, "s:startfile", &filepath)) |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5197 return NULL; |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5198 Py_BEGIN_ALLOW_THREADS |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5199 rc = ShellExecute((HWND)0, NULL, filepath, NULL, NULL, SW_SHOWNORMAL); |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5200 Py_END_ALLOW_THREADS |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5201 if (rc <= (HINSTANCE)32) |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5202 return win32_error("startfile", filepath); |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5203 Py_INCREF(Py_None); |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5204 return Py_None; |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5205 } |
|
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5206 #endif |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5207 |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5208 static PyMethodDef posix_methods[] = { |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5209 {"access", posix_access, METH_VARARGS, posix_access__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5210 #ifdef HAVE_TTYNAME |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5211 {"ttyname", posix_ttyname, METH_VARARGS, posix_ttyname__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5212 #endif |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5213 {"chdir", posix_chdir, METH_VARARGS, posix_chdir__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5214 {"chmod", posix_chmod, METH_VARARGS, posix_chmod__doc__}, |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5215 #ifdef HAVE_CHOWN |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5216 {"chown", posix_chown, METH_VARARGS, posix_chown__doc__}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
5217 #endif /* HAVE_CHOWN */ |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5218 #ifdef HAVE_CTERMID |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5219 {"ctermid", posix_ctermid, METH_VARARGS, posix_ctermid__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5220 #endif |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
5221 #ifdef HAVE_GETCWD |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5222 {"getcwd", posix_getcwd, METH_VARARGS, posix_getcwd__doc__}, |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
5223 #endif |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5224 #ifdef HAVE_LINK |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5225 {"link", posix_link, METH_VARARGS, posix_link__doc__}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
5226 #endif /* HAVE_LINK */ |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5227 {"listdir", posix_listdir, METH_VARARGS, posix_listdir__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5228 {"lstat", posix_lstat, METH_VARARGS, posix_lstat__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5229 {"mkdir", posix_mkdir, METH_VARARGS, posix_mkdir__doc__}, |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5230 #ifdef HAVE_NICE |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5231 {"nice", posix_nice, METH_VARARGS, posix_nice__doc__}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
5232 #endif /* HAVE_NICE */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5233 #ifdef HAVE_READLINK |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5234 {"readlink", posix_readlink, METH_VARARGS, posix_readlink__doc__}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
5235 #endif /* HAVE_READLINK */ |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5236 {"rename", posix_rename, METH_VARARGS, posix_rename__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5237 {"rmdir", posix_rmdir, METH_VARARGS, posix_rmdir__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5238 {"stat", posix_stat, METH_VARARGS, posix_stat__doc__}, |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5239 #ifdef HAVE_SYMLINK |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5240 {"symlink", posix_symlink, METH_VARARGS, posix_symlink__doc__}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
5241 #endif /* HAVE_SYMLINK */ |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
5242 #ifdef HAVE_SYSTEM |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5243 {"system", posix_system, METH_VARARGS, posix_system__doc__}, |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
5244 #endif |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5245 {"umask", posix_umask, METH_VARARGS, posix_umask__doc__}, |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5246 #ifdef HAVE_UNAME |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5247 {"uname", posix_uname, METH_VARARGS, posix_uname__doc__}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
5248 #endif /* HAVE_UNAME */ |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5249 {"unlink", posix_unlink, METH_VARARGS, posix_unlink__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5250 {"remove", posix_unlink, METH_VARARGS, posix_remove__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5251 {"utime", posix_utime, METH_VARARGS, posix_utime__doc__}, |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5252 #ifdef HAVE_TIMES |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5253 {"times", posix_times, METH_VARARGS, posix_times__doc__}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
5254 #endif /* HAVE_TIMES */ |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5255 {"_exit", posix__exit, METH_VARARGS, posix__exit__doc__}, |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
5256 #ifdef HAVE_EXECV |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5257 {"execv", posix_execv, METH_VARARGS, posix_execv__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5258 {"execve", posix_execve, METH_VARARGS, posix_execve__doc__}, |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
5259 #endif /* HAVE_EXECV */ |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
5260 #ifdef HAVE_SPAWNV |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5261 {"spawnv", posix_spawnv, METH_VARARGS, posix_spawnv__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5262 {"spawnve", posix_spawnve, METH_VARARGS, posix_spawnve__doc__}, |
|
9954
c404a6b0cdb1
Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents:
9939
diff
changeset
|
5263 #endif /* HAVE_SPAWNV */ |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
5264 #ifdef HAVE_FORK |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5265 {"fork", posix_fork, METH_VARARGS, posix_fork__doc__}, |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
5266 #endif /* HAVE_FORK */ |
|
13601
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
5267 #if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) |
|
13058
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
5268 {"openpty", posix_openpty, METH_VARARGS, posix_openpty__doc__}, |
|
13601
ef8b20b9f6f5
Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents:
13582
diff
changeset
|
5269 #endif /* HAVE_OPENPTY || HAVE__GETPTY */ |
|
13058
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
5270 #ifdef HAVE_FORKPTY |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
5271 {"forkpty", posix_forkpty, METH_VARARGS, posix_forkpty__doc__}, |
|
53f4022c0cd5
Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents:
12865
diff
changeset
|
5272 #endif /* HAVE_FORKPTY */ |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
5273 #ifdef HAVE_GETEGID |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5274 {"getegid", posix_getegid, METH_VARARGS, posix_getegid__doc__}, |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
5275 #endif /* HAVE_GETEGID */ |
|
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
5276 #ifdef HAVE_GETEUID |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5277 {"geteuid", posix_geteuid, METH_VARARGS, posix_geteuid__doc__}, |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
5278 #endif /* HAVE_GETEUID */ |
|
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
5279 #ifdef HAVE_GETGID |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5280 {"getgid", posix_getgid, METH_VARARGS, posix_getgid__doc__}, |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
5281 #endif /* HAVE_GETGID */ |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5282 #ifdef HAVE_GETGROUPS |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5283 {"getgroups", posix_getgroups, METH_VARARGS, posix_getgroups__doc__}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5284 #endif |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5285 {"getpid", posix_getpid, METH_VARARGS, posix_getpid__doc__}, |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5286 #ifdef HAVE_GETPGRP |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5287 {"getpgrp", posix_getpgrp, METH_VARARGS, posix_getpgrp__doc__}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
5288 #endif /* HAVE_GETPGRP */ |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
5289 #ifdef HAVE_GETPPID |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5290 {"getppid", posix_getppid, METH_VARARGS, posix_getppid__doc__}, |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
5291 #endif /* HAVE_GETPPID */ |
|
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
5292 #ifdef HAVE_GETUID |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5293 {"getuid", posix_getuid, METH_VARARGS, posix_getuid__doc__}, |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
5294 #endif /* HAVE_GETUID */ |
|
11570
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
5295 #ifdef HAVE_GETLOGIN |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
5296 {"getlogin", posix_getlogin, METH_VARARGS, posix_getlogin__doc__}, |
|
885820fa7e31
Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents:
11560
diff
changeset
|
5297 #endif |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
5298 #ifdef HAVE_KILL |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5299 {"kill", posix_kill, METH_VARARGS, posix_kill__doc__}, |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
5300 #endif /* HAVE_KILL */ |
|
3735
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
5301 #ifdef HAVE_PLOCK |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5302 {"plock", posix_plock, METH_VARARGS, posix_plock__doc__}, |
|
3735
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
5303 #endif /* HAVE_PLOCK */ |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
5304 #ifdef HAVE_POPEN |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5305 {"popen", posix_popen, METH_VARARGS, posix_popen__doc__}, |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
5306 #ifdef MS_WIN32 |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
5307 {"popen2", win32_popen2, METH_VARARGS}, |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
5308 {"popen3", win32_popen3, METH_VARARGS}, |
|
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
5309 {"popen4", win32_popen4, METH_VARARGS}, |
|
14752
46a6990769d1
Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents:
14586
diff
changeset
|
5310 {"startfile", win32_startfile, METH_VARARGS, win32_startfile__doc__}, |
|
13468
b907ebf3b052
- improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents:
13462
diff
changeset
|
5311 #endif |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
5312 #endif /* HAVE_POPEN */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5313 #ifdef HAVE_SETUID |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5314 {"setuid", posix_setuid, METH_VARARGS, posix_setuid__doc__}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
5315 #endif /* HAVE_SETUID */ |
|
13582
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
5316 #ifdef HAVE_SETEUID |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
5317 {"seteuid", posix_seteuid, METH_VARARGS, posix_seteuid__doc__}, |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
5318 #endif /* HAVE_SETEUID */ |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
5319 #ifdef HAVE_SETEGID |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
5320 {"setegid", posix_setegid, METH_VARARGS, posix_setegid__doc__}, |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
5321 #endif /* HAVE_SETEGID */ |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
5322 #ifdef HAVE_SETREUID |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
5323 {"setreuid", posix_setreuid, METH_VARARGS, posix_setreuid__doc__}, |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
5324 #endif /* HAVE_SETREUID */ |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
5325 #ifdef HAVE_SETREGID |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
5326 {"setregid", posix_setregid, METH_VARARGS, posix_setregid__doc__}, |
|
084a758051e0
From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents:
13576
diff
changeset
|
5327 #endif /* HAVE_SETREGID */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5328 #ifdef HAVE_SETGID |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5329 {"setgid", posix_setgid, METH_VARARGS, posix_setgid__doc__}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
5330 #endif /* HAVE_SETGID */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5331 #ifdef HAVE_SETPGRP |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5332 {"setpgrp", posix_setpgrp, METH_VARARGS, posix_setpgrp__doc__}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
5333 #endif /* HAVE_SETPGRP */ |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
5334 #ifdef HAVE_WAIT |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5335 {"wait", posix_wait, METH_VARARGS, posix_wait__doc__}, |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
5336 #endif /* HAVE_WAIT */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5337 #ifdef HAVE_WAITPID |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5338 {"waitpid", posix_waitpid, METH_VARARGS, posix_waitpid__doc__}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
5339 #endif /* HAVE_WAITPID */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5340 #ifdef HAVE_SETSID |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5341 {"setsid", posix_setsid, METH_VARARGS, posix_setsid__doc__}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
5342 #endif /* HAVE_SETSID */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5343 #ifdef HAVE_SETPGID |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5344 {"setpgid", posix_setpgid, METH_VARARGS, posix_setpgid__doc__}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
5345 #endif /* HAVE_SETPGID */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5346 #ifdef HAVE_TCGETPGRP |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5347 {"tcgetpgrp", posix_tcgetpgrp, METH_VARARGS, posix_tcgetpgrp__doc__}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
5348 #endif /* HAVE_TCGETPGRP */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5349 #ifdef HAVE_TCSETPGRP |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5350 {"tcsetpgrp", posix_tcsetpgrp, METH_VARARGS, posix_tcsetpgrp__doc__}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
5351 #endif /* HAVE_TCSETPGRP */ |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5352 {"open", posix_open, METH_VARARGS, posix_open__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5353 {"close", posix_close, METH_VARARGS, posix_close__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5354 {"dup", posix_dup, METH_VARARGS, posix_dup__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5355 {"dup2", posix_dup2, METH_VARARGS, posix_dup2__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5356 {"lseek", posix_lseek, METH_VARARGS, posix_lseek__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5357 {"read", posix_read, METH_VARARGS, posix_read__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5358 {"write", posix_write, METH_VARARGS, posix_write__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5359 {"fstat", posix_fstat, METH_VARARGS, posix_fstat__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5360 {"fdopen", posix_fdopen, METH_VARARGS, posix_fdopen__doc__}, |
|
13641
38ea27455cbb
new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents:
13620
diff
changeset
|
5361 {"isatty", posix_isatty, METH_VARARGS, posix_isatty__doc__}, |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
5362 #ifdef HAVE_PIPE |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5363 {"pipe", posix_pipe, METH_VARARGS, posix_pipe__doc__}, |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
5364 #endif |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
5365 #ifdef HAVE_MKFIFO |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5366 {"mkfifo", posix_mkfifo, METH_VARARGS, posix_mkfifo__doc__}, |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
5367 #endif |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
5368 #ifdef HAVE_FTRUNCATE |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5369 {"ftruncate", posix_ftruncate, METH_VARARGS, posix_ftruncate__doc__}, |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
5370 #endif |
|
3801
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
5371 #ifdef HAVE_PUTENV |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5372 {"putenv", posix_putenv, METH_VARARGS, posix_putenv__doc__}, |
|
3801
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
5373 #endif |
|
6315
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
5374 #ifdef HAVE_STRERROR |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5375 {"strerror", posix_strerror, METH_VARARGS, posix_strerror__doc__}, |
|
6315
d25489c5a22f
Add strerror() interface.
Guido van Rossum <guido@python.org>
parents:
6130
diff
changeset
|
5376 #endif |
|
9822
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
5377 #ifdef HAVE_FSYNC |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5378 {"fsync", posix_fsync, METH_VARARGS, posix_fsync__doc__}, |
|
9822
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
5379 #endif |
|
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
5380 #ifdef HAVE_FDATASYNC |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5381 {"fdatasync", posix_fdatasync, METH_VARARGS, posix_fdatasync__doc__}, |
|
9822
17e4d81949b9
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents:
9795
diff
changeset
|
5382 #endif |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
5383 #ifdef HAVE_SYS_WAIT_H |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
5384 #ifdef WIFSTOPPED |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5385 {"WIFSTOPPED", posix_WIFSTOPPED, METH_VARARGS, posix_WIFSTOPPED__doc__}, |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
5386 #endif /* WIFSTOPPED */ |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
5387 #ifdef WIFSIGNALED |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5388 {"WIFSIGNALED", posix_WIFSIGNALED, METH_VARARGS, posix_WIFSIGNALED__doc__}, |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
5389 #endif /* WIFSIGNALED */ |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
5390 #ifdef WIFEXITED |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5391 {"WIFEXITED", posix_WIFEXITED, METH_VARARGS, posix_WIFEXITED__doc__}, |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
5392 #endif /* WIFEXITED */ |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
5393 #ifdef WEXITSTATUS |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5394 {"WEXITSTATUS", posix_WEXITSTATUS, METH_VARARGS, posix_WEXITSTATUS__doc__}, |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
5395 #endif /* WEXITSTATUS */ |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
5396 #ifdef WTERMSIG |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5397 {"WTERMSIG", posix_WTERMSIG, METH_VARARGS, posix_WTERMSIG__doc__}, |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
5398 #endif /* WTERMSIG */ |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
5399 #ifdef WSTOPSIG |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5400 {"WSTOPSIG", posix_WSTOPSIG, METH_VARARGS, posix_WSTOPSIG__doc__}, |
|
8810
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
5401 #endif /* WSTOPSIG */ |
|
4aa76480d812
Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents:
8708
diff
changeset
|
5402 #endif /* HAVE_SYS_WAIT_H */ |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
5403 #ifdef HAVE_FSTATVFS |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5404 {"fstatvfs", posix_fstatvfs, METH_VARARGS, posix_fstatvfs__doc__}, |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
5405 #endif |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
5406 #ifdef HAVE_STATVFS |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5407 {"statvfs", posix_statvfs, METH_VARARGS, posix_statvfs__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5408 #endif |
|
15765
6d8f7e1242c0
Anonymous SF bug report #128053 point out that the #ifdef for
Guido van Rossum <guido@python.org>
parents:
15511
diff
changeset
|
5409 #ifdef HAVE_TMPFILE |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5410 {"tmpfile", posix_tmpfile, METH_VARARGS, posix_tmpfile__doc__}, |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
5411 #endif |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5412 #ifdef HAVE_TEMPNAM |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5413 {"tempnam", posix_tempnam, METH_VARARGS, posix_tempnam__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5414 #endif |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5415 #ifdef HAVE_TMPNAM |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5416 {"tmpnam", posix_tmpnam, METH_VARARGS, posix_tmpnam__doc__}, |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5417 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5418 #ifdef HAVE_CONFSTR |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5419 {"confstr", posix_confstr, METH_VARARGS, posix_confstr__doc__}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5420 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5421 #ifdef HAVE_SYSCONF |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5422 {"sysconf", posix_sysconf, METH_VARARGS, posix_sysconf__doc__}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5423 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5424 #ifdef HAVE_FPATHCONF |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5425 {"fpathconf", posix_fpathconf, METH_VARARGS, posix_fpathconf__doc__}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5426 #endif |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5427 #ifdef HAVE_PATHCONF |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5428 {"pathconf", posix_pathconf, METH_VARARGS, posix_pathconf__doc__}, |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5429 #endif |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5430 {"abort", posix_abort, METH_VARARGS, posix_abort__doc__}, |
| 6 | 5431 {NULL, NULL} /* Sentinel */ |
| 5432 }; | |
| 5433 | |
| 5434 | |
|
4789
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5435 static int |
|
13442
ed72067aac03
this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents:
13389
diff
changeset
|
5436 ins(PyObject *d, char *symbol, long value) |
|
4789
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5437 { |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5438 PyObject* v = PyInt_FromLong(value); |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5439 if (!v || PyDict_SetItemString(d, symbol, v) < 0) |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5440 return -1; /* triggers fatal error */ |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5441 |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5442 Py_DECREF(v); |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5443 return 0; |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5444 } |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5445 |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5446 #if defined(PYOS_OS2) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5447 /* Insert Platform-Specific Constant Values (Strings & Numbers) of Common Use */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5448 static int insertvalues(PyObject *d) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5449 { |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5450 APIRET rc; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5451 ULONG values[QSV_MAX+1]; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5452 PyObject *v; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5453 char *ver, tmp[10]; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5454 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5455 Py_BEGIN_ALLOW_THREADS |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5456 rc = DosQuerySysInfo(1, QSV_MAX, &values[1], sizeof(values)); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5457 Py_END_ALLOW_THREADS |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5458 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5459 if (rc != NO_ERROR) { |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5460 os2_error(rc); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5461 return -1; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5462 } |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5463 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5464 if (ins(d, "meminstalled", values[QSV_TOTPHYSMEM])) return -1; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5465 if (ins(d, "memkernel", values[QSV_TOTRESMEM])) return -1; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5466 if (ins(d, "memvirtual", values[QSV_TOTAVAILMEM])) return -1; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5467 if (ins(d, "maxpathlen", values[QSV_MAX_PATH_LENGTH])) return -1; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5468 if (ins(d, "maxnamelen", values[QSV_MAX_COMP_LENGTH])) return -1; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5469 if (ins(d, "revision", values[QSV_VERSION_REVISION])) return -1; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5470 if (ins(d, "timeslice", values[QSV_MIN_SLICE])) return -1; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5471 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5472 switch (values[QSV_VERSION_MINOR]) { |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5473 case 0: ver = "2.00"; break; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5474 case 10: ver = "2.10"; break; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5475 case 11: ver = "2.11"; break; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5476 case 30: ver = "3.00"; break; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5477 case 40: ver = "4.00"; break; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5478 case 50: ver = "5.00"; break; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5479 default: |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5480 sprintf(tmp, "%d-%d", values[QSV_VERSION_MAJOR], |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5481 values[QSV_VERSION_MINOR]); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5482 ver = &tmp[0]; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5483 } |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5484 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5485 /* Add Indicator of the Version of the Operating System */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5486 v = PyString_FromString(ver); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5487 if (!v || PyDict_SetItemString(d, "version", v) < 0) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5488 return -1; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5489 Py_DECREF(v); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5490 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5491 /* Add Indicator of Which Drive was Used to Boot the System */ |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5492 tmp[0] = 'A' + values[QSV_BOOT_DRIVE] - 1; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5493 tmp[1] = ':'; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5494 tmp[2] = '\0'; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5495 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5496 v = PyString_FromString(tmp); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5497 if (!v || PyDict_SetItemString(d, "bootdrive", v) < 0) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5498 return -1; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5499 Py_DECREF(v); |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5500 |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5501 return 0; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5502 } |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5503 #endif |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5504 |
|
4789
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5505 static int |
|
13651
8a063423e0b7
Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents:
13642
diff
changeset
|
5506 all_ins(PyObject *d) |
|
4789
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5507 { |
|
9785
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
5508 #ifdef F_OK |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
5509 if (ins(d, "F_OK", (long)F_OK)) return -1; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
5510 #endif |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
5511 #ifdef R_OK |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
5512 if (ins(d, "R_OK", (long)R_OK)) return -1; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
5513 #endif |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
5514 #ifdef W_OK |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
5515 if (ins(d, "W_OK", (long)W_OK)) return -1; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
5516 #endif |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
5517 #ifdef X_OK |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
5518 if (ins(d, "X_OK", (long)X_OK)) return -1; |
|
facb457b4d32
Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
5519 #endif |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5520 #ifdef NGROUPS_MAX |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5521 if (ins(d, "NGROUPS_MAX", (long)NGROUPS_MAX)) return -1; |
|
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5522 #endif |
|
11532
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5523 #ifdef TMP_MAX |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5524 if (ins(d, "TMP_MAX", (long)TMP_MAX)) return -1; |
|
2951e2d27852
Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents:
11391
diff
changeset
|
5525 #endif |
|
4789
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5526 #ifdef WNOHANG |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5527 if (ins(d, "WNOHANG", (long)WNOHANG)) return -1; |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5528 #endif |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5529 #ifdef O_RDONLY |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5530 if (ins(d, "O_RDONLY", (long)O_RDONLY)) return -1; |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5531 #endif |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5532 #ifdef O_WRONLY |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5533 if (ins(d, "O_WRONLY", (long)O_WRONLY)) return -1; |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5534 #endif |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5535 #ifdef O_RDWR |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5536 if (ins(d, "O_RDWR", (long)O_RDWR)) return -1; |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5537 #endif |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5538 #ifdef O_NDELAY |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5539 if (ins(d, "O_NDELAY", (long)O_NDELAY)) return -1; |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5540 #endif |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5541 #ifdef O_NONBLOCK |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5542 if (ins(d, "O_NONBLOCK", (long)O_NONBLOCK)) return -1; |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5543 #endif |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5544 #ifdef O_APPEND |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5545 if (ins(d, "O_APPEND", (long)O_APPEND)) return -1; |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5546 #endif |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5547 #ifdef O_DSYNC |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5548 if (ins(d, "O_DSYNC", (long)O_DSYNC)) return -1; |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5549 #endif |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5550 #ifdef O_RSYNC |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5551 if (ins(d, "O_RSYNC", (long)O_RSYNC)) return -1; |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5552 #endif |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5553 #ifdef O_SYNC |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5554 if (ins(d, "O_SYNC", (long)O_SYNC)) return -1; |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5555 #endif |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5556 #ifdef O_NOCTTY |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5557 if (ins(d, "O_NOCTTY", (long)O_NOCTTY)) return -1; |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5558 #endif |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5559 #ifdef O_CREAT |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5560 if (ins(d, "O_CREAT", (long)O_CREAT)) return -1; |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5561 #endif |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5562 #ifdef O_EXCL |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5563 if (ins(d, "O_EXCL", (long)O_EXCL)) return -1; |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5564 #endif |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5565 #ifdef O_TRUNC |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5566 if (ins(d, "O_TRUNC", (long)O_TRUNC)) return -1; |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5567 #endif |
|
5967
9e4ddb459b10
Added O_BINARY and O_TEXT (for Windows).
Guido van Rossum <guido@python.org>
parents:
5725
diff
changeset
|
5568 #ifdef O_BINARY |
|
9e4ddb459b10
Added O_BINARY and O_TEXT (for Windows).
Guido van Rossum <guido@python.org>
parents:
5725
diff
changeset
|
5569 if (ins(d, "O_BINARY", (long)O_BINARY)) return -1; |
|
9e4ddb459b10
Added O_BINARY and O_TEXT (for Windows).
Guido van Rossum <guido@python.org>
parents:
5725
diff
changeset
|
5570 #endif |
|
9e4ddb459b10
Added O_BINARY and O_TEXT (for Windows).
Guido van Rossum <guido@python.org>
parents:
5725
diff
changeset
|
5571 #ifdef O_TEXT |
|
9e4ddb459b10
Added O_BINARY and O_TEXT (for Windows).
Guido van Rossum <guido@python.org>
parents:
5725
diff
changeset
|
5572 if (ins(d, "O_TEXT", (long)O_TEXT)) return -1; |
|
9e4ddb459b10
Added O_BINARY and O_TEXT (for Windows).
Guido van Rossum <guido@python.org>
parents:
5725
diff
changeset
|
5573 #endif |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5574 |
|
10069
5e01645ee41b
Add _P_WAIT etc. for NT.
Guido van Rossum <guido@python.org>
parents:
10066
diff
changeset
|
5575 #ifdef HAVE_SPAWNV |
|
10188
6633c3fca626
The symbols P_* (for spawn*(), MS specific) should not have a leading
Guido van Rossum <guido@python.org>
parents:
10178
diff
changeset
|
5576 if (ins(d, "P_WAIT", (long)_P_WAIT)) return -1; |
|
6633c3fca626
The symbols P_* (for spawn*(), MS specific) should not have a leading
Guido van Rossum <guido@python.org>
parents:
10178
diff
changeset
|
5577 if (ins(d, "P_NOWAIT", (long)_P_NOWAIT)) return -1; |
|
6633c3fca626
The symbols P_* (for spawn*(), MS specific) should not have a leading
Guido van Rossum <guido@python.org>
parents:
10178
diff
changeset
|
5578 if (ins(d, "P_OVERLAY", (long)_OLD_P_OVERLAY)) return -1; |
|
6633c3fca626
The symbols P_* (for spawn*(), MS specific) should not have a leading
Guido van Rossum <guido@python.org>
parents:
10178
diff
changeset
|
5579 if (ins(d, "P_NOWAITO", (long)_P_NOWAITO)) return -1; |
|
6633c3fca626
The symbols P_* (for spawn*(), MS specific) should not have a leading
Guido van Rossum <guido@python.org>
parents:
10178
diff
changeset
|
5580 if (ins(d, "P_DETACH", (long)_P_DETACH)) return -1; |
|
10069
5e01645ee41b
Add _P_WAIT etc. for NT.
Guido van Rossum <guido@python.org>
parents:
10066
diff
changeset
|
5581 #endif |
|
5e01645ee41b
Add _P_WAIT etc. for NT.
Guido van Rossum <guido@python.org>
parents:
10066
diff
changeset
|
5582 |
|
6766
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5583 #if defined(PYOS_OS2) |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5584 if (insertvalues(d)) return -1; |
|
89092ad1e660
Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents:
6717
diff
changeset
|
5585 #endif |
|
4789
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5586 return 0; |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5587 } |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5588 |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5589 |
|
6717
64a75211cf72
Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
5590 #if ( defined(_MSC_VER) || defined(__WATCOMC__) ) && !defined(__QNX__) |
|
6367
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
6315
diff
changeset
|
5591 #define INITFUNC initnt |
|
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
6315
diff
changeset
|
5592 #define MODNAME "nt" |
|
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
6315
diff
changeset
|
5593 #else |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
5594 #if defined(PYOS_OS2) |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
5595 #define INITFUNC initos2 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
5596 #define MODNAME "os2" |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
5597 #else |
|
6367
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
6315
diff
changeset
|
5598 #define INITFUNC initposix |
|
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
6315
diff
changeset
|
5599 #define MODNAME "posix" |
|
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
6315
diff
changeset
|
5600 #endif |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6578
diff
changeset
|
5601 #endif |
|
4789
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5602 |
|
9588
38023a425e48
Add DL_EXPORT() to all modules that could possibly be used
Guido van Rossum <guido@python.org>
parents:
9307
diff
changeset
|
5603 DL_EXPORT(void) |
|
13651
8a063423e0b7
Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents:
13642
diff
changeset
|
5604 INITFUNC(void) |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5605 { |
| 4672 | 5606 PyObject *m, *d, *v; |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5607 |
|
6367
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
6315
diff
changeset
|
5608 m = Py_InitModule4(MODNAME, |
|
5699
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
5609 posix_methods, |
|
76fd5281f98a
Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents:
5584
diff
changeset
|
5610 posix__doc__, |
|
6367
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
6315
diff
changeset
|
5611 (PyObject *)NULL, |
|
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
6315
diff
changeset
|
5612 PYTHON_API_VERSION); |
| 4672 | 5613 d = PyModule_GetDict(m); |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5614 |
|
6367
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
6315
diff
changeset
|
5615 /* Initialize environ dictionary */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5616 v = convertenviron(); |
| 4672 | 5617 if (v == NULL || PyDict_SetItemString(d, "environ", v) != 0) |
|
6367
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
6315
diff
changeset
|
5618 return; |
| 4672 | 5619 Py_DECREF(v); |
|
11559
22f4cf16b5a3
Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents:
11532
diff
changeset
|
5620 |
|
4789
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5621 if (all_ins(d)) |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5622 return; |
|
d45ba64b82fd
1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents:
4785
diff
changeset
|
5623 |
|
11577
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5624 if (setup_confname_tables(d)) |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5625 return; |
|
57c1685acb16
Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents:
11574
diff
changeset
|
5626 |
|
10133
5718e83020ae
Got rid of the file-global PosixError. This was redundant since it
Barry Warsaw <barry@python.org>
parents:
10092
diff
changeset
|
5627 PyDict_SetItemString(d, "error", PyExc_OSError); |
|
11230
b69859b69763
posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents:
11172
diff
changeset
|
5628 |
|
11686
93bed60355e4
The initialization of posix_putenv_garbage should only be done when it
Guido van Rossum <guido@python.org>
parents:
11639
diff
changeset
|
5629 #ifdef HAVE_PUTENV |
|
15904
149458a5740a
Plug memory leak.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
15765
diff
changeset
|
5630 if (posix_putenv_garbage == NULL) |
|
149458a5740a
Plug memory leak.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
15765
diff
changeset
|
5631 posix_putenv_garbage = PyDict_New(); |
|
11686
93bed60355e4
The initialization of posix_putenv_garbage should only be done when it
Guido van Rossum <guido@python.org>
parents:
11639
diff
changeset
|
5632 #endif |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
5633 } |
