annotate Modules/posixmodule.c @ 25838:8540887bcec6 2.2

Backport of 2.183: Fix memory leak in add_subclass() found by NealN with valgrind.
author Guido van Rossum <guido@python.org>
date Fri, 18 Oct 2002 13:42:21 +0000
parents c5417f0ee5f0
children 6ba940cd99ef
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 117
diff changeset
1
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 /* POSIX module implementation */
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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"
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
20 #include "structseq.h"
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
21
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
22 #if defined(PYOS_OS2)
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
23 #define INCL_DOS
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
24 #define INCL_DOSERRORS
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
25 #define INCL_DOSPROCESS
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
26 #define INCL_NOPMAPI
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
27 #include <os2.h>
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
28 #endif
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
29
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
30 #include <sys/types.h>
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
31 #include <sys/stat.h>
20537
01af91aeccd4 Shut up warnings for setgroups() on Linux -- you have to #include
Guido van Rossum <guido@python.org>
parents: 20508
diff changeset
32
2740
3e370a4b103b sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents: 2615
diff changeset
33 #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
34 #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
35 #endif
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
36
4600
d36250aefb82 Keep gcc -Wall happy.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
37 #ifdef HAVE_SIGNAL_H
d36250aefb82 Keep gcc -Wall happy.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
38 #include <signal.h>
d36250aefb82 Keep gcc -Wall happy.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
39 #endif
d36250aefb82 Keep gcc -Wall happy.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
40
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
41 #ifdef HAVE_FCNTL_H
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
42 #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
43 #endif /* HAVE_FCNTL_H */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
44
20537
01af91aeccd4 Shut up warnings for setgroups() on Linux -- you have to #include
Guido van Rossum <guido@python.org>
parents: 20508
diff changeset
45 #ifdef HAVE_GRP_H
01af91aeccd4 Shut up warnings for setgroups() on Linux -- you have to #include
Guido van Rossum <guido@python.org>
parents: 20508
diff changeset
46 #include <grp.h>
01af91aeccd4 Shut up warnings for setgroups() on Linux -- you have to #include
Guido van Rossum <guido@python.org>
parents: 20508
diff changeset
47 #endif
01af91aeccd4 Shut up warnings for setgroups() on Linux -- you have to #include
Guido van Rossum <guido@python.org>
parents: 20508
diff changeset
48
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
49 /* Various compilers have only certain posix functions */
18835
2dea40e40d9d Patch #411138: Rename config.h to pyconfig.h. Closes bug #231774.
Martin v. Löwis <martin@v.loewis.de>
parents: 18749
diff changeset
50 /* XXX Gosh I wish these were all moved into pyconfig.h */
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
51 #if defined(PYCC_VACPP) && defined(PYOS_OS2)
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
52 #include <process.h>
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
53 #else
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
54 #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
55 #define HAVE_GETCWD 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
56 #define HAVE_OPENDIR 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
57 #define HAVE_SYSTEM 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
58 #if defined(__OS2__)
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
59 #define HAVE_EXECV 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
60 #define HAVE_WAIT 1
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
61 #endif
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
62 #include <process.h>
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
63 #else
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
64 #ifdef __BORLANDC__ /* Borland compiler */
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
65 #define HAVE_EXECV 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
66 #define HAVE_GETCWD 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
67 #define HAVE_OPENDIR 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
68 #define HAVE_PIPE 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
69 #define HAVE_POPEN 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
70 #define HAVE_SYSTEM 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
71 #define HAVE_WAIT 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
72 #else
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
73 #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
74 #define HAVE_GETCWD 1
3408756ec601 changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents: 3695
diff changeset
75 #ifdef MS_WIN32
9954
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
76 #define HAVE_SPAWNV 1
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
77 #define HAVE_EXECV 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
78 #define HAVE_PIPE 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
79 #define HAVE_POPEN 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
80 #define HAVE_SYSTEM 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
81 #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
82 #endif /* !MS_WIN32 */
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
83 #else /* all other compilers */
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
84 /* 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
85 #define HAVE_EXECV 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
86 #define HAVE_FORK 1
17419
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
87 #if defined(__USLC__) && defined(__SCO_VERSION__) /* SCO UDK Compiler */
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
88 #define HAVE_FORK1 1
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
89 #endif
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
90 #define HAVE_GETCWD 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
91 #define HAVE_GETEGID 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
92 #define HAVE_GETEUID 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
93 #define HAVE_GETGID 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
94 #define HAVE_GETPPID 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
95 #define HAVE_GETUID 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
96 #define HAVE_KILL 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
97 #define HAVE_OPENDIR 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
98 #define HAVE_PIPE 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
99 #define HAVE_POPEN 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
100 #define HAVE_SYSTEM 1
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
101 #define HAVE_WAIT 1
9939
faf351e31571 Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents: 9824
diff changeset
102 #define HAVE_TTYNAME 1
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
103 #endif /* _MSC_VER */
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
104 #endif /* __BORLANDC__ */
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
105 #endif /* ! __WATCOMC__ || __QNX__ */
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
106 #endif /* ! __IBMC__ */
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
107
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
108 #ifndef _MSC_VER
2740
3e370a4b103b sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents: 2615
diff changeset
109
14837
b7787a9052e3 Add missing prototypes for the benefit of SunOS 4.1.4 */
Guido van Rossum <guido@python.org>
parents: 14767
diff changeset
110 #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
111 /* 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
112 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
113 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
114 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
115 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
116 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
117 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
118 #endif
b7787a9052e3 Add missing prototypes for the benefit of SunOS 4.1.4 */
Guido van Rossum <guido@python.org>
parents: 14767
diff changeset
119
2740
3e370a4b103b sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents: 2615
diff changeset
120 #ifdef NeXT
3e370a4b103b sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents: 2615
diff changeset
121 /* 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
122 #undef HAVE_UNISTD_H
3e370a4b103b sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents: 2615
diff changeset
123 #undef HAVE_UTIME_H
5584
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
124 #define HAVE_WAITPID
2740
3e370a4b103b sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents: 2615
diff changeset
125 /* #undef HAVE_GETCWD */
9970
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
126 #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
127 #endif
3e370a4b103b sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents: 2615
diff changeset
128
13694
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13675
diff changeset
129 #ifndef HAVE_UNISTD_H
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
130 #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
131 extern int mkdir(char *);
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
132 #else
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
133 #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
134 extern int mkdir(const char *);
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
135 #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
136 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
137 #endif
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
138 #endif
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
139 #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
140 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
141 extern int rmdir(char *);
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
142 #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
143 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
144 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
145 #endif
17831
5c06a9596fbf SF patch #418147 Fixes to allow compiling w/ Borland, from Stephen Hansen.
Tim Peters <tim.peters@gmail.com>
parents: 17822
diff changeset
146 #ifdef __BORLANDC__
5c06a9596fbf SF patch #418147 Fixes to allow compiling w/ Borland, from Stephen Hansen.
Tim Peters <tim.peters@gmail.com>
parents: 17822
diff changeset
147 extern int chmod(const char *, int);
5c06a9596fbf SF patch #418147 Fixes to allow compiling w/ Borland, from Stephen Hansen.
Tim Peters <tim.peters@gmail.com>
parents: 17822
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 chmod(const char *, mode_t);
17831
5c06a9596fbf SF patch #418147 Fixes to allow compiling w/ Borland, from Stephen Hansen.
Tim Peters <tim.peters@gmail.com>
parents: 17822
diff changeset
150 #endif
13442
ed72067aac03 this one's a bit risky, but I've spent some considerable time
Fredrik Lundh <fredrik@pythonware.com>
parents: 13389
diff changeset
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 extern int pclose(FILE *);
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
159 #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
160 extern int symlink(const char *, const char *);
2370
e386035f897d fix comment opener after #endif
Guido van Rossum <guido@python.org>
parents: 2298
diff changeset
161 #endif /* HAVE_SYMLINK */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
162 #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
163 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
164 #endif /* HAVE_LSTAT */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
165 #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
166
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
167 #endif /* !_MSC_VER */
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
168
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
169 #ifdef HAVE_UTIME_H
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
170 #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
171 #endif /* HAVE_UTIME_H */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
172
1915
80818c106e3e * Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents: 1845
diff changeset
173 #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
174 #include <sys/utime.h>
80818c106e3e * Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents: 1845
diff changeset
175 #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
176 #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
177
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
178 #ifdef HAVE_SYS_TIMES_H
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
179 #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
180 #endif /* HAVE_SYS_TIMES_H */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
181
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
182 #ifdef HAVE_SYS_PARAM_H
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
183 #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
184 #endif /* HAVE_SYS_PARAM_H */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
185
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
186 #ifdef HAVE_SYS_UTSNAME_H
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
187 #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
188 #endif /* HAVE_SYS_UTSNAME_H */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
189
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
190 #ifndef MAXPATHLEN
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
191 #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
192 #endif /* MAXPATHLEN */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
193
2055
cf31eab6ab5a Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents: 1983
diff changeset
194 #ifdef HAVE_DIRENT_H
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
195 #include <dirent.h>
2055
cf31eab6ab5a Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents: 1983
diff changeset
196 #define NAMLEN(dirent) strlen((dirent)->d_name)
cf31eab6ab5a Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents: 1983
diff changeset
197 #else
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
198 #if defined(__WATCOMC__) && !defined(__QNX__)
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
199 #include <direct.h>
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
200 #define NAMLEN(dirent) strlen((dirent)->d_name)
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
201 #else
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
202 #define dirent direct
2055
cf31eab6ab5a Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents: 1983
diff changeset
203 #define NAMLEN(dirent) (dirent)->d_namlen
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
204 #endif
2055
cf31eab6ab5a Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents: 1983
diff changeset
205 #ifdef HAVE_SYS_NDIR_H
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
206 #include <sys/ndir.h>
2055
cf31eab6ab5a Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents: 1983
diff changeset
207 #endif
cf31eab6ab5a Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents: 1983
diff changeset
208 #ifdef HAVE_SYS_DIR_H
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
209 #include <sys/dir.h>
2055
cf31eab6ab5a Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents: 1983
diff changeset
210 #endif
cf31eab6ab5a Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents: 1983
diff changeset
211 #ifdef HAVE_NDIR_H
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
212 #include <ndir.h>
2055
cf31eab6ab5a Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents: 1983
diff changeset
213 #endif
cf31eab6ab5a Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents: 1983
diff changeset
214 #endif
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
215
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
216 #ifdef _MSC_VER
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
217 #include <direct.h>
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
218 #include <io.h>
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
219 #include <process.h>
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
220 #define WINDOWS_LEAN_AND_MEAN
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
221 #include <windows.h>
3702
3408756ec601 changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents: 3695
diff changeset
222 #ifdef MS_WIN32
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
223 #define popen _popen
1815
6353fe25cdce * Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents: 1792
diff changeset
224 #define pclose _pclose
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
225 #else /* 16-bit Windows */
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
226 #include <dos.h>
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
227 #include <ctype.h>
3702
3408756ec601 changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents: 3695
diff changeset
228 #endif /* MS_WIN32 */
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
229 #endif /* _MSC_VER */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
230
6766
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
231 #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
232 #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
233 #endif /* OS2 */
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
234
9970
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
235 #ifdef UNION_WAIT
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
236 /* 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
237
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
238 #ifndef WIFEXITED
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
239 #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
240 #endif
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
241
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
242 #ifndef WEXITSTATUS
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
243 #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
244 #endif
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
245
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
246 #ifndef WTERMSIG
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
247 #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
248 #endif
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
249
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
250 #endif /* UNION_WAIT */
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
251
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
252 /* 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
253 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
254 #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
255 #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
256 #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
257
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 #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
259 #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
260 #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
261
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
262 /* 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
263 #undef STAT
19754
e1f1e9ebf050 Enable large file support on Win32 systems.
Tim Peters <tim.peters@gmail.com>
parents: 19568
diff changeset
264 #if defined(MS_WIN64) || defined(MS_WIN32)
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
265 # define STAT _stati64
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
266 # define FSTAT _fstati64
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
267 # define STRUCT_STAT struct _stati64
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
268 #else
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
269 # define STAT stat
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
270 # define FSTAT fstat
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
271 # define STRUCT_STAT struct stat
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
272 #endif
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
273
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
274
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
275 /* Return a dictionary corresponding to the POSIX environment table */
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
276
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
277 #if !defined(_MSC_VER) && ( !defined(__WATCOMC__) || defined(__QNX__) )
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
278 extern char **environ;
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
279 #endif /* !_MSC_VER */
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
280
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
281 static PyObject *
13651
8a063423e0b7 Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents: 13642
diff changeset
282 convertenviron(void)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
283 {
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
284 PyObject *d;
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
285 char **e;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
286 d = PyDict_New();
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
287 if (d == NULL)
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
288 return NULL;
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
289 if (environ == NULL)
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
290 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
291 /* This part ignores errors */
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
292 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
293 PyObject *k;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
294 PyObject *v;
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
295 char *p = strchr(*e, '=');
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
296 if (p == NULL)
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
297 continue;
11172
8e74ed154f60 It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents: 11095
diff changeset
298 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
299 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
300 PyErr_Clear();
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
301 continue;
11172
8e74ed154f60 It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents: 11095
diff changeset
302 }
8e74ed154f60 It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents: 11095
diff changeset
303 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
304 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
305 PyErr_Clear();
8e74ed154f60 It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents: 11095
diff changeset
306 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
307 continue;
8e74ed154f60 It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents: 11095
diff changeset
308 }
8e74ed154f60 It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents: 11095
diff changeset
309 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
310 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
311 PyErr_Clear();
8e74ed154f60 It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents: 11095
diff changeset
312 }
8e74ed154f60 It turns out that modifying the environment strings is not safe.
Guido van Rossum <guido@python.org>
parents: 11095
diff changeset
313 Py_DECREF(k);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
314 Py_DECREF(v);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
315 }
6766
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
316 #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
317 {
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
318 APIRET rc;
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
319 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
320
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
321 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
322 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
323 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
324 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
325 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
326 }
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
327 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
328 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
329 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
330 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
331 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
332 }
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
333 }
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
334 #endif
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
335 return d;
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
336 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
337
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
338
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
339 /* Set a POSIX-specific error from errno, and return NULL */
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
340
8708
acf49c9def7d Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents: 8497
diff changeset
341 static PyObject *
13651
8a063423e0b7 Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents: 13642
diff changeset
342 posix_error(void)
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
343 {
10133
5718e83020ae Got rid of the file-global PosixError. This was redundant since it
Barry Warsaw <barry@python.org>
parents: 10092
diff changeset
344 return PyErr_SetFromErrno(PyExc_OSError);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
345 }
8708
acf49c9def7d Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents: 8497
diff changeset
346 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
347 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
348 {
10133
5718e83020ae Got rid of the file-global PosixError. This was redundant since it
Barry Warsaw <barry@python.org>
parents: 10092
diff changeset
349 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
350 }
acf49c9def7d Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents: 8497
diff changeset
351
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
352 static PyObject *
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
353 posix_error_with_allocated_filename(char* name)
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
354 {
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
355 PyObject *rc = PyErr_SetFromErrnoWithFilename(PyExc_OSError, name);
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
356 PyMem_Free(name);
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
357 return rc;
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
358 }
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
359
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
360 #ifdef MS_WIN32
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
361 static PyObject *
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
362 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
363 {
13974
3e6e3d05d00b Fix for bug #110670 - Win32 os.listdir raises confusing errors:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13960
diff changeset
364 /* 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
365 (_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
366 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
367 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
368 */
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
369 errno = GetLastError();
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
370 if (filename)
13974
3e6e3d05d00b Fix for bug #110670 - Win32 os.listdir raises confusing errors:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13960
diff changeset
371 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
372 else
13974
3e6e3d05d00b Fix for bug #110670 - Win32 os.listdir raises confusing errors:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13960
diff changeset
373 return PyErr_SetFromWindowsErr(errno);
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
374 }
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
375 #endif
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
376
6766
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
377 #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
378 /**********************************************************************
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
379 * 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
380 **********************************************************************/
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
381 static void
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
382 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
383 {
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
384 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
385
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
386 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
387 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
388
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
389 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
390 *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
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 /* 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
394 if (reason) {
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
395 strcat(msgbuf, " : ");
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
396 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
397 }
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
398 }
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 /**********************************************************************
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
401 * 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
402 *
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
403 * 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
404 * 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
405 *
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
406 * Notes:
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
407 * 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
408 * 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
409 *
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 static char *
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
412 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
413 {
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
414 APIRET rc;
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
415 ULONG msglen;
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 /* 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
418 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
419 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
420 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
421 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
422
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
423 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
424 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
425 else
21075
dc641e1256f9 Repair a botched PyOS_snprintf conversion.
Tim Peters <tim.peters@gmail.com>
parents: 21073
diff changeset
426 PyOS_snprintf(msgbuf, msgbuflen,
21073
304b34023876 sprintf -> PyOS_snprintf in some "obviously safe" cases.
Tim Peters <tim.peters@gmail.com>
parents: 21066
diff changeset
427 "unknown OS error #%d", errorcode);
6766
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 return msgbuf;
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
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
432 /* 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
433 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
434 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
435
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
436 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
437 {
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
438 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
439 PyObject *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 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
442
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
443 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
444 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
445 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
446 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
447 }
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
448 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
449 }
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
450
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
451 #endif /* OS2 */
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
452
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
453 /* POSIX generic methods */
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
454
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
455 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
456 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
457 {
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
458 int fd;
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
459 int res;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
460 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
461 return NULL;
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
462 Py_BEGIN_ALLOW_THREADS
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
463 res = (*func)(fd);
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
464 Py_END_ALLOW_THREADS
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
465 if (res < 0)
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
466 return posix_error();
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
467 Py_INCREF(Py_None);
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
468 return Py_None;
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
469 }
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
470
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
471
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
472 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
473 posix_1str(PyObject *args, char *format, int (*func)(const char*))
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
474 {
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
475 char *path1 = NULL;
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
476 int res;
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
477 if (!PyArg_ParseTuple(args, format,
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
478 Py_FileSystemDefaultEncoding, &path1))
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
479 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
480 Py_BEGIN_ALLOW_THREADS
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
481 res = (*func)(path1);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
482 Py_END_ALLOW_THREADS
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
483 if (res < 0)
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
484 return posix_error_with_allocated_filename(path1);
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
485 PyMem_Free(path1);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
486 Py_INCREF(Py_None);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
487 return Py_None;
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
488 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
489
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
490 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
491 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
492 int (*func)(const char *, const char *))
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
493 {
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
494 char *path1 = NULL, *path2 = NULL;
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
495 int res;
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
496 if (!PyArg_ParseTuple(args, format,
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
497 Py_FileSystemDefaultEncoding, &path1,
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
498 Py_FileSystemDefaultEncoding, &path2))
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
499 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
500 Py_BEGIN_ALLOW_THREADS
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
501 res = (*func)(path1, path2);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
502 Py_END_ALLOW_THREADS
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
503 PyMem_Free(path1);
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
504 PyMem_Free(path2);
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
505 if (res != 0)
8708
acf49c9def7d Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents: 8497
diff changeset
506 /* XXX how to report both path1 and path2??? */
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
507 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
508 Py_INCREF(Py_None);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
509 return Py_None;
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
510 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
511
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
512 static char stat_result__doc__[] =
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
513 "stat_result: Result from stat or lstat.\n\n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
514 This object may be accessed either as a tuple of\n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
515 (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)\n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
516 or via the attributes st_mode, st_ino, st_dev, st_nlink, st_uid, and so on.\n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
517 \n\
20543
a8995a6de8d0 Don't leave bare newlines in long strings -- VC doesn't like that.
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
518 Posix/windows: If your platform supports st_blksize, st_blocks, or st_rdev,\n\
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
519 they are available as attributes only.\n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
520 \n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
521 See os.stat for more information.\n";
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
522
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
523 static PyStructSequence_Field stat_result_fields[] = {
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
524 {"st_mode", "protection bits"},
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
525 {"st_ino", "inode"},
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
526 {"st_dev", "device"},
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
527 {"st_nlink", "number of hard links"},
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
528 {"st_uid", "user ID of owner"},
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
529 {"st_gid", "group ID of owner"},
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
530 {"st_size", "total size, in bytes"},
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
531 {"st_atime", "time of last access"},
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
532 {"st_mtime", "time of last modification"},
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
533 {"st_ctime", "time of last change"},
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
534 #ifdef HAVE_ST_BLKSIZE
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
535 {"st_blksize", "blocksize for filesystem I/O"},
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
536 #endif
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
537 #ifdef HAVE_ST_BLOCKS
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
538 {"st_blocks", "number of blocks allocated"},
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
539 #endif
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
540 #ifdef HAVE_ST_RDEV
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
541 {"st_rdev", "device type (if inode device)"},
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
542 #endif
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
543 {0}
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
544 };
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
545
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
546 #ifdef HAVE_ST_BLKSIZE
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
547 #define ST_BLKSIZE_IDX 10
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
548 #else
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
549 #define ST_BLKSIZE_IDX 9
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
550 #endif
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
551
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
552 #ifdef HAVE_ST_BLOCKS
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
553 #define ST_BLOCKS_IDX (ST_BLKSIZE_IDX+1)
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
554 #else
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
555 #define ST_BLOCKS_IDX ST_BLKSIZE_IDX
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
556 #endif
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
557
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
558 #ifdef HAVE_ST_RDEV
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
559 #define ST_RDEV_IDX (ST_BLOCKS_IDX+1)
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
560 #else
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
561 #define ST_RDEV_IDX ST_BLOCKS_IDX
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
562 #endif
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
563
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
564 static PyStructSequence_Desc stat_result_desc = {
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
565 "stat_result", /* name */
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
566 stat_result__doc__, /* doc */
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
567 stat_result_fields,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
568 10
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
569 };
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
570
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
571 static char statvfs_result__doc__[] =
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
572 "statvfs_result: Result from statvfs or fstatvfs.\n\n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
573 This object may be accessed either as a tuple of\n\
20543
a8995a6de8d0 Don't leave bare newlines in long strings -- VC doesn't like that.
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
574 (bsize,frsize,blocks,bfree,bavail,files,ffree,favail,flag,namemax),\n\
a8995a6de8d0 Don't leave bare newlines in long strings -- VC doesn't like that.
Guido van Rossum <guido@python.org>
parents: 20539
diff changeset
575 or via the attributes f_bsize, f_frsize, f_blocks, f_bfree, and so on.\n\
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
576 \n\
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
577 See os.statvfs for more information.\n";
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
578
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
579 static PyStructSequence_Field statvfs_result_fields[] = {
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
580 {"f_bsize", },
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
581 {"f_frsize", },
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
582 {"f_blocks", },
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
583 {"f_bfree", },
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
584 {"f_bavail", },
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
585 {"f_files", },
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
586 {"f_ffree", },
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
587 {"f_favail", },
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
588 {"f_flag", },
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
589 {"f_namemax",},
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
590 {0}
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
591 };
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
592
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
593 static PyStructSequence_Desc statvfs_result_desc = {
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
594 "statvfs_result", /* name */
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
595 statvfs_result__doc__, /* doc */
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
596 statvfs_result_fields,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
597 10
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
598 };
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
599
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
600 static PyTypeObject StatResultType;
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
601 static PyTypeObject StatVFSResultType;
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
602
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
603 /* 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
604 (used by posix_stat() and posix_fstat()) */
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
605 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
606 _pystat_fromstructstat(STRUCT_STAT st)
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
607 {
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
608 PyObject *v = PyStructSequence_New(&StatResultType);
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
609 if (v == NULL)
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
610 return NULL;
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
611
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
612 PyStructSequence_SET_ITEM(v, 0, PyInt_FromLong((long)st.st_mode));
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
613 #ifdef HAVE_LARGEFILE_SUPPORT
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
614 PyStructSequence_SET_ITEM(v, 1,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
615 PyLong_FromLongLong((LONG_LONG)st.st_ino));
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
616 #else
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
617 PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long)st.st_ino));
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
618 #endif
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
619 #if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS)
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
620 PyStructSequence_SET_ITEM(v, 2,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
621 PyLong_FromLongLong((LONG_LONG)st.st_dev));
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
622 #else
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
623 PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long)st.st_dev));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
624 #endif
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
625 PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long)st.st_nlink));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
626 PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long)st.st_uid));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
627 PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long)st.st_gid));
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
628 #ifdef HAVE_LARGEFILE_SUPPORT
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
629 PyStructSequence_SET_ITEM(v, 6,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
630 PyLong_FromLongLong((LONG_LONG)st.st_size));
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
631 #else
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
632 PyStructSequence_SET_ITEM(v, 6, PyInt_FromLong(st.st_size));
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
633 #endif
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
634 #if SIZEOF_TIME_T > SIZEOF_LONG
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
635 PyStructSequence_SET_ITEM(v, 7,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
636 PyLong_FromLongLong((LONG_LONG)st.st_atime));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
637 PyStructSequence_SET_ITEM(v, 8,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
638 PyLong_FromLongLong((LONG_LONG)st.st_mtime));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
639 PyStructSequence_SET_ITEM(v, 9,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
640 PyLong_FromLongLong((LONG_LONG)st.st_ctime));
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
641 #else
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
642 PyStructSequence_SET_ITEM(v, 7, PyInt_FromLong((long)st.st_atime));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
643 PyStructSequence_SET_ITEM(v, 8, PyInt_FromLong((long)st.st_mtime));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
644 PyStructSequence_SET_ITEM(v, 9, PyInt_FromLong((long)st.st_ctime));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
645 #endif
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
646
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
647 #ifdef HAVE_ST_BLKSIZE
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
648 PyStructSequence_SET_ITEM(v, ST_BLKSIZE_IDX,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
649 PyInt_FromLong((long)st.st_blksize));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
650 #endif
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
651 #ifdef HAVE_ST_BLOCKS
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
652 PyStructSequence_SET_ITEM(v, ST_BLOCKS_IDX,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
653 PyInt_FromLong((long)st.st_blocks));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
654 #endif
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
655 #ifdef HAVE_ST_RDEV
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
656 PyStructSequence_SET_ITEM(v, ST_RDEV_IDX,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
657 PyInt_FromLong((long)st.st_rdev));
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
658 #endif
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
659
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
660 if (PyErr_Occurred()) {
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
661 Py_DECREF(v);
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
662 return NULL;
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
663 }
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
664
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
665 return v;
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
666 }
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
667
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
668 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
669 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
670 int (*statfunc)(const char *, STRUCT_STAT *))
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
671 {
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
672 STRUCT_STAT st;
21489
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
673 char *path = NULL; /* pass this to stat; do not free() it */
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
674 char *pathfree = NULL; /* this memory must be free'd */
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
675 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
676
ca7b99d27a40 Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents: 12393
diff changeset
677 #ifdef MS_WIN32
21489
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
678 int pathlen;
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
679 char pathcopy[MAX_PATH];
12435
ca7b99d27a40 Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents: 12393
diff changeset
680 #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
681
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
682 if (!PyArg_ParseTuple(args, format,
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
683 Py_FileSystemDefaultEncoding, &path))
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
684 return NULL;
21489
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
685 pathfree = path;
12435
ca7b99d27a40 Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents: 12393
diff changeset
686
ca7b99d27a40 Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents: 12393
diff changeset
687 #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
688 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
689 /* 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
690 if (pathlen > MAX_PATH) {
21489
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
691 PyMem_Free(pathfree);
12435
ca7b99d27a40 Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents: 12393
diff changeset
692 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
693 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
694 }
ca7b99d27a40 Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents: 12393
diff changeset
695
21489
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
696 /* Remove trailing slash or backslash, unless it's the current
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
697 drive root (/ or \) or a specific drive's root (like c:\ or c:/).
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
698 */
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
699 if (pathlen > 0 &&
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
700 (path[pathlen-1]== '\\' || path[pathlen-1] == '/')) {
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
701 /* It does end with a slash -- exempt the root drive cases. */
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
702 /* XXX UNC root drives should also be exempted? */
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
703 if (pathlen == 1 || (pathlen == 3 && path[1] == ':'))
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
704 /* leave it alone */;
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
705 else {
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
706 /* nuke the trailing backslash */
12435
ca7b99d27a40 Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents: 12393
diff changeset
707 strncpy(pathcopy, path, pathlen);
21489
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
708 pathcopy[pathlen-1] = '\0';
12435
ca7b99d27a40 Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents: 12393
diff changeset
709 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
710 }
ca7b99d27a40 Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents: 12393
diff changeset
711 }
ca7b99d27a40 Patch by Brian Hooper, somewhat augmented by GvR, to strip a trailing
Guido van Rossum <guido@python.org>
parents: 12393
diff changeset
712 #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
713
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
714 Py_BEGIN_ALLOW_THREADS
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
715 res = (*statfunc)(path, &st);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
716 Py_END_ALLOW_THREADS
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
717 if (res != 0)
21489
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
718 return posix_error_with_allocated_filename(pathfree);
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
719
1d1c46824fc3 SF bug #495021: Crash calling os.stat with a trailing backslash
Tim Peters <tim.peters@gmail.com>
parents: 21313
diff changeset
720 PyMem_Free(pathfree);
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
721 return _pystat_fromstructstat(st);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
722 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
723
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
724
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
725 /* POSIX methods */
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
726
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
727 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
728 "access(path, mode) -> 1 if granted, 0 otherwise\n\
23901
01cdd38d35fa Corect speling and add \n\ to line ends in new docstring for access().
Guido van Rossum <guido@python.org>
parents: 23898
diff changeset
729 Use the real uid/gid to test for access to a path. Note that most\n\
01cdd38d35fa Corect speling and add \n\ to line ends in new docstring for access().
Guido van Rossum <guido@python.org>
parents: 23898
diff changeset
730 operations will use the effective uid/gid, therefore this routine can\n\
01cdd38d35fa Corect speling and add \n\ to line ends in new docstring for access().
Guido van Rossum <guido@python.org>
parents: 23898
diff changeset
731 be used in a suid/sgid environment to test if the invoking user has the\n\
01cdd38d35fa Corect speling and add \n\ to line ends in new docstring for access().
Guido van Rossum <guido@python.org>
parents: 23898
diff changeset
732 specified access to the path. The mode argument can be F_OK to test\n\
01cdd38d35fa Corect speling and add \n\ to line ends in new docstring for access().
Guido van Rossum <guido@python.org>
parents: 23898
diff changeset
733 existence, or the inclusive-OR of R_OK, W_OK, and X_OK.";
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
734
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
735 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
736 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
737 {
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
738 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
739 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
740 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
741
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
742 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
743 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
744 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
745 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
746 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
747 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
748 }
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
749
9939
faf351e31571 Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents: 9824
diff changeset
750 #ifndef F_OK
faf351e31571 Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents: 9824
diff changeset
751 #define F_OK 0
faf351e31571 Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents: 9824
diff changeset
752 #endif
faf351e31571 Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents: 9824
diff changeset
753 #ifndef R_OK
faf351e31571 Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents: 9824
diff changeset
754 #define R_OK 4
faf351e31571 Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents: 9824
diff changeset
755 #endif
faf351e31571 Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents: 9824
diff changeset
756 #ifndef W_OK
faf351e31571 Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents: 9824
diff changeset
757 #define W_OK 2
faf351e31571 Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents: 9824
diff changeset
758 #endif
faf351e31571 Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents: 9824
diff changeset
759 #ifndef X_OK
faf351e31571 Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents: 9824
diff changeset
760 #define X_OK 1
faf351e31571 Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents: 9824
diff changeset
761 #endif
faf351e31571 Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents: 9824
diff changeset
762
faf351e31571 Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents: 9824
diff changeset
763 #ifdef HAVE_TTYNAME
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
764 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
765 "ttyname(fd) -> String\n\
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
766 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
767
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
768 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
769 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
770 {
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
771 int id;
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
772 char *ret;
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
773
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
774 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
775 return NULL;
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
776
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
777 ret = ttyname(id);
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
778 if (ret == NULL)
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
779 return(posix_error());
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
780 return(PyString_FromString(ret));
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
781 }
9939
faf351e31571 Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents: 9824
diff changeset
782 #endif
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
783
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
784 #ifdef HAVE_CTERMID
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
785 static char posix_ctermid__doc__[] =
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
786 "ctermid() -> String\n\
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
787 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
788
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
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_ctermid(PyObject *self, PyObject *args)
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
791 {
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
792 char *ret;
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
793 char buffer[L_ctermid];
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
794
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
795 if (!PyArg_ParseTuple(args, ":ctermid"))
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
796 return NULL;
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
797
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
798 #ifdef USE_CTERMID_R
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
799 ret = ctermid_r(buffer);
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
800 #else
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
801 ret = ctermid(buffer);
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
802 #endif
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
803 if (ret == NULL)
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
804 return(posix_error());
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
805 return(PyString_FromString(buffer));
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
806 }
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
807 #endif
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
808
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
809 static char posix_chdir__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
810 "chdir(path) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
811 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
812
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
813 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
814 posix_chdir(PyObject *self, PyObject *args)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
815 {
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
816 return posix_1str(args, "et:chdir", chdir);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
817 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
818
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
819
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
820 static char posix_chmod__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
821 "chmod(path, mode) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
822 Change the access permissions of a file.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
823
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
824 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
825 posix_chmod(PyObject *self, PyObject *args)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
826 {
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
827 char *path = NULL;
12139
338e055b7cc0 Two robustness patches:
Guido van Rossum <guido@python.org>
parents: 11893
diff changeset
828 int i;
338e055b7cc0 Two robustness patches:
Guido van Rossum <guido@python.org>
parents: 11893
diff changeset
829 int res;
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
830 if (!PyArg_ParseTuple(args, "eti", Py_FileSystemDefaultEncoding,
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
831 &path, &i))
12139
338e055b7cc0 Two robustness patches:
Guido van Rossum <guido@python.org>
parents: 11893
diff changeset
832 return NULL;
338e055b7cc0 Two robustness patches:
Guido van Rossum <guido@python.org>
parents: 11893
diff changeset
833 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
834 res = chmod(path, i);
12139
338e055b7cc0 Two robustness patches:
Guido van Rossum <guido@python.org>
parents: 11893
diff changeset
835 Py_END_ALLOW_THREADS
338e055b7cc0 Two robustness patches:
Guido van Rossum <guido@python.org>
parents: 11893
diff changeset
836 if (res < 0)
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
837 return posix_error_with_allocated_filename(path);
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
838 PyMem_Free(path);
12139
338e055b7cc0 Two robustness patches:
Guido van Rossum <guido@python.org>
parents: 11893
diff changeset
839 Py_INCREF(Py_None);
338e055b7cc0 Two robustness patches:
Guido van Rossum <guido@python.org>
parents: 11893
diff changeset
840 return Py_None;
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
841 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
842
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
843
20264
d092abcf9c4b Add chroot call. Implements feature #459267.
Martin v. Löwis <martin@v.loewis.de>
parents: 19754
diff changeset
844 #ifdef HAVE_CHROOT
d092abcf9c4b Add chroot call. Implements feature #459267.
Martin v. Löwis <martin@v.loewis.de>
parents: 19754
diff changeset
845 static char posix_chroot__doc__[] =
d092abcf9c4b Add chroot call. Implements feature #459267.
Martin v. Löwis <martin@v.loewis.de>
parents: 19754
diff changeset
846 "chroot(path) -> None\n\
d092abcf9c4b Add chroot call. Implements feature #459267.
Martin v. Löwis <martin@v.loewis.de>
parents: 19754
diff changeset
847 Change root directory to path.";
d092abcf9c4b Add chroot call. Implements feature #459267.
Martin v. Löwis <martin@v.loewis.de>
parents: 19754
diff changeset
848
d092abcf9c4b Add chroot call. Implements feature #459267.
Martin v. Löwis <martin@v.loewis.de>
parents: 19754
diff changeset
849 static PyObject *
d092abcf9c4b Add chroot call. Implements feature #459267.
Martin v. Löwis <martin@v.loewis.de>
parents: 19754
diff changeset
850 posix_chroot(PyObject *self, PyObject *args)
d092abcf9c4b Add chroot call. Implements feature #459267.
Martin v. Löwis <martin@v.loewis.de>
parents: 19754
diff changeset
851 {
d092abcf9c4b Add chroot call. Implements feature #459267.
Martin v. Löwis <martin@v.loewis.de>
parents: 19754
diff changeset
852 return posix_1str(args, "et:chroot", chroot);
d092abcf9c4b Add chroot call. Implements feature #459267.
Martin v. Löwis <martin@v.loewis.de>
parents: 19754
diff changeset
853 }
d092abcf9c4b Add chroot call. Implements feature #459267.
Martin v. Löwis <martin@v.loewis.de>
parents: 19754
diff changeset
854 #endif
d092abcf9c4b Add chroot call. Implements feature #459267.
Martin v. Löwis <martin@v.loewis.de>
parents: 19754
diff changeset
855
9822
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
856 #ifdef HAVE_FSYNC
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
857 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
858 "fsync(fildes) -> None\n\
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
859 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
860
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
861 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
862 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
863 {
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
864 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
865 }
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
866 #endif /* HAVE_FSYNC */
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
867
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
868 #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
869
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
870 #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
871 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
872 #endif
5f638a299888 Hopefully fix the problem with undeclared fdatasync() on HP-UX that
Guido van Rossum <guido@python.org>
parents: 14752
diff changeset
873
9822
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
874 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
875 "fdatasync(fildes) -> None\n\
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
876 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
877 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
878
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
879 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
880 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
881 {
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
882 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
883 }
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
884 #endif /* HAVE_FDATASYNC */
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
885
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
886
13513
6057f44b0b7a - stupid typo.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13511
diff changeset
887 #ifdef HAVE_CHOWN
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
888 static char posix_chown__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
889 "chown(path, uid, gid) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
890 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
891
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
892 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
893 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
894 {
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
895 char *path = NULL;
13511
18395ca5c30e -- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents: 13486
diff changeset
896 int uid, gid;
18395ca5c30e -- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents: 13486
diff changeset
897 int res;
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
898 if (!PyArg_ParseTuple(args, "etii:chown",
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
899 Py_FileSystemDefaultEncoding, &path,
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
900 &uid, &gid))
13511
18395ca5c30e -- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents: 13486
diff changeset
901 return NULL;
18395ca5c30e -- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents: 13486
diff changeset
902 Py_BEGIN_ALLOW_THREADS
18395ca5c30e -- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents: 13486
diff changeset
903 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
904 Py_END_ALLOW_THREADS
18395ca5c30e -- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents: 13486
diff changeset
905 if (res < 0)
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
906 return posix_error_with_allocated_filename(path);
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
907 PyMem_Free(path);
13511
18395ca5c30e -- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents: 13486
diff changeset
908 Py_INCREF(Py_None);
18395ca5c30e -- get rid of a compiler warning on unix. (as reported
Fredrik Lundh <fredrik@pythonware.com>
parents: 13486
diff changeset
909 return Py_None;
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
910 }
1792
a584b4bbbc59 Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
911 #endif /* HAVE_CHOWN */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
912
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
913
2740
3e370a4b103b sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents: 2615
diff changeset
914 #ifdef HAVE_GETCWD
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
915 static char posix_getcwd__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
916 "getcwd() -> path\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
917 Return a string representing the current working directory.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
918
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
919 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
920 posix_getcwd(PyObject *self, PyObject *args)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
921 {
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
922 char buf[1026];
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
923 char *res;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
924 if (!PyArg_ParseTuple(args, ":getcwd"))
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
925 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
926 Py_BEGIN_ALLOW_THREADS
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
927 res = getcwd(buf, sizeof buf);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
928 Py_END_ALLOW_THREADS
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
929 if (res == NULL)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
930 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
931 return PyString_FromString(buf);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
932 }
2740
3e370a4b103b sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents: 2615
diff changeset
933 #endif
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
934
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
935
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
936 #ifdef HAVE_LINK
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
937 static char posix_link__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
938 "link(src, dst) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
939 Create a hard link to a file.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
940
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
941 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
942 posix_link(PyObject *self, PyObject *args)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
943 {
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
944 return posix_2str(args, "etet:link", link);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
945 }
1792
a584b4bbbc59 Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
946 #endif /* HAVE_LINK */
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
947
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
948
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
949 static char posix_listdir__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
950 "listdir(path) -> list_of_strings\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
951 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
952 \n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
953 path: path of directory to list\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
954 \n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
955 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
956 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
957
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
958 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
959 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
960 {
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
961 /* 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
962 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
963 #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
964
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
965 PyObject *d, *v;
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
966 HANDLE hFindFile;
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
967 WIN32_FIND_DATA FileData;
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
968 /* MAX_PATH characters could mean a bigger encoded string */
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
969 char namebuf[MAX_PATH*2+5];
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
970 char *bufptr = namebuf;
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
971 int len = sizeof(namebuf)/sizeof(namebuf[0]);
14586
cd1b9d8d045d Closes SF bug 113894: on Windows, things like os.listdir("k:") and
Tim Peters <tim.peters@gmail.com>
parents: 14375
diff changeset
972 char ch;
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
973
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
974 if (!PyArg_ParseTuple(args, "et#:listdir",
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
975 Py_FileSystemDefaultEncoding, &bufptr, &len))
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
976 return NULL;
14586
cd1b9d8d045d Closes SF bug 113894: on Windows, things like os.listdir("k:") and
Tim Peters <tim.peters@gmail.com>
parents: 14375
diff changeset
977 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
978 if (ch != '/' && ch != '\\' && ch != ':')
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
979 namebuf[len++] = '/';
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
980 strcpy(namebuf + len, "*.*");
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
981
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
982 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
983 return NULL;
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
984
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
985 hFindFile = FindFirstFile(namebuf, &FileData);
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
986 if (hFindFile == INVALID_HANDLE_VALUE) {
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
987 errno = GetLastError();
8839
c2f9e505f75a In Win32 version of listdir(), when FindFirstFile() returns
Guido van Rossum <guido@python.org>
parents: 8823
diff changeset
988 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
989 return PyList_New(0);
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
990 return win32_error("FindFirstFile", namebuf);
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
991 }
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
992 do {
2845
051bacab59af suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents: 2740
diff changeset
993 if (FileData.cFileName[0] == '.' &&
051bacab59af suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents: 2740
diff changeset
994 (FileData.cFileName[1] == '\0' ||
051bacab59af suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents: 2740
diff changeset
995 FileData.cFileName[1] == '.' &&
051bacab59af suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents: 2740
diff changeset
996 FileData.cFileName[2] == '\0'))
051bacab59af suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents: 2740
diff changeset
997 continue;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
998 v = PyString_FromString(FileData.cFileName);
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
999 if (v == NULL) {
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1000 Py_DECREF(d);
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1001 d = NULL;
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1002 break;
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1003 }
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1004 if (PyList_Append(d, v) != 0) {
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1005 Py_DECREF(v);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1006 Py_DECREF(d);
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1007 d = NULL;
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1008 break;
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1009 }
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1010 Py_DECREF(v);
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1011 } while (FindNextFile(hFindFile, &FileData) == TRUE);
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1012
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
1013 if (FindClose(hFindFile) == FALSE)
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1014 return win32_error("FindClose", namebuf);
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1015
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1016 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
1017
14586
cd1b9d8d045d Closes SF bug 113894: on Windows, things like os.listdir("k:") and
Tim Peters <tim.peters@gmail.com>
parents: 14375
diff changeset
1018 #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
1019
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1020 #ifndef MAX_PATH
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1021 #define MAX_PATH 250
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1022 #endif
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1023 char *name, *pt;
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1024 int len;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1025 PyObject *d, *v;
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1026 char namebuf[MAX_PATH+5];
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1027 struct _find_t ep;
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1028
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
1029 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
1030 return NULL;
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1031 if (len >= MAX_PATH) {
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1032 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
1033 return NULL;
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1034 }
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1035 strcpy(namebuf, name);
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1036 for (pt = namebuf; *pt; pt++)
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1037 if (*pt == '/')
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1038 *pt = '\\';
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1039 if (namebuf[len-1] != '\\')
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1040 namebuf[len++] = '\\';
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1041 strcpy(namebuf + len, "*.*");
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1042
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1043 if ((d = PyList_New(0)) == NULL)
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1044 return NULL;
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1045
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1046 if (_dos_findfirst(namebuf, _A_RDONLY |
4785
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
1047 _A_HIDDEN | _A_SYSTEM | _A_SUBDIR, &ep) != 0)
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
1048 {
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1049 errno = ENOENT;
10887
af07389c8517 posix_listdir(): When an error occurs, call
Barry Warsaw <barry@python.org>
parents: 10526
diff changeset
1050 return posix_error_with_filename(name);
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1051 }
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1052 do {
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1053 if (ep.name[0] == '.' &&
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1054 (ep.name[1] == '\0' ||
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1055 ep.name[1] == '.' &&
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1056 ep.name[2] == '\0'))
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1057 continue;
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1058 strcpy(namebuf, ep.name);
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1059 for (pt = namebuf; *pt; pt++)
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1060 if (isupper(*pt))
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1061 *pt = tolower(*pt);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1062 v = PyString_FromString(namebuf);
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1063 if (v == NULL) {
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1064 Py_DECREF(d);
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1065 d = NULL;
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1066 break;
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1067 }
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1068 if (PyList_Append(d, v) != 0) {
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1069 Py_DECREF(v);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1070 Py_DECREF(d);
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1071 d = NULL;
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1072 break;
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1073 }
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1074 Py_DECREF(v);
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1075 } while (_dos_findnext(&ep) == 0);
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1076
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1077 return d;
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1078
14586
cd1b9d8d045d Closes SF bug 113894: on Windows, things like os.listdir("k:") and
Tim Peters <tim.peters@gmail.com>
parents: 14375
diff changeset
1079 #elif defined(PYOS_OS2)
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1080
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1081 #ifndef MAX_PATH
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1082 #define MAX_PATH CCHMAXPATH
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1083 #endif
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1084 char *name, *pt;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1085 int len;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1086 PyObject *d, *v;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1087 char namebuf[MAX_PATH+5];
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1088 HDIR hdir = 1;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1089 ULONG srchcnt = 1;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1090 FILEFINDBUF3 ep;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1091 APIRET rc;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1092
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
1093 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
1094 return NULL;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1095 if (len >= MAX_PATH) {
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1096 PyErr_SetString(PyExc_ValueError, "path too long");
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1097 return NULL;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1098 }
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1099 strcpy(namebuf, name);
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1100 for (pt = namebuf; *pt; pt++)
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1101 if (*pt == '/')
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1102 *pt = '\\';
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1103 if (namebuf[len-1] != '\\')
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1104 namebuf[len++] = '\\';
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1105 strcpy(namebuf + len, "*.*");
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1106
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1107 if ((d = PyList_New(0)) == NULL)
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1108 return NULL;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1109
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
1110 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
1111 &hdir, /* Handle to Use While Search Directory */
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1112 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
1113 &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
1114 &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
1115 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
1116
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1117 if (rc != NO_ERROR) {
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1118 errno = ENOENT;
10887
af07389c8517 posix_listdir(): When an error occurs, call
Barry Warsaw <barry@python.org>
parents: 10526
diff changeset
1119 return posix_error_with_filename(name);
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1120 }
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1121
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
1122 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
1123 do {
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1124 if (ep.achName[0] == '.'
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1125 && (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
1126 continue; /* Skip Over "." and ".." Names */
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1127
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1128 strcpy(namebuf, ep.achName);
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1129
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
1130 /* 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
1131 /* (Removed Forced Lowercasing Code) */
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1132
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1133 v = PyString_FromString(namebuf);
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1134 if (v == NULL) {
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1135 Py_DECREF(d);
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1136 d = NULL;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1137 break;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1138 }
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1139 if (PyList_Append(d, v) != 0) {
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1140 Py_DECREF(v);
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1141 Py_DECREF(d);
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1142 d = NULL;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1143 break;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1144 }
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1145 Py_DECREF(v);
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1146 } 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
1147 }
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1148
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1149 return d;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
1150 #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
1151
643
02d3f161b7f5 Use getargs() function.
Guido van Rossum <guido@python.org>
parents: 373
diff changeset
1152 char *name;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1153 PyObject *d, *v;
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1154 DIR *dirp;
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1155 struct dirent *ep;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
1156 if (!PyArg_ParseTuple(args, "s:listdir", &name))
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1157 return NULL;
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
1158 if ((dirp = opendir(name)) == NULL) {
10887
af07389c8517 posix_listdir(): When an error occurs, call
Barry Warsaw <barry@python.org>
parents: 10526
diff changeset
1159 return posix_error_with_filename(name);
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
1160 }
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1161 if ((d = PyList_New(0)) == NULL) {
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1162 closedir(dirp);
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1163 return NULL;
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1164 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1165 while ((ep = readdir(dirp)) != NULL) {
2845
051bacab59af suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents: 2740
diff changeset
1166 if (ep->d_name[0] == '.' &&
051bacab59af suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents: 2740
diff changeset
1167 (NAMLEN(ep) == 1 ||
4600
d36250aefb82 Keep gcc -Wall happy.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
1168 (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
1169 continue;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1170 v = PyString_FromStringAndSize(ep->d_name, NAMLEN(ep));
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1171 if (v == NULL) {
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1172 Py_DECREF(d);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1173 d = NULL;
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1174 break;
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1175 }
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1176 if (PyList_Append(d, v) != 0) {
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1177 Py_DECREF(v);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1178 Py_DECREF(d);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1179 d = NULL;
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1180 break;
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1181 }
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1182 Py_DECREF(v);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1183 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1184 closedir(dirp);
200
9d01965f4f48 Incorporated MSDOS changes (untested).
Guido van Rossum <guido@python.org>
parents: 199
diff changeset
1185
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1186 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
1187
14586
cd1b9d8d045d Closes SF bug 113894: on Windows, things like os.listdir("k:") and
Tim Peters <tim.peters@gmail.com>
parents: 14375
diff changeset
1188 #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
1189 } /* end of posix_listdir */
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1190
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1191 #ifdef MS_WIN32
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1192 /* A helper function for abspath on win32 */
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1193 static PyObject *
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1194 posix__getfullpathname(PyObject *self, PyObject *args)
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1195 {
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1196 /* assume encoded strings wont more than double no of chars */
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1197 char inbuf[MAX_PATH*2];
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1198 char *inbufp = inbuf;
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1199 int insize = sizeof(inbuf)/sizeof(inbuf[0]);
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1200 char outbuf[MAX_PATH*2];
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1201 char *temp;
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1202 if (!PyArg_ParseTuple (args, "et#:_getfullpathname",
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1203 Py_FileSystemDefaultEncoding, &inbufp,
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1204 &insize))
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1205 return NULL;
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1206 if (!GetFullPathName(inbuf, sizeof(outbuf)/sizeof(outbuf[0]),
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1207 outbuf, &temp))
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1208 return win32_error("GetFullPathName", inbuf);
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1209 return PyString_FromString(outbuf);
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1210 } /* end of posix__getfullpathname */
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1211 #endif /* MS_WIN32 */
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1212
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1213 static char posix_mkdir__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1214 "mkdir(path [, mode=0777]) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1215 Create a directory.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1216
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1217 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
1218 posix_mkdir(PyObject *self, PyObject *args)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1219 {
3418
0ac5fbaf8aef Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents: 3387
diff changeset
1220 int res;
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1221 char *path = NULL;
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1222 int mode = 0777;
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1223 if (!PyArg_ParseTuple(args, "et|i:mkdir",
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1224 Py_FileSystemDefaultEncoding, &path, &mode))
3418
0ac5fbaf8aef Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents: 3387
diff changeset
1225 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1226 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
1227 #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
1228 res = mkdir(path);
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1229 #else
3418
0ac5fbaf8aef Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents: 3387
diff changeset
1230 res = mkdir(path, mode);
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1231 #endif
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1232 Py_END_ALLOW_THREADS
3418
0ac5fbaf8aef Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents: 3387
diff changeset
1233 if (res < 0)
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1234 return posix_error_with_allocated_filename(path);
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1235 PyMem_Free(path);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1236 Py_INCREF(Py_None);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1237 return Py_None;
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1238 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1239
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1240
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1241 #ifdef HAVE_NICE
18486
26fc905ddc12 Re-do the broken-nice() patch to break less platforms. Hopefully none :P
Thomas Wouters <thomas@python.org>
parents: 18476
diff changeset
1242 #if defined(HAVE_BROKEN_NICE) && defined(HAVE_SYS_RESOURCE_H)
26fc905ddc12 Re-do the broken-nice() patch to break less platforms. Hopefully none :P
Thomas Wouters <thomas@python.org>
parents: 18476
diff changeset
1243 #if defined(HAVE_GETPRIORITY) && !defined(PRIO_PROCESS)
26fc905ddc12 Re-do the broken-nice() patch to break less platforms. Hopefully none :P
Thomas Wouters <thomas@python.org>
parents: 18476
diff changeset
1244 #include <sys/resource.h>
26fc905ddc12 Re-do the broken-nice() patch to break less platforms. Hopefully none :P
Thomas Wouters <thomas@python.org>
parents: 18476
diff changeset
1245 #endif
26fc905ddc12 Re-do the broken-nice() patch to break less platforms. Hopefully none :P
Thomas Wouters <thomas@python.org>
parents: 18476
diff changeset
1246 #endif
26fc905ddc12 Re-do the broken-nice() patch to break less platforms. Hopefully none :P
Thomas Wouters <thomas@python.org>
parents: 18476
diff changeset
1247
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1248 static char posix_nice__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1249 "nice(inc) -> new_priority\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1250 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
1251
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1252 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
1253 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
1254 {
950cd37fcddc * Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents: 1177
diff changeset
1255 int increment, value;
950cd37fcddc * Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents: 1177
diff changeset
1256
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
1257 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
1258 return NULL;
18476
04e25c01849b Patch #439995 (slightly modified from the uploaded version):
Thomas Wouters <thomas@python.org>
parents: 17831
diff changeset
1259
04e25c01849b Patch #439995 (slightly modified from the uploaded version):
Thomas Wouters <thomas@python.org>
parents: 17831
diff changeset
1260 /* There are two flavours of 'nice': one that returns the new
04e25c01849b Patch #439995 (slightly modified from the uploaded version):
Thomas Wouters <thomas@python.org>
parents: 17831
diff changeset
1261 priority (as required by almost all standards out there) and the
18486
26fc905ddc12 Re-do the broken-nice() patch to break less platforms. Hopefully none :P
Thomas Wouters <thomas@python.org>
parents: 18476
diff changeset
1262 Linux/FreeBSD/BSDI one, which returns '0' on success and advices
26fc905ddc12 Re-do the broken-nice() patch to break less platforms. Hopefully none :P
Thomas Wouters <thomas@python.org>
parents: 18476
diff changeset
1263 the use of getpriority() to get the new priority.
18476
04e25c01849b Patch #439995 (slightly modified from the uploaded version):
Thomas Wouters <thomas@python.org>
parents: 17831
diff changeset
1264
04e25c01849b Patch #439995 (slightly modified from the uploaded version):
Thomas Wouters <thomas@python.org>
parents: 17831
diff changeset
1265 If we are of the nice family that returns the new priority, we
04e25c01849b Patch #439995 (slightly modified from the uploaded version):
Thomas Wouters <thomas@python.org>
parents: 17831
diff changeset
1266 need to clear errno before the call, and check if errno is filled
04e25c01849b Patch #439995 (slightly modified from the uploaded version):
Thomas Wouters <thomas@python.org>
parents: 17831
diff changeset
1267 before calling posix_error() on a returnvalue of -1, because the
04e25c01849b Patch #439995 (slightly modified from the uploaded version):
Thomas Wouters <thomas@python.org>
parents: 17831
diff changeset
1268 -1 may be the actual new priority! */
04e25c01849b Patch #439995 (slightly modified from the uploaded version):
Thomas Wouters <thomas@python.org>
parents: 17831
diff changeset
1269
04e25c01849b Patch #439995 (slightly modified from the uploaded version):
Thomas Wouters <thomas@python.org>
parents: 17831
diff changeset
1270 errno = 0;
1181
950cd37fcddc * Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents: 1177
diff changeset
1271 value = nice(increment);
18486
26fc905ddc12 Re-do the broken-nice() patch to break less platforms. Hopefully none :P
Thomas Wouters <thomas@python.org>
parents: 18476
diff changeset
1272 #if defined(HAVE_BROKEN_NICE) && defined(HAVE_GETPRIORITY)
18476
04e25c01849b Patch #439995 (slightly modified from the uploaded version):
Thomas Wouters <thomas@python.org>
parents: 17831
diff changeset
1273 if (value == 0)
04e25c01849b Patch #439995 (slightly modified from the uploaded version):
Thomas Wouters <thomas@python.org>
parents: 17831
diff changeset
1274 value = getpriority(PRIO_PROCESS, 0);
04e25c01849b Patch #439995 (slightly modified from the uploaded version):
Thomas Wouters <thomas@python.org>
parents: 17831
diff changeset
1275 #endif
04e25c01849b Patch #439995 (slightly modified from the uploaded version):
Thomas Wouters <thomas@python.org>
parents: 17831
diff changeset
1276 if (value == -1 && errno != 0)
04e25c01849b Patch #439995 (slightly modified from the uploaded version):
Thomas Wouters <thomas@python.org>
parents: 17831
diff changeset
1277 /* either nice() or getpriority() returned an error */
1181
950cd37fcddc * Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents: 1177
diff changeset
1278 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1279 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
1280 }
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1281 #endif /* HAVE_NICE */
199
0a3e33cfd4a9 Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents: 145
diff changeset
1282
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1283
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1284 static char posix_rename__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1285 "rename(old, new) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1286 Rename a file or directory.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1287
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1288 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
1289 posix_rename(PyObject *self, PyObject *args)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1290 {
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1291 return posix_2str(args, "etet:rename", rename);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1292 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1293
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1294
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1295 static char posix_rmdir__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1296 "rmdir(path) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1297 Remove a directory.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1298
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1299 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
1300 posix_rmdir(PyObject *self, PyObject *args)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1301 {
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1302 return posix_1str(args, "et:rmdir", rmdir);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1303 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1304
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1305
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1306 static char posix_stat__doc__[] =
22255
093942bae1a6 Update docstrings to use te attribute names of the new structures returned
Fred Drake <fdrake@acm.org>
parents: 21713
diff changeset
1307 "stat(path) -> (st_mode, st_ino, st_dev, st_nlink, st_uid, st_gid,\n\
093942bae1a6 Update docstrings to use te attribute names of the new structures returned
Fred Drake <fdrake@acm.org>
parents: 21713
diff changeset
1308 st_size, st_atime, st_mtime, st_ctime)\n\
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1309 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
1310
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1311 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
1312 posix_stat(PyObject *self, PyObject *args)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1313 {
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1314 return posix_do_stat(self, args, "et:stat", STAT);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1315 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1316
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1317
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1318 #ifdef HAVE_SYSTEM
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1319 static char posix_system__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1320 "system(command) -> exit_status\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1321 Execute the command (a string) in a subshell.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1322
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1323 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
1324 posix_system(PyObject *self, PyObject *args)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1325 {
643
02d3f161b7f5 Use getargs() function.
Guido van Rossum <guido@python.org>
parents: 373
diff changeset
1326 char *command;
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
1327 long sts;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
1328 if (!PyArg_ParseTuple(args, "s:system", &command))
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1329 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1330 Py_BEGIN_ALLOW_THREADS
643
02d3f161b7f5 Use getargs() function.
Guido van Rossum <guido@python.org>
parents: 373
diff changeset
1331 sts = system(command);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1332 Py_END_ALLOW_THREADS
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1333 return PyInt_FromLong(sts);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1334 }
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1335 #endif
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1336
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1337
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1338 static char posix_umask__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1339 "umask(new_mask) -> old_mask\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1340 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
1341
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1342 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
1343 posix_umask(PyObject *self, PyObject *args)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1344 {
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1345 int i;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
1346 if (!PyArg_ParseTuple(args, "i:umask", &i))
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1347 return NULL;
18749
c6ef71e943dd Remove warnings from the SGI compiler.
Fred Drake <fdrake@acm.org>
parents: 18674
diff changeset
1348 i = (int)umask(i);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1349 if (i < 0)
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1350 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1351 return PyInt_FromLong((long)i);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1352 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1353
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1354
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1355 static char posix_unlink__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1356 "unlink(path) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1357 Remove a file (same as remove(path)).";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1358
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1359 static char posix_remove__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1360 "remove(path) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1361 Remove a file (same as unlink(path)).";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1362
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1363 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
1364 posix_unlink(PyObject *self, PyObject *args)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1365 {
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
1366 return posix_1str(args, "et:remove", unlink);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1367 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1368
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1369
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1370 #ifdef HAVE_UNAME
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1371 static char posix_uname__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1372 "uname() -> (sysname, nodename, release, version, machine)\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1373 Return a tuple identifying the current operating system.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1374
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1375 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
1376 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
1377 {
5b521fe4d1f6 Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents: 643
diff changeset
1378 struct utsname u;
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
1379 int res;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
1380 if (!PyArg_ParseTuple(args, ":uname"))
731
c65fc172f16d Check empty argument lists.
Guido van Rossum <guido@python.org>
parents: 658
diff changeset
1381 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1382 Py_BEGIN_ALLOW_THREADS
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
1383 res = uname(&u);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1384 Py_END_ALLOW_THREADS
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
1385 if (res < 0)
658
5b521fe4d1f6 Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents: 643
diff changeset
1386 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1387 return Py_BuildValue("(sssss)",
4785
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
1388 u.sysname,
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
1389 u.nodename,
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
1390 u.release,
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
1391 u.version,
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
1392 u.machine);
658
5b521fe4d1f6 Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents: 643
diff changeset
1393 }
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1394 #endif /* HAVE_UNAME */
199
0a3e33cfd4a9 Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents: 145
diff changeset
1395
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1396
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1397 static char posix_utime__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1398 "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
1399 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
1400 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
1401 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
1402
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1403 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
1404 posix_utime(PyObject *self, PyObject *args)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1405 {
643
02d3f161b7f5 Use getargs() function.
Guido van Rossum <guido@python.org>
parents: 373
diff changeset
1406 char *path;
2236
1b662497426b uname 64-bit fix
Guido van Rossum <guido@python.org>
parents: 2114
diff changeset
1407 long atime, mtime;
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
1408 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
1409 PyObject* arg;
199
0a3e33cfd4a9 Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents: 145
diff changeset
1410
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
1411 /* 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
1412 #ifdef HAVE_UTIME_H
199
0a3e33cfd4a9 Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents: 145
diff changeset
1413 struct utimbuf buf;
0a3e33cfd4a9 Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents: 145
diff changeset
1414 #define ATIME buf.actime
0a3e33cfd4a9 Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents: 145
diff changeset
1415 #define MTIME buf.modtime
0a3e33cfd4a9 Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents: 145
diff changeset
1416 #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
1417 #else /* HAVE_UTIME_H */
199
0a3e33cfd4a9 Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents: 145
diff changeset
1418 time_t buf[2];
0a3e33cfd4a9 Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents: 145
diff changeset
1419 #define ATIME buf[0]
0a3e33cfd4a9 Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents: 145
diff changeset
1420 #define MTIME buf[1]
0a3e33cfd4a9 Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents: 145
diff changeset
1421 #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
1422 #endif /* HAVE_UTIME_H */
199
0a3e33cfd4a9 Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents: 145
diff changeset
1423
12533
5235656f9d0f posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents: 12503
diff changeset
1424 if (!PyArg_ParseTuple(args, "sO:utime", &path, &arg))
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1425 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
1426 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
1427 /* 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
1428 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
1429 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
1430 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
1431 }
5235656f9d0f posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents: 12503
diff changeset
1432 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
1433 PyErr_SetString(PyExc_TypeError,
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
1434 "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
1435 return NULL;
5235656f9d0f posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents: 12503
diff changeset
1436 }
5235656f9d0f posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents: 12503
diff changeset
1437 else {
5235656f9d0f posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents: 12503
diff changeset
1438 ATIME = atime;
5235656f9d0f posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents: 12503
diff changeset
1439 MTIME = mtime;
5235656f9d0f posix_utime(): Allow the second argument to be None, which invokes the
Barry Warsaw <barry@python.org>
parents: 12503
diff changeset
1440 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
1441 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
1442 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
1443 }
926
c156d4960c2b * Makefile: cosmetics
Guido van Rossum <guido@python.org>
parents: 861
diff changeset
1444 if (res < 0)
8708
acf49c9def7d Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents: 8497
diff changeset
1445 return posix_error_with_filename(path);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1446 Py_INCREF(Py_None);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1447 return Py_None;
199
0a3e33cfd4a9 Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents: 145
diff changeset
1448 #undef UTIME_ARG
0a3e33cfd4a9 Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents: 145
diff changeset
1449 #undef ATIME
0a3e33cfd4a9 Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents: 145
diff changeset
1450 #undef MTIME
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1451 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1452
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1453
264
72d1b89be35a Added popen().
Guido van Rossum <guido@python.org>
parents: 257
diff changeset
1454 /* Process operations */
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1455
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1456 static char posix__exit__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1457 "_exit(status)\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1458 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
1459
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1460 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
1461 posix__exit(PyObject *self, PyObject *args)
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1462 {
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1463 int sts;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
1464 if (!PyArg_ParseTuple(args, "i:_exit", &sts))
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1465 return NULL;
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1466 _exit(sts);
4600
d36250aefb82 Keep gcc -Wall happy.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
1467 return NULL; /* Make gcc -Wall happy */
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1468 }
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1469
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1470
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1471 #ifdef HAVE_EXECV
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1472 static char posix_execv__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1473 "execv(path, args)\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1474 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
1475 \n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1476 path: path of executable file\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1477 args: tuple or list of strings";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1478
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1479 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
1480 posix_execv(PyObject *self, PyObject *args)
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1481 {
643
02d3f161b7f5 Use getargs() function.
Guido van Rossum <guido@python.org>
parents: 373
diff changeset
1482 char *path;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1483 PyObject *argv;
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1484 char **argvlist;
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1485 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
1486 PyObject *(*getitem)(PyObject *, int);
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1487
1360
1808ca5d8883 * import.c (MAGIC): Changed magic word to avoid confusion about exec
Guido van Rossum <guido@python.org>
parents: 1329
diff changeset
1488 /* execv has two arguments: (path, argv), where
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1489 argv is a list or tuple of strings. */
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1490
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
1491 if (!PyArg_ParseTuple(args, "sO:execv", &path, &argv))
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1492 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1493 if (PyList_Check(argv)) {
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1494 argc = PyList_Size(argv);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1495 getitem = PyList_GetItem;
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1496 }
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1497 else if (PyTuple_Check(argv)) {
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1498 argc = PyTuple_Size(argv);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1499 getitem = PyTuple_GetItem;
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1500 }
643
02d3f161b7f5 Use getargs() function.
Guido van Rossum <guido@python.org>
parents: 373
diff changeset
1501 else {
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
1502 PyErr_SetString(PyExc_TypeError, "execv() arg 2 must be a tuple or list");
12503
211483bd0a51 Michael Hudson:
Guido van Rossum <guido@python.org>
parents: 12435
diff changeset
1503 return NULL;
211483bd0a51 Michael Hudson:
Guido van Rossum <guido@python.org>
parents: 12435
diff changeset
1504 }
211483bd0a51 Michael Hudson:
Guido van Rossum <guido@python.org>
parents: 12435
diff changeset
1505
211483bd0a51 Michael Hudson:
Guido van Rossum <guido@python.org>
parents: 12435
diff changeset
1506 if (argc == 0) {
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
1507 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
1508 return NULL;
02d3f161b7f5 Use getargs() function.
Guido van Rossum <guido@python.org>
parents: 373
diff changeset
1509 }
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1510
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1511 argvlist = PyMem_NEW(char *, argc+1);
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1512 if (argvlist == NULL)
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1513 return NULL;
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1514 for (i = 0; i < argc; i++) {
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1515 if (!PyArg_Parse((*getitem)(argv, i), "s", &argvlist[i])) {
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1516 PyMem_DEL(argvlist);
12503
211483bd0a51 Michael Hudson:
Guido van Rossum <guido@python.org>
parents: 12435
diff changeset
1517 PyErr_SetString(PyExc_TypeError,
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
1518 "execv() arg 2 must contain only strings");
12503
211483bd0a51 Michael Hudson:
Guido van Rossum <guido@python.org>
parents: 12435
diff changeset
1519 return NULL;
211483bd0a51 Michael Hudson:
Guido van Rossum <guido@python.org>
parents: 12435
diff changeset
1520
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1521 }
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1522 }
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1523 argvlist[argc] = NULL;
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1524
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1525 #ifdef BAD_EXEC_PROTOTYPES
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1526 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
1527 #else /* BAD_EXEC_PROTOTYPES */
643
02d3f161b7f5 Use getargs() function.
Guido van Rossum <guido@python.org>
parents: 373
diff changeset
1528 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
1529 #endif /* BAD_EXEC_PROTOTYPES */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1530
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1531 /* If we get here it's definitely an error */
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1532
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1533 PyMem_DEL(argvlist);
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1534 return posix_error();
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1535 }
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1536
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1537
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1538 static char posix_execve__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1539 "execve(path, args, env)\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1540 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
1541 \n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1542 path: path of executable file\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1543 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
1544 env: dictionary of strings mapping to strings";
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1545
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1546 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
1547 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
1548 {
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1549 char *path;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1550 PyObject *argv, *env;
1395
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1551 char **argvlist;
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1552 char **envlist;
5058
371464f6666b posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents: 4789
diff changeset
1553 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
1554 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
1555 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
1556
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1557 /* 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
1558 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
1559 like posix.environ. */
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1560
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
1561 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
1562 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1563 if (PyList_Check(argv)) {
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1564 argc = PyList_Size(argv);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1565 getitem = PyList_GetItem;
1395
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1566 }
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1567 else if (PyTuple_Check(argv)) {
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1568 argc = PyTuple_Size(argv);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1569 getitem = PyTuple_GetItem;
1395
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1570 }
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1571 else {
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
1572 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
1573 return NULL;
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1574 }
5058
371464f6666b posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents: 4789
diff changeset
1575 if (!PyMapping_Check(env)) {
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
1576 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
1577 return NULL;
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1578 }
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1579
12503
211483bd0a51 Michael Hudson:
Guido van Rossum <guido@python.org>
parents: 12435
diff changeset
1580 if (argc == 0) {
211483bd0a51 Michael Hudson:
Guido van Rossum <guido@python.org>
parents: 12435
diff changeset
1581 PyErr_SetString(PyExc_ValueError,
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
1582 "execve() arg 2 must not be empty");
12503
211483bd0a51 Michael Hudson:
Guido van Rossum <guido@python.org>
parents: 12435
diff changeset
1583 return NULL;
211483bd0a51 Michael Hudson:
Guido van Rossum <guido@python.org>
parents: 12435
diff changeset
1584 }
211483bd0a51 Michael Hudson:
Guido van Rossum <guido@python.org>
parents: 12435
diff changeset
1585
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1586 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
1587 if (argvlist == NULL) {
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1588 PyErr_NoMemory();
1395
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1589 return NULL;
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1590 }
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1591 for (i = 0; i < argc; i++) {
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1592 if (!PyArg_Parse((*getitem)(argv, i),
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
1593 "s;execve() arg 2 must contain only strings",
4785
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
1594 &argvlist[i]))
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
1595 {
1395
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1596 goto fail_1;
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1597 }
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1598 }
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1599 argvlist[argc] = NULL;
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1600
13576
61e4c29d53d8 replace PyXXX_Length calls with PyXXX_Size calls
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 13513
diff changeset
1601 i = PyMapping_Size(env);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1602 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
1603 if (envlist == NULL) {
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1604 PyErr_NoMemory();
1395
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1605 goto fail_1;
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1606 }
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1607 envc = 0;
5058
371464f6666b posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents: 4789
diff changeset
1608 keys = PyMapping_Keys(env);
371464f6666b posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents: 4789
diff changeset
1609 vals = PyMapping_Values(env);
371464f6666b posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents: 4789
diff changeset
1610 if (!keys || !vals)
371464f6666b posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents: 4789
diff changeset
1611 goto fail_2;
371464f6666b posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents: 4789
diff changeset
1612
371464f6666b posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents: 4789
diff changeset
1613 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
1614 char *p, *k, *v;
21172
df2ffb0cd6bb posix_execve(), posix_spawnve(), posix_putenv():
Tim Peters <tim.peters@gmail.com>
parents: 21094
diff changeset
1615 size_t len;
5058
371464f6666b posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents: 4789
diff changeset
1616
371464f6666b posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents: 4789
diff changeset
1617 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
1618 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
1619 if (!key || !val)
371464f6666b posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents: 4789
diff changeset
1620 goto fail_2;
371464f6666b posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents: 4789
diff changeset
1621
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
1622 if (!PyArg_Parse(key, "s;execve() arg 3 contains a non-string key", &k) ||
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
1623 !PyArg_Parse(val, "s;execve() arg 3 contains a non-string value", &v))
4785
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
1624 {
1395
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1625 goto fail_2;
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1626 }
6766
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
1627
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
1628 #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
1629 /* 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
1630 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
1631 #endif
21172
df2ffb0cd6bb posix_execve(), posix_spawnve(), posix_putenv():
Tim Peters <tim.peters@gmail.com>
parents: 21094
diff changeset
1632 len = PyString_Size(key) + PyString_Size(val) + 2;
df2ffb0cd6bb posix_execve(), posix_spawnve(), posix_putenv():
Tim Peters <tim.peters@gmail.com>
parents: 21094
diff changeset
1633 p = PyMem_NEW(char, len);
1395
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1634 if (p == NULL) {
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1635 PyErr_NoMemory();
1395
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1636 goto fail_2;
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1637 }
21172
df2ffb0cd6bb posix_execve(), posix_spawnve(), posix_putenv():
Tim Peters <tim.peters@gmail.com>
parents: 21094
diff changeset
1638 PyOS_snprintf(p, len, "%s=%s", k, v);
1395
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1639 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
1640 #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
1641 }
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
1642 #endif
1395
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1643 }
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1644 envlist[envc] = 0;
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1645
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1646
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1647 #ifdef BAD_EXEC_PROTOTYPES
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
1648 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
1649 #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
1650 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
1651 #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
1652
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1653 /* 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
1654
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1655 (void) posix_error();
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1656
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1657 fail_2:
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1658 while (--envc >= 0)
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1659 PyMem_DEL(envlist[envc]);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1660 PyMem_DEL(envlist);
1395
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1661 fail_1:
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1662 PyMem_DEL(argvlist);
5058
371464f6666b posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents: 4789
diff changeset
1663 Py_XDECREF(vals);
371464f6666b posix_execve(): Accept any mapping protocol object for the env
Barry Warsaw <barry@python.org>
parents: 4789
diff changeset
1664 Py_XDECREF(keys);
1395
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1665 return NULL;
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1666 }
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
1667 #endif /* HAVE_EXECV */
1395
be61e072a505 Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents: 1388
diff changeset
1668
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1669
9954
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1670 #ifdef HAVE_SPAWNV
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1671 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
1672 "spawnv(mode, path, args)\n\
21295
59894496b5c7 SF patch #489173: Make os.spawnv not block the interpreter, from
Tim Peters <tim.peters@gmail.com>
parents: 21172
diff changeset
1673 Execute the program 'path' in a new process.\n\
9954
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1674 \n\
10066
d7f434d784bf spawnv, spawnve docstrings: added mode parameter; this is required!
Fred Drake <fdrake@acm.org>
parents: 10056
diff changeset
1675 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
1676 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
1677 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
1678
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1679 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
1680 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
1681 {
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1682 char *path;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1683 PyObject *argv;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1684 char **argvlist;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1685 int mode, i, argc;
19568
b0f5278a2ab4 SF bug [#456252] Python should never stomp on [u]intptr_t.
Tim Peters <tim.peters@gmail.com>
parents: 19490
diff changeset
1686 Py_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
1687 PyObject *(*getitem)(PyObject *, int);
9954
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1688
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1689 /* 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
1690 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
1691
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
1692 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
1693 return NULL;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1694 if (PyList_Check(argv)) {
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1695 argc = PyList_Size(argv);
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1696 getitem = PyList_GetItem;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1697 }
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1698 else if (PyTuple_Check(argv)) {
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1699 argc = PyTuple_Size(argv);
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1700 getitem = PyTuple_GetItem;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1701 }
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1702 else {
21040
c3e6e63d9ba2 Correct typo. Fixes #484611.
Martin v. Löwis <martin@v.loewis.de>
parents: 20855
diff changeset
1703 PyErr_SetString(PyExc_TypeError, "spawnv() 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
1704 return NULL;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1705 }
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1706
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1707 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
1708 if (argvlist == NULL)
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1709 return NULL;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1710 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
1711 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
1712 PyMem_DEL(argvlist);
12814
b1b260a2de98 Michael Hudson <mwh21@cam.ac.uk>:
Fred Drake <fdrake@acm.org>
parents: 12564
diff changeset
1713 PyErr_SetString(PyExc_TypeError,
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
1714 "spawnv() arg 2 must contain only strings");
12814
b1b260a2de98 Michael Hudson <mwh21@cam.ac.uk>:
Fred Drake <fdrake@acm.org>
parents: 12564
diff changeset
1715 return NULL;
9954
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1716 }
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1717 }
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1718 argvlist[argc] = NULL;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1719
10069
5e01645ee41b Add _P_WAIT etc. for NT.
Guido van Rossum <guido@python.org>
parents: 10066
diff changeset
1720 if (mode == _OLD_P_OVERLAY)
5e01645ee41b Add _P_WAIT etc. for NT.
Guido van Rossum <guido@python.org>
parents: 10066
diff changeset
1721 mode = _P_OVERLAY;
21295
59894496b5c7 SF patch #489173: Make os.spawnv not block the interpreter, from
Tim Peters <tim.peters@gmail.com>
parents: 21172
diff changeset
1722
59894496b5c7 SF patch #489173: Make os.spawnv not block the interpreter, from
Tim Peters <tim.peters@gmail.com>
parents: 21172
diff changeset
1723 Py_BEGIN_ALLOW_THREADS
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
1724 spawnval = _spawnv(mode, path, argvlist);
21295
59894496b5c7 SF patch #489173: Make os.spawnv not block the interpreter, from
Tim Peters <tim.peters@gmail.com>
parents: 21172
diff changeset
1725 Py_END_ALLOW_THREADS
59894496b5c7 SF patch #489173: Make os.spawnv not block the interpreter, from
Tim Peters <tim.peters@gmail.com>
parents: 21172
diff changeset
1726
9954
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1727 PyMem_DEL(argvlist);
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1728
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
1729 if (spawnval == -1)
9954
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1730 return posix_error();
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1731 else
13462
4cf0de29c08c - fixed pointer size test in spawn functions. also added
Fredrik Lundh <fredrik@pythonware.com>
parents: 13442
diff changeset
1732 #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
1733 return Py_BuildValue("l", (long) spawnval);
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
1734 #else
13462
4cf0de29c08c - fixed pointer size test in spawn functions. also added
Fredrik Lundh <fredrik@pythonware.com>
parents: 13442
diff changeset
1735 return Py_BuildValue("L", (LONG_LONG) spawnval);
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
1736 #endif
9954
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1737 }
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1738
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1739
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1740 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
1741 "spawnve(mode, path, args, env)\n\
21295
59894496b5c7 SF patch #489173: Make os.spawnv not block the interpreter, from
Tim Peters <tim.peters@gmail.com>
parents: 21172
diff changeset
1742 Execute the program 'path' in a new process.\n\
9954
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1743 \n\
10066
d7f434d784bf spawnv, spawnve docstrings: added mode parameter; this is required!
Fred Drake <fdrake@acm.org>
parents: 10056
diff changeset
1744 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
1745 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
1746 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
1747 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
1748
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1749 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
1750 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
1751 {
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1752 char *path;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1753 PyObject *argv, *env;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1754 char **argvlist;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1755 char **envlist;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1756 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
1757 int mode, i, pos, argc, envc;
19568
b0f5278a2ab4 SF bug [#456252] Python should never stomp on [u]intptr_t.
Tim Peters <tim.peters@gmail.com>
parents: 19490
diff changeset
1758 Py_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
1759 PyObject *(*getitem)(PyObject *, int);
9954
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1760
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1761 /* 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
1762 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
1763 like posix.environ. */
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1764
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
1765 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
1766 return NULL;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1767 if (PyList_Check(argv)) {
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1768 argc = PyList_Size(argv);
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1769 getitem = PyList_GetItem;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1770 }
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1771 else if (PyTuple_Check(argv)) {
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1772 argc = PyTuple_Size(argv);
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1773 getitem = PyTuple_GetItem;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1774 }
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1775 else {
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
1776 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
1777 return NULL;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1778 }
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1779 if (!PyMapping_Check(env)) {
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
1780 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
1781 return NULL;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1782 }
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1783
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1784 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
1785 if (argvlist == NULL) {
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1786 PyErr_NoMemory();
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1787 return NULL;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1788 }
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1789 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
1790 if (!PyArg_Parse((*getitem)(argv, i),
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
1791 "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
1792 &argvlist[i]))
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1793 {
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1794 goto fail_1;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1795 }
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1796 }
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1797 argvlist[argc] = NULL;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1798
13576
61e4c29d53d8 replace PyXXX_Length calls with PyXXX_Size calls
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 13513
diff changeset
1799 i = PyMapping_Size(env);
9954
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1800 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
1801 if (envlist == NULL) {
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1802 PyErr_NoMemory();
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1803 goto fail_1;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1804 }
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1805 envc = 0;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1806 keys = PyMapping_Keys(env);
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1807 vals = PyMapping_Values(env);
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1808 if (!keys || !vals)
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1809 goto fail_2;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1810
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1811 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
1812 char *p, *k, *v;
21172
df2ffb0cd6bb posix_execve(), posix_spawnve(), posix_putenv():
Tim Peters <tim.peters@gmail.com>
parents: 21094
diff changeset
1813 size_t len;
9954
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1814
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1815 key = PyList_GetItem(keys, pos);
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1816 val = PyList_GetItem(vals, pos);
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1817 if (!key || !val)
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1818 goto fail_2;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1819
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
1820 if (!PyArg_Parse(key, "s;spawnve() arg 3 contains a non-string key", &k) ||
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
1821 !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
1822 {
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1823 goto fail_2;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1824 }
21172
df2ffb0cd6bb posix_execve(), posix_spawnve(), posix_putenv():
Tim Peters <tim.peters@gmail.com>
parents: 21094
diff changeset
1825 len = PyString_Size(key) + PyString_Size(val) + 2;
df2ffb0cd6bb posix_execve(), posix_spawnve(), posix_putenv():
Tim Peters <tim.peters@gmail.com>
parents: 21094
diff changeset
1826 p = PyMem_NEW(char, len);
9954
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1827 if (p == NULL) {
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1828 PyErr_NoMemory();
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1829 goto fail_2;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1830 }
21172
df2ffb0cd6bb posix_execve(), posix_spawnve(), posix_putenv():
Tim Peters <tim.peters@gmail.com>
parents: 21094
diff changeset
1831 PyOS_snprintf(p, len, "%s=%s", k, v);
9954
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1832 envlist[envc++] = p;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1833 }
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1834 envlist[envc] = 0;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1835
10069
5e01645ee41b Add _P_WAIT etc. for NT.
Guido van Rossum <guido@python.org>
parents: 10066
diff changeset
1836 if (mode == _OLD_P_OVERLAY)
5e01645ee41b Add _P_WAIT etc. for NT.
Guido van Rossum <guido@python.org>
parents: 10066
diff changeset
1837 mode = _P_OVERLAY;
21295
59894496b5c7 SF patch #489173: Make os.spawnv not block the interpreter, from
Tim Peters <tim.peters@gmail.com>
parents: 21172
diff changeset
1838
59894496b5c7 SF patch #489173: Make os.spawnv not block the interpreter, from
Tim Peters <tim.peters@gmail.com>
parents: 21172
diff changeset
1839 Py_BEGIN_ALLOW_THREADS
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
1840 spawnval = _spawnve(mode, path, argvlist, envlist);
21295
59894496b5c7 SF patch #489173: Make os.spawnv not block the interpreter, from
Tim Peters <tim.peters@gmail.com>
parents: 21172
diff changeset
1841 Py_END_ALLOW_THREADS
59894496b5c7 SF patch #489173: Make os.spawnv not block the interpreter, from
Tim Peters <tim.peters@gmail.com>
parents: 21172
diff changeset
1842
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
1843 if (spawnval == -1)
9954
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1844 (void) posix_error();
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1845 else
13462
4cf0de29c08c - fixed pointer size test in spawn functions. also added
Fredrik Lundh <fredrik@pythonware.com>
parents: 13442
diff changeset
1846 #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
1847 res = Py_BuildValue("l", (long) spawnval);
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
1848 #else
13462
4cf0de29c08c - fixed pointer size test in spawn functions. also added
Fredrik Lundh <fredrik@pythonware.com>
parents: 13442
diff changeset
1849 res = Py_BuildValue("L", (LONG_LONG) spawnval);
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
1850 #endif
9954
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1851
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1852 fail_2:
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1853 while (--envc >= 0)
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1854 PyMem_DEL(envlist[envc]);
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1855 PyMem_DEL(envlist);
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1856 fail_1:
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1857 PyMem_DEL(argvlist);
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1858 Py_XDECREF(vals);
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1859 Py_XDECREF(keys);
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1860 return res;
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1861 }
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1862 #endif /* HAVE_SPAWNV */
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1863
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
1864
17419
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1865 #ifdef HAVE_FORK1
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1866 static char posix_fork1__doc__[] =
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1867 "fork1() -> pid\n\
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1868 Fork a child process with a single multiplexed (i.e., not bound) thread.\n\
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1869 \n\
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1870 Return 0 to child process and PID of child to parent process.";
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1871
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1872 static PyObject *
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1873 posix_fork1(self, args)
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1874 PyObject *self;
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1875 PyObject *args;
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1876 {
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1877 int pid;
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1878 if (!PyArg_ParseTuple(args, ":fork1"))
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1879 return NULL;
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1880 pid = fork1();
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1881 if (pid == -1)
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1882 return posix_error();
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1883 PyOS_AfterFork();
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1884 return PyInt_FromLong((long)pid);
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1885 }
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1886 #endif
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1887
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
1888
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
1889 #ifdef HAVE_FORK
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1890 static char posix_fork__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1891 "fork() -> pid\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1892 Fork a child process.\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1893 \n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1894 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
1895
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1896 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
1897 posix_fork(PyObject *self, PyObject *args)
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1898 {
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1899 int pid;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
1900 if (!PyArg_ParseTuple(args, ":fork"))
731
c65fc172f16d Check empty argument lists.
Guido van Rossum <guido@python.org>
parents: 658
diff changeset
1901 return NULL;
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1902 pid = fork();
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1903 if (pid == -1)
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1904 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
1905 if (pid == 0)
1c0d35ba16b1 Fix bug #392, reported by Jonathan Giddy <jon@dstc.edu.au>:
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
1906 PyOS_AfterFork();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1907 return PyInt_FromLong((long)pid);
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1908 }
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
1909 #endif
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
1910
13058
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1911 #if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY)
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1912 #ifdef HAVE_PTY_H
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1913 #include <pty.h>
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1914 #else
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1915 #ifdef HAVE_LIBUTIL_H
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1916 #include <libutil.h>
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1917 #endif /* HAVE_LIBUTIL_H */
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1918 #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
1919 #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
1920
ef8b20b9f6f5 Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents: 13582
diff changeset
1921 #if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY)
13058
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1922 static char posix_openpty__doc__[] =
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1923 "openpty() -> (master_fd, slave_fd)\n\
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1924 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
1925
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1926 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
1927 posix_openpty(PyObject *self, PyObject *args)
13058
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1928 {
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1929 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
1930 #ifndef HAVE_OPENPTY
ef8b20b9f6f5 Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents: 13582
diff changeset
1931 char * slave_name;
ef8b20b9f6f5 Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents: 13582
diff changeset
1932 #endif
ef8b20b9f6f5 Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents: 13582
diff changeset
1933
13058
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1934 if (!PyArg_ParseTuple(args, ":openpty"))
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1935 return NULL;
13601
ef8b20b9f6f5 Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents: 13582
diff changeset
1936
ef8b20b9f6f5 Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents: 13582
diff changeset
1937 #ifdef HAVE_OPENPTY
13058
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1938 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
1939 return posix_error();
13601
ef8b20b9f6f5 Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents: 13582
diff changeset
1940 #else
ef8b20b9f6f5 Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents: 13582
diff changeset
1941 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
1942 if (slave_name == NULL)
ef8b20b9f6f5 Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents: 13582
diff changeset
1943 return posix_error();
ef8b20b9f6f5 Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents: 13582
diff changeset
1944
ef8b20b9f6f5 Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents: 13582
diff changeset
1945 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
1946 if (slave_fd < 0)
ef8b20b9f6f5 Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents: 13582
diff changeset
1947 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
1948 #endif /* HAVE_OPENPTY */
13601
ef8b20b9f6f5 Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents: 13582
diff changeset
1949
13058
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1950 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
1951
13058
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1952 }
13601
ef8b20b9f6f5 Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents: 13582
diff changeset
1953 #endif /* defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) */
13058
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1954
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1955 #ifdef HAVE_FORKPTY
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1956 static char posix_forkpty__doc__[] =
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1957 "forkpty() -> (pid, master_fd)\n\
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1958 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
1959 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
1960 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
1961
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1962 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
1963 posix_forkpty(PyObject *self, PyObject *args)
13058
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1964 {
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1965 int master_fd, pid;
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1966
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1967 if (!PyArg_ParseTuple(args, ":forkpty"))
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1968 return NULL;
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1969 pid = forkpty(&master_fd, NULL, NULL, NULL);
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1970 if (pid == -1)
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1971 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
1972 if (pid == 0)
1c0d35ba16b1 Fix bug #392, reported by Jonathan Giddy <jon@dstc.edu.au>:
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
1973 PyOS_AfterFork();
13058
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1974 return Py_BuildValue("(ii)", pid, master_fd);
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1975 }
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
1976 #endif
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1977
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
1978 #ifdef HAVE_GETEGID
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1979 static char posix_getegid__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1980 "getegid() -> egid\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1981 Return the current process's effective group id.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1982
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1983 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
1984 posix_getegid(PyObject *self, PyObject *args)
861
76095a8b96ca Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents: 793
diff changeset
1985 {
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
1986 if (!PyArg_ParseTuple(args, ":getegid"))
861
76095a8b96ca Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents: 793
diff changeset
1987 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1988 return PyInt_FromLong((long)getegid());
861
76095a8b96ca Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents: 793
diff changeset
1989 }
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
1990 #endif
861
76095a8b96ca Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents: 793
diff changeset
1991
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1992
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
1993 #ifdef HAVE_GETEUID
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1994 static char posix_geteuid__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1995 "geteuid() -> euid\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1996 Return the current process's effective user id.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
1997
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
1998 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
1999 posix_geteuid(PyObject *self, PyObject *args)
861
76095a8b96ca Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents: 793
diff changeset
2000 {
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
2001 if (!PyArg_ParseTuple(args, ":geteuid"))
861
76095a8b96ca Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents: 793
diff changeset
2002 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2003 return PyInt_FromLong((long)geteuid());
861
76095a8b96ca Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents: 793
diff changeset
2004 }
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
2005 #endif
861
76095a8b96ca Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents: 793
diff changeset
2006
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2007
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
2008 #ifdef HAVE_GETGID
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2009 static char posix_getgid__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2010 "getgid() -> gid\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2011 Return the current process's group id.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2012
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2013 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
2014 posix_getgid(PyObject *self, PyObject *args)
861
76095a8b96ca Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents: 793
diff changeset
2015 {
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
2016 if (!PyArg_ParseTuple(args, ":getgid"))
861
76095a8b96ca Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents: 793
diff changeset
2017 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2018 return PyInt_FromLong((long)getgid());
861
76095a8b96ca Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents: 793
diff changeset
2019 }
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
2020 #endif
861
76095a8b96ca Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents: 793
diff changeset
2021
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2022
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2023 static char posix_getpid__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2024 "getpid() -> pid\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2025 Return the current process id";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2026
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2027 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
2028 posix_getpid(PyObject *self, PyObject *args)
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
2029 {
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
2030 if (!PyArg_ParseTuple(args, ":getpid"))
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
2031 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2032 return PyInt_FromLong((long)getpid());
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
2033 }
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
2034
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2035
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2036 #ifdef HAVE_GETGROUPS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2037 static char posix_getgroups__doc__[] = "\
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2038 getgroups() -> list of group IDs\n\
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2039 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
2040
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2041 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
2042 posix_getgroups(PyObject *self, PyObject *args)
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2043 {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2044 PyObject *result = NULL;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2045
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2046 if (PyArg_ParseTuple(args, ":getgroups")) {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2047 #ifdef NGROUPS_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2048 #define MAX_GROUPS NGROUPS_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2049 #else
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2050 /* 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
2051 #define MAX_GROUPS 64
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2052 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2053 gid_t grouplist[MAX_GROUPS];
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2054 int n;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2055
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2056 n = getgroups(MAX_GROUPS, grouplist);
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2057 if (n < 0)
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2058 posix_error();
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2059 else {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2060 result = PyList_New(n);
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2061 if (result != NULL) {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2062 PyObject *o;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2063 int i;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2064 for (i = 0; i < n; ++i) {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2065 o = PyInt_FromLong((long)grouplist[i]);
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2066 if (o == NULL) {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2067 Py_DECREF(result);
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2068 result = NULL;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2069 break;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2070 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2071 PyList_SET_ITEM(result, i, o);
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2072 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2073 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2074 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2075 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2076 return result;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2077 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2078 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
2079
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
2080 #ifdef HAVE_GETPGRP
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2081 static char posix_getpgrp__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2082 "getpgrp() -> pgrp\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2083 Return the current process group id.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2084
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2085 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
2086 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
2087 {
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
2088 if (!PyArg_ParseTuple(args, ":getpgrp"))
273
af1c8f5d0b37 Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents: 264
diff changeset
2089 return NULL;
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
2090 #ifdef GETPGRP_HAVE_ARG
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2091 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
2092 #else /* GETPGRP_HAVE_ARG */
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2093 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
2094 #endif /* GETPGRP_HAVE_ARG */
273
af1c8f5d0b37 Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents: 264
diff changeset
2095 }
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
2096 #endif /* HAVE_GETPGRP */
273
af1c8f5d0b37 Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents: 264
diff changeset
2097
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2098
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
2099 #ifdef HAVE_SETPGRP
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2100 static char posix_setpgrp__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2101 "setpgrp() -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2102 Make this process a session leader.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2103
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2104 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
2105 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
2106 {
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
2107 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
2108 return NULL;
1983
80bd7af73201 distinguish between getpgrp and setpgrp arg requirements
Guido van Rossum <guido@python.org>
parents: 1915
diff changeset
2109 #ifdef SETPGRP_HAVE_ARG
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
2110 if (setpgrp(0, 0) < 0)
1983
80bd7af73201 distinguish between getpgrp and setpgrp arg requirements
Guido van Rossum <guido@python.org>
parents: 1915
diff changeset
2111 #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
2112 if (setpgrp() < 0)
1983
80bd7af73201 distinguish between getpgrp and setpgrp arg requirements
Guido van Rossum <guido@python.org>
parents: 1915
diff changeset
2113 #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
2114 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2115 Py_INCREF(Py_None);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2116 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
2117 }
f49d2311776b posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents: 943
diff changeset
2118
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
2119 #endif /* HAVE_SETPGRP */
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
2120
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
2121 #ifdef HAVE_GETPPID
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2122 static char posix_getppid__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2123 "getppid() -> ppid\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2124 Return the parent's process id.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2125
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2126 static PyObject *
13651
8a063423e0b7 Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents: 13642
diff changeset
2127 posix_getppid(PyObject *self, PyObject *args)
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
2128 {
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
2129 if (!PyArg_ParseTuple(args, ":getppid"))
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
2130 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2131 return PyInt_FromLong((long)getppid());
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
2132 }
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
2133 #endif
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
2134
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2135
11570
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
2136 #ifdef HAVE_GETLOGIN
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
2137 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
2138 getlogin() -> string\n\
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
2139 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
2140
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
2141 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
2142 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
2143 {
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
2144 PyObject *result = NULL;
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
2145
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
2146 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
2147 char *name;
1091ad9a0303 posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents: 15318
diff changeset
2148 int old_errno = errno;
1091ad9a0303 posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents: 15318
diff changeset
2149
1091ad9a0303 posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents: 15318
diff changeset
2150 errno = 0;
1091ad9a0303 posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents: 15318
diff changeset
2151 name = getlogin();
1091ad9a0303 posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents: 15318
diff changeset
2152 if (name == NULL) {
1091ad9a0303 posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents: 15318
diff changeset
2153 if (errno)
1091ad9a0303 posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents: 15318
diff changeset
2154 posix_error();
1091ad9a0303 posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents: 15318
diff changeset
2155 else
1091ad9a0303 posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents: 15318
diff changeset
2156 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
2157 "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
2158 }
11570
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
2159 else
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
2160 result = PyString_FromString(name);
15485
1091ad9a0303 posix_getlogin(): Handle the possibility that getlogin() can return
Fred Drake <fdrake@acm.org>
parents: 15318
diff changeset
2161 errno = old_errno;
11570
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
2162 }
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
2163 return result;
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
2164 }
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
2165 #endif
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
2166
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
2167 #ifdef HAVE_GETUID
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2168 static char posix_getuid__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2169 "getuid() -> uid\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2170 Return the current process's user id.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2171
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2172 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
2173 posix_getuid(PyObject *self, PyObject *args)
861
76095a8b96ca Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents: 793
diff changeset
2174 {
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
2175 if (!PyArg_ParseTuple(args, ":getuid"))
861
76095a8b96ca Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents: 793
diff changeset
2176 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2177 return PyInt_FromLong((long)getuid());
861
76095a8b96ca Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents: 793
diff changeset
2178 }
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
2179 #endif
861
76095a8b96ca Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents: 793
diff changeset
2180
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2181
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
2182 #ifdef HAVE_KILL
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2183 static char posix_kill__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2184 "kill(pid, sig) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2185 Kill a process with a signal.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2186
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2187 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
2188 posix_kill(PyObject *self, PyObject *args)
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
2189 {
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
2190 int pid, sig;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
2191 if (!PyArg_ParseTuple(args, "ii:kill", &pid, &sig))
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
2192 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
2193 #if defined(PYOS_OS2)
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2194 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
2195 APIRET rc;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2196 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
2197 return os2_error(rc);
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2198
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2199 } else if (sig == XCPT_SIGNAL_KILLPROC) {
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2200 APIRET rc;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2201 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
2202 return os2_error(rc);
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2203
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2204 } else
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
2205 return NULL; /* Unrecognized Signal Requested */
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2206 #else
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
2207 if (kill(pid, sig) == -1)
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
2208 return posix_error();
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2209 #endif
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2210 Py_INCREF(Py_None);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2211 return Py_None;
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
2212 }
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
2213 #endif
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
2214
3735
4692cb46008e Added plock() system call.
Guido van Rossum <guido@python.org>
parents: 3702
diff changeset
2215 #ifdef HAVE_PLOCK
4692cb46008e Added plock() system call.
Guido van Rossum <guido@python.org>
parents: 3702
diff changeset
2216
4692cb46008e Added plock() system call.
Guido van Rossum <guido@python.org>
parents: 3702
diff changeset
2217 #ifdef HAVE_SYS_LOCK_H
4692cb46008e Added plock() system call.
Guido van Rossum <guido@python.org>
parents: 3702
diff changeset
2218 #include <sys/lock.h>
4692cb46008e Added plock() system call.
Guido van Rossum <guido@python.org>
parents: 3702
diff changeset
2219 #endif
4692cb46008e Added plock() system call.
Guido van Rossum <guido@python.org>
parents: 3702
diff changeset
2220
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2221 static char posix_plock__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2222 "plock(op) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2223 Lock program segments into memory.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2224
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2225 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
2226 posix_plock(PyObject *self, PyObject *args)
3735
4692cb46008e Added plock() system call.
Guido van Rossum <guido@python.org>
parents: 3702
diff changeset
2227 {
4692cb46008e Added plock() system call.
Guido van Rossum <guido@python.org>
parents: 3702
diff changeset
2228 int op;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
2229 if (!PyArg_ParseTuple(args, "i:plock", &op))
3735
4692cb46008e Added plock() system call.
Guido van Rossum <guido@python.org>
parents: 3702
diff changeset
2230 return NULL;
4692cb46008e Added plock() system call.
Guido van Rossum <guido@python.org>
parents: 3702
diff changeset
2231 if (plock(op) == -1)
4692cb46008e Added plock() system call.
Guido van Rossum <guido@python.org>
parents: 3702
diff changeset
2232 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2233 Py_INCREF(Py_None);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
2234 return Py_None;
3735
4692cb46008e Added plock() system call.
Guido van Rossum <guido@python.org>
parents: 3702
diff changeset
2235 }
4692cb46008e Added plock() system call.
Guido van Rossum <guido@python.org>
parents: 3702
diff changeset
2236 #endif
4692cb46008e Added plock() system call.
Guido van Rossum <guido@python.org>
parents: 3702
diff changeset
2237
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2238
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
2239 #ifdef HAVE_POPEN
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2240 static char posix_popen__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2241 "popen(command [, mode='r' [, bufsize]]) -> pipe\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
2242 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
2243
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2244 #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
2245 static int
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2246 async_system(const char *command)
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2247 {
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2248 char *p, errormsg[256], args[1024];
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2249 RESULTCODES rcodes;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2250 APIRET rc;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2251 char *shell = getenv("COMSPEC");
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2252 if (!shell)
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2253 shell = "cmd";
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2254
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2255 strcpy(args, shell);
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2256 p = &args[ strlen(args)+1 ];
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2257 strcpy(p, "/c ");
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2258 strcat(p, command);
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2259 p += strlen(p) + 1;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2260 *p = '\0';
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2261
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2262 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
2263 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
2264 args,
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
2265 NULL, /* Inherit Parent's Environment */
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2266 &rcodes, shell);
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2267 return rc;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2268 }
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2269
6766
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
2270 static FILE *
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
2271 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
2272 {
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2273 HFILE rhan, whan;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2274 FILE *retfd = NULL;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2275 APIRET rc = DosCreatePipe(&rhan, &whan, pipesize);
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2276
6766
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
2277 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
2278 *err = rc;
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
2279 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
2280 }
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2281
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
2282 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
2283 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
2284
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
2285 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
2286 close(1); /* Make STDOUT Available for Reallocation */
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2287
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
2288 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
2289 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
2290
20855
6398d1055fcf Patch #474169: Move fdopen calls out of critical section.
Martin v. Löwis <martin@v.loewis.de>
parents: 20551
diff changeset
2291 rc = async_system(command);
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2292 }
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2293
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
2294 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
2295 DosExitCritSec(); /* Now Allow Other Threads to Run */
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2296
20855
6398d1055fcf Patch #474169: Move fdopen calls out of critical section.
Martin v. Löwis <martin@v.loewis.de>
parents: 20551
diff changeset
2297 if (rc == NO_ERROR)
6398d1055fcf Patch #474169: Move fdopen calls out of critical section.
Martin v. Löwis <martin@v.loewis.de>
parents: 20551
diff changeset
2298 retfd = fdopen(rhan, mode); /* And Return Pipe Read Handle */
6398d1055fcf Patch #474169: Move fdopen calls out of critical section.
Martin v. Löwis <martin@v.loewis.de>
parents: 20551
diff changeset
2299
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
2300 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
2301 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
2302
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
2303 } 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
2304 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
2305
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
2306 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
2307 close(0); /* Make STDIN Available for Reallocation */
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2308
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
2309 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
2310 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
2311
20855
6398d1055fcf Patch #474169: Move fdopen calls out of critical section.
Martin v. Löwis <martin@v.loewis.de>
parents: 20551
diff changeset
2312 rc = async_system(command);
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2313 }
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2314
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
2315 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
2316 DosExitCritSec(); /* Now Allow Other Threads to Run */
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2317
20855
6398d1055fcf Patch #474169: Move fdopen calls out of critical section.
Martin v. Löwis <martin@v.loewis.de>
parents: 20551
diff changeset
2318 if (rc == NO_ERROR)
6398d1055fcf Patch #474169: Move fdopen calls out of critical section.
Martin v. Löwis <martin@v.loewis.de>
parents: 20551
diff changeset
2319 retfd = fdopen(whan, mode); /* And Return Pipe Write Handle */
6398d1055fcf Patch #474169: Move fdopen calls out of critical section.
Martin v. Löwis <martin@v.loewis.de>
parents: 20551
diff changeset
2320
6717
64a75211cf72 Patch for QNX, by Chris Herborth. Also left-aligned preprocessor
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
2321 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
2322 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
2323
6766
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
2324 } else {
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
2325 *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
2326 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
2327 }
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2328 }
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2329
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2330 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
2331 posix_popen(PyObject *self, PyObject *args)
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2332 {
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2333 char *name;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2334 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
2335 int err, bufsize = -1;
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2336 FILE *fp;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2337 PyObject *f;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
2338 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
2339 return NULL;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2340 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
2341 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
2342 Py_END_ALLOW_THREADS
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2343 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
2344 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
2345
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2346 f = PyFile_FromFile(fp, name, mode, fclose);
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2347 if (f != NULL)
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2348 PyFile_SetBufSize(f, bufsize);
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2349 return f;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2350 }
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
2351
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2352 #elif defined(MS_WIN32)
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2353
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2354 /*
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2355 * Portable 'popen' replacement for Win32.
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2356 *
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2357 * 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
2358 * 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
2359 * 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
2360 */
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2361
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2362 #include <malloc.h>
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2363 #include <io.h>
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2364 #include <fcntl.h>
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2365
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2366 /* 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
2367 #define POPEN_1 1
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2368 #define POPEN_2 2
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2369 #define POPEN_3 3
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2370 #define POPEN_4 4
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2371
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2372 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
2373 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
2374
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
2375 /*
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
2376 * 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
2377 * 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
2378 * 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
2379 */
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
2380 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
2381
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2382
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2383 /* 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
2384 *
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2385 * 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
2386 * 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
2387 */
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2388
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2389 static PyObject *
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2390 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
2391 {
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2392 PyObject *f, *s;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2393 int tm = 0;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2394
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2395 char *cmdstring;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2396 char *mode = "r";
13479
93ae34aa20ab - added popen.popen2/popen3/popen4 support for
Fredrik Lundh <fredrik@pythonware.com>
parents: 13478
diff changeset
2397 int bufsize = -1;
13478
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2398 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
2399 return NULL;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2400
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2401 s = PyTuple_New(0);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2402
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2403 if (*mode == 'r')
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2404 tm = _O_RDONLY;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2405 else if (*mode != 'w') {
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
2406 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
2407 return NULL;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2408 } else
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2409 tm = _O_WRONLY;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2410
13478
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2411 if (bufsize != -1) {
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
2412 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
2413 return NULL;
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2414 }
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2415
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2416 if (*(mode+1) == 't')
13479
93ae34aa20ab - added popen.popen2/popen3/popen4 support for
Fredrik Lundh <fredrik@pythonware.com>
parents: 13478
diff changeset
2417 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
2418 else if (*(mode+1) == 'b')
13479
93ae34aa20ab - added popen.popen2/popen3/popen4 support for
Fredrik Lundh <fredrik@pythonware.com>
parents: 13478
diff changeset
2419 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
2420 else
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2421 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
2422
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2423 return f;
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
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2426 /* Variation on win32pipe.popen
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 * 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
2429 * 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
2430 */
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 static PyObject *
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2433 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
2434 {
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2435 PyObject *f;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2436 int tm=0;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2437
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2438 char *cmdstring;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2439 char *mode = "t";
13478
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2440 int bufsize = -1;
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2441 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
2442 return NULL;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2443
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2444 if (*mode == 't')
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2445 tm = _O_TEXT;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2446 else if (*mode != 'b') {
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
2447 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
2448 return NULL;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2449 } else
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2450 tm = _O_BINARY;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2451
13478
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2452 if (bufsize != -1) {
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
2453 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
2454 return NULL;
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2455 }
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2456
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2457 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
2458
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2459 return f;
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
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2462 /*
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2463 * Variation on <om win32pipe.popen>
13479
93ae34aa20ab - added popen.popen2/popen3/popen4 support for
Fredrik Lundh <fredrik@pythonware.com>
parents: 13478
diff changeset
2464 *
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2465 * 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
2466 * stdout and stderr
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2467 */
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2469 static PyObject *
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2470 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
2471 {
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2472 PyObject *f;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2473 int tm = 0;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2474
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2475 char *cmdstring;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2476 char *mode = "t";
13478
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2477 int bufsize = -1;
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2478 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
2479 return NULL;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2480
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2481 if (*mode == 't')
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2482 tm = _O_TEXT;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2483 else if (*mode != 'b') {
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
2484 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
2485 return NULL;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2486 } else
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2487 tm = _O_BINARY;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2488
13478
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2489 if (bufsize != -1) {
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
2490 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
2491 return NULL;
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2492 }
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2493
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2494 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
2495
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2496 return f;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2497 }
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2498
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2499 /*
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2500 * Variation on win32pipe.popen
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 * 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
2503 * 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
2504 */
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2505
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2506 static PyObject *
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2507 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
2508 {
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2509 PyObject *f;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2510 int tm = 0;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2511
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2512 char *cmdstring;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2513 char *mode = "t";
13478
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2514 int bufsize = -1;
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2515 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
2516 return NULL;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2517
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2518 if (*mode == 't')
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2519 tm = _O_TEXT;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2520 else if (*mode != 'b') {
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
2521 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
2522 return NULL;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2523 } else
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2524 tm = _O_BINARY;
13478
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2525
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2526 if (bufsize != -1) {
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
2527 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
2528 return NULL;
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2529 }
70d351fcb8d5 - added optional bufsize argument to new popen methods.
Fredrik Lundh <fredrik@pythonware.com>
parents: 13468
diff changeset
2530
13479
93ae34aa20ab - added popen.popen2/popen3/popen4 support for
Fredrik Lundh <fredrik@pythonware.com>
parents: 13478
diff changeset
2531 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
2532
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2533 return f;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2534 }
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2535
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
2536 static BOOL
13960
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2537 _PyPopenCreateProcess(char *cmdstring,
13486
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2538 HANDLE hStdin,
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2539 HANDLE hStdout,
13960
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2540 HANDLE hStderr,
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2541 HANDLE *hProcess)
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2542 {
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2543 PROCESS_INFORMATION piProcInfo;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2544 STARTUPINFO siStartInfo;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2545 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
2546 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
2547 int i;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2548 int x;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2549
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2550 if (i = GetEnvironmentVariable("COMSPEC",NULL,0)) {
19490
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2551 char *comshell;
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2552
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2553 s1 = (char *)_alloca(i);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2554 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
2555 return x;
19490
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2556
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2557 /* Explicitly check if we are using COMMAND.COM. If we are
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2558 * then use the w9xpopen hack.
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2559 */
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2560 comshell = s1 + x;
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2561 while (comshell >= s1 && *comshell != '\\')
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2562 --comshell;
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2563 ++comshell;
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2564
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2565 if (GetVersion() < 0x80000000 &&
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2566 _stricmp(comshell, "command.com") != 0) {
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2567 /* NT/2000 and not using command.com. */
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2568 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
2569 s2 = (char *)_alloca(x);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2570 ZeroMemory(s2, x);
21094
c2150313d9d1 More sprintf -> PyOS_snprintf.
Tim Peters <tim.peters@gmail.com>
parents: 21075
diff changeset
2571 PyOS_snprintf(s2, x, "%s%s%s", s1, s3, cmdstring);
13468
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 else {
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2574 /*
19490
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2575 * Oh gag, we're on Win9x or using COMMAND.COM. Use
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2576 * the workaround listed in KB: Q150956
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2577 */
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
2578 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
2579 struct stat statinfo;
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2580 GetModuleFileName(NULL, modulepath, sizeof(modulepath));
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2581 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
2582 if (modulepath[i] == '\\')
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2583 x = i+1;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2584 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
2585 /* 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
2586 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
2587 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
2588 (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
2589 -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
2590 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
2591 /* 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
2592 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
2593 */
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
2594 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
2595 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
2596 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
2597 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
2598 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
2599 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
2600 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
2601 (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
2602 -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
2603 /* 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
2604 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
2605 "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
2606 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
2607 (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
2608 */
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
2609 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
2610 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
2611 "Can not locate '%s' which is needed "
19490
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2612 "for popen to work with your shell "
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2613 "or platform.",
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
2614 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
2615 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
2616 }
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
2617 }
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2618 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
2619 strlen(modulepath) +
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2620 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
2621
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2622 s2 = (char *)_alloca(x);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2623 ZeroMemory(s2, x);
21094
c2150313d9d1 More sprintf -> PyOS_snprintf.
Tim Peters <tim.peters@gmail.com>
parents: 21075
diff changeset
2624 PyOS_snprintf(
c2150313d9d1 More sprintf -> PyOS_snprintf.
Tim Peters <tim.peters@gmail.com>
parents: 21075
diff changeset
2625 s2, x,
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
2626 "%s \"%s%s%s\"",
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2627 modulepath,
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2628 s1,
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2629 s3,
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2630 cmdstring);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2631 }
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2632 }
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2633
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2634 /* 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
2635 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
2636 else {
19490
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2637 PyErr_SetString(PyExc_RuntimeError,
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2638 "Cannot locate a COMSPEC environment variable to "
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2639 "use as the shell");
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
2640 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
2641 }
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2642
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2643 ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2644 siStartInfo.cb = sizeof(STARTUPINFO);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2645 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
2646 siStartInfo.hStdInput = hStdin;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2647 siStartInfo.hStdOutput = hStdout;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2648 siStartInfo.hStdError = hStderr;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2649 siStartInfo.wShowWindow = SW_HIDE;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2650
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2651 if (CreateProcess(NULL,
13486
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2652 s2,
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2653 NULL,
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2654 NULL,
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2655 TRUE,
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2656 CREATE_NEW_CONSOLE,
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2657 NULL,
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2658 NULL,
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2659 &siStartInfo,
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2660 &piProcInfo) ) {
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2661 /* 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
2662 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
2663
13960
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2664 /* Return process handle */
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2665 *hProcess = piProcInfo.hProcess;
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2666 return TRUE;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2667 }
19490
c6385038de39 SF patch [ #455137 ] Makes popen work with COMMAND.COM on WNT, from
Tim Peters <tim.peters@gmail.com>
parents: 19370
diff changeset
2668 win32_error("CreateProcess", s2);
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2669 return FALSE;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2670 }
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2671
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2672 /* 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
2673
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2674 static PyObject *
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2675 _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
2676 {
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2677 HANDLE hChildStdinRd, hChildStdinWr, hChildStdoutRd, hChildStdoutWr,
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2678 hChildStderrRd, hChildStderrWr, hChildStdinWrDup, hChildStdoutRdDup,
13960
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2679 hChildStderrRdDup, hProcess; /* hChildStdoutWrDup; */
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2680
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2681 SECURITY_ATTRIBUTES saAttr;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2682 BOOL fSuccess;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2683 int fd1, fd2, fd3;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2684 FILE *f1, *f2, *f3;
13960
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2685 long file_count;
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2686 PyObject *f;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2687
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2688 saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2689 saAttr.bInheritHandle = TRUE;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2690 saAttr.lpSecurityDescriptor = NULL;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2691
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2692 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
2693 return win32_error("CreatePipe", NULL);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2694
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2695 /* 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
2696 * 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
2697 * 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
2698 * being created. */
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2699 fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdinWr,
13486
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2700 GetCurrentProcess(), &hChildStdinWrDup, 0,
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2701 FALSE,
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2702 DUPLICATE_SAME_ACCESS);
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2703 if (!fSuccess)
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2704 return win32_error("DuplicateHandle", NULL);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2705
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2706 /* 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
2707 that we're using. */
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2708 CloseHandle(hChildStdinWr);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2709
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2710 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
2711 return win32_error("CreatePipe", NULL);
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 fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdoutRd,
13486
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2714 GetCurrentProcess(), &hChildStdoutRdDup, 0,
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2715 FALSE, DUPLICATE_SAME_ACCESS);
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2716 if (!fSuccess)
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2717 return win32_error("DuplicateHandle", 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 /* 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
2720 that we're using. */
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2721 CloseHandle(hChildStdoutRd);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2722
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2723 if (n != POPEN_4) {
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2724 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
2725 return win32_error("CreatePipe", NULL);
13486
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2726 fSuccess = DuplicateHandle(GetCurrentProcess(),
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2727 hChildStderrRd,
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2728 GetCurrentProcess(),
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2729 &hChildStderrRdDup, 0,
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2730 FALSE, DUPLICATE_SAME_ACCESS);
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2731 if (!fSuccess)
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2732 return win32_error("DuplicateHandle", NULL);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2733 /* 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
2734 CloseHandle(hChildStderrRd);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2735 }
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2736
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2737 switch (n) {
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2738 case POPEN_1:
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2739 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
2740 case _O_WRONLY | _O_TEXT:
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2741 /* 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
2742 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
2743 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
2744 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
2745 PyFile_SetBufSize(f, 0);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2746 /* 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
2747 CloseHandle(hChildStdoutRdDup);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2748 CloseHandle(hChildStderrRdDup);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2749 break;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2750
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2751 case _O_RDONLY | _O_TEXT:
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2752 /* 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
2753 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
2754 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
2755 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
2756 PyFile_SetBufSize(f, 0);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2757 /* 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
2758 CloseHandle(hChildStdinWrDup);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2759 CloseHandle(hChildStderrRdDup);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2760 break;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2761
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2762 case _O_RDONLY | _O_BINARY:
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2763 /* 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
2764 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
2765 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
2766 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
2767 PyFile_SetBufSize(f, 0);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2768 /* 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
2769 CloseHandle(hChildStdinWrDup);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2770 CloseHandle(hChildStderrRdDup);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2771 break;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2772
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2773 case _O_WRONLY | _O_BINARY:
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2774 /* 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
2775 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
2776 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
2777 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
2778 PyFile_SetBufSize(f, 0);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2779 /* 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
2780 CloseHandle(hChildStdoutRdDup);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2781 CloseHandle(hChildStderrRdDup);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2782 break;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2783 }
13960
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2784 file_count = 1;
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2785 break;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2786
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2787 case POPEN_2:
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2788 case POPEN_4:
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2789 {
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2790 char *m1, *m2;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2791 PyObject *p1, *p2;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2792
24885
8791193b09d6 SF bug 595919: popenN return only text mode pipes
Tim Peters <tim.peters@gmail.com>
parents: 24431
diff changeset
2793 if (mode & _O_TEXT) {
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2794 m1 = "r";
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2795 m2 = "w";
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2796 } else {
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2797 m1 = "rb";
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2798 m2 = "wb";
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2799 }
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2800
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2801 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
2802 f1 = _fdopen(fd1, m2);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2803 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
2804 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
2805 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
2806 PyFile_SetBufSize(p1, 0);
13960
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2807 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
2808 PyFile_SetBufSize(p2, 0);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2809
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2810 if (n != 4)
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2811 CloseHandle(hChildStderrRdDup);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2812
13486
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2813 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
2814 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
2815 Py_XDECREF(p2);
13960
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2816 file_count = 2;
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2817 break;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2818 }
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2819
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2820 case POPEN_3:
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2821 {
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2822 char *m1, *m2;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2823 PyObject *p1, *p2, *p3;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2824
24885
8791193b09d6 SF bug 595919: popenN return only text mode pipes
Tim Peters <tim.peters@gmail.com>
parents: 24431
diff changeset
2825 if (mode & _O_TEXT) {
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2826 m1 = "r";
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2827 m2 = "w";
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2828 } else {
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2829 m1 = "rb";
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2830 m2 = "wb";
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2831 }
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2832
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2833 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
2834 f1 = _fdopen(fd1, m2);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2835 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
2836 f2 = _fdopen(fd2, m1);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2837 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
2838 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
2839 p1 = PyFile_FromFile(f1, cmdstring, m2, _PyPclose);
13960
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2840 p2 = PyFile_FromFile(f2, cmdstring, m1, _PyPclose);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2841 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
2842 PyFile_SetBufSize(p1, 0);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2843 PyFile_SetBufSize(p2, 0);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2844 PyFile_SetBufSize(p3, 0);
13486
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2845 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
2846 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
2847 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
2848 Py_XDECREF(p3);
13960
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2849 file_count = 3;
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2850 break;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2851 }
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2852 }
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2853
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2854 if (n == POPEN_4) {
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2855 if (!_PyPopenCreateProcess(cmdstring,
13486
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2856 hChildStdinRd,
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2857 hChildStdoutWr,
13960
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2858 hChildStdoutWr,
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2859 &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
2860 return NULL;
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2861 }
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2862 else {
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2863 if (!_PyPopenCreateProcess(cmdstring,
13486
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2864 hChildStdinRd,
32b686da3e51 - changed the nt.popen2 return values back to
Fredrik Lundh <fredrik@pythonware.com>
parents: 13479
diff changeset
2865 hChildStdoutWr,
13960
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2866 hChildStderrWr,
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2867 &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
2868 return NULL;
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2869 }
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2870
13960
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2871 /*
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2872 * 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
2873 * 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
2874 * 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
2875 * 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
2876 * 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
2877 * 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
2878 * 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
2879 * 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
2880 * and variable number of files involved.
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2881 */
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2882 if (!_PyPopenProcs) {
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2883 _PyPopenProcs = PyDict_New();
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2884 }
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2885
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2886 if (_PyPopenProcs) {
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2887 PyObject *procObj, *hProcessObj, *intObj, *fileObj[3];
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2888 int ins_rc[3];
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2889
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2890 fileObj[0] = fileObj[1] = fileObj[2] = NULL;
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2891 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
2892
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2893 procObj = PyList_New(2);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2894 hProcessObj = PyLong_FromVoidPtr(hProcess);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2895 intObj = PyInt_FromLong(file_count);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2896
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2897 if (procObj && hProcessObj && intObj) {
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2898 PyList_SetItem(procObj,0,hProcessObj);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2899 PyList_SetItem(procObj,1,intObj);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2900
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2901 fileObj[0] = PyLong_FromVoidPtr(f1);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2902 if (fileObj[0]) {
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2903 ins_rc[0] = PyDict_SetItem(_PyPopenProcs,
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2904 fileObj[0],
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2905 procObj);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2906 }
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2907 if (file_count >= 2) {
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2908 fileObj[1] = PyLong_FromVoidPtr(f2);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2909 if (fileObj[1]) {
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2910 ins_rc[1] = PyDict_SetItem(_PyPopenProcs,
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2911 fileObj[1],
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2912 procObj);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2913 }
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2914 }
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2915 if (file_count >= 3) {
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2916 fileObj[2] = PyLong_FromVoidPtr(f3);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2917 if (fileObj[2]) {
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2918 ins_rc[2] = PyDict_SetItem(_PyPopenProcs,
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2919 fileObj[2],
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2920 procObj);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2921 }
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2922 }
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2923
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2924 if (ins_rc[0] < 0 || !fileObj[0] ||
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2925 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
2926 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
2927 /* Something failed - remove any dictionary
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2928 * entries that did make it.
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2929 */
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2930 if (!ins_rc[0] && fileObj[0]) {
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2931 PyDict_DelItem(_PyPopenProcs,
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2932 fileObj[0]);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2933 }
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2934 if (!ins_rc[1] && fileObj[1]) {
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2935 PyDict_DelItem(_PyPopenProcs,
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2936 fileObj[1]);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2937 }
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2938 if (!ins_rc[2] && fileObj[2]) {
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2939 PyDict_DelItem(_PyPopenProcs,
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2940 fileObj[2]);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2941 }
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2942 }
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2943 }
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2944
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2945 /*
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2946 * 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
2947 * 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
2948 * that got placed in the dictionary.
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2949 */
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2950 Py_XDECREF(procObj);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2951 Py_XDECREF(fileObj[0]);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2952 Py_XDECREF(fileObj[1]);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2953 Py_XDECREF(fileObj[2]);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2954 }
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2955
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2956 /* 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
2957 * 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
2958 * 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
2959 * 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
2960 * 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
2961
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2962 if (!CloseHandle(hChildStdinRd))
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2963 return win32_error("CloseHandle", NULL);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2964
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2965 if (!CloseHandle(hChildStdoutWr))
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2966 return win32_error("CloseHandle", NULL);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2967
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2968 if ((n != 4) && (!CloseHandle(hChildStderrWr)))
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2969 return win32_error("CloseHandle", NULL);
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2970
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2971 return f;
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
2972 }
13675
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
2973
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
2974 /*
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
2975 * 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
2976 * 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
2977 *
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2978 * 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
2979 * 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
2980 * 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
2981 * 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
2982 * 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
2983 * 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
2984 * 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
2985 * 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
2986 * handles using that list.
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2987 *
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
2988 * 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
2989 * 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
2990 * 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
2991 * 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
2992 * 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
2993 * 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
2994 * 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
2995 */
14341
ab61c335a04d Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents: 14001
diff changeset
2996
ab61c335a04d Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents: 14001
diff changeset
2997 /* 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
2998 * 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
2999 * 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
3000 * 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
3001 * 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
3002 * 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
3003 * 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
3004 * 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
3005 * *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
3006 * 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
3007 * 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
3008 * 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
3009 */
ab61c335a04d Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents: 14001
diff changeset
3010
13675
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
3011 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
3012 {
13720
d3f694023642 - changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents: 13694
diff changeset
3013 int result;
13675
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
3014 DWORD exit_code;
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
3015 HANDLE hProcess;
13960
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3016 PyObject *procObj, *hProcessObj, *intObj, *fileObj;
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3017 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
3018 #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
3019 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
3020 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
3021 #endif
ab61c335a04d Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents: 14001
diff changeset
3022
13720
d3f694023642 - changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents: 13694
diff changeset
3023 /* 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
3024 * 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
3025 */
d3f694023642 - changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents: 13694
diff changeset
3026 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
3027
14341
ab61c335a04d Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents: 14001
diff changeset
3028 #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
3029 /* 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
3030 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
3031 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
3032 /* 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
3033 * 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
3034 * 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
3035 */
ab61c335a04d Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents: 14001
diff changeset
3036 Py_FatalError("unable to allocate interpreter state "
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
3037 "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
3038 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
3039 }
ab61c335a04d Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents: 14001
diff changeset
3040 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
3041 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
3042 Py_FatalError("unable to allocate thread state "
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
3043 "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
3044 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
3045 }
ab61c335a04d Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents: 14001
diff changeset
3046 /* 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
3047 * 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
3048 * 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
3049 */
ab61c335a04d Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents: 14001
diff changeset
3050 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
3051 #endif
ab61c335a04d Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents: 14001
diff changeset
3052
13675
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
3053 if (_PyPopenProcs) {
13960
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3054 if ((fileObj = PyLong_FromVoidPtr(file)) != NULL &&
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3055 (procObj = PyDict_GetItem(_PyPopenProcs,
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3056 fileObj)) != NULL &&
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3057 (hProcessObj = PyList_GetItem(procObj,0)) != NULL &&
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3058 (intObj = PyList_GetItem(procObj,1)) != NULL) {
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3059
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3060 hProcess = PyLong_AsVoidPtr(hProcessObj);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3061 file_count = PyInt_AsLong(intObj);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3062
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3063 if (file_count > 1) {
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3064 /* Still other files referencing process */
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3065 file_count--;
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3066 PyList_SetItem(procObj,1,
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3067 PyInt_FromLong(file_count));
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3068 } else {
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3069 /* 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
3070 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
3071 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
3072 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
3073 /* 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
3074 * 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
3075 */
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
3076 result = exit_code;
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
3077 } else {
13720
d3f694023642 - changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents: 13694
diff changeset
3078 /* 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
3079 * 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
3080 * 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
3081 * 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
3082 * 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
3083 */
13720
d3f694023642 - changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents: 13694
diff changeset
3084 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
3085 /* 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
3086 * 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
3087 */
d3f694023642 - changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents: 13694
diff changeset
3088 errno = GetLastError();
d3f694023642 - changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents: 13694
diff changeset
3089 }
d3f694023642 - changed windows pclose to make sure we don't return before the
Fredrik Lundh <fredrik@pythonware.com>
parents: 13694
diff changeset
3090 result = -1;
13675
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
3091 }
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
3092
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
3093 /* 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
3094 CloseHandle(hProcess);
13960
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3095 }
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3096
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3097 /* Remove this file pointer from dictionary */
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3098 PyDict_DelItem(_PyPopenProcs, fileObj);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3099
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3100 if (PyDict_Size(_PyPopenProcs) == 0) {
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3101 Py_DECREF(_PyPopenProcs);
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3102 _PyPopenProcs = NULL;
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3103 }
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3104
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3105 } /* if object retrieval ok */
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3106
7dde74c1ebbe Patch #101032, from David Bolen:
Mark Hammond <mhammond@skippinet.com.au>
parents: 13761
diff changeset
3107 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
3108 } /* if _PyPopenProcs */
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
3109
14341
ab61c335a04d Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents: 14001
diff changeset
3110 #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
3111 /* 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
3112 * 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
3113 * 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
3114 * 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
3115 * 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
3116 */
ab61c335a04d Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents: 14001
diff changeset
3117 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
3118 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
3119 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
3120 #endif
ab61c335a04d Fix test_popen2 on Windows, recently broken by changes to the dict(!)
Tim Peters <tim.peters@gmail.com>
parents: 14001
diff changeset
3121
13675
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
3122 return result;
b1959f006566 -- added code to the new Windows popen functions to make close
Fredrik Lundh <fredrik@pythonware.com>
parents: 13667
diff changeset
3123 }
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
3124
0f6809eba50a Repaired damaged comments, and extra spaces in fatal error msgs we'd better
Tim Peters <tim.peters@gmail.com>
parents: 14341
diff changeset
3125 #else /* which OS? */
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3126 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
3127 posix_popen(PyObject *self, PyObject *args)
264
72d1b89be35a Added popen().
Guido van Rossum <guido@python.org>
parents: 257
diff changeset
3128 {
2114
7947c0d16ca0 added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents: 2061
diff changeset
3129 char *name;
7947c0d16ca0 added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents: 2061
diff changeset
3130 char *mode = "r";
7947c0d16ca0 added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents: 2061
diff changeset
3131 int bufsize = -1;
264
72d1b89be35a Added popen().
Guido van Rossum <guido@python.org>
parents: 257
diff changeset
3132 FILE *fp;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3133 PyObject *f;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3134 if (!PyArg_ParseTuple(args, "s|si:popen", &name, &mode, &bufsize))
264
72d1b89be35a Added popen().
Guido van Rossum <guido@python.org>
parents: 257
diff changeset
3135 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3136 Py_BEGIN_ALLOW_THREADS
643
02d3f161b7f5 Use getargs() function.
Guido van Rossum <guido@python.org>
parents: 373
diff changeset
3137 fp = popen(name, mode);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3138 Py_END_ALLOW_THREADS
264
72d1b89be35a Added popen().
Guido van Rossum <guido@python.org>
parents: 257
diff changeset
3139 if (fp == NULL)
72d1b89be35a Added popen().
Guido van Rossum <guido@python.org>
parents: 257
diff changeset
3140 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3141 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
3142 if (f != NULL)
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3143 PyFile_SetBufSize(f, bufsize);
2114
7947c0d16ca0 added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents: 2061
diff changeset
3144 return f;
264
72d1b89be35a Added popen().
Guido van Rossum <guido@python.org>
parents: 257
diff changeset
3145 }
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
3146 #endif
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
3147
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3148 #endif /* HAVE_POPEN */
264
72d1b89be35a Added popen().
Guido van Rossum <guido@python.org>
parents: 257
diff changeset
3149
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3150
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3151 #ifdef HAVE_SETUID
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3152 static char posix_setuid__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3153 "setuid(uid) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3154 Set the current process's user id.";
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3155 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
3156 posix_setuid(PyObject *self, PyObject *args)
1405
90c5e2bb4da5 * posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents: 1395
diff changeset
3157 {
90c5e2bb4da5 * posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents: 1395
diff changeset
3158 int uid;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3159 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
3160 return NULL;
90c5e2bb4da5 * posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents: 1395
diff changeset
3161 if (setuid(uid) < 0)
90c5e2bb4da5 * posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents: 1395
diff changeset
3162 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3163 Py_INCREF(Py_None);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3164 return Py_None;
1405
90c5e2bb4da5 * posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents: 1395
diff changeset
3165 }
1792
a584b4bbbc59 Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
3166 #endif /* HAVE_SETUID */
1405
90c5e2bb4da5 * posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents: 1395
diff changeset
3167
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3168
13582
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3169 #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
3170 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
3171 "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
3172 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
3173 static PyObject *
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3174 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
3175 {
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3176 int euid;
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3177 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
3178 return NULL;
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3179 } 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
3180 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
3181 } else {
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3182 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
3183 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
3184 }
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3185 }
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3186 #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
3187
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3188 #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
3189 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
3190 "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
3191 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
3192 static PyObject *
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3193 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
3194 {
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3195 int egid;
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3196 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
3197 return NULL;
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3198 } 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
3199 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
3200 } else {
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3201 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
3202 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
3203 }
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3204 }
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3205 #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
3206
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3207 #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
3208 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
3209 "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
3210 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
3211 static PyObject *
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3212 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
3213 {
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3214 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
3215 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
3216 return NULL;
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3217 } 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
3218 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
3219 } else {
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3220 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
3221 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
3222 }
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3223 }
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3224 #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
3225
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3226 #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
3227 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
3228 "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
3229 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
3230 static PyObject *
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3231 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
3232 {
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3233 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
3234 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
3235 return NULL;
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3236 } 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
3237 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
3238 } else {
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3239 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
3240 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
3241 }
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3242 }
084a758051e0 From Sam Rushing's Medusa, via SF patch #100858: add & document
Andrew M. Kuchling <amk@amk.ca>
parents: 13576
diff changeset
3243 #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
3244
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3245 #ifdef HAVE_SETGID
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3246 static char posix_setgid__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3247 "setgid(gid) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3248 Set the current process's group id.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3249
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3250 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
3251 posix_setgid(PyObject *self, PyObject *args)
1405
90c5e2bb4da5 * posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents: 1395
diff changeset
3252 {
90c5e2bb4da5 * posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents: 1395
diff changeset
3253 int gid;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3254 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
3255 return NULL;
90c5e2bb4da5 * posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents: 1395
diff changeset
3256 if (setgid(gid) < 0)
90c5e2bb4da5 * posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents: 1395
diff changeset
3257 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3258 Py_INCREF(Py_None);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3259 return Py_None;
1405
90c5e2bb4da5 * posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents: 1395
diff changeset
3260 }
1792
a584b4bbbc59 Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
3261 #endif /* HAVE_SETGID */
1405
90c5e2bb4da5 * posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents: 1395
diff changeset
3262
20508
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3263 #ifdef HAVE_SETGROUPS
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3264 static char posix_setgroups__doc__[] =
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3265 "setgroups(list) -> None\n\
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3266 Set the groups of the current process to list.";
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3267
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3268 static PyObject *
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3269 posix_setgroups(PyObject *self, PyObject *args)
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3270 {
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3271 PyObject *groups;
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3272 int i, len;
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3273 gid_t grouplist[MAX_GROUPS];
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3274
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3275 if (!PyArg_ParseTuple(args, "O:setgid", &groups))
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3276 return NULL;
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3277 if (!PySequence_Check(groups)) {
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3278 PyErr_SetString(PyExc_TypeError, "setgroups argument must be a sequence");
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3279 return NULL;
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3280 }
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3281 len = PySequence_Size(groups);
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3282 if (len > MAX_GROUPS) {
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3283 PyErr_SetString(PyExc_ValueError, "too many groups");
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3284 return NULL;
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3285 }
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3286 for(i = 0; i < len; i++) {
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3287 PyObject *elem;
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3288 elem = PySequence_GetItem(groups, i);
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3289 if (!elem)
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3290 return NULL;
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3291 if (!PyInt_Check(elem)) {
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3292 PyErr_SetString(PyExc_TypeError,
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3293 "groups must be integers");
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3294 Py_DECREF(elem);
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3295 return NULL;
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3296 }
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3297 /* XXX: check that value fits into gid_t. */
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3298 grouplist[i] = PyInt_AsLong(elem);
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3299 Py_DECREF(elem);
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3300 }
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3301
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3302 if (setgroups(len, grouplist) < 0)
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3303 return posix_error();
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3304 Py_INCREF(Py_None);
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3305 return Py_None;
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3306 }
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
3307 #endif /* HAVE_SETGROUPS */
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3308
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3309 #ifdef HAVE_WAITPID
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3310 static char posix_waitpid__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3311 "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
3312 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
3313
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3314 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
3315 posix_waitpid(PyObject *self, PyObject *args)
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
3316 {
9970
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3317 int pid, options;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3318 #ifdef UNION_WAIT
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3319 union wait status;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3320 #define status_i (status.w_status)
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3321 #else
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3322 int status;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3323 #define status_i status
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3324 #endif
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3325 status_i = 0;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3326
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3327 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
3328 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3329 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
3330 #ifdef NeXT
9970
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3331 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
3332 #else
b82a61a884cf Oops, the patch for NeXT always replaced waitpid() with wait4() --
Guido van Rossum <guido@python.org>
parents: 9970
diff changeset
3333 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
3334 #endif
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3335 Py_END_ALLOW_THREADS
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
3336 if (pid == -1)
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
3337 return posix_error();
931
d8608ed1cc3b Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents: 926
diff changeset
3338 else
9970
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3339 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
3340 }
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3341 #endif /* HAVE_WAITPID */
931
d8608ed1cc3b Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents: 926
diff changeset
3342
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3343
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
3344 #ifdef HAVE_WAIT
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3345 static char posix_wait__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3346 "wait() -> (pid, status)\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3347 Wait for completion of a child process.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3348
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3349 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
3350 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
3351 {
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3352 int pid;
9970
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3353 #ifdef UNION_WAIT
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3354 union wait status;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3355 #define status_i (status.w_status)
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3356 #else
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3357 int status;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3358 #define status_i status
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3359 #endif
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3360 if (!PyArg_ParseTuple(args, ":wait"))
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3361 return NULL;
9970
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3362 status_i = 0;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3363 Py_BEGIN_ALLOW_THREADS
9970
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3364 pid = wait(&status);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3365 Py_END_ALLOW_THREADS
931
d8608ed1cc3b Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents: 926
diff changeset
3366 if (pid == -1)
d8608ed1cc3b Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents: 926
diff changeset
3367 return posix_error();
d8608ed1cc3b Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents: 926
diff changeset
3368 else
9970
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
3369 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
3370 #undef status_i
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
3371 }
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
3372 #endif
257
a46558ad0bed Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents: 200
diff changeset
3373
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3374
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3375 static char posix_lstat__doc__[] =
22255
093942bae1a6 Update docstrings to use te attribute names of the new structures returned
Fred Drake <fdrake@acm.org>
parents: 21713
diff changeset
3376 "lstat(path) -> (st_mode, st_ino, st_dev, st_nlink, st_uid, st_gid,\n\
093942bae1a6 Update docstrings to use te attribute names of the new structures returned
Fred Drake <fdrake@acm.org>
parents: 21713
diff changeset
3377 st_size, st_atime, st_mtime, st_ctime)\n\
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3378 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
3379
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3380 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
3381 posix_lstat(PyObject *self, PyObject *args)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3382 {
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3383 #ifdef HAVE_LSTAT
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
3384 return posix_do_stat(self, args, "et:lstat", lstat);
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3385 #else /* !HAVE_LSTAT */
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
3386 return posix_do_stat(self, args, "et:lstat", STAT);
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3387 #endif /* !HAVE_LSTAT */
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3388 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3389
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3390
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3391 #ifdef HAVE_READLINK
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3392 static char posix_readlink__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3393 "readlink(path) -> path\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3394 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
3395
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3396 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
3397 posix_readlink(PyObject *self, PyObject *args)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3398 {
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3399 char buf[MAXPATHLEN];
643
02d3f161b7f5 Use getargs() function.
Guido van Rossum <guido@python.org>
parents: 373
diff changeset
3400 char *path;
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3401 int n;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3402 if (!PyArg_ParseTuple(args, "s:readlink", &path))
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3403 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3404 Py_BEGIN_ALLOW_THREADS
731
c65fc172f16d Check empty argument lists.
Guido van Rossum <guido@python.org>
parents: 658
diff changeset
3405 n = readlink(path, buf, (int) sizeof buf);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3406 Py_END_ALLOW_THREADS
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3407 if (n < 0)
8708
acf49c9def7d Several changes to support inclusion of filename in relevent
Barry Warsaw <barry@python.org>
parents: 8497
diff changeset
3408 return posix_error_with_filename(path);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3409 return PyString_FromStringAndSize(buf, n);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3410 }
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3411 #endif /* HAVE_READLINK */
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3412
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3413
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3414 #ifdef HAVE_SYMLINK
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3415 static char posix_symlink__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3416 "symlink(src, dst) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3417 Create a symbolic link.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3418
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
3419 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
3420 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
3421 {
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
3422 return posix_2str(args, "etet: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
3423 }
bc125f0d2c5d Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents: 6766
diff changeset
3424 #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
3425
bc125f0d2c5d Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents: 6766
diff changeset
3426
bc125f0d2c5d Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents: 6766
diff changeset
3427 #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
3428 #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
3429 #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
3430 #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
3431
6766
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
3432 #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
3433 static long
13651
8a063423e0b7 Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents: 13642
diff changeset
3434 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
3435 {
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
3436 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
3437
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
3438 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
3439 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
3440 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
3441
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
3442 return value;
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
3443 }
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
3444
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
3445 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
3446 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
3447 {
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3448 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
3449 return NULL;
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
3450
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
3451 /* 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
3452 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
3453 (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
3454 (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
3455 (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
3456 (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
3457 (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
3458 }
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
3459 #else /* not OS2 */
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3460 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
3461 posix_times(PyObject *self, PyObject *args)
793
cbf0ef998a4a Added times() (from time)
Guido van Rossum <guido@python.org>
parents: 731
diff changeset
3462 {
cbf0ef998a4a Added times() (from time)
Guido van Rossum <guido@python.org>
parents: 731
diff changeset
3463 struct tms t;
cbf0ef998a4a Added times() (from time)
Guido van Rossum <guido@python.org>
parents: 731
diff changeset
3464 clock_t c;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3465 if (!PyArg_ParseTuple(args, ":times"))
793
cbf0ef998a4a Added times() (from time)
Guido van Rossum <guido@python.org>
parents: 731
diff changeset
3466 return NULL;
cbf0ef998a4a Added times() (from time)
Guido van Rossum <guido@python.org>
parents: 731
diff changeset
3467 errno = 0;
cbf0ef998a4a Added times() (from time)
Guido van Rossum <guido@python.org>
parents: 731
diff changeset
3468 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
3469 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
3470 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3471 return Py_BuildValue("ddddd",
4785
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
3472 (double)t.tms_utime / HZ,
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
3473 (double)t.tms_stime / HZ,
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
3474 (double)t.tms_cutime / HZ,
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
3475 (double)t.tms_cstime / HZ,
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
3476 (double)c / HZ);
793
cbf0ef998a4a Added times() (from time)
Guido van Rossum <guido@python.org>
parents: 731
diff changeset
3477 }
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
3478 #endif /* not OS2 */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3479 #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
3480
bc125f0d2c5d Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents: 6766
diff changeset
3481
4233
1099159ec821 Use #ifdef MS_WIN32 instead of _MSC_VER > 850.
Guido van Rossum <guido@python.org>
parents: 3801
diff changeset
3482 #ifdef MS_WIN32
1915
80818c106e3e * Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents: 1845
diff changeset
3483 #define HAVE_TIMES /* so the method table will pick it up */
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3484 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
3485 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
3486 {
80818c106e3e * Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents: 1845
diff changeset
3487 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
3488 HANDLE hProc;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3489 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
3490 return NULL;
80818c106e3e * Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents: 1845
diff changeset
3491 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
3492 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
3493 /* 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
3494 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
3495 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
3496 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
3497 */
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3498 return Py_BuildValue(
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3499 "ddddd",
10178
f0a57ccf233c Fixed totally bogus conversion factors used in the Win32 version of
Guido van Rossum <guido@python.org>
parents: 10133
diff changeset
3500 (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
3501 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
3502 (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
3503 user.dwLowDateTime*1e-7),
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3504 (double)0,
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3505 (double)0,
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3506 (double)0);
1915
80818c106e3e * Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents: 1845
diff changeset
3507 }
3702
3408756ec601 changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents: 3695
diff changeset
3508 #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
3509
bc125f0d2c5d Moved some #ifdefs around that got put in the wrong place by the
Guido van Rossum <guido@python.org>
parents: 6766
diff changeset
3510 #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
3511 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
3512 "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
3513 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
3514 #endif
1050
f49d2311776b posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents: 943
diff changeset
3515
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3516
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3517 #ifdef HAVE_SETSID
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3518 static char posix_setsid__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3519 "setsid() -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3520 Call the system call setsid().";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3521
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3522 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
3523 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
3524 {
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3525 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
3526 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
3527 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
3528 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3529 Py_INCREF(Py_None);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3530 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
3531 }
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3532 #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
3533
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3534 #ifdef HAVE_SETPGID
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3535 static char posix_setpgid__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3536 "setpgid(pid, pgrp) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3537 Call the system call setpgid().";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3538
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3539 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
3540 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
3541 {
f49d2311776b posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents: 943
diff changeset
3542 int pid, pgrp;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3543 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
3544 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
3545 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
3546 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3547 Py_INCREF(Py_None);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3548 return Py_None;
1051
f54e64c8b9b7 * Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents: 1050
diff changeset
3549 }
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3550 #endif /* HAVE_SETPGID */
1051
f54e64c8b9b7 * Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents: 1050
diff changeset
3551
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3552
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3553 #ifdef HAVE_TCGETPGRP
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3554 static char posix_tcgetpgrp__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3555 "tcgetpgrp(fd) -> pgid\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3556 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
3557
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3558 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
3559 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
3560 {
f54e64c8b9b7 * Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents: 1050
diff changeset
3561 int fd, pgid;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3562 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
3563 return NULL;
f54e64c8b9b7 * Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents: 1050
diff changeset
3564 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
3565 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
3566 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3567 return PyInt_FromLong((long)pgid);
1051
f54e64c8b9b7 * Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents: 1050
diff changeset
3568 }
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3569 #endif /* HAVE_TCGETPGRP */
1051
f54e64c8b9b7 * Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents: 1050
diff changeset
3570
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3571
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3572 #ifdef HAVE_TCSETPGRP
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3573 static char posix_tcsetpgrp__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3574 "tcsetpgrp(fd, pgid) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3575 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
3576
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3577 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
3578 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
3579 {
f54e64c8b9b7 * Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents: 1050
diff changeset
3580 int fd, pgid;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3581 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
3582 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
3583 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
3584 return posix_error();
4785
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
3585 Py_INCREF(Py_None);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3586 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
3587 }
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
3588 #endif /* HAVE_TCSETPGRP */
793
cbf0ef998a4a Added times() (from time)
Guido van Rossum <guido@python.org>
parents: 731
diff changeset
3589
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 /* 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
3591
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3592 static char posix_open__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3593 "open(filename, flag [, mode=0777]) -> fd\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3594 Open a file (for low level IO).";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3595
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3596 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
3597 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
3598 {
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
3599 char *file = 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
3600 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
3601 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
3602 int fd;
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
3603 if (!PyArg_ParseTuple(args, "eti|i",
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
3604 Py_FileSystemDefaultEncoding, &file,
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
3605 &flag, &mode))
4785
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
3606 return NULL;
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
3607
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3608 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
3609 fd = open(file, flag, mode);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3610 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
3611 if (fd < 0)
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
3612 return posix_error_with_allocated_filename(file);
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
3613 PyMem_Free(file);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3614 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
3615 }
673dd9bbdbf1 New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents: 1252
diff changeset
3616
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3617
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3618 static char posix_close__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3619 "close(fd) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3620 Close a file descriptor (for low level IO).";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3621
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3622 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
3623 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
3624 {
673dd9bbdbf1 New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents: 1252
diff changeset
3625 int fd, res;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3626 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
3627 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3628 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
3629 res = close(fd);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3630 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
3631 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
3632 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3633 Py_INCREF(Py_None);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3634 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
3635 }
673dd9bbdbf1 New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents: 1252
diff changeset
3636
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3637
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3638 static char posix_dup__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3639 "dup(fd) -> fd2\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3640 Return a duplicate of a file descriptor.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3641
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3642 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
3643 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
3644 {
673dd9bbdbf1 New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents: 1252
diff changeset
3645 int fd;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3646 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
3647 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3648 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
3649 fd = dup(fd);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3650 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
3651 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
3652 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3653 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
3654 }
673dd9bbdbf1 New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents: 1252
diff changeset
3655
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3656
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3657 static char posix_dup2__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3658 "dup2(fd, fd2) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3659 Duplicate file descriptor.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3660
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3661 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
3662 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
3663 {
673dd9bbdbf1 New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents: 1252
diff changeset
3664 int fd, fd2, res;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3665 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
3666 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3667 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
3668 res = dup2(fd, fd2);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3669 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
3670 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
3671 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3672 Py_INCREF(Py_None);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3673 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
3674 }
673dd9bbdbf1 New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents: 1252
diff changeset
3675
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3676
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3677 static char posix_lseek__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3678 "lseek(fd, pos, how) -> newpos\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3679 Set the current position of a file descriptor.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3680
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3681 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
3682 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
3683 {
673dd9bbdbf1 New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents: 1252
diff changeset
3684 int fd, how;
19754
e1f1e9ebf050 Enable large file support on Win32 systems.
Tim Peters <tim.peters@gmail.com>
parents: 19568
diff changeset
3685 #if defined(MS_WIN64) || defined(MS_WIN32)
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
3686 LONG_LONG pos, res;
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
3687 #else
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3688 off_t pos, res;
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
3689 #endif
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3690 PyObject *posobj;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3691 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
3692 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
3693 #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
3694 /* 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
3695 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
3696 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
3697 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
3698 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
3699 }
1792
a584b4bbbc59 Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
3700 #endif /* SEEK_END */
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3701
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3702 #if !defined(HAVE_LARGEFILE_SUPPORT)
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3703 pos = PyInt_AsLong(posobj);
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3704 #else
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3705 pos = PyLong_Check(posobj) ?
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3706 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
3707 #endif
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3708 if (PyErr_Occurred())
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3709 return NULL;
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3710
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3711 Py_BEGIN_ALLOW_THREADS
19754
e1f1e9ebf050 Enable large file support on Win32 systems.
Tim Peters <tim.peters@gmail.com>
parents: 19568
diff changeset
3712 #if defined(MS_WIN64) || defined(MS_WIN32)
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
3713 res = _lseeki64(fd, pos, how);
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
3714 #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
3715 res = lseek(fd, pos, how);
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
3716 #endif
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3717 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
3718 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
3719 return posix_error();
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3720
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3721 #if !defined(HAVE_LARGEFILE_SUPPORT)
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3722 return PyInt_FromLong(res);
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3723 #else
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3724 return PyLong_FromLongLong(res);
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3725 #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
3726 }
673dd9bbdbf1 New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents: 1252
diff changeset
3727
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3728
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3729 static char posix_read__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3730 "read(fd, buffersize) -> string\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3731 Read a file descriptor.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3732
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3733 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
3734 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
3735 {
3667
eabbb3c1818f Avoid core dump in resizestring() on read() with 0 bytes.
Guido van Rossum <guido@python.org>
parents: 3622
diff changeset
3736 int fd, size, n;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3737 PyObject *buffer;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3738 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
3739 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3740 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
3741 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
3742 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3743 Py_BEGIN_ALLOW_THREADS
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3744 n = read(fd, PyString_AsString(buffer), size);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3745 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
3746 if (n < 0) {
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3747 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
3748 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
3749 }
3667
eabbb3c1818f Avoid core dump in resizestring() on read() with 0 bytes.
Guido van Rossum <guido@python.org>
parents: 3622
diff changeset
3750 if (n != size)
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3751 _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
3752 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
3753 }
673dd9bbdbf1 New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents: 1252
diff changeset
3754
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3755
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3756 static char posix_write__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3757 "write(fd, string) -> byteswritten\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3758 Write a string to a file descriptor.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3759
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3760 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
3761 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
3762 {
673dd9bbdbf1 New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents: 1252
diff changeset
3763 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
3764 char *buffer;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3765 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
3766 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3767 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
3768 size = write(fd, buffer, size);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3769 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
3770 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
3771 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3772 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
3773 }
673dd9bbdbf1 New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents: 1252
diff changeset
3774
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3775
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3776 static char posix_fstat__doc__[]=
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3777 "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
3778 Like stat(), but for an open file descriptor.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3779
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3780 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
3781 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
3782 {
673dd9bbdbf1 New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents: 1252
diff changeset
3783 int fd;
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
3784 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
3785 int res;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3786 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
3787 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3788 Py_BEGIN_ALLOW_THREADS
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
3789 res = FSTAT(fd, &st);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3790 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
3791 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
3792 return posix_error();
13153
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
3793
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
3794 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
3795 }
673dd9bbdbf1 New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents: 1252
diff changeset
3796
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3797
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3798 static char posix_fdopen__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3799 "fdopen(fd, [, mode='r' [, bufsize]]) -> file_object\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3800 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
3801
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3802 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
3803 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
3804 {
673dd9bbdbf1 New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents: 1252
diff changeset
3805 int fd;
2114
7947c0d16ca0 added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents: 2061
diff changeset
3806 char *mode = "r";
7947c0d16ca0 added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents: 2061
diff changeset
3807 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
3808 FILE *fp;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3809 PyObject *f;
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3810 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
3811 return NULL;
4785
9fc380b1a445 Minor formatting changes.
Barry Warsaw <barry@python.org>
parents: 4672
diff changeset
3812
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3813 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
3814 fp = fdopen(fd, mode);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3815 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
3816 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
3817 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3818 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
3819 if (f != NULL)
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3820 PyFile_SetBufSize(f, bufsize);
2114
7947c0d16ca0 added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents: 2061
diff changeset
3821 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
3822 }
673dd9bbdbf1 New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents: 1252
diff changeset
3823
13641
38ea27455cbb new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents: 13620
diff changeset
3824 static char posix_isatty__doc__[] =
38ea27455cbb new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents: 13620
diff changeset
3825 "isatty(fd) -> Boolean\n\
38ea27455cbb new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents: 13620
diff changeset
3826 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
3827 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
3828
38ea27455cbb new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents: 13620
diff changeset
3829 static PyObject *
13642
dacc9f167e95 ANSIfy the just-checked-in isatty() wrapper.
Thomas Wouters <thomas@python.org>
parents: 13641
diff changeset
3830 posix_isatty(PyObject *self, PyObject *args)
13641
38ea27455cbb new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents: 13620
diff changeset
3831 {
38ea27455cbb new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents: 13620
diff changeset
3832 int fd;
38ea27455cbb new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents: 13620
diff changeset
3833 if (!PyArg_ParseTuple(args, "i:isatty", &fd))
38ea27455cbb new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents: 13620
diff changeset
3834 return NULL;
38ea27455cbb new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents: 13620
diff changeset
3835 return Py_BuildValue("i", isatty(fd));
38ea27455cbb new method isatty from Thomas Wouters
Skip Montanaro <skip@pobox.com>
parents: 13620
diff changeset
3836 }
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3837
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3838 #ifdef HAVE_PIPE
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3839 static char posix_pipe__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3840 "pipe() -> (read_end, write_end)\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3841 Create a pipe.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3842
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3843 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
3844 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
3845 {
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
3846 #if defined(PYOS_OS2)
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
3847 HFILE read, write;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
3848 APIRET rc;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
3849
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3850 if (!PyArg_ParseTuple(args, ":pipe"))
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
3851 return NULL;
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
3852
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
3853 Py_BEGIN_ALLOW_THREADS
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
3854 rc = DosCreatePipe( &read, &write, 4096);
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
3855 Py_END_ALLOW_THREADS
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
3856 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
3857 return os2_error(rc);
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
3858
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
3859 return Py_BuildValue("(ii)", read, write);
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
3860 #else
3702
3408756ec601 changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents: 3695
diff changeset
3861 #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
3862 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
3863 int res;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3864 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
3865 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3866 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
3867 res = pipe(fds);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3868 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
3869 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
3870 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3871 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
3872 #else /* MS_WIN32 */
1815
6353fe25cdce * Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents: 1792
diff changeset
3873 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
3874 int read_fd, write_fd;
1815
6353fe25cdce * Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents: 1792
diff changeset
3875 BOOL ok;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3876 if (!PyArg_ParseTuple(args, ":pipe"))
1815
6353fe25cdce * Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents: 1792
diff changeset
3877 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3878 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
3879 ok = CreatePipe(&read, &write, NULL, 0);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3880 Py_END_ALLOW_THREADS
1815
6353fe25cdce * Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents: 1792
diff changeset
3881 if (!ok)
13468
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
3882 return win32_error("CreatePipe", NULL);
19568
b0f5278a2ab4 SF bug [#456252] Python should never stomp on [u]intptr_t.
Tim Peters <tim.peters@gmail.com>
parents: 19490
diff changeset
3883 read_fd = _open_osfhandle((Py_intptr_t)read, 0);
b0f5278a2ab4 SF bug [#456252] Python should never stomp on [u]intptr_t.
Tim Peters <tim.peters@gmail.com>
parents: 19490
diff changeset
3884 write_fd = _open_osfhandle((Py_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
3885 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
3886 #endif /* MS_WIN32 */
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
3887 #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
3888 }
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3889 #endif /* HAVE_PIPE */
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3890
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3891
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3892 #ifdef HAVE_MKFIFO
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3893 static char posix_mkfifo__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3894 "mkfifo(file, [, mode=0666]) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3895 Create a FIFO (a POSIX named pipe).";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3896
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3897 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
3898 posix_mkfifo(PyObject *self, PyObject *args)
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3899 {
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3900 char *file;
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3901 int mode = 0666;
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3902 int res;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3903 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
3904 return NULL;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3905 Py_BEGIN_ALLOW_THREADS
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3906 res = mkfifo(file, mode);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3907 Py_END_ALLOW_THREADS
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3908 if (res < 0)
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3909 return posix_error();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3910 Py_INCREF(Py_None);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3911 return Py_None;
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3912 }
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3913 #endif
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3914
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3915
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3916 #ifdef HAVE_FTRUNCATE
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3917 static char posix_ftruncate__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3918 "ftruncate(fd, length) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3919 Truncate a file to a specified length.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
3920
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3921 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
3922 posix_ftruncate(PyObject *self, PyObject *args)
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3923 {
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3924 int fd;
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3925 off_t length;
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3926 int res;
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3927 PyObject *lenobj;
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3928
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
3929 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
3930 return NULL;
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3931
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3932 #if !defined(HAVE_LARGEFILE_SUPPORT)
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3933 length = PyInt_AsLong(lenobj);
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3934 #else
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3935 length = PyLong_Check(lenobj) ?
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3936 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
3937 #endif
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
3938 if (PyErr_Occurred())
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3939 return NULL;
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3940
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3941 Py_BEGIN_ALLOW_THREADS
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3942 res = ftruncate(fd, length);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3943 Py_END_ALLOW_THREADS
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3944 if (res < 0) {
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3945 PyErr_SetFromErrno(PyExc_IOError);
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3946 return NULL;
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3947 }
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3948 Py_INCREF(Py_None);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
3949 return Py_None;
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3950 }
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
3951 #endif
793
cbf0ef998a4a Added times() (from time)
Guido van Rossum <guido@python.org>
parents: 731
diff changeset
3952
5584
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3953 #ifdef NeXT
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3954 #define HAVE_PUTENV
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3955 /* 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
3956 static int
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3957 putenv(char *newval)
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3958 {
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3959 extern char **environ;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3960
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3961 static int firstTime = 1;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3962 char **ep;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3963 char *cp;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3964 int esiz;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3965 char *np;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3966
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3967 if (!(np = strchr(newval, '=')))
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3968 return 1;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3969 *np = '\0';
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3970
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3971 /* look it up */
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3972 for (ep=environ ; *ep ; ep++)
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3973 {
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3974 /* this should always be true... */
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3975 if (cp = strchr(*ep, '='))
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3976 {
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3977 *cp = '\0';
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3978 if (!strcmp(*ep, newval))
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3979 {
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3980 /* got it! */
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3981 *cp = '=';
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3982 break;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3983 }
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3984 *cp = '=';
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3985 }
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3986 else
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3987 {
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3988 *np = '=';
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3989 return 1;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3990 }
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3991 }
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3992
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3993 *np = '=';
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3994 if (*ep)
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3995 {
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3996 /* the string was already there:
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3997 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
3998 *ep = newval;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
3999 return 0;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4000 }
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4001
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4002 /* expand environ by one */
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4003 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
4004 esiz++;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4005 if (firstTime)
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4006 {
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4007 char **epp;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4008 char **newenv;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4009 if (!(newenv = malloc(esiz * sizeof(char *))))
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4010 return 1;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4011
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4012 for (ep=environ, epp=newenv ; *ep ;)
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4013 *epp++ = *ep++;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4014 *epp++ = newval;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4015 *epp = (char *) 0;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4016 environ = newenv;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4017 }
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4018 else
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4019 {
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4020 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
4021 return 1;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4022 environ[esiz - 2] = newval;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4023 environ[esiz - 1] = (char *) 0;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4024 firstTime = 0;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4025 }
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4026
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4027 return 0;
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4028 }
6130
2d9582eee112 Added /**/ around #end tags
Guido van Rossum <guido@python.org>
parents: 6027
diff changeset
4029 #endif /* NeXT */
5584
85c5043c9316 Enable putenv and waitpid (== wait4) for NeXT.
Guido van Rossum <guido@python.org>
parents: 5361
diff changeset
4030
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
4031
3801
843121a226ca Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents: 3735
diff changeset
4032 #ifdef HAVE_PUTENV
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
4033 static char posix_putenv__doc__[] =
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
4034 "putenv(key, value) -> None\n\
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
4035 Change or add an environment variable.";
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
4036
11230
b69859b69763 posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents: 11172
diff changeset
4037 /* 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
4038 * 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
4039 static PyObject *posix_putenv_garbage;
b69859b69763 posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents: 11172
diff changeset
4040
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
4041 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
4042 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
4043 {
843121a226ca Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents: 3735
diff changeset
4044 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
4045 char *new;
11230
b69859b69763 posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents: 11172
diff changeset
4046 PyObject *newstr;
21172
df2ffb0cd6bb posix_execve(), posix_spawnve(), posix_putenv():
Tim Peters <tim.peters@gmail.com>
parents: 21094
diff changeset
4047 size_t len;
3801
843121a226ca Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents: 3735
diff changeset
4048
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4049 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
4050 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
4051
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
4052 #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
4053 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
4054 APIRET rc;
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
4055
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
4056 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
4057 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
4058
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
4059 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
4060 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
4061 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
4062
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
4063 } 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
4064 APIRET rc;
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
4065
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
4066 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
4067 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
4068
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
4069 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
4070 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
4071 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
4072 } else {
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
4073 #endif
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
4074
11230
b69859b69763 posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents: 11172
diff changeset
4075 /* XXX This can leak memory -- not easy to fix :-( */
21172
df2ffb0cd6bb posix_execve(), posix_spawnve(), posix_putenv():
Tim Peters <tim.peters@gmail.com>
parents: 21094
diff changeset
4076 len = strlen(s1) + strlen(s2) + 2;
df2ffb0cd6bb posix_execve(), posix_spawnve(), posix_putenv():
Tim Peters <tim.peters@gmail.com>
parents: 21094
diff changeset
4077 /* len includes space for a trailing \0; the size arg to
df2ffb0cd6bb posix_execve(), posix_spawnve(), posix_putenv():
Tim Peters <tim.peters@gmail.com>
parents: 21094
diff changeset
4078 PyString_FromStringAndSize does not count that */
df2ffb0cd6bb posix_execve(), posix_spawnve(), posix_putenv():
Tim Peters <tim.peters@gmail.com>
parents: 21094
diff changeset
4079 newstr = PyString_FromStringAndSize(NULL, (int)len - 1);
11230
b69859b69763 posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents: 11172
diff changeset
4080 if (newstr == NULL)
b69859b69763 posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents: 11172
diff changeset
4081 return PyErr_NoMemory();
b69859b69763 posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents: 11172
diff changeset
4082 new = PyString_AS_STRING(newstr);
21172
df2ffb0cd6bb posix_execve(), posix_spawnve(), posix_putenv():
Tim Peters <tim.peters@gmail.com>
parents: 21094
diff changeset
4083 PyOS_snprintf(new, len, "%s=%s", 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
4084 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
4085 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
4086 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
4087 }
11230
b69859b69763 posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents: 11172
diff changeset
4088 /* 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
4089 * 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
4090 * 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
4091 * was still accessible until then. */
b69859b69763 posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents: 11172
diff changeset
4092 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
4093 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
4094 /* 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
4095 PyErr_Clear();
b69859b69763 posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents: 11172
diff changeset
4096 }
b69859b69763 posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents: 11172
diff changeset
4097 else {
b69859b69763 posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents: 11172
diff changeset
4098 Py_DECREF(newstr);
b69859b69763 posix_putenv(): Constrain memory leakage when setting the same
Fred Drake <fdrake@acm.org>
parents: 11172
diff changeset
4099 }
6766
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
4100
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
4101 #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
4102 }
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
4103 #endif
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
4104 Py_INCREF(Py_None);
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
4105 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
4106 }
6315
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4107 #endif /* putenv */
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4108
20551
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4109 #ifdef HAVE_UNSETENV
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4110 static char posix_unsetenv__doc__[] =
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4111 "unsetenv(key) -> None\n\
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4112 Delete an environment variable.";
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4113
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4114 static PyObject *
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4115 posix_unsetenv(PyObject *self, PyObject *args)
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4116 {
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4117 char *s1;
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4118
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4119 if (!PyArg_ParseTuple(args, "s:unsetenv", &s1))
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4120 return NULL;
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4121
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4122 unsetenv(s1);
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4123
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4124 /* Remove the key from posix_putenv_garbage;
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4125 * this will cause it to be collected. This has to
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4126 * happen after the real unsetenv() call because the
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4127 * old value was still accessible until then.
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4128 */
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4129 if (PyDict_DelItem(posix_putenv_garbage,
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4130 PyTuple_GET_ITEM(args, 0))) {
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4131 /* really not much we can do; just leak */
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4132 PyErr_Clear();
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4133 }
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4134
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4135 Py_INCREF(Py_None);
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4136 return Py_None;
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4137 }
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4138 #endif /* unsetenv */
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
4139
6315
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4140 #ifdef HAVE_STRERROR
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4141 static char posix_strerror__doc__[] =
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4142 "strerror(code) -> string\n\
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4143 Translate an error code to a message string.";
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4144
17518
f939ce52a734 Make some private symbols static.
Guido van Rossum <guido@python.org>
parents: 17419
diff changeset
4145 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
4146 posix_strerror(PyObject *self, PyObject *args)
6315
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4147 {
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4148 int code;
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4149 char *message;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4150 if (!PyArg_ParseTuple(args, "i:strerror", &code))
6315
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4151 return NULL;
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4152 message = strerror(code);
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4153 if (message == NULL) {
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4154 PyErr_SetString(PyExc_ValueError,
15318
8aa947e1eee8 Ka-Ping Yee <ping@lfw.org>:
Fred Drake <fdrake@acm.org>
parents: 14995
diff changeset
4155 "strerror() argument out of range");
6315
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4156 return NULL;
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4157 }
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4158 return PyString_FromString(message);
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4159 }
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4160 #endif /* strerror */
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
4161
3801
843121a226ca Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents: 3735
diff changeset
4162
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
4163 #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
4164
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4165 #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
4166 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
4167 "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
4168 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
4169
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4170 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
4171 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
4172 {
9970
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4173 #ifdef UNION_WAIT
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4174 union wait status;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4175 #define status_i (status.w_status)
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4176 #else
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4177 int status;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4178 #define status_i status
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4179 #endif
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4180 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
4181
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4182 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
4183 {
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4184 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
4185 }
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4186
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4187 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
4188 #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
4189 }
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4190 #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
4191
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4192 #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
4193 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
4194 "WIFSIGNALED(status) -> Boolean\n\
10286
3b81a7d418cb # Typo in docstring (Retrun -> Return).
Guido van Rossum <guido@python.org>
parents: 10263
diff changeset
4195 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
4196
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4197 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
4198 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
4199 {
9970
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4200 #ifdef UNION_WAIT
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4201 union wait status;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4202 #define status_i (status.w_status)
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4203 #else
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4204 int status;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4205 #define status_i status
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4206 #endif
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4207 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
4208
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4209 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
4210 {
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4211 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
4212 }
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4213
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4214 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
4215 #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
4216 }
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4217 #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
4218
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4219 #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
4220 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
4221 "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
4222 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
4223 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
4224
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4225 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
4226 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
4227 {
9970
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4228 #ifdef UNION_WAIT
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4229 union wait status;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4230 #define status_i (status.w_status)
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4231 #else
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4232 int status;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4233 #define status_i status
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4234 #endif
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4235 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
4236
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4237 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
4238 {
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4239 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
4240 }
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4241
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4242 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
4243 #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
4244 }
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4245 #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
4246
9970
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4247 #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
4248 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
4249 "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
4250 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
4251
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4252 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
4253 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
4254 {
9970
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4255 #ifdef UNION_WAIT
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4256 union wait status;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4257 #define status_i (status.w_status)
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4258 #else
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4259 int status;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4260 #define status_i status
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4261 #endif
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4262 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
4263
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4264 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
4265 {
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4266 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
4267 }
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4268
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4269 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
4270 #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
4271 }
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4272 #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
4273
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4274 #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
4275 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
4276 "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
4277 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
4278 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
4279
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4280 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
4281 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
4282 {
9970
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4283 #ifdef UNION_WAIT
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4284 union wait status;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4285 #define status_i (status.w_status)
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4286 #else
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4287 int status;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4288 #define status_i status
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4289 #endif
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4290 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
4291
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4292 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
4293 {
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4294 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
4295 }
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4296
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4297 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
4298 #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
4299 }
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4300 #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
4301
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4302 #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
4303 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
4304 "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
4305 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
4306
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4307 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
4308 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
4309 {
9970
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4310 #ifdef UNION_WAIT
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4311 union wait status;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4312 #define status_i (status.w_status)
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4313 #else
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4314 int status;
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4315 #define status_i status
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4316 #endif
8efa37a770c6 Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents: 9954
diff changeset
4317 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
4318
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4319 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
4320 {
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4321 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
4322 }
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4323
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4324 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
4325 #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
4326 }
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4327 #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
4328
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4329 #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
4330
4aa76480d812 Patch by Jody Winston (with my changes) to add some of the "wait
Guido van Rossum <guido@python.org>
parents: 8708
diff changeset
4331
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4332 #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
4333 #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
4334 /* 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
4335 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
4336 #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
4337 #endif
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4338 #include <sys/statvfs.h>
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4339
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4340 static PyObject*
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4341 _pystatvfs_fromstructstatvfs(struct statvfs st) {
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4342 PyObject *v = PyStructSequence_New(&StatVFSResultType);
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4343 if (v == NULL)
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4344 return NULL;
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4345
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4346 #if !defined(HAVE_LARGEFILE_SUPPORT)
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4347 PyStructSequence_SET_ITEM(v, 0, PyInt_FromLong((long) st.f_bsize));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4348 PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long) st.f_frsize));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4349 PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long) st.f_blocks));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4350 PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long) st.f_bfree));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4351 PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long) st.f_bavail));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4352 PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long) st.f_files));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4353 PyStructSequence_SET_ITEM(v, 6, PyInt_FromLong((long) st.f_ffree));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4354 PyStructSequence_SET_ITEM(v, 7, PyInt_FromLong((long) st.f_favail));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4355 PyStructSequence_SET_ITEM(v, 8, PyInt_FromLong((long) st.f_flag));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4356 PyStructSequence_SET_ITEM(v, 9, PyInt_FromLong((long) st.f_namemax));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4357 #else
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4358 PyStructSequence_SET_ITEM(v, 0, PyInt_FromLong((long) st.f_bsize));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4359 PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long) st.f_frsize));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4360 PyStructSequence_SET_ITEM(v, 2,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4361 PyLong_FromLongLong((LONG_LONG) st.f_blocks));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4362 PyStructSequence_SET_ITEM(v, 3,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4363 PyLong_FromLongLong((LONG_LONG) st.f_bfree));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4364 PyStructSequence_SET_ITEM(v, 4,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4365 PyLong_FromLongLong((LONG_LONG) st.f_bavail));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4366 PyStructSequence_SET_ITEM(v, 5,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4367 PyLong_FromLongLong((LONG_LONG) st.f_files));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4368 PyStructSequence_SET_ITEM(v, 6,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4369 PyLong_FromLongLong((LONG_LONG) st.f_ffree));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4370 PyStructSequence_SET_ITEM(v, 7,
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4371 PyLong_FromLongLong((LONG_LONG) st.f_favail));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4372 PyStructSequence_SET_ITEM(v, 8, PyInt_FromLong((long) st.f_flag));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4373 PyStructSequence_SET_ITEM(v, 9, PyInt_FromLong((long) st.f_namemax));
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4374 #endif
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4375
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4376 return v;
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4377 }
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4378
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4379 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
4380 "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
4381 (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
4382 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
4383
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4384 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
4385 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
4386 {
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4387 int fd, res;
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4388 struct statvfs st;
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4389
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4390 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
4391 return NULL;
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4392 Py_BEGIN_ALLOW_THREADS
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4393 res = fstatvfs(fd, &st);
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4394 Py_END_ALLOW_THREADS
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4395 if (res != 0)
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4396 return posix_error();
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4397
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4398 return _pystatvfs_fromstructstatvfs(st);
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4399 }
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4400 #endif /* HAVE_FSTATVFS */
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4401
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4402
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4403 #if defined(HAVE_STATVFS)
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4404 #include <sys/statvfs.h>
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4405
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4406 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
4407 "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
4408 (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
4409 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
4410
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4411 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
4412 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
4413 {
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4414 char *path;
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4415 int res;
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4416 struct statvfs st;
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4417 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
4418 return NULL;
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4419 Py_BEGIN_ALLOW_THREADS
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4420 res = statvfs(path, &st);
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4421 Py_END_ALLOW_THREADS
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4422 if (res != 0)
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4423 return posix_error_with_filename(path);
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4424
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
4425 return _pystatvfs_fromstructstatvfs(st);
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4426 }
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4427 #endif /* HAVE_STATVFS */
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4428
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
4429
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4430 #ifdef HAVE_TEMPNAM
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4431 static char posix_tempnam__doc__[] = "\
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4432 tempnam([dir[, prefix]]) -> string\n\
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4433 Return a unique name for a temporary file.\n\
24431
f4436e1b1868 Fix docstring to be consistent with parameter name (prefix)
Neal Norwitz <nnorwitz@gmail.com>
parents: 23901
diff changeset
4434 The directory and a prefix may be specified as strings; they may be omitted\n\
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4435 or None if not needed.";
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4436
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4437 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
4438 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
4439 {
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4440 PyObject *result = NULL;
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4441 char *dir = NULL;
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4442 char *pfx = NULL;
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4443 char *name;
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4444
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4445 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
4446 return NULL;
19370
bafbe5cc941f added warnings about security risk of using tmpnam and tempnam
Skip Montanaro <skip@pobox.com>
parents: 18835
diff changeset
4447
bafbe5cc941f added warnings about security risk of using tmpnam and tempnam
Skip Montanaro <skip@pobox.com>
parents: 18835
diff changeset
4448 if (PyErr_Warn(PyExc_RuntimeWarning,
bafbe5cc941f added warnings about security risk of using tmpnam and tempnam
Skip Montanaro <skip@pobox.com>
parents: 18835
diff changeset
4449 "tempnam is a potential security risk to your program") < 0)
bafbe5cc941f added warnings about security risk of using tmpnam and tempnam
Skip Montanaro <skip@pobox.com>
parents: 18835
diff changeset
4450 return NULL;
bafbe5cc941f added warnings about security risk of using tmpnam and tempnam
Skip Montanaro <skip@pobox.com>
parents: 18835
diff changeset
4451
18674
9ee8f16b0e27 On Windows, tempnam() is spelled with a leading underscore.
Fred Drake <fdrake@acm.org>
parents: 18486
diff changeset
4452 #ifdef MS_WIN32
9ee8f16b0e27 On Windows, tempnam() is spelled with a leading underscore.
Fred Drake <fdrake@acm.org>
parents: 18486
diff changeset
4453 name = _tempnam(dir, pfx);
9ee8f16b0e27 On Windows, tempnam() is spelled with a leading underscore.
Fred Drake <fdrake@acm.org>
parents: 18486
diff changeset
4454 #else
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4455 name = tempnam(dir, pfx);
18674
9ee8f16b0e27 On Windows, tempnam() is spelled with a leading underscore.
Fred Drake <fdrake@acm.org>
parents: 18486
diff changeset
4456 #endif
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4457 if (name == NULL)
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4458 return PyErr_NoMemory();
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4459 result = PyString_FromString(name);
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4460 free(name);
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4461 return result;
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4462 }
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4463 #endif
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4464
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4465
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4466 #ifdef HAVE_TMPFILE
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4467 static char posix_tmpfile__doc__[] = "\
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4468 tmpfile() -> file object\n\
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4469 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
4470
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4471 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
4472 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
4473 {
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4474 FILE *fp;
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4475
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4476 if (!PyArg_ParseTuple(args, ":tmpfile"))
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4477 return NULL;
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4478 fp = tmpfile();
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4479 if (fp == NULL)
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4480 return posix_error();
24992
c5417f0ee5f0 backport gvanrossum's checkin of
Michael W. Hudson <mwh@python.net>
parents: 24885
diff changeset
4481 return PyFile_FromFile(fp, "<tmpfile>", "w+b", fclose);
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4482 }
9939
faf351e31571 Only do ttyname() when HAVE_TTYNAME is defined.
Guido van Rossum <guido@python.org>
parents: 9824
diff changeset
4483 #endif
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4484
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4485
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4486 #ifdef HAVE_TMPNAM
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4487 static char posix_tmpnam__doc__[] = "\
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4488 tmpnam() -> string\n\
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4489 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
4490
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4491 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
4492 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
4493 {
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4494 char buffer[L_tmpnam];
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4495 char *name;
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4496
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4497 if (!PyArg_ParseTuple(args, ":tmpnam"))
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4498 return NULL;
19370
bafbe5cc941f added warnings about security risk of using tmpnam and tempnam
Skip Montanaro <skip@pobox.com>
parents: 18835
diff changeset
4499
bafbe5cc941f added warnings about security risk of using tmpnam and tempnam
Skip Montanaro <skip@pobox.com>
parents: 18835
diff changeset
4500 if (PyErr_Warn(PyExc_RuntimeWarning,
bafbe5cc941f added warnings about security risk of using tmpnam and tempnam
Skip Montanaro <skip@pobox.com>
parents: 18835
diff changeset
4501 "tmpnam is a potential security risk to your program") < 0)
bafbe5cc941f added warnings about security risk of using tmpnam and tempnam
Skip Montanaro <skip@pobox.com>
parents: 18835
diff changeset
4502 return NULL;
bafbe5cc941f added warnings about security risk of using tmpnam and tempnam
Skip Montanaro <skip@pobox.com>
parents: 18835
diff changeset
4503
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
4504 #ifdef USE_TMPNAM_R
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4505 name = tmpnam_r(buffer);
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4506 #else
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4507 name = tmpnam(buffer);
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4508 #endif
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4509 if (name == NULL) {
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4510 PyErr_SetObject(PyExc_OSError,
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4511 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
4512 #ifdef USE_TMPNAM_R
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4513 "unexpected NULL from tmpnam_r"
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4514 #else
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4515 "unexpected NULL from tmpnam"
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4516 #endif
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4517 ));
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4518 return NULL;
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4519 }
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4520 return PyString_FromString(buffer);
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4521 }
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4522 #endif
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4523
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
4524
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4525 /* 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
4526 * 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
4527 * 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
4528 * 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
4529 * 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
4530 * 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
4531 *
57c1685acb16 Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents: 11574
diff changeset
4532 * 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
4533 * 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
4534 * 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
4535 */
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4536 struct constdef {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4537 char *name;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4538 long value;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4539 };
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4540
11570
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4541 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
4542 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
4543 size_t tablesize)
11570
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4544 {
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4545 if (PyInt_Check(arg)) {
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4546 *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
4547 return 1;
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4548 }
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4549 if (PyString_Check(arg)) {
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4550 /* 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
4551 size_t lo = 0;
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
4552 size_t mid;
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
4553 size_t hi = tablesize;
32816ce60a49 Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 13058
diff changeset
4554 int cmp;
11570
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4555 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
4556 while (lo < hi) {
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4557 mid = (lo + hi) / 2;
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4558 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
4559 if (cmp < 0)
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4560 hi = mid;
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4561 else if (cmp > 0)
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4562 lo = mid + 1;
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4563 else {
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4564 *valuep = table[mid].value;
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4565 return 1;
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4566 }
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4567 }
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4568 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
4569 }
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4570 else
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4571 PyErr_SetString(PyExc_TypeError,
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4572 "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
4573 return 0;
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4574 }
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4575
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4576
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4577 #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
4578 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
4579 #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
4580 {"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
4581 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4582 #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
4583 {"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
4584 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4585 #ifdef _PC_ASYNC_IO
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4586 {"PC_ASYNC_IO", _PC_ASYNC_IO},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4587 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4588 #ifdef _PC_CHOWN_RESTRICTED
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4589 {"PC_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4590 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4591 #ifdef _PC_FILESIZEBITS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4592 {"PC_FILESIZEBITS", _PC_FILESIZEBITS},
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 _PC_LAST
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4595 {"PC_LAST", _PC_LAST},
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 _PC_LINK_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4598 {"PC_LINK_MAX", _PC_LINK_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 _PC_MAX_CANON
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4601 {"PC_MAX_CANON", _PC_MAX_CANON},
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 _PC_MAX_INPUT
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4604 {"PC_MAX_INPUT", _PC_MAX_INPUT},
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 _PC_NAME_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4607 {"PC_NAME_MAX", _PC_NAME_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4608 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4609 #ifdef _PC_NO_TRUNC
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4610 {"PC_NO_TRUNC", _PC_NO_TRUNC},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4611 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4612 #ifdef _PC_PATH_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4613 {"PC_PATH_MAX", _PC_PATH_MAX},
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 _PC_PIPE_BUF
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4616 {"PC_PIPE_BUF", _PC_PIPE_BUF},
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 _PC_PRIO_IO
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4619 {"PC_PRIO_IO", _PC_PRIO_IO},
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 _PC_SOCK_MAXBUF
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4622 {"PC_SOCK_MAXBUF", _PC_SOCK_MAXBUF},
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 _PC_SYNC_IO
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4625 {"PC_SYNC_IO", _PC_SYNC_IO},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4626 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4627 #ifdef _PC_VDISABLE
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4628 {"PC_VDISABLE", _PC_VDISABLE},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4629 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4630 };
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4631
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4632 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
4633 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
4634 {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4635 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
4636 sizeof(posix_constants_pathconf)
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4637 / sizeof(struct constdef));
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4638 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4639 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4640
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4641 #ifdef HAVE_FPATHCONF
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4642 static char posix_fpathconf__doc__[] = "\
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4643 fpathconf(fd, name) -> integer\n\
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4644 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
4645 If there is no limit, return -1.";
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4646
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4647 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
4648 posix_fpathconf(PyObject *self, PyObject *args)
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4649 {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4650 PyObject *result = NULL;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4651 int name, fd;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4652
11570
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
4653 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
4654 conv_path_confname, &name)) {
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4655 long limit;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4656
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4657 errno = 0;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4658 limit = fpathconf(fd, name);
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4659 if (limit == -1 && errno != 0)
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4660 posix_error();
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4661 else
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4662 result = PyInt_FromLong(limit);
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4663 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4664 return result;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4665 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4666 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4667
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4668
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4669 #ifdef HAVE_PATHCONF
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4670 static char posix_pathconf__doc__[] = "\
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4671 pathconf(path, name) -> integer\n\
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4672 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
4673 If there is no limit, return -1.";
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4674
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4675 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
4676 posix_pathconf(PyObject *self, PyObject *args)
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4677 {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4678 PyObject *result = NULL;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4679 int name;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4680 char *path;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4681
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4682 if (PyArg_ParseTuple(args, "sO&:pathconf", &path,
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4683 conv_path_confname, &name)) {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4684 long limit;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4685
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4686 errno = 0;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4687 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
4688 if (limit == -1 && errno != 0) {
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4689 if (errno == EINVAL)
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4690 /* could be a path or name problem */
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4691 posix_error();
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4692 else
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4693 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
4694 }
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4695 else
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4696 result = PyInt_FromLong(limit);
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4697 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4698 return result;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4699 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4700 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4701
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4702 #ifdef HAVE_CONFSTR
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4703 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
4704 #ifdef _CS_ARCHITECTURE
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4705 {"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
4706 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4707 #ifdef _CS_HOSTNAME
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4708 {"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
4709 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4710 #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
4711 {"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
4712 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4713 #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
4714 {"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
4715 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4716 #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
4717 {"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
4718 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4719 #ifdef _CS_LFS64_CFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4720 {"CS_LFS64_CFLAGS", _CS_LFS64_CFLAGS},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4721 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4722 #ifdef _CS_LFS64_LDFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4723 {"CS_LFS64_LDFLAGS", _CS_LFS64_LDFLAGS},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4724 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4725 #ifdef _CS_LFS64_LIBS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4726 {"CS_LFS64_LIBS", _CS_LFS64_LIBS},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4727 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4728 #ifdef _CS_LFS64_LINTFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4729 {"CS_LFS64_LINTFLAGS", _CS_LFS64_LINTFLAGS},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4730 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4731 #ifdef _CS_LFS_CFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4732 {"CS_LFS_CFLAGS", _CS_LFS_CFLAGS},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4733 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4734 #ifdef _CS_LFS_LDFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4735 {"CS_LFS_LDFLAGS", _CS_LFS_LDFLAGS},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4736 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4737 #ifdef _CS_LFS_LIBS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4738 {"CS_LFS_LIBS", _CS_LFS_LIBS},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4739 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4740 #ifdef _CS_LFS_LINTFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4741 {"CS_LFS_LINTFLAGS", _CS_LFS_LINTFLAGS},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4742 #endif
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4743 #ifdef _CS_MACHINE
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4744 {"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
4745 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4746 #ifdef _CS_PATH
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4747 {"CS_PATH", _CS_PATH},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4748 #endif
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4749 #ifdef _CS_RELEASE
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4750 {"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
4751 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4752 #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
4753 {"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
4754 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4755 #ifdef _CS_SYSNAME
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4756 {"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
4757 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4758 #ifdef _CS_VERSION
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4759 {"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
4760 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4761 #ifdef _CS_XBS5_ILP32_OFF32_CFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4762 {"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
4763 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4764 #ifdef _CS_XBS5_ILP32_OFF32_LDFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4765 {"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
4766 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4767 #ifdef _CS_XBS5_ILP32_OFF32_LIBS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4768 {"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
4769 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4770 #ifdef _CS_XBS5_ILP32_OFF32_LINTFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4771 {"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
4772 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4773 #ifdef _CS_XBS5_ILP32_OFFBIG_CFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4774 {"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
4775 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4776 #ifdef _CS_XBS5_ILP32_OFFBIG_LDFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4777 {"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
4778 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4779 #ifdef _CS_XBS5_ILP32_OFFBIG_LIBS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4780 {"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
4781 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4782 #ifdef _CS_XBS5_ILP32_OFFBIG_LINTFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4783 {"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
4784 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4785 #ifdef _CS_XBS5_LP64_OFF64_CFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4786 {"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
4787 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4788 #ifdef _CS_XBS5_LP64_OFF64_LDFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4789 {"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
4790 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4791 #ifdef _CS_XBS5_LP64_OFF64_LIBS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4792 {"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
4793 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4794 #ifdef _CS_XBS5_LP64_OFF64_LINTFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4795 {"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
4796 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4797 #ifdef _CS_XBS5_LPBIG_OFFBIG_CFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4798 {"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
4799 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4800 #ifdef _CS_XBS5_LPBIG_OFFBIG_LDFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4801 {"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
4802 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4803 #ifdef _CS_XBS5_LPBIG_OFFBIG_LIBS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4804 {"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
4805 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4806 #ifdef _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4807 {"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
4808 #endif
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4809 #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
4810 {"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
4811 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4812 #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
4813 {"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
4814 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4815 #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
4816 {"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
4817 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4818 #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
4819 {"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
4820 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4821 #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
4822 {"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
4823 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4824 #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
4825 {"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
4826 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4827 #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
4828 {"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
4829 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4830 #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
4831 {"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
4832 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4833 #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
4834 {"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
4835 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4836 #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
4837 {"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
4838 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4839 #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
4840 {"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
4841 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4842 #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
4843 {"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
4844 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4845 #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
4846 {"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
4847 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4848 };
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4849
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4850 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
4851 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
4852 {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4853 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
4854 sizeof(posix_constants_confstr)
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4855 / sizeof(struct constdef));
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4856 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4857
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4858 static char posix_confstr__doc__[] = "\
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4859 confstr(name) -> string\n\
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4860 Return a string-valued system configuration variable.";
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4861
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4862 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
4863 posix_confstr(PyObject *self, PyObject *args)
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4864 {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4865 PyObject *result = NULL;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4866 int name;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4867 char buffer[64];
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4868
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4869 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
4870 int len = confstr(name, buffer, sizeof(buffer));
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4871
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4872 errno = 0;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4873 if (len == 0) {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4874 if (errno != 0)
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4875 posix_error();
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4876 else
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4877 result = PyString_FromString("");
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4878 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4879 else {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4880 if (len >= sizeof(buffer)) {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4881 result = PyString_FromStringAndSize(NULL, len);
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4882 if (result != NULL)
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4883 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
4884 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4885 else
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4886 result = PyString_FromString(buffer);
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4887 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4888 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4889 return result;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4890 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4891 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4892
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4893
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4894 #ifdef HAVE_SYSCONF
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4895 static struct constdef posix_constants_sysconf[] = {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4896 #ifdef _SC_2_CHAR_TERM
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4897 {"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
4898 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4899 #ifdef _SC_2_C_BIND
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4900 {"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
4901 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4902 #ifdef _SC_2_C_DEV
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4903 {"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
4904 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4905 #ifdef _SC_2_C_VERSION
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4906 {"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
4907 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4908 #ifdef _SC_2_FORT_DEV
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4909 {"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
4910 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4911 #ifdef _SC_2_FORT_RUN
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4912 {"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
4913 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4914 #ifdef _SC_2_LOCALEDEF
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4915 {"SC_2_LOCALEDEF", _SC_2_LOCALEDEF},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4916 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4917 #ifdef _SC_2_SW_DEV
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4918 {"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
4919 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4920 #ifdef _SC_2_UPE
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4921 {"SC_2_UPE", _SC_2_UPE},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4922 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4923 #ifdef _SC_2_VERSION
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4924 {"SC_2_VERSION", _SC_2_VERSION},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4925 #endif
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4926 #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
4927 {"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
4928 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4929 #ifdef _SC_ACL
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4930 {"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
4931 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4932 #ifdef _SC_AIO_LISTIO_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4933 {"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
4934 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4935 #ifdef _SC_AIO_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4936 {"SC_AIO_MAX", _SC_AIO_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4937 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4938 #ifdef _SC_AIO_PRIO_DELTA_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4939 {"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
4940 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4941 #ifdef _SC_ARG_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4942 {"SC_ARG_MAX", _SC_ARG_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4943 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4944 #ifdef _SC_ASYNCHRONOUS_IO
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4945 {"SC_ASYNCHRONOUS_IO", _SC_ASYNCHRONOUS_IO},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4946 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4947 #ifdef _SC_ATEXIT_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4948 {"SC_ATEXIT_MAX", _SC_ATEXIT_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4949 #endif
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4950 #ifdef _SC_AUDIT
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4951 {"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
4952 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4953 #ifdef _SC_AVPHYS_PAGES
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4954 {"SC_AVPHYS_PAGES", _SC_AVPHYS_PAGES},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4955 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4956 #ifdef _SC_BC_BASE_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4957 {"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
4958 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4959 #ifdef _SC_BC_DIM_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4960 {"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
4961 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4962 #ifdef _SC_BC_SCALE_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4963 {"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
4964 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4965 #ifdef _SC_BC_STRING_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4966 {"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
4967 #endif
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4968 #ifdef _SC_CAP
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
4969 {"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
4970 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4971 #ifdef _SC_CHARCLASS_NAME_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4972 {"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
4973 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4974 #ifdef _SC_CHAR_BIT
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4975 {"SC_CHAR_BIT", _SC_CHAR_BIT},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4976 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4977 #ifdef _SC_CHAR_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4978 {"SC_CHAR_MAX", _SC_CHAR_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4979 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4980 #ifdef _SC_CHAR_MIN
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4981 {"SC_CHAR_MIN", _SC_CHAR_MIN},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4982 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4983 #ifdef _SC_CHILD_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4984 {"SC_CHILD_MAX", _SC_CHILD_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4985 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4986 #ifdef _SC_CLK_TCK
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4987 {"SC_CLK_TCK", _SC_CLK_TCK},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4988 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4989 #ifdef _SC_COHER_BLKSZ
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4990 {"SC_COHER_BLKSZ", _SC_COHER_BLKSZ},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4991 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4992 #ifdef _SC_COLL_WEIGHTS_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4993 {"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
4994 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4995 #ifdef _SC_DCACHE_ASSOC
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4996 {"SC_DCACHE_ASSOC", _SC_DCACHE_ASSOC},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4997 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4998 #ifdef _SC_DCACHE_BLKSZ
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
4999 {"SC_DCACHE_BLKSZ", _SC_DCACHE_BLKSZ},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5000 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5001 #ifdef _SC_DCACHE_LINESZ
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5002 {"SC_DCACHE_LINESZ", _SC_DCACHE_LINESZ},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5003 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5004 #ifdef _SC_DCACHE_SZ
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5005 {"SC_DCACHE_SZ", _SC_DCACHE_SZ},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5006 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5007 #ifdef _SC_DCACHE_TBLKSZ
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5008 {"SC_DCACHE_TBLKSZ", _SC_DCACHE_TBLKSZ},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5009 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5010 #ifdef _SC_DELAYTIMER_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5011 {"SC_DELAYTIMER_MAX", _SC_DELAYTIMER_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5012 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5013 #ifdef _SC_EQUIV_CLASS_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5014 {"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
5015 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5016 #ifdef _SC_EXPR_NEST_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5017 {"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
5018 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5019 #ifdef _SC_FSYNC
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5020 {"SC_FSYNC", _SC_FSYNC},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5021 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5022 #ifdef _SC_GETGR_R_SIZE_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5023 {"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
5024 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5025 #ifdef _SC_GETPW_R_SIZE_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5026 {"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
5027 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5028 #ifdef _SC_ICACHE_ASSOC
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5029 {"SC_ICACHE_ASSOC", _SC_ICACHE_ASSOC},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5030 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5031 #ifdef _SC_ICACHE_BLKSZ
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5032 {"SC_ICACHE_BLKSZ", _SC_ICACHE_BLKSZ},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5033 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5034 #ifdef _SC_ICACHE_LINESZ
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5035 {"SC_ICACHE_LINESZ", _SC_ICACHE_LINESZ},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5036 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5037 #ifdef _SC_ICACHE_SZ
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5038 {"SC_ICACHE_SZ", _SC_ICACHE_SZ},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5039 #endif
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5040 #ifdef _SC_INF
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5041 {"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
5042 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5043 #ifdef _SC_INT_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5044 {"SC_INT_MAX", _SC_INT_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5045 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5046 #ifdef _SC_INT_MIN
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5047 {"SC_INT_MIN", _SC_INT_MIN},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5048 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5049 #ifdef _SC_IOV_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5050 {"SC_IOV_MAX", _SC_IOV_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5051 #endif
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5052 #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
5053 {"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
5054 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5055 #ifdef _SC_JOB_CONTROL
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5056 {"SC_JOB_CONTROL", _SC_JOB_CONTROL},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5057 #endif
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5058 #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
5059 {"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
5060 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5061 #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
5062 {"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
5063 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5064 #ifdef _SC_LINE_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5065 {"SC_LINE_MAX", _SC_LINE_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5066 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5067 #ifdef _SC_LOGIN_NAME_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5068 {"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
5069 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5070 #ifdef _SC_LOGNAME_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5071 {"SC_LOGNAME_MAX", _SC_LOGNAME_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5072 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5073 #ifdef _SC_LONG_BIT
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5074 {"SC_LONG_BIT", _SC_LONG_BIT},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5075 #endif
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5076 #ifdef _SC_MAC
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5077 {"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
5078 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5079 #ifdef _SC_MAPPED_FILES
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5080 {"SC_MAPPED_FILES", _SC_MAPPED_FILES},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5081 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5082 #ifdef _SC_MAXPID
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5083 {"SC_MAXPID", _SC_MAXPID},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5084 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5085 #ifdef _SC_MB_LEN_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5086 {"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
5087 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5088 #ifdef _SC_MEMLOCK
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5089 {"SC_MEMLOCK", _SC_MEMLOCK},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5090 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5091 #ifdef _SC_MEMLOCK_RANGE
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5092 {"SC_MEMLOCK_RANGE", _SC_MEMLOCK_RANGE},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5093 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5094 #ifdef _SC_MEMORY_PROTECTION
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5095 {"SC_MEMORY_PROTECTION", _SC_MEMORY_PROTECTION},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5096 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5097 #ifdef _SC_MESSAGE_PASSING
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5098 {"SC_MESSAGE_PASSING", _SC_MESSAGE_PASSING},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5099 #endif
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5100 #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
5101 {"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
5102 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5103 #ifdef _SC_MQ_OPEN_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5104 {"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
5105 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5106 #ifdef _SC_MQ_PRIO_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5107 {"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
5108 #endif
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5109 #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
5110 {"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
5111 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5112 #ifdef _SC_NGROUPS_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5113 {"SC_NGROUPS_MAX", _SC_NGROUPS_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5114 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5115 #ifdef _SC_NL_ARGMAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5116 {"SC_NL_ARGMAX", _SC_NL_ARGMAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5117 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5118 #ifdef _SC_NL_LANGMAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5119 {"SC_NL_LANGMAX", _SC_NL_LANGMAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5120 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5121 #ifdef _SC_NL_MSGMAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5122 {"SC_NL_MSGMAX", _SC_NL_MSGMAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5123 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5124 #ifdef _SC_NL_NMAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5125 {"SC_NL_NMAX", _SC_NL_NMAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5126 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5127 #ifdef _SC_NL_SETMAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5128 {"SC_NL_SETMAX", _SC_NL_SETMAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5129 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5130 #ifdef _SC_NL_TEXTMAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5131 {"SC_NL_TEXTMAX", _SC_NL_TEXTMAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5132 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5133 #ifdef _SC_NPROCESSORS_CONF
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5134 {"SC_NPROCESSORS_CONF", _SC_NPROCESSORS_CONF},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5135 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5136 #ifdef _SC_NPROCESSORS_ONLN
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5137 {"SC_NPROCESSORS_ONLN", _SC_NPROCESSORS_ONLN},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5138 #endif
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5139 #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
5140 {"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
5141 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5142 #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
5143 {"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
5144 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5145 #ifdef _SC_NZERO
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5146 {"SC_NZERO", _SC_NZERO},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5147 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5148 #ifdef _SC_OPEN_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5149 {"SC_OPEN_MAX", _SC_OPEN_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5150 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5151 #ifdef _SC_PAGESIZE
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5152 {"SC_PAGESIZE", _SC_PAGESIZE},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5153 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5154 #ifdef _SC_PAGE_SIZE
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5155 {"SC_PAGE_SIZE", _SC_PAGE_SIZE},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5156 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5157 #ifdef _SC_PASS_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5158 {"SC_PASS_MAX", _SC_PASS_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5159 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5160 #ifdef _SC_PHYS_PAGES
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5161 {"SC_PHYS_PAGES", _SC_PHYS_PAGES},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5162 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5163 #ifdef _SC_PII
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5164 {"SC_PII", _SC_PII},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5165 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5166 #ifdef _SC_PII_INTERNET
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5167 {"SC_PII_INTERNET", _SC_PII_INTERNET},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5168 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5169 #ifdef _SC_PII_INTERNET_DGRAM
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5170 {"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
5171 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5172 #ifdef _SC_PII_INTERNET_STREAM
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5173 {"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
5174 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5175 #ifdef _SC_PII_OSI
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5176 {"SC_PII_OSI", _SC_PII_OSI},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5177 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5178 #ifdef _SC_PII_OSI_CLTS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5179 {"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
5180 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5181 #ifdef _SC_PII_OSI_COTS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5182 {"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
5183 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5184 #ifdef _SC_PII_OSI_M
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5185 {"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
5186 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5187 #ifdef _SC_PII_SOCKET
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5188 {"SC_PII_SOCKET", _SC_PII_SOCKET},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5189 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5190 #ifdef _SC_PII_XTI
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5191 {"SC_PII_XTI", _SC_PII_XTI},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5192 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5193 #ifdef _SC_POLL
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5194 {"SC_POLL", _SC_POLL},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5195 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5196 #ifdef _SC_PRIORITIZED_IO
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5197 {"SC_PRIORITIZED_IO", _SC_PRIORITIZED_IO},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5198 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5199 #ifdef _SC_PRIORITY_SCHEDULING
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5200 {"SC_PRIORITY_SCHEDULING", _SC_PRIORITY_SCHEDULING},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5201 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5202 #ifdef _SC_REALTIME_SIGNALS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5203 {"SC_REALTIME_SIGNALS", _SC_REALTIME_SIGNALS},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5204 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5205 #ifdef _SC_RE_DUP_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5206 {"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
5207 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5208 #ifdef _SC_RTSIG_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5209 {"SC_RTSIG_MAX", _SC_RTSIG_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5210 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5211 #ifdef _SC_SAVED_IDS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5212 {"SC_SAVED_IDS", _SC_SAVED_IDS},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5213 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5214 #ifdef _SC_SCHAR_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5215 {"SC_SCHAR_MAX", _SC_SCHAR_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5216 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5217 #ifdef _SC_SCHAR_MIN
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5218 {"SC_SCHAR_MIN", _SC_SCHAR_MIN},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5219 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5220 #ifdef _SC_SELECT
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5221 {"SC_SELECT", _SC_SELECT},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5222 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5223 #ifdef _SC_SEMAPHORES
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5224 {"SC_SEMAPHORES", _SC_SEMAPHORES},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5225 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5226 #ifdef _SC_SEM_NSEMS_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5227 {"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
5228 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5229 #ifdef _SC_SEM_VALUE_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5230 {"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
5231 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5232 #ifdef _SC_SHARED_MEMORY_OBJECTS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5233 {"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
5234 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5235 #ifdef _SC_SHRT_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5236 {"SC_SHRT_MAX", _SC_SHRT_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5237 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5238 #ifdef _SC_SHRT_MIN
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5239 {"SC_SHRT_MIN", _SC_SHRT_MIN},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5240 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5241 #ifdef _SC_SIGQUEUE_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5242 {"SC_SIGQUEUE_MAX", _SC_SIGQUEUE_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5243 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5244 #ifdef _SC_SIGRT_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5245 {"SC_SIGRT_MAX", _SC_SIGRT_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5246 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5247 #ifdef _SC_SIGRT_MIN
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5248 {"SC_SIGRT_MIN", _SC_SIGRT_MIN},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5249 #endif
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5250 #ifdef _SC_SOFTPOWER
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5251 {"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
5252 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5253 #ifdef _SC_SPLIT_CACHE
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5254 {"SC_SPLIT_CACHE", _SC_SPLIT_CACHE},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5255 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5256 #ifdef _SC_SSIZE_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5257 {"SC_SSIZE_MAX", _SC_SSIZE_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5258 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5259 #ifdef _SC_STACK_PROT
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5260 {"SC_STACK_PROT", _SC_STACK_PROT},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5261 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5262 #ifdef _SC_STREAM_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5263 {"SC_STREAM_MAX", _SC_STREAM_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5264 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5265 #ifdef _SC_SYNCHRONIZED_IO
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5266 {"SC_SYNCHRONIZED_IO", _SC_SYNCHRONIZED_IO},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5267 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5268 #ifdef _SC_THREADS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5269 {"SC_THREADS", _SC_THREADS},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5270 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5271 #ifdef _SC_THREAD_ATTR_STACKADDR
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5272 {"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
5273 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5274 #ifdef _SC_THREAD_ATTR_STACKSIZE
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5275 {"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
5276 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5277 #ifdef _SC_THREAD_DESTRUCTOR_ITERATIONS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5278 {"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
5279 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5280 #ifdef _SC_THREAD_KEYS_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5281 {"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
5282 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5283 #ifdef _SC_THREAD_PRIORITY_SCHEDULING
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5284 {"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
5285 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5286 #ifdef _SC_THREAD_PRIO_INHERIT
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5287 {"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
5288 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5289 #ifdef _SC_THREAD_PRIO_PROTECT
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5290 {"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
5291 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5292 #ifdef _SC_THREAD_PROCESS_SHARED
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5293 {"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
5294 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5295 #ifdef _SC_THREAD_SAFE_FUNCTIONS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5296 {"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
5297 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5298 #ifdef _SC_THREAD_STACK_MIN
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5299 {"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
5300 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5301 #ifdef _SC_THREAD_THREADS_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5302 {"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
5303 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5304 #ifdef _SC_TIMERS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5305 {"SC_TIMERS", _SC_TIMERS},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5306 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5307 #ifdef _SC_TIMER_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5308 {"SC_TIMER_MAX", _SC_TIMER_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5309 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5310 #ifdef _SC_TTY_NAME_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5311 {"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
5312 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5313 #ifdef _SC_TZNAME_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5314 {"SC_TZNAME_MAX", _SC_TZNAME_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5315 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5316 #ifdef _SC_T_IOV_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5317 {"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
5318 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5319 #ifdef _SC_UCHAR_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5320 {"SC_UCHAR_MAX", _SC_UCHAR_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5321 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5322 #ifdef _SC_UINT_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5323 {"SC_UINT_MAX", _SC_UINT_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5324 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5325 #ifdef _SC_UIO_MAXIOV
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5326 {"SC_UIO_MAXIOV", _SC_UIO_MAXIOV},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5327 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5328 #ifdef _SC_ULONG_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5329 {"SC_ULONG_MAX", _SC_ULONG_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5330 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5331 #ifdef _SC_USHRT_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5332 {"SC_USHRT_MAX", _SC_USHRT_MAX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5333 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5334 #ifdef _SC_VERSION
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5335 {"SC_VERSION", _SC_VERSION},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5336 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5337 #ifdef _SC_WORD_BIT
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5338 {"SC_WORD_BIT", _SC_WORD_BIT},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5339 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5340 #ifdef _SC_XBS5_ILP32_OFF32
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5341 {"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
5342 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5343 #ifdef _SC_XBS5_ILP32_OFFBIG
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5344 {"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
5345 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5346 #ifdef _SC_XBS5_LP64_OFF64
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5347 {"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
5348 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5349 #ifdef _SC_XBS5_LPBIG_OFFBIG
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5350 {"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
5351 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5352 #ifdef _SC_XOPEN_CRYPT
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5353 {"SC_XOPEN_CRYPT", _SC_XOPEN_CRYPT},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5354 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5355 #ifdef _SC_XOPEN_ENH_I18N
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5356 {"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
5357 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5358 #ifdef _SC_XOPEN_LEGACY
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5359 {"SC_XOPEN_LEGACY", _SC_XOPEN_LEGACY},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5360 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5361 #ifdef _SC_XOPEN_REALTIME
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5362 {"SC_XOPEN_REALTIME", _SC_XOPEN_REALTIME},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5363 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5364 #ifdef _SC_XOPEN_REALTIME_THREADS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5365 {"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
5366 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5367 #ifdef _SC_XOPEN_SHM
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5368 {"SC_XOPEN_SHM", _SC_XOPEN_SHM},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5369 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5370 #ifdef _SC_XOPEN_UNIX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5371 {"SC_XOPEN_UNIX", _SC_XOPEN_UNIX},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5372 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5373 #ifdef _SC_XOPEN_VERSION
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5374 {"SC_XOPEN_VERSION", _SC_XOPEN_VERSION},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5375 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5376 #ifdef _SC_XOPEN_XCU_VERSION
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5377 {"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
5378 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5379 #ifdef _SC_XOPEN_XPG2
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5380 {"SC_XOPEN_XPG2", _SC_XOPEN_XPG2},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5381 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5382 #ifdef _SC_XOPEN_XPG3
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5383 {"SC_XOPEN_XPG3", _SC_XOPEN_XPG3},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5384 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5385 #ifdef _SC_XOPEN_XPG4
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5386 {"SC_XOPEN_XPG4", _SC_XOPEN_XPG4},
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5387 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5388 };
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5389
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5390 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
5391 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
5392 {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5393 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
5394 sizeof(posix_constants_sysconf)
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5395 / sizeof(struct constdef));
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5396 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5397
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5398 static char posix_sysconf__doc__[] = "\
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5399 sysconf(name) -> integer\n\
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5400 Return an integer-valued system configuration variable.";
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5401
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5402 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
5403 posix_sysconf(PyObject *self, PyObject *args)
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5404 {
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5405 PyObject *result = NULL;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5406 int name;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5407
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5408 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
5409 int value;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5410
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5411 errno = 0;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5412 value = sysconf(name);
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5413 if (value == -1 && errno != 0)
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5414 posix_error();
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5415 else
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5416 result = PyInt_FromLong(value);
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5417 }
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5418 return result;
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5419 }
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
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5422
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
5423 /* 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
5424 * 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
5425 * 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
5426 * 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
5427 *
57c1685acb16 Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents: 11574
diff changeset
5428 * 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
5429 * 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
5430 * 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
5431 */
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
5432
57c1685acb16 Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents: 11574
diff changeset
5433 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
5434 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
5435 {
57c1685acb16 Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents: 11574
diff changeset
5436 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
5437 (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
5438 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
5439 (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
5440
57c1685acb16 Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents: 11574
diff changeset
5441 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
5442 }
57c1685acb16 Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents: 11574
diff changeset
5443
57c1685acb16 Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents: 11574
diff changeset
5444 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
5445 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
5446 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
5447 {
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
5448 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
5449 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
5450 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
5451
57c1685acb16 Rip out the code to check the ordering of the tables used to map
Fred Drake <fdrake@acm.org>
parents: 11574
diff changeset
5452 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
5453 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
5454 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
5455 return -1;
a0498b15244c setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents: 12150
diff changeset
5456
a0498b15244c setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents: 12150
diff changeset
5457 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
5458 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
5459 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
5460 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
5461 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
5462 return -1;
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5463 }
12393
a0498b15244c setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents: 12150
diff changeset
5464 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
5465 }
12393
a0498b15244c setup_confname_table(): Close memory leak caused by not decref'ing the
Barry Warsaw <barry@python.org>
parents: 12150
diff changeset
5466 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
5467 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
5468 return status;
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5469 }
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5470
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
5471 /* 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
5472 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
5473 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
5474 {
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5475 #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
5476 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
5477 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
5478 / 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
5479 "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
5480 return -1;
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5481 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5482 #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
5483 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
5484 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
5485 / 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
5486 "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
5487 return -1;
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5488 #endif
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5489 #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
5490 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
5491 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
5492 / 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
5493 "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
5494 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
5495 #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
5496 return 0;
11574
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5497 }
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5498
fd0d31c346b2 Added table entries for Irix 6.5 names for confstr()/sysconf()/
Fred Drake <fdrake@acm.org>
parents: 11570
diff changeset
5499
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5500 static char posix_abort__doc__[] = "\
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5501 abort() -> does not return!\n\
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5502 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
5503 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
5504
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5505 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
5506 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
5507 {
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5508 if (!PyArg_ParseTuple(args, ":abort"))
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5509 return NULL;
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5510 abort();
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5511 /*NOTREACHED*/
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5512 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
5513 return NULL;
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5514 }
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
5515
14752
46a6990769d1 Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents: 14586
diff changeset
5516 #ifdef MS_WIN32
46a6990769d1 Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents: 14586
diff changeset
5517 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
5518 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
5519 \n\
46a6990769d1 Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents: 14586
diff changeset
5520 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
5521 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
5522 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
5523 \n\
46a6990769d1 Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents: 14586
diff changeset
5524 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
5525 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
5526 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
5527 \n\
46a6990769d1 Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents: 14586
diff changeset
5528 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
5529 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
5530 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
5531
46a6990769d1 Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents: 14586
diff changeset
5532 static PyObject *
46a6990769d1 Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents: 14586
diff changeset
5533 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
5534 {
46a6990769d1 Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents: 14586
diff changeset
5535 char *filepath;
46a6990769d1 Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents: 14586
diff changeset
5536 HINSTANCE rc;
46a6990769d1 Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents: 14586
diff changeset
5537 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
5538 return NULL;
46a6990769d1 Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents: 14586
diff changeset
5539 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
5540 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
5541 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
5542 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
5543 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
5544 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
5545 return Py_None;
46a6990769d1 Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents: 14586
diff changeset
5546 }
46a6990769d1 Implemented new os.startfile function, unique to Windows, exposing a
Tim Peters <tim.peters@gmail.com>
parents: 14586
diff changeset
5547 #endif
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5548
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5549 static PyMethodDef posix_methods[] = {
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5550 {"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
5551 #ifdef HAVE_TTYNAME
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5552 {"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
5553 #endif
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5554 {"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
5555 {"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
5556 #ifdef HAVE_CHOWN
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5557 {"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
5558 #endif /* HAVE_CHOWN */
20264
d092abcf9c4b Add chroot call. Implements feature #459267.
Martin v. Löwis <martin@v.loewis.de>
parents: 19754
diff changeset
5559 #ifdef HAVE_CHROOT
d092abcf9c4b Add chroot call. Implements feature #459267.
Martin v. Löwis <martin@v.loewis.de>
parents: 19754
diff changeset
5560 {"chroot", posix_chroot, METH_VARARGS, posix_chroot__doc__},
d092abcf9c4b Add chroot call. Implements feature #459267.
Martin v. Löwis <martin@v.loewis.de>
parents: 19754
diff changeset
5561 #endif
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5562 #ifdef HAVE_CTERMID
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5563 {"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
5564 #endif
2740
3e370a4b103b sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents: 2615
diff changeset
5565 #ifdef HAVE_GETCWD
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5566 {"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
5567 #endif
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
5568 #ifdef HAVE_LINK
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5569 {"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
5570 #endif /* HAVE_LINK */
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5571 {"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
5572 {"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
5573 {"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
5574 #ifdef HAVE_NICE
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5575 {"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
5576 #endif /* HAVE_NICE */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
5577 #ifdef HAVE_READLINK
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5578 {"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
5579 #endif /* HAVE_READLINK */
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5580 {"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
5581 {"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
5582 {"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
5583 #ifdef HAVE_SYMLINK
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5584 {"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
5585 #endif /* HAVE_SYMLINK */
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
5586 #ifdef HAVE_SYSTEM
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5587 {"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
5588 #endif
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5589 {"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
5590 #ifdef HAVE_UNAME
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5591 {"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
5592 #endif /* HAVE_UNAME */
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5593 {"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
5594 {"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
5595 {"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
5596 #ifdef HAVE_TIMES
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5597 {"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
5598 #endif /* HAVE_TIMES */
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5599 {"_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
5600 #ifdef HAVE_EXECV
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5601 {"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
5602 {"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
5603 #endif /* HAVE_EXECV */
9954
c404a6b0cdb1 Add spawnv and spawnve functions for Win32 platforms.
Guido van Rossum <guido@python.org>
parents: 9939
diff changeset
5604 #ifdef HAVE_SPAWNV
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5605 {"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
5606 {"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
5607 #endif /* HAVE_SPAWNV */
17419
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
5608 #ifdef HAVE_FORK1
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
5609 {"fork1", posix_fork1, METH_VARARGS, posix_fork1__doc__},
3fadc37cfa92 Unixware 7 support by Billy G. Allie (SF patch 413011)
Guido van Rossum <guido@python.org>
parents: 16792
diff changeset
5610 #endif /* HAVE_FORK1 */
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
5611 #ifdef HAVE_FORK
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5612 {"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
5613 #endif /* HAVE_FORK */
13601
ef8b20b9f6f5 Move (actually copy) support for the sgi._getpty() function into
Thomas Wouters <thomas@python.org>
parents: 13582
diff changeset
5614 #if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY)
13058
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
5615 {"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
5616 #endif /* HAVE_OPENPTY || HAVE__GETPTY */
13058
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
5617 #ifdef HAVE_FORKPTY
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
5618 {"forkpty", posix_forkpty, METH_VARARGS, posix_forkpty__doc__},
53f4022c0cd5 Thomas Wouters <thomas@xs4all.net>:
Fred Drake <fdrake@acm.org>
parents: 12865
diff changeset
5619 #endif /* HAVE_FORKPTY */
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
5620 #ifdef HAVE_GETEGID
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5621 {"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
5622 #endif /* HAVE_GETEGID */
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
5623 #ifdef HAVE_GETEUID
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5624 {"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
5625 #endif /* HAVE_GETEUID */
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
5626 #ifdef HAVE_GETGID
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5627 {"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
5628 #endif /* HAVE_GETGID */
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5629 #ifdef HAVE_GETGROUPS
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5630 {"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
5631 #endif
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5632 {"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
5633 #ifdef HAVE_GETPGRP
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5634 {"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
5635 #endif /* HAVE_GETPGRP */
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
5636 #ifdef HAVE_GETPPID
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5637 {"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
5638 #endif /* HAVE_GETPPID */
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
5639 #ifdef HAVE_GETUID
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5640 {"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
5641 #endif /* HAVE_GETUID */
11570
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
5642 #ifdef HAVE_GETLOGIN
885820fa7e31 Added support for getlogin(); does *not* use getlogin_r() where
Fred Drake <fdrake@acm.org>
parents: 11560
diff changeset
5643 {"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
5644 #endif
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
5645 #ifdef HAVE_KILL
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5646 {"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
5647 #endif /* HAVE_KILL */
3735
4692cb46008e Added plock() system call.
Guido van Rossum <guido@python.org>
parents: 3702
diff changeset
5648 #ifdef HAVE_PLOCK
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5649 {"plock", posix_plock, METH_VARARGS, posix_plock__doc__},
3735
4692cb46008e Added plock() system call.
Guido van Rossum <guido@python.org>
parents: 3702
diff changeset
5650 #endif /* HAVE_PLOCK */
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
5651 #ifdef HAVE_POPEN
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5652 {"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
5653 #ifdef MS_WIN32
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
5654 {"popen2", win32_popen2, METH_VARARGS},
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
5655 {"popen3", win32_popen3, METH_VARARGS},
b907ebf3b052 - improved os.popen support for windows, based on win32pipe
Fredrik Lundh <fredrik@pythonware.com>
parents: 13462
diff changeset
5656 {"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
5657 {"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
5658 #endif
3601
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
5659 #endif /* HAVE_POPEN */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
5660 #ifdef HAVE_SETUID
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5661 {"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
5662 #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
5663 #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
5664 {"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
5665 #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
5666 #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
5667 {"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
5668 #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
5669 #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
5670 {"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
5671 #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
5672 #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
5673 {"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
5674 #endif /* HAVE_SETREGID */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
5675 #ifdef HAVE_SETGID
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5676 {"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
5677 #endif /* HAVE_SETGID */
20508
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
5678 #ifdef HAVE_SETGROUPS
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
5679 {"setgroups", posix_setgroups, METH_VARARGS, posix_setgroups__doc__},
8e0c31849c64 Expose setgroups. Fixes feature request #468116.
Martin v. Löwis <martin@v.loewis.de>
parents: 20264
diff changeset
5680 #endif /* HAVE_SETGROUPS */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
5681 #ifdef HAVE_SETPGRP
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5682 {"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
5683 #endif /* HAVE_SETPGRP */
2456
bc03225a4493 changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents: 2370
diff changeset
5684 #ifdef HAVE_WAIT
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5685 {"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
5686 #endif /* HAVE_WAIT */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
5687 #ifdef HAVE_WAITPID
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5688 {"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
5689 #endif /* HAVE_WAITPID */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
5690 #ifdef HAVE_SETSID
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5691 {"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
5692 #endif /* HAVE_SETSID */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
5693 #ifdef HAVE_SETPGID
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5694 {"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
5695 #endif /* HAVE_SETPGID */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
5696 #ifdef HAVE_TCGETPGRP
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5697 {"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
5698 #endif /* HAVE_TCGETPGRP */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
5699 #ifdef HAVE_TCSETPGRP
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5700 {"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
5701 #endif /* HAVE_TCSETPGRP */
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5702 {"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
5703 {"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
5704 {"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
5705 {"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
5706 {"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
5707 {"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
5708 {"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
5709 {"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
5710 {"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
5711 {"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
5712 #ifdef HAVE_PIPE
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5713 {"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
5714 #endif
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
5715 #ifdef HAVE_MKFIFO
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5716 {"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
5717 #endif
5a7a76166e7e Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents: 3418
diff changeset
5718 #ifdef HAVE_FTRUNCATE
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5719 {"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
5720 #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
5721 #ifdef HAVE_PUTENV
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5722 {"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
5723 #endif
20551
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
5724 #ifdef HAVE_UNSETENV
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
5725 {"unsetenv", posix_unsetenv, METH_VARARGS, posix_unsetenv__doc__},
c9608c790f6f SF patch #460805 by Chris Gonnerman: Support for unsetenv()
Guido van Rossum <guido@python.org>
parents: 20548
diff changeset
5726 #endif
6315
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
5727 #ifdef HAVE_STRERROR
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5728 {"strerror", posix_strerror, METH_VARARGS, posix_strerror__doc__},
6315
d25489c5a22f Add strerror() interface.
Guido van Rossum <guido@python.org>
parents: 6130
diff changeset
5729 #endif
9822
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
5730 #ifdef HAVE_FSYNC
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5731 {"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
5732 #endif
17e4d81949b9 Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
Guido van Rossum <guido@python.org>
parents: 9795
diff changeset
5733 #ifdef HAVE_FDATASYNC
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5734 {"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
5735 #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
5736 #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
5737 #ifdef WIFSTOPPED
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5738 {"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
5739 #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
5740 #ifdef WIFSIGNALED
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5741 {"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
5742 #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
5743 #ifdef WIFEXITED
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5744 {"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
5745 #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
5746 #ifdef WEXITSTATUS
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5747 {"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
5748 #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
5749 #ifdef WTERMSIG
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5750 {"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
5751 #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
5752 #ifdef WSTOPSIG
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5753 {"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
5754 #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
5755 #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
5756 #ifdef HAVE_FSTATVFS
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5757 {"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
5758 #endif
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
5759 #ifdef HAVE_STATVFS
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5760 {"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
5761 #endif
15765
6d8f7e1242c0 Anonymous SF bug report #128053 point out that the #ifdef for
Guido van Rossum <guido@python.org>
parents: 15511
diff changeset
5762 #ifdef HAVE_TMPFILE
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5763 {"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
5764 #endif
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5765 #ifdef HAVE_TEMPNAM
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5766 {"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
5767 #endif
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5768 #ifdef HAVE_TMPNAM
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5769 {"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
5770 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5771 #ifdef HAVE_CONFSTR
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5772 {"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
5773 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5774 #ifdef HAVE_SYSCONF
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5775 {"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
5776 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5777 #ifdef HAVE_FPATHCONF
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5778 {"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
5779 #endif
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5780 #ifdef HAVE_PATHCONF
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5781 {"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
5782 #endif
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5783 {"abort", posix_abort, METH_VARARGS, posix_abort__doc__},
17817
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
5784 #ifdef MS_WIN32
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
5785 {"_getfullpathname", posix__getfullpathname, METH_VARARGS, NULL},
f7c385226f65 Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
Mark Hammond <mhammond@skippinet.com.au>
parents: 17518
diff changeset
5786 #endif
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5787 {NULL, NULL} /* Sentinel */
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5788 };
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5789
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5790
4789
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5791 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
5792 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
5793 {
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5794 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
5795 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
5796 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
5797
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5798 Py_DECREF(v);
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5799 return 0;
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5800 }
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5801
6766
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5802 #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
5803 /* 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
5804 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
5805 {
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5806 APIRET rc;
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5807 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
5808 PyObject *v;
21066
225c7dd17e37 Fixes for possible buffer overflows in sprintf() usages.
Marc-André Lemburg <mal@egenix.com>
parents: 21040
diff changeset
5809 char *ver, tmp[50];
6766
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5810
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5811 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
5812 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
5813 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
5814
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5815 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
5816 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
5817 return -1;
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5818 }
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5819
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5820 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
5821 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
5822 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
5823 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
5824 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
5825 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
5826 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
5827
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5828 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
5829 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
5830 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
5831 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
5832 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
5833 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
5834 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
5835 default:
21073
304b34023876 sprintf -> PyOS_snprintf in some "obviously safe" cases.
Tim Peters <tim.peters@gmail.com>
parents: 21066
diff changeset
5836 PyOS_snprintf(tmp, sizeof(tmp),
304b34023876 sprintf -> PyOS_snprintf in some "obviously safe" cases.
Tim Peters <tim.peters@gmail.com>
parents: 21066
diff changeset
5837 "%d-%d", values[QSV_VERSION_MAJOR],
304b34023876 sprintf -> PyOS_snprintf in some "obviously safe" cases.
Tim Peters <tim.peters@gmail.com>
parents: 21066
diff changeset
5838 values[QSV_VERSION_MINOR]);
6766
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5839 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
5840 }
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5841
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5842 /* 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
5843 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
5844 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
5845 return -1;
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5846 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
5847
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5848 /* 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
5849 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
5850 tmp[1] = ':';
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5851 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
5852
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5853 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
5854 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
5855 return -1;
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5856 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
5857
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5858 return 0;
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5859 }
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5860 #endif
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5861
4789
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5862 static int
13651
8a063423e0b7 Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents: 13642
diff changeset
5863 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
5864 {
9785
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
5865 #ifdef F_OK
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
5866 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
5867 #endif
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
5868 #ifdef R_OK
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
5869 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
5870 #endif
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
5871 #ifdef W_OK
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
5872 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
5873 #endif
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
5874 #ifdef X_OK
facb457b4d32 Changes for long file support by Steve Clift.
Guido van Rossum <guido@python.org>
parents: 9588
diff changeset
5875 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
5876 #endif
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5877 #ifdef NGROUPS_MAX
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5878 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
5879 #endif
11532
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5880 #ifdef TMP_MAX
2951e2d27852 Added support for abort(), ctermid(), tmpfile(), tempnam(), tmpnam(),
Fred Drake <fdrake@acm.org>
parents: 11391
diff changeset
5881 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
5882 #endif
4789
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5883 #ifdef WNOHANG
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5884 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
5885 #endif
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5886 #ifdef O_RDONLY
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5887 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
5888 #endif
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5889 #ifdef O_WRONLY
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5890 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
5891 #endif
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5892 #ifdef O_RDWR
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5893 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
5894 #endif
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5895 #ifdef O_NDELAY
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5896 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
5897 #endif
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5898 #ifdef O_NONBLOCK
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5899 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
5900 #endif
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5901 #ifdef O_APPEND
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5902 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
5903 #endif
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5904 #ifdef O_DSYNC
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5905 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
5906 #endif
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5907 #ifdef O_RSYNC
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5908 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
5909 #endif
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5910 #ifdef O_SYNC
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5911 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
5912 #endif
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5913 #ifdef O_NOCTTY
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5914 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
5915 #endif
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5916 #ifdef O_CREAT
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5917 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
5918 #endif
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5919 #ifdef O_EXCL
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5920 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
5921 #endif
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5922 #ifdef O_TRUNC
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5923 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
5924 #endif
5967
9e4ddb459b10 Added O_BINARY and O_TEXT (for Windows).
Guido van Rossum <guido@python.org>
parents: 5725
diff changeset
5925 #ifdef O_BINARY
9e4ddb459b10 Added O_BINARY and O_TEXT (for Windows).
Guido van Rossum <guido@python.org>
parents: 5725
diff changeset
5926 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
5927 #endif
9e4ddb459b10 Added O_BINARY and O_TEXT (for Windows).
Guido van Rossum <guido@python.org>
parents: 5725
diff changeset
5928 #ifdef O_TEXT
9e4ddb459b10 Added O_BINARY and O_TEXT (for Windows).
Guido van Rossum <guido@python.org>
parents: 5725
diff changeset
5929 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
5930 #endif
20548
a56427e5c5e1 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
Martin v. Löwis <martin@v.loewis.de>
parents: 20543
diff changeset
5931 #ifdef O_LARGEFILE
a56427e5c5e1 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
Martin v. Löwis <martin@v.loewis.de>
parents: 20543
diff changeset
5932 if (ins(d, "O_LARGEFILE", (long)O_LARGEFILE)) return -1;
a56427e5c5e1 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
Martin v. Löwis <martin@v.loewis.de>
parents: 20543
diff changeset
5933 #endif
a56427e5c5e1 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
Martin v. Löwis <martin@v.loewis.de>
parents: 20543
diff changeset
5934
a56427e5c5e1 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
Martin v. Löwis <martin@v.loewis.de>
parents: 20543
diff changeset
5935 /* GNU extensions. */
a56427e5c5e1 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
Martin v. Löwis <martin@v.loewis.de>
parents: 20543
diff changeset
5936 #ifdef O_DIRECT
a56427e5c5e1 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
Martin v. Löwis <martin@v.loewis.de>
parents: 20543
diff changeset
5937 /* Direct disk access. */
a56427e5c5e1 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
Martin v. Löwis <martin@v.loewis.de>
parents: 20543
diff changeset
5938 if (ins(d, "O_DIRECT", (long)O_DIRECT)) return -1;
a56427e5c5e1 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
Martin v. Löwis <martin@v.loewis.de>
parents: 20543
diff changeset
5939 #endif
a56427e5c5e1 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
Martin v. Löwis <martin@v.loewis.de>
parents: 20543
diff changeset
5940 #ifdef O_DIRECTORY
a56427e5c5e1 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
Martin v. Löwis <martin@v.loewis.de>
parents: 20543
diff changeset
5941 /* Must be a directory. */
a56427e5c5e1 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
Martin v. Löwis <martin@v.loewis.de>
parents: 20543
diff changeset
5942 if (ins(d, "O_DIRECTORY", (long)O_DIRECTORY)) return -1;
a56427e5c5e1 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
Martin v. Löwis <martin@v.loewis.de>
parents: 20543
diff changeset
5943 #endif
a56427e5c5e1 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
Martin v. Löwis <martin@v.loewis.de>
parents: 20543
diff changeset
5944 #ifdef O_NOFOLLOW
a56427e5c5e1 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
Martin v. Löwis <martin@v.loewis.de>
parents: 20543
diff changeset
5945 /* Do not follow links. */
a56427e5c5e1 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
Martin v. Löwis <martin@v.loewis.de>
parents: 20543
diff changeset
5946 if (ins(d, "O_NOFOLLOW", (long)O_NOFOLLOW)) return -1;
a56427e5c5e1 Expose O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
Martin v. Löwis <martin@v.loewis.de>
parents: 20543
diff changeset
5947 #endif
6766
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5948
10069
5e01645ee41b Add _P_WAIT etc. for NT.
Guido van Rossum <guido@python.org>
parents: 10066
diff changeset
5949 #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
5950 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
5951 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
5952 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
5953 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
5954 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
5955 #endif
5e01645ee41b Add _P_WAIT etc. for NT.
Guido van Rossum <guido@python.org>
parents: 10066
diff changeset
5956
6766
89092ad1e660 Another large batch of patches from Jeff Rush for OS/2.
Guido van Rossum <guido@python.org>
parents: 6717
diff changeset
5957 #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
5958 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
5959 #endif
4789
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5960 return 0;
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5961 }
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5962
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5963
17831
5c06a9596fbf SF patch #418147 Fixes to allow compiling w/ Borland, from Stephen Hansen.
Tim Peters <tim.peters@gmail.com>
parents: 17822
diff changeset
5964 #if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__)) && !defined(__QNX__)
6367
2c29b8982643 Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents: 6315
diff changeset
5965 #define INITFUNC initnt
2c29b8982643 Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents: 6315
diff changeset
5966 #define MODNAME "nt"
17831
5c06a9596fbf SF patch #418147 Fixes to allow compiling w/ Borland, from Stephen Hansen.
Tim Peters <tim.peters@gmail.com>
parents: 17822
diff changeset
5967
5c06a9596fbf SF patch #418147 Fixes to allow compiling w/ Borland, from Stephen Hansen.
Tim Peters <tim.peters@gmail.com>
parents: 17822
diff changeset
5968 #elif defined(PYOS_OS2)
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
5969 #define INITFUNC initos2
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
5970 #define MODNAME "os2"
17831
5c06a9596fbf SF patch #418147 Fixes to allow compiling w/ Borland, from Stephen Hansen.
Tim Peters <tim.peters@gmail.com>
parents: 17822
diff changeset
5971
6626
5e31d381fa47 os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents: 6578
diff changeset
5972 #else
6367
2c29b8982643 Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents: 6315
diff changeset
5973 #define INITFUNC initposix
2c29b8982643 Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents: 6315
diff changeset
5974 #define MODNAME "posix"
2c29b8982643 Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents: 6315
diff changeset
5975 #endif
4789
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5976
9588
38023a425e48 Add DL_EXPORT() to all modules that could possibly be used
Guido van Rossum <guido@python.org>
parents: 9307
diff changeset
5977 DL_EXPORT(void)
13651
8a063423e0b7 Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents: 13642
diff changeset
5978 INITFUNC(void)
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
5979 {
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
5980 PyObject *m, *d, *v;
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
5981
6367
2c29b8982643 Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents: 6315
diff changeset
5982 m = Py_InitModule4(MODNAME,
5699
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
5983 posix_methods,
76fd5281f98a Added doc strings (Neil Schemenauer).
Guido van Rossum <guido@python.org>
parents: 5584
diff changeset
5984 posix__doc__,
6367
2c29b8982643 Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents: 6315
diff changeset
5985 (PyObject *)NULL,
2c29b8982643 Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents: 6315
diff changeset
5986 PYTHON_API_VERSION);
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
5987 d = PyModule_GetDict(m);
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
5988
6367
2c29b8982643 Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents: 6315
diff changeset
5989 /* Initialize environ dictionary */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
5990 v = convertenviron();
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
5991 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
5992 return;
4672
5b53268f547a Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
5993 Py_DECREF(v);
11559
22f4cf16b5a3 Added bindings for getgroups(), fpathconf(), pathconf(), confstr(),
Fred Drake <fdrake@acm.org>
parents: 11532
diff changeset
5994
4789
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5995 if (all_ins(d))
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5996 return;
d45ba64b82fd 1. Export open(2) flag constants for every defined constant
Barry Warsaw <barry@python.org>
parents: 4785
diff changeset
5997
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
5998 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
5999 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
6000
10133
5718e83020ae Got rid of the file-global PosixError. This was redundant since it
Barry Warsaw <barry@python.org>
parents: 10092
diff changeset
6001 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
6002
11686
93bed60355e4 The initialization of posix_putenv_garbage should only be done when it
Guido van Rossum <guido@python.org>
parents: 11639
diff changeset
6003 #ifdef HAVE_PUTENV
15904
149458a5740a Plug memory leak.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 15765
diff changeset
6004 if (posix_putenv_garbage == NULL)
149458a5740a Plug memory leak.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 15765
diff changeset
6005 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
6006 #endif
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
6007
21313
91dd223829c6 Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents: 21295
diff changeset
6008 stat_result_desc.name = MODNAME ".stat_result";
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
6009 PyStructSequence_InitType(&StatResultType, &stat_result_desc);
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
6010 PyDict_SetItemString(d, "stat_result", (PyObject*) &StatResultType);
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
6011
21313
91dd223829c6 Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents: 21295
diff changeset
6012 statvfs_result_desc.name = MODNAME ".statvfs_result";
20539
2d599a36b67a SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents: 20537
diff changeset
6013 PyStructSequence_InitType(&StatVFSResultType, &statvfs_result_desc);
21579
ac4b1c4c3b12 Backport gvanrossum's checkin of version 2.217:
Michael W. Hudson <mwh@python.net>
parents: 21489
diff changeset
6014 PyDict_SetItemString(d, "statvfs_result", (PyObject*) &StatVFSResultType);
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1441
diff changeset
6015 }