Mercurial > cpython-lru_cache-weakref
annotate Modules/posixmodule.c @ 4566:6403c94de50d legacy-trunk
Added safeguard against failure in __del__.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 27 Nov 1996 19:39:58 +0000 |
| parents | 65d2d8e67da3 |
| children | d36250aefb82 |
| rev | line source |
|---|---|
|
145
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
117
diff
changeset
|
1 /*********************************************************** |
|
2061
172ba04a5191
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
2055
diff
changeset
|
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
|
172ba04a5191
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
2055
diff
changeset
|
3 The Netherlands. |
|
145
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
117
diff
changeset
|
4 |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
117
diff
changeset
|
5 All Rights Reserved |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
117
diff
changeset
|
6 |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
145
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
117
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
145
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
117
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
12 Centrum or CWI or Corporation for National Research Initiatives or |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
13 CNRI not be used in advertising or publicity pertaining to |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
14 distribution of the software without specific, written prior |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
15 permission. |
|
145
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
117
diff
changeset
|
16 |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
17 While CWI is the initial source for this software, a modified version |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
18 is made available by the Corporation for National Research Initiatives |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
19 (CNRI) at the Internet address ftp://ftp.python.org. |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
20 |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4233
diff
changeset
|
28 PERFORMANCE OF THIS SOFTWARE. |
|
145
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
117
diff
changeset
|
29 |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
117
diff
changeset
|
30 ******************************************************************/ |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
117
diff
changeset
|
31 |
| 6 | 32 /* POSIX module implementation */ |
| 33 | |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
34 /* 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
|
35 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
|
36 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
|
37 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
|
38 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
|
39 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
|
40 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
41 /* See also ../Dos/dosmodule.c */ |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
42 |
| 86 | 43 #include "allobjects.h" |
| 6 | 44 #include "modsupport.h" |
| 926 | 45 #include "ceval.h" |
| 6 | 46 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
47 #include <string.h> |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
48 #include <errno.h> |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
49 #include <sys/types.h> |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
50 #include <sys/stat.h> |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
51 #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
|
52 #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
|
53 #endif |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
54 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
55 #include "mytime.h" /* For clock_t on some systems */ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
56 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
57 #ifdef HAVE_FCNTL_H |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
58 #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
|
59 #endif /* HAVE_FCNTL_H */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
60 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
61 /* Various compilers have only certain posix functions */ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
62 #ifdef __WATCOMC__ /* Watcom compiler */ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
63 #define HAVE_GETCWD 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
64 #define HAVE_OPENDIR 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
65 #define HAVE_SYSTEM 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
66 #if defined(__OS2__) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
67 #define HAVE_EXECV 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
68 #define HAVE_WAIT 1 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
69 #endif |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
70 #include <process.h> |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
71 #else |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
72 #ifdef __BORLANDC__ /* Borland compiler */ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
73 #define HAVE_EXECV 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
74 #define HAVE_GETCWD 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
75 #define HAVE_GETEGID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
76 #define HAVE_GETEUID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
77 #define HAVE_GETGID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
78 #define HAVE_GETPPID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
79 #define HAVE_GETUID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
80 #define HAVE_KILL 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
81 #define HAVE_OPENDIR 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
82 #define HAVE_PIPE 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
83 #define HAVE_POPEN 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
84 #define HAVE_SYSTEM 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
85 #define HAVE_WAIT 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
86 #else |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
87 #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
|
88 #define HAVE_GETCWD 1 |
|
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
89 #ifdef MS_WIN32 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
90 #define HAVE_EXECV 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
91 #define HAVE_PIPE 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
92 #define HAVE_POPEN 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
93 #define HAVE_SYSTEM 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
94 #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
|
95 #endif /* !MS_WIN32 */ |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
96 #else /* all other compilers */ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
97 /* 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
|
98 #define HAVE_EXECV 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
99 #define HAVE_FORK 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
100 #define HAVE_GETCWD 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
101 #define HAVE_GETEGID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
102 #define HAVE_GETEUID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
103 #define HAVE_GETGID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
104 #define HAVE_GETPPID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
105 #define HAVE_GETUID 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
106 #define HAVE_KILL 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
107 #define HAVE_OPENDIR 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
108 #define HAVE_PIPE 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
109 #define HAVE_POPEN 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
110 #define HAVE_SYSTEM 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
111 #define HAVE_WAIT 1 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
112 #endif /* _MSC_VER */ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
113 #endif /* __BORLANDC__ */ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
114 #endif /* ! __WATCOMC__ */ |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
115 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
116 #ifndef _MSC_VER |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
117 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
118 #ifdef HAVE_UNISTD_H |
|
1191
38f0054f44a7
Added separate main program for the Mac: macmain.c
Guido van Rossum <guido@python.org>
parents:
1181
diff
changeset
|
119 #include <unistd.h> |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
120 #endif |
|
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
121 |
|
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
122 #ifdef NeXT |
|
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
123 /* 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
|
124 #undef HAVE_UNISTD_H |
|
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
125 #undef HAVE_UTIME_H |
|
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
126 /* #undef HAVE_GETCWD */ |
|
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 |
|
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
129 #ifdef HAVE_UNISTD_H |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
130 /* XXX These are for SunOS4.1.3 but shouldn't hurt elsewhere */ |
|
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
131 extern int rename(); |
|
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
132 extern int pclose(); |
|
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
133 extern int lstat(); |
|
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
134 extern int symlink(); |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
135 #else /* !HAVE_UNISTD_H */ |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
136 #if defined(__WATCOMC__) || defined(_MSC_VER) |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
137 extern int mkdir PROTO((const char *)); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
138 #else |
|
1322
f3c907efe5d7
* config.c: different default PYTHONPATH for MS-DOS
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
139 extern int mkdir PROTO((const char *, mode_t)); |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
140 #endif |
|
1322
f3c907efe5d7
* config.c: different default PYTHONPATH for MS-DOS
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
141 extern int chdir PROTO((const char *)); |
|
f3c907efe5d7
* config.c: different default PYTHONPATH for MS-DOS
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
142 extern int rmdir PROTO((const char *)); |
|
1177
533e36de1e4d
* Configure.py: use #!/usr/local/bin/python
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
143 extern int chmod PROTO((const char *, mode_t)); |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
144 extern int chown PROTO((const char *, uid_t, gid_t)); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
145 extern char *getcwd PROTO((char *, int)); |
|
1322
f3c907efe5d7
* config.c: different default PYTHONPATH for MS-DOS
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
146 extern char *strerror PROTO((int)); |
|
1177
533e36de1e4d
* Configure.py: use #!/usr/local/bin/python
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
147 extern int link PROTO((const char *, const char *)); |
|
533e36de1e4d
* Configure.py: use #!/usr/local/bin/python
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
148 extern int rename PROTO((const char *, const char *)); |
|
533e36de1e4d
* Configure.py: use #!/usr/local/bin/python
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
149 extern int stat PROTO((const char *, struct stat *)); |
|
533e36de1e4d
* Configure.py: use #!/usr/local/bin/python
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
150 extern int unlink PROTO((const char *)); |
|
533e36de1e4d
* Configure.py: use #!/usr/local/bin/python
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
151 extern int pclose PROTO((FILE *)); |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
152 #ifdef HAVE_SYMLINK |
|
1177
533e36de1e4d
* Configure.py: use #!/usr/local/bin/python
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
153 extern int symlink PROTO((const char *, const char *)); |
|
2370
e386035f897d
fix comment opener after #endif
Guido van Rossum <guido@python.org>
parents:
2298
diff
changeset
|
154 #endif /* HAVE_SYMLINK */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
155 #ifdef HAVE_LSTAT |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
156 extern int lstat PROTO((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
|
157 #endif /* HAVE_LSTAT */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
158 #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
|
159 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
160 #endif /* !_MSC_VER */ |
| 6 | 161 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
162 #ifdef HAVE_UTIME_H |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
163 #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
|
164 #endif /* HAVE_UTIME_H */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
165 |
|
1915
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
166 #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
|
167 #include <sys/utime.h> |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
168 #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
|
169 #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
|
170 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
171 #ifdef HAVE_SYS_TIMES_H |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
172 #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
|
173 #endif /* HAVE_SYS_TIMES_H */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
174 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
175 #ifdef HAVE_SYS_PARAM_H |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
176 #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
|
177 #endif /* HAVE_SYS_PARAM_H */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
178 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
179 #ifdef HAVE_SYS_UTSNAME_H |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
180 #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
|
181 #endif /* HAVE_SYS_UTSNAME_H */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
182 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
183 #ifndef MAXPATHLEN |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
184 #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
|
185 #endif /* MAXPATHLEN */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
186 |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
187 #ifdef HAVE_DIRENT_H |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
188 #include <dirent.h> |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
189 #define NAMLEN(dirent) strlen((dirent)->d_name) |
|
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
190 #else |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
191 #ifdef __WATCOMC__ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
192 #include <direct.h> |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
193 #define NAMLEN(dirent) strlen((dirent)->d_name) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
194 #else |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
195 #define dirent direct |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
196 #define NAMLEN(dirent) (dirent)->d_namlen |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
197 #endif |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
198 #ifdef HAVE_SYS_NDIR_H |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
199 #include <sys/ndir.h> |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
200 #endif |
|
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
201 #ifdef HAVE_SYS_DIR_H |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
202 #include <sys/dir.h> |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
203 #endif |
|
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
204 #ifdef HAVE_NDIR_H |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
205 #include <ndir.h> |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
206 #endif |
|
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
207 #endif |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
208 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
209 #ifdef _MSC_VER |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
210 #include <direct.h> |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
211 #include <io.h> |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
212 #include <process.h> |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
213 #include <windows.h> |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
214 #ifdef MS_WIN32 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
215 #define popen _popen |
|
1815
6353fe25cdce
* Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents:
1792
diff
changeset
|
216 #define pclose _pclose |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
217 #else /* 16-bit Windows */ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
218 #include <dos.h> |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
219 #include <ctype.h> |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
220 #endif /* MS_WIN32 */ |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
221 #endif /* _MSC_VER */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
222 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
223 #ifdef OS2 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
224 #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
|
225 #endif /* OS2 */ |
| 6 | 226 |
| 227 /* Return a dictionary corresponding to the POSIX environment table */ | |
| 228 | |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
229 #if !defined(_MSC_VER) && !defined(__WATCOMC__) |
| 6 | 230 extern char **environ; |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
231 #endif /* !_MSC_VER */ |
| 6 | 232 |
| 233 static object * | |
| 234 convertenviron() | |
| 235 { | |
| 236 object *d; | |
| 237 char **e; | |
| 238 d = newdictobject(); | |
| 239 if (d == NULL) | |
| 240 return NULL; | |
| 241 if (environ == NULL) | |
| 242 return d; | |
| 243 /* XXX This part ignores errors */ | |
| 244 for (e = environ; *e != NULL; e++) { | |
| 245 object *v; | |
| 246 char *p = strchr(*e, '='); | |
| 247 if (p == NULL) | |
| 248 continue; | |
| 249 v = newstringobject(p+1); | |
| 250 if (v == NULL) | |
| 251 continue; | |
| 252 *p = '\0'; | |
| 253 (void) dictinsert(d, *e, v); | |
| 254 *p = '='; | |
| 255 DECREF(v); | |
| 256 } | |
| 257 return d; | |
| 258 } | |
| 259 | |
| 260 | |
| 261 static object *PosixError; /* Exception posix.error */ | |
| 262 | |
| 263 /* Set a POSIX-specific error from errno, and return NULL */ | |
| 264 | |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
265 static object * posix_error() |
|
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
266 { |
|
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
267 return err_errno(PosixError); |
| 6 | 268 } |
| 269 | |
| 270 | |
| 271 /* POSIX generic methods */ | |
| 272 | |
| 273 static object * | |
| 274 posix_1str(args, func) | |
| 275 object *args; | |
| 276 int (*func) FPROTO((const char *)); | |
| 277 { | |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
278 char *path1; |
| 926 | 279 int res; |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
280 if (!getargs(args, "s", &path1)) |
| 6 | 281 return NULL; |
| 926 | 282 BGN_SAVE |
| 283 res = (*func)(path1); | |
| 284 END_SAVE | |
| 285 if (res < 0) | |
| 6 | 286 return posix_error(); |
| 287 INCREF(None); | |
| 288 return None; | |
| 289 } | |
| 290 | |
| 291 static object * | |
| 292 posix_2str(args, func) | |
| 293 object *args; | |
| 294 int (*func) FPROTO((const char *, const char *)); | |
| 295 { | |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
296 char *path1, *path2; |
| 926 | 297 int res; |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1287
diff
changeset
|
298 if (!getargs(args, "(ss)", &path1, &path2)) |
| 6 | 299 return NULL; |
| 926 | 300 BGN_SAVE |
| 301 res = (*func)(path1, path2); | |
| 302 END_SAVE | |
| 303 if (res < 0) | |
| 6 | 304 return posix_error(); |
| 305 INCREF(None); | |
| 306 return None; | |
| 307 } | |
| 308 | |
| 309 static object * | |
| 310 posix_strint(args, func) | |
| 311 object *args; | |
| 312 int (*func) FPROTO((const char *, int)); | |
| 313 { | |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
314 char *path; |
| 6 | 315 int i; |
| 926 | 316 int res; |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1287
diff
changeset
|
317 if (!getargs(args, "(si)", &path, &i)) |
| 6 | 318 return NULL; |
| 926 | 319 BGN_SAVE |
| 320 res = (*func)(path, i); | |
| 321 END_SAVE | |
| 322 if (res < 0) | |
| 6 | 323 return posix_error(); |
| 324 INCREF(None); | |
| 325 return None; | |
| 326 } | |
| 327 | |
| 328 static object * | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
329 posix_strintint(args, func) |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
330 object *args; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
331 int (*func) FPROTO((const char *, int, int)); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
332 { |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
333 char *path; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
334 int i,i2; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
335 int res; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
336 if (!getargs(args, "(sii)", &path, &i, &i2)) |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
337 return NULL; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
338 BGN_SAVE |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
339 res = (*func)(path, i, i2); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
340 END_SAVE |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
341 if (res < 0) |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
342 return posix_error(); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
343 INCREF(None); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
344 return None; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
345 } |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
346 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
347 static object * |
| 6 | 348 posix_do_stat(self, args, statfunc) |
| 349 object *self; | |
| 350 object *args; | |
| 351 int (*statfunc) FPROTO((const char *, struct stat *)); | |
| 352 { | |
| 353 struct stat st; | |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
354 char *path; |
| 926 | 355 int res; |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
356 if (!getargs(args, "s", &path)) |
| 6 | 357 return NULL; |
| 926 | 358 BGN_SAVE |
| 359 res = (*statfunc)(path, &st); | |
| 360 END_SAVE | |
| 361 if (res != 0) | |
| 6 | 362 return posix_error(); |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
363 return mkvalue("(llllllllll)", |
|
1252
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
364 (long)st.st_mode, |
|
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
365 (long)st.st_ino, |
|
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
366 (long)st.st_dev, |
|
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
367 (long)st.st_nlink, |
|
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
368 (long)st.st_uid, |
|
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
369 (long)st.st_gid, |
|
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
370 (long)st.st_size, |
|
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
371 (long)st.st_atime, |
|
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
372 (long)st.st_mtime, |
|
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
373 (long)st.st_ctime); |
| 6 | 374 } |
| 375 | |
| 376 | |
| 377 /* POSIX methods */ | |
| 378 | |
| 379 static object * | |
| 380 posix_chdir(self, args) | |
| 381 object *self; | |
| 382 object *args; | |
| 383 { | |
| 384 return posix_1str(args, chdir); | |
| 385 } | |
| 386 | |
| 387 static object * | |
| 388 posix_chmod(self, args) | |
| 389 object *self; | |
| 390 object *args; | |
| 391 { | |
| 392 return posix_strint(args, chmod); | |
| 393 } | |
| 394 | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
395 #ifdef HAVE_CHOWN |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
396 static object * |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
397 posix_chown(self, args) |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
398 object *self; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
399 object *args; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
400 { |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
401 return posix_strintint(args, chown); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
402 } |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
403 #endif /* HAVE_CHOWN */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
404 |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
405 #ifdef HAVE_GETCWD |
| 6 | 406 static object * |
| 407 posix_getcwd(self, args) | |
| 408 object *self; | |
| 409 object *args; | |
| 410 { | |
| 411 char buf[1026]; | |
| 926 | 412 char *res; |
| 6 | 413 if (!getnoarg(args)) |
| 414 return NULL; | |
| 926 | 415 BGN_SAVE |
| 416 res = getcwd(buf, sizeof buf); | |
| 417 END_SAVE | |
| 418 if (res == NULL) | |
| 6 | 419 return posix_error(); |
| 420 return newstringobject(buf); | |
| 421 } | |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
422 #endif |
| 6 | 423 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
424 #ifdef HAVE_LINK |
| 6 | 425 static object * |
| 426 posix_link(self, args) | |
| 427 object *self; | |
| 428 object *args; | |
| 429 { | |
| 430 return posix_2str(args, link); | |
| 431 } | |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
432 #endif /* HAVE_LINK */ |
| 6 | 433 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
434 static object * |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
435 posix_listdir(self, args) |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
436 object *self; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
437 object *args; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
438 { |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
439 #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
|
440 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
441 char *name; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
442 int len; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
443 object *d, *v; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
444 HANDLE hFindFile; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
445 WIN32_FIND_DATA FileData; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
446 char namebuf[MAX_PATH+5]; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
447 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
448 if (!getargs(args, "s#", &name, &len)) |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
449 return NULL; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
450 if (len >= MAX_PATH) { |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
451 err_setstr(ValueError, "path too long"); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
452 return NULL; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
453 } |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
454 strcpy(namebuf, name); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
455 if (namebuf[len-1] != '/' && namebuf[len-1] != '\\') |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
456 namebuf[len++] = '/'; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
457 strcpy(namebuf + len, "*.*"); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
458 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
459 if ((d = newlistobject(0)) == NULL) |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
460 return NULL; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
461 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
462 hFindFile = FindFirstFile(namebuf, &FileData); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
463 if (hFindFile == INVALID_HANDLE_VALUE) { |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
464 errno = GetLastError(); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
465 return posix_error(); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
466 } |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
467 do { |
|
2845
051bacab59af
suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents:
2740
diff
changeset
|
468 if (FileData.cFileName[0] == '.' && |
|
051bacab59af
suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents:
2740
diff
changeset
|
469 (FileData.cFileName[1] == '\0' || |
|
051bacab59af
suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents:
2740
diff
changeset
|
470 FileData.cFileName[1] == '.' && |
|
051bacab59af
suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents:
2740
diff
changeset
|
471 FileData.cFileName[2] == '\0')) |
|
051bacab59af
suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents:
2740
diff
changeset
|
472 continue; |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
473 v = newstringobject(FileData.cFileName); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
474 if (v == NULL) { |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
475 DECREF(d); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
476 d = NULL; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
477 break; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
478 } |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
479 if (addlistitem(d, v) != 0) { |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
480 DECREF(v); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
481 DECREF(d); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
482 d = NULL; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
483 break; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
484 } |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
485 DECREF(v); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
486 } while (FindNextFile(hFindFile, &FileData) == TRUE); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
487 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
488 if (FindClose(hFindFile) == FALSE) { |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
489 errno = GetLastError(); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
490 return posix_error(); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
491 } |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
492 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
493 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
|
494 |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
495 #else /* !MS_WIN32 */ |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
496 #ifdef _MSC_VER /* 16-bit Windows */ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
497 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
498 #ifndef MAX_PATH |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
499 #define MAX_PATH 250 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
500 #endif |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
501 char *name, *pt; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
502 int len; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
503 object *d, *v; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
504 char namebuf[MAX_PATH+5]; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
505 struct _find_t ep; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
506 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
507 if (!getargs(args, "s#", &name, &len)) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
508 return NULL; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
509 if (len >= MAX_PATH) { |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
510 err_setstr(ValueError, "path too long"); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
511 return NULL; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
512 } |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
513 strcpy(namebuf, name); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
514 for (pt = namebuf; *pt; pt++) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
515 if (*pt == '/') |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
516 *pt = '\\'; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
517 if (namebuf[len-1] != '\\') |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
518 namebuf[len++] = '\\'; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
519 strcpy(namebuf + len, "*.*"); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
520 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
521 if ((d = newlistobject(0)) == NULL) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
522 return NULL; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
523 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
524 if (_dos_findfirst(namebuf, _A_RDONLY | |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
525 _A_HIDDEN | _A_SYSTEM | _A_SUBDIR, &ep) != 0){ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
526 errno = ENOENT; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
527 return posix_error(); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
528 } |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
529 do { |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
530 if (ep.name[0] == '.' && |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
531 (ep.name[1] == '\0' || |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
532 ep.name[1] == '.' && |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
533 ep.name[2] == '\0')) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
534 continue; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
535 strcpy(namebuf, ep.name); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
536 for (pt = namebuf; *pt; pt++) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
537 if (isupper(*pt)) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
538 *pt = tolower(*pt); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
539 v = newstringobject(namebuf); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
540 if (v == NULL) { |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
541 DECREF(d); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
542 d = NULL; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
543 break; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
544 } |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
545 if (addlistitem(d, v) != 0) { |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
546 DECREF(v); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
547 DECREF(d); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
548 d = NULL; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
549 break; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
550 } |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
551 DECREF(v); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
552 } while (_dos_findnext(&ep) == 0); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
553 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
554 return d; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
555 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
556 #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
|
557 |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
558 char *name; |
|
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
559 object *d, *v; |
| 6 | 560 DIR *dirp; |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
561 struct dirent *ep; |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
562 if (!getargs(args, "s", &name)) |
| 6 | 563 return NULL; |
| 926 | 564 BGN_SAVE |
| 565 if ((dirp = opendir(name)) == NULL) { | |
| 566 RET_SAVE | |
| 6 | 567 return posix_error(); |
| 926 | 568 } |
| 6 | 569 if ((d = newlistobject(0)) == NULL) { |
| 570 closedir(dirp); | |
| 926 | 571 RET_SAVE |
| 6 | 572 return NULL; |
| 573 } | |
| 574 while ((ep = readdir(dirp)) != NULL) { | |
|
2845
051bacab59af
suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents:
2740
diff
changeset
|
575 if (ep->d_name[0] == '.' && |
|
051bacab59af
suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents:
2740
diff
changeset
|
576 (NAMLEN(ep) == 1 || |
|
051bacab59af
suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents:
2740
diff
changeset
|
577 ep->d_name[1] == '.' && NAMLEN(ep) == 2)) |
|
051bacab59af
suppress . and .. in listdir return value
Guido van Rossum <guido@python.org>
parents:
2740
diff
changeset
|
578 continue; |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1983
diff
changeset
|
579 v = newsizedstringobject(ep->d_name, NAMLEN(ep)); |
| 6 | 580 if (v == NULL) { |
| 581 DECREF(d); | |
| 582 d = NULL; | |
| 583 break; | |
| 584 } | |
| 585 if (addlistitem(d, v) != 0) { | |
| 586 DECREF(v); | |
| 587 DECREF(d); | |
| 588 d = NULL; | |
| 589 break; | |
| 590 } | |
| 591 DECREF(v); | |
| 592 } | |
| 593 closedir(dirp); | |
| 926 | 594 END_SAVE |
|
200
9d01965f4f48
Incorporated MSDOS changes (untested).
Guido van Rossum <guido@python.org>
parents:
199
diff
changeset
|
595 |
| 6 | 596 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
|
597 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
598 #endif /* !_MSC_VER */ |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
599 #endif /* !MS_WIN32 */ |
| 6 | 600 } |
| 601 | |
| 602 static object * | |
| 603 posix_mkdir(self, args) | |
| 604 object *self; | |
| 605 object *args; | |
| 606 { | |
|
3418
0ac5fbaf8aef
Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents:
3387
diff
changeset
|
607 int res; |
|
0ac5fbaf8aef
Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents:
3387
diff
changeset
|
608 char *path; |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
609 int mode = 0777; |
|
3418
0ac5fbaf8aef
Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents:
3387
diff
changeset
|
610 if (!newgetargs(args, "s|i", &path, &mode)) |
|
0ac5fbaf8aef
Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents:
3387
diff
changeset
|
611 return NULL; |
|
0ac5fbaf8aef
Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents:
3387
diff
changeset
|
612 BGN_SAVE |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
613 #if defined(__WATCOMC__) || defined(_MSC_VER) |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
614 res = mkdir(path); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
615 #else |
|
3418
0ac5fbaf8aef
Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents:
3387
diff
changeset
|
616 res = mkdir(path, mode); |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
617 #endif |
|
3418
0ac5fbaf8aef
Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents:
3387
diff
changeset
|
618 END_SAVE |
|
0ac5fbaf8aef
Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents:
3387
diff
changeset
|
619 if (res < 0) |
|
0ac5fbaf8aef
Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents:
3387
diff
changeset
|
620 return posix_error(); |
|
0ac5fbaf8aef
Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents:
3387
diff
changeset
|
621 INCREF(None); |
|
0ac5fbaf8aef
Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents:
3387
diff
changeset
|
622 return None; |
| 6 | 623 } |
| 624 | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
625 #ifdef HAVE_NICE |
|
1181
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
626 static object * |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
627 posix_nice(self, args) |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
628 object *self; |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
629 object *args; |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
630 { |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
631 int increment, value; |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
632 |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
633 if (!getargs(args, "i", &increment)) |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
634 return NULL; |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
635 value = nice(increment); |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
636 if (value == -1) |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
637 return posix_error(); |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
638 return newintobject((long) value); |
|
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
639 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
640 #endif /* HAVE_NICE */ |
|
199
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
641 |
| 6 | 642 static object * |
| 643 posix_rename(self, args) | |
| 644 object *self; | |
| 645 object *args; | |
| 646 { | |
| 647 return posix_2str(args, rename); | |
| 648 } | |
| 649 | |
| 650 static object * | |
| 651 posix_rmdir(self, args) | |
| 652 object *self; | |
| 653 object *args; | |
| 654 { | |
| 655 return posix_1str(args, rmdir); | |
| 656 } | |
| 657 | |
| 658 static object * | |
| 659 posix_stat(self, args) | |
| 660 object *self; | |
| 661 object *args; | |
| 662 { | |
| 663 return posix_do_stat(self, args, stat); | |
| 664 } | |
| 665 | |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
666 #ifdef HAVE_SYSTEM |
| 6 | 667 static object * |
| 668 posix_system(self, args) | |
| 669 object *self; | |
| 670 object *args; | |
| 671 { | |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
672 char *command; |
| 926 | 673 long sts; |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
674 if (!getargs(args, "s", &command)) |
| 6 | 675 return NULL; |
| 926 | 676 BGN_SAVE |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
677 sts = system(command); |
| 926 | 678 END_SAVE |
| 679 return newintobject(sts); | |
| 6 | 680 } |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
681 #endif |
| 6 | 682 |
| 683 static object * | |
| 684 posix_umask(self, args) | |
| 685 object *self; | |
| 686 object *args; | |
| 687 { | |
| 688 int i; | |
| 689 if (!getintarg(args, &i)) | |
| 690 return NULL; | |
| 691 i = umask(i); | |
| 692 if (i < 0) | |
| 693 return posix_error(); | |
| 694 return newintobject((long)i); | |
| 695 } | |
| 696 | |
| 697 static object * | |
| 698 posix_unlink(self, args) | |
| 699 object *self; | |
| 700 object *args; | |
| 701 { | |
| 702 return posix_1str(args, unlink); | |
| 703 } | |
| 704 | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
705 #ifdef HAVE_UNAME |
|
658
5b521fe4d1f6
Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents:
643
diff
changeset
|
706 static object * |
|
5b521fe4d1f6
Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents:
643
diff
changeset
|
707 posix_uname(self, args) |
|
5b521fe4d1f6
Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents:
643
diff
changeset
|
708 object *self; |
|
5b521fe4d1f6
Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents:
643
diff
changeset
|
709 object *args; |
|
5b521fe4d1f6
Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents:
643
diff
changeset
|
710 { |
|
5b521fe4d1f6
Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents:
643
diff
changeset
|
711 struct utsname u; |
|
5b521fe4d1f6
Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents:
643
diff
changeset
|
712 object *v; |
| 926 | 713 int res; |
|
731
c65fc172f16d
Check empty argument lists.
Guido van Rossum <guido@python.org>
parents:
658
diff
changeset
|
714 if (!getnoarg(args)) |
|
c65fc172f16d
Check empty argument lists.
Guido van Rossum <guido@python.org>
parents:
658
diff
changeset
|
715 return NULL; |
| 926 | 716 BGN_SAVE |
| 717 res = uname(&u); | |
| 718 END_SAVE | |
| 719 if (res < 0) | |
|
658
5b521fe4d1f6
Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents:
643
diff
changeset
|
720 return posix_error(); |
|
1252
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
721 return mkvalue("(sssss)", |
|
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
722 u.sysname, |
|
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
723 u.nodename, |
|
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
724 u.release, |
|
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
725 u.version, |
|
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
726 u.machine); |
|
658
5b521fe4d1f6
Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents:
643
diff
changeset
|
727 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
728 #endif /* HAVE_UNAME */ |
|
199
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
729 |
| 6 | 730 static object * |
|
199
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
731 posix_utime(self, args) |
| 6 | 732 object *self; |
| 733 object *args; | |
| 734 { | |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
735 char *path; |
| 2236 | 736 long atime, mtime; |
| 926 | 737 int res; |
|
199
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
738 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
739 #ifdef HAVE_UTIME_H |
|
199
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
740 struct utimbuf buf; |
|
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
741 #define ATIME buf.actime |
|
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
742 #define MTIME buf.modtime |
|
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
743 #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
|
744 #else /* HAVE_UTIME_H */ |
|
199
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
745 time_t buf[2]; |
|
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
746 #define ATIME buf[0] |
|
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
747 #define MTIME buf[1] |
|
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
748 #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
|
749 #endif /* HAVE_UTIME_H */ |
|
199
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
750 |
| 2236 | 751 if (!getargs(args, "(s(ll))", &path, &atime, &mtime)) |
| 6 | 752 return NULL; |
| 2236 | 753 ATIME = atime; |
|
2298
fe8db78f311c
correct typo in utime stub
Guido van Rossum <guido@python.org>
parents:
2236
diff
changeset
|
754 MTIME = mtime; |
| 926 | 755 BGN_SAVE |
| 756 res = utime(path, UTIME_ARG); | |
| 757 END_SAVE | |
| 758 if (res < 0) | |
| 6 | 759 return posix_error(); |
| 760 INCREF(None); | |
| 761 return None; | |
|
199
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
762 #undef UTIME_ARG |
|
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
763 #undef ATIME |
|
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
764 #undef MTIME |
| 6 | 765 } |
| 766 | |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
767 |
| 264 | 768 /* Process operations */ |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
769 |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
770 static object * |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
771 posix__exit(self, args) |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
772 object *self; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
773 object *args; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
774 { |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
775 int sts; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
776 if (!getintarg(args, &sts)) |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
777 return NULL; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
778 _exit(sts); |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
779 /* NOTREACHED */ |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
780 } |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
781 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
782 #ifdef HAVE_EXECV |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
783 static object * |
|
1360
1808ca5d8883
* import.c (MAGIC): Changed magic word to avoid confusion about exec
Guido van Rossum <guido@python.org>
parents:
1329
diff
changeset
|
784 posix_execv(self, args) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
785 object *self; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
786 object *args; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
787 { |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
788 char *path; |
|
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
789 object *argv; |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
790 char **argvlist; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
791 int i, argc; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
792 object *(*getitem) PROTO((object *, int)); |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
793 |
|
1360
1808ca5d8883
* import.c (MAGIC): Changed magic word to avoid confusion about exec
Guido van Rossum <guido@python.org>
parents:
1329
diff
changeset
|
794 /* execv has two arguments: (path, argv), where |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
795 argv is a list or tuple of strings. */ |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
796 |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
797 if (!getargs(args, "(sO)", &path, &argv)) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
798 return NULL; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
799 if (is_listobject(argv)) { |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
800 argc = getlistsize(argv); |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
801 getitem = getlistitem; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
802 } |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
803 else if (is_tupleobject(argv)) { |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
804 argc = gettuplesize(argv); |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
805 getitem = gettupleitem; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
806 } |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
807 else { |
|
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
808 badarg: |
|
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
809 err_badarg(); |
|
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
810 return NULL; |
|
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
811 } |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
812 |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
813 argvlist = NEW(char *, argc+1); |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
814 if (argvlist == NULL) |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
815 return NULL; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
816 for (i = 0; i < argc; i++) { |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
817 if (!getargs((*getitem)(argv, i), "s", &argvlist[i])) { |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
818 DEL(argvlist); |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
819 goto badarg; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
820 } |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
821 } |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
822 argvlist[argc] = NULL; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
823 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
824 #ifdef BAD_EXEC_PROTOTYPES |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
825 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
|
826 #else /* BAD_EXEC_PROTOTYPES */ |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
827 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
|
828 #endif /* BAD_EXEC_PROTOTYPES */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
829 |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
830 /* If we get here it's definitely an error */ |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
831 |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
832 DEL(argvlist); |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
833 return posix_error(); |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
834 } |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
835 |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
836 static object * |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
837 posix_execve(self, args) |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
838 object *self; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
839 object *args; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
840 { |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
841 char *path; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
842 object *argv, *env; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
843 char **argvlist; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
844 char **envlist; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
845 object *key, *val; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
846 int i, pos, argc, envc; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
847 object *(*getitem) PROTO((object *, int)); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
848 |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
849 /* 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
|
850 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
|
851 like posix.environ. */ |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
852 |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
853 if (!getargs(args, "(sOO)", &path, &argv, &env)) |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
854 return NULL; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
855 if (is_listobject(argv)) { |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
856 argc = getlistsize(argv); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
857 getitem = getlistitem; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
858 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
859 else if (is_tupleobject(argv)) { |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
860 argc = gettuplesize(argv); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
861 getitem = gettupleitem; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
862 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
863 else { |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
864 err_setstr(TypeError, "argv must be tuple or list"); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
865 return NULL; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
866 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
867 if (!is_dictobject(env)) { |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
868 err_setstr(TypeError, "env must be dictionary"); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
869 return NULL; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
870 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
871 |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
872 argvlist = NEW(char *, argc+1); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
873 if (argvlist == NULL) { |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
874 err_nomem(); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
875 return NULL; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
876 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
877 for (i = 0; i < argc; i++) { |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
878 if (!getargs((*getitem)(argv, i), |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
879 "s;argv must be list of strings", |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
880 &argvlist[i])) { |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
881 goto fail_1; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
882 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
883 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
884 argvlist[argc] = NULL; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
885 |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
886 i = getmappingsize(env); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
887 envlist = NEW(char *, i + 1); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
888 if (envlist == NULL) { |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
889 err_nomem(); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
890 goto fail_1; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
891 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
892 pos = 0; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
893 envc = 0; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
894 while (mappinggetnext(env, &pos, &key, &val)) { |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
895 char *p, *k, *v; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
896 if (!getargs(key, "s;non-string key in env", &k) || |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
897 !getargs(val, "s;non-string value in env", &v)) { |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
898 goto fail_2; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
899 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
900 p = NEW(char, getstringsize(key) + getstringsize(val) + 2); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
901 if (p == NULL) { |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
902 err_nomem(); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
903 goto fail_2; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
904 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
905 sprintf(p, "%s=%s", k, v); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
906 envlist[envc++] = p; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
907 } |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
908 envlist[envc] = 0; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
909 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
910 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
911 #ifdef BAD_EXEC_PROTOTYPES |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
912 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
|
913 #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
|
914 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
|
915 #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
|
916 |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
917 /* 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
|
918 |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
919 (void) posix_error(); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
920 |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
921 fail_2: |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
922 while (--envc >= 0) |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
923 DEL(envlist[envc]); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
924 DEL(envlist); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
925 fail_1: |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
926 DEL(argvlist); |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
927 |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
928 return NULL; |
|
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
929 } |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
930 #endif /* HAVE_EXECV */ |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
931 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
932 #ifdef HAVE_FORK |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
933 static object * |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
934 posix_fork(self, args) |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
935 object *self; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
936 object *args; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
937 { |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
938 int pid; |
|
731
c65fc172f16d
Check empty argument lists.
Guido van Rossum <guido@python.org>
parents:
658
diff
changeset
|
939 if (!getnoarg(args)) |
|
c65fc172f16d
Check empty argument lists.
Guido van Rossum <guido@python.org>
parents:
658
diff
changeset
|
940 return NULL; |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
941 pid = fork(); |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
942 if (pid == -1) |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
943 return posix_error(); |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
944 return newintobject((long)pid); |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
945 } |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
946 #endif |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
947 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
948 #ifdef HAVE_GETEGID |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
949 static object * |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
950 posix_getegid(self, args) |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
951 object *self; |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
952 object *args; |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
953 { |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
954 if (!getnoarg(args)) |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
955 return NULL; |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
956 return newintobject((long)getegid()); |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
957 } |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
958 #endif |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
959 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
960 #ifdef HAVE_GETEUID |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
961 static object * |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
962 posix_geteuid(self, args) |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
963 object *self; |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
964 object *args; |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
965 { |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
966 if (!getnoarg(args)) |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
967 return NULL; |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
968 return newintobject((long)geteuid()); |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
969 } |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
970 #endif |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
971 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
972 #ifdef HAVE_GETGID |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
973 static object * |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
974 posix_getgid(self, args) |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
975 object *self; |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
976 object *args; |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
977 { |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
978 if (!getnoarg(args)) |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
979 return NULL; |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
980 return newintobject((long)getgid()); |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
981 } |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
982 #endif |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
983 |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
984 static object * |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
985 posix_getpid(self, args) |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
986 object *self; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
987 object *args; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
988 { |
|
273
af1c8f5d0b37
Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents:
264
diff
changeset
|
989 if (!getnoarg(args)) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
990 return NULL; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
991 return newintobject((long)getpid()); |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
992 } |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
993 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
994 #ifdef HAVE_GETPGRP |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
995 static object * |
|
273
af1c8f5d0b37
Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents:
264
diff
changeset
|
996 posix_getpgrp(self, args) |
|
af1c8f5d0b37
Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents:
264
diff
changeset
|
997 object *self; |
|
af1c8f5d0b37
Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents:
264
diff
changeset
|
998 object *args; |
|
af1c8f5d0b37
Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents:
264
diff
changeset
|
999 { |
|
af1c8f5d0b37
Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents:
264
diff
changeset
|
1000 if (!getnoarg(args)) |
|
af1c8f5d0b37
Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents:
264
diff
changeset
|
1001 return NULL; |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1002 #ifdef GETPGRP_HAVE_ARG |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1003 return newintobject((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
|
1004 #else /* GETPGRP_HAVE_ARG */ |
|
731
c65fc172f16d
Check empty argument lists.
Guido van Rossum <guido@python.org>
parents:
658
diff
changeset
|
1005 return newintobject((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
|
1006 #endif /* GETPGRP_HAVE_ARG */ |
|
273
af1c8f5d0b37
Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents:
264
diff
changeset
|
1007 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1008 #endif /* HAVE_GETPGRP */ |
|
273
af1c8f5d0b37
Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents:
264
diff
changeset
|
1009 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1010 #ifdef HAVE_SETPGRP |
|
273
af1c8f5d0b37
Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents:
264
diff
changeset
|
1011 static object * |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1012 posix_setpgrp(self, args) |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1013 object *self; |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1014 object *args; |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1015 { |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1016 if (!getnoarg(args)) |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1017 return NULL; |
|
1983
80bd7af73201
distinguish between getpgrp and setpgrp arg requirements
Guido van Rossum <guido@python.org>
parents:
1915
diff
changeset
|
1018 #ifdef SETPGRP_HAVE_ARG |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1019 if (setpgrp(0, 0) < 0) |
|
1983
80bd7af73201
distinguish between getpgrp and setpgrp arg requirements
Guido van Rossum <guido@python.org>
parents:
1915
diff
changeset
|
1020 #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
|
1021 if (setpgrp() < 0) |
|
1983
80bd7af73201
distinguish between getpgrp and setpgrp arg requirements
Guido van Rossum <guido@python.org>
parents:
1915
diff
changeset
|
1022 #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
|
1023 return posix_error(); |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1024 INCREF(None); |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1025 return None; |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1026 } |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1027 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1028 #endif /* HAVE_SETPGRP */ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1029 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1030 #ifdef HAVE_GETPPID |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1031 static object * |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1032 posix_getppid(self, args) |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1033 object *self; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1034 object *args; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1035 { |
|
273
af1c8f5d0b37
Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents:
264
diff
changeset
|
1036 if (!getnoarg(args)) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1037 return NULL; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1038 return newintobject((long)getppid()); |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1039 } |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1040 #endif |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1041 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1042 #ifdef HAVE_GETUID |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1043 static object * |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1044 posix_getuid(self, args) |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1045 object *self; |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1046 object *args; |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1047 { |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1048 if (!getnoarg(args)) |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1049 return NULL; |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1050 return newintobject((long)getuid()); |
|
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1051 } |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1052 #endif |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1053 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1054 #ifdef HAVE_KILL |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1055 static object * |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1056 posix_kill(self, args) |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1057 object *self; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1058 object *args; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1059 { |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1060 int pid, sig; |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1287
diff
changeset
|
1061 if (!getargs(args, "(ii)", &pid, &sig)) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1062 return NULL; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1063 if (kill(pid, sig) == -1) |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1064 return posix_error(); |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1065 INCREF(None); |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1066 return None; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1067 } |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1068 #endif |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1069 |
|
3735
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1070 #ifdef HAVE_PLOCK |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1071 |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1072 #ifdef HAVE_SYS_LOCK_H |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1073 #include <sys/lock.h> |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1074 #endif |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1075 |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1076 static object * |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1077 posix_plock(self, args) |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1078 object *self; |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1079 object *args; |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1080 { |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1081 int op; |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1082 if (!getargs(args, "i", &op)) |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1083 return NULL; |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1084 if (plock(op) == -1) |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1085 return posix_error(); |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1086 INCREF(None); |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1087 return None; |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1088 } |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1089 #endif |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1090 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1091 #ifdef HAVE_POPEN |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1092 static object * |
| 264 | 1093 posix_popen(self, args) |
| 1094 object *self; | |
| 1095 object *args; | |
| 1096 { | |
|
2114
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1097 char *name; |
|
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1098 char *mode = "r"; |
|
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1099 int bufsize = -1; |
| 264 | 1100 FILE *fp; |
|
2114
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1101 object *f; |
|
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1102 if (!newgetargs(args, "s|si", &name, &mode, &bufsize)) |
| 264 | 1103 return NULL; |
| 926 | 1104 BGN_SAVE |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
1105 fp = popen(name, mode); |
| 926 | 1106 END_SAVE |
| 264 | 1107 if (fp == NULL) |
| 1108 return posix_error(); | |
|
2114
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1109 f = newopenfileobject(fp, name, mode, pclose); |
|
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1110 if (f != NULL) |
|
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1111 setfilebufsize(f, bufsize); |
|
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1112 return f; |
| 264 | 1113 } |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1114 #endif /* HAVE_POPEN */ |
| 264 | 1115 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1116 #ifdef HAVE_SETUID |
| 264 | 1117 static object * |
|
1405
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1118 posix_setuid(self, args) |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1119 object *self; |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1120 object *args; |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1121 { |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1122 int uid; |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1123 if (!getargs(args, "i", &uid)) |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1124 return NULL; |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1125 if (setuid(uid) < 0) |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1126 return posix_error(); |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1127 INCREF(None); |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1128 return None; |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1129 } |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1130 #endif /* HAVE_SETUID */ |
|
1405
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1131 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1132 #ifdef HAVE_SETGID |
|
1405
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1133 static object * |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1134 posix_setgid(self, args) |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1135 object *self; |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1136 object *args; |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1137 { |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1138 int gid; |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1139 if (!getargs(args, "i", &gid)) |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1140 return NULL; |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1141 if (setgid(gid) < 0) |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1142 return posix_error(); |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1143 INCREF(None); |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1144 return None; |
|
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1145 } |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1146 #endif /* HAVE_SETGID */ |
|
1405
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1147 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1148 #ifdef HAVE_WAITPID |
|
1405
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1149 static object * |
|
931
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1150 posix_waitpid(self, args) |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1151 object *self; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1152 object *args; |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1153 { |
|
3695
1454138c6f2d
Clear waitpid() status arg in case there's no process to report with
Guido van Rossum <guido@python.org>
parents:
3667
diff
changeset
|
1154 int pid, options, sts = 0; |
|
931
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1155 if (!getargs(args, "(ii)", &pid, &options)) |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1156 return NULL; |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1157 BGN_SAVE |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1158 pid = waitpid(pid, &sts, options); |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1159 END_SAVE |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1160 if (pid == -1) |
|
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1161 return posix_error(); |
|
931
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1162 else |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1163 return mkvalue("ii", pid, sts); |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1164 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1165 #endif /* HAVE_WAITPID */ |
|
931
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1166 |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1167 #ifdef HAVE_WAIT |
|
931
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1168 static object * |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1169 posix_wait(self, args) |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1170 object *self; |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1171 object *args; |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1172 { |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1173 int pid, sts; |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1174 BGN_SAVE |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1175 pid = wait(&sts); |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1176 END_SAVE |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1177 if (pid == -1) |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1178 return posix_error(); |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1179 else |
|
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1180 return mkvalue("ii", pid, sts); |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1181 } |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1182 #endif |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1183 |
| 6 | 1184 static object * |
| 1185 posix_lstat(self, args) | |
| 1186 object *self; | |
| 1187 object *args; | |
| 1188 { | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1189 #ifdef HAVE_LSTAT |
| 6 | 1190 return posix_do_stat(self, args, lstat); |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1191 #else /* !HAVE_LSTAT */ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1192 return posix_do_stat(self, args, stat); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1193 #endif /* !HAVE_LSTAT */ |
| 6 | 1194 } |
| 1195 | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1196 #ifdef HAVE_READLINK |
| 6 | 1197 static object * |
| 1198 posix_readlink(self, args) | |
| 1199 object *self; | |
| 1200 object *args; | |
| 1201 { | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1202 char buf[MAXPATHLEN]; |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
373
diff
changeset
|
1203 char *path; |
| 6 | 1204 int n; |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1205 if (!getargs(args, "s", &path)) |
| 6 | 1206 return NULL; |
| 926 | 1207 BGN_SAVE |
|
731
c65fc172f16d
Check empty argument lists.
Guido van Rossum <guido@python.org>
parents:
658
diff
changeset
|
1208 n = readlink(path, buf, (int) sizeof buf); |
| 926 | 1209 END_SAVE |
| 6 | 1210 if (n < 0) |
| 1211 return posix_error(); | |
| 1212 return newsizedstringobject(buf, n); | |
| 1213 } | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1214 #endif /* HAVE_READLINK */ |
| 6 | 1215 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1216 #ifdef HAVE_SYMLINK |
| 6 | 1217 static object * |
| 1218 posix_symlink(self, args) | |
| 1219 object *self; | |
| 1220 object *args; | |
| 1221 { | |
| 1222 return posix_2str(args, symlink); | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1223 } |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1224 #endif /* HAVE_SYMLINK */ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1225 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1226 #ifdef HAVE_TIMES |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1227 #ifndef HZ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1228 #define HZ 60 /* Universal constant :-) */ |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1229 #endif /* HZ */ |
|
793
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
1230 static object * |
|
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
1231 posix_times(self, args) |
|
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
1232 object *self; |
|
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
1233 object *args; |
|
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
1234 { |
|
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
1235 struct tms t; |
|
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
1236 clock_t c; |
|
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
1237 if (!getnoarg(args)) |
|
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
1238 return NULL; |
|
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
1239 errno = 0; |
|
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
1240 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
|
1241 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
|
1242 return posix_error(); |
|
3088
75936990a330
added 5th return item, clock time, to posix.times()
Guido van Rossum <guido@python.org>
parents:
2845
diff
changeset
|
1243 return mkvalue("ddddd", |
|
1191
38f0054f44a7
Added separate main program for the Mac: macmain.c
Guido van Rossum <guido@python.org>
parents:
1181
diff
changeset
|
1244 (double)t.tms_utime / HZ, |
|
38f0054f44a7
Added separate main program for the Mac: macmain.c
Guido van Rossum <guido@python.org>
parents:
1181
diff
changeset
|
1245 (double)t.tms_stime / HZ, |
|
38f0054f44a7
Added separate main program for the Mac: macmain.c
Guido van Rossum <guido@python.org>
parents:
1181
diff
changeset
|
1246 (double)t.tms_cutime / HZ, |
|
3088
75936990a330
added 5th return item, clock time, to posix.times()
Guido van Rossum <guido@python.org>
parents:
2845
diff
changeset
|
1247 (double)t.tms_cstime / HZ, |
|
75936990a330
added 5th return item, clock time, to posix.times()
Guido van Rossum <guido@python.org>
parents:
2845
diff
changeset
|
1248 (double)c / HZ); |
|
793
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
1249 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1250 #endif /* HAVE_TIMES */ |
|
4233
1099159ec821
Use #ifdef MS_WIN32 instead of _MSC_VER > 850.
Guido van Rossum <guido@python.org>
parents:
3801
diff
changeset
|
1251 #ifdef MS_WIN32 |
|
1915
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
1252 #define HAVE_TIMES /* so the method table will pick it up */ |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
1253 static object * |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
1254 posix_times(self, args) |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
1255 object *self; |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
1256 object *args; |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
1257 { |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
1258 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
|
1259 HANDLE hProc; |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
1260 if (!getnoarg(args)) |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
1261 return NULL; |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
1262 hProc = GetCurrentProcess(); |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
1263 GetProcessTimes(hProc,&create, &exit, &kernel, &user); |
|
3088
75936990a330
added 5th return item, clock time, to posix.times()
Guido van Rossum <guido@python.org>
parents:
2845
diff
changeset
|
1264 return mkvalue("ddddd", |
|
1915
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
1265 (double)(kernel.dwHighDateTime*2E32+kernel.dwLowDateTime) / 2E6, |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
1266 (double)(user.dwHighDateTime*2E32+user.dwLowDateTime) / 2E6, |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
1267 (double)0, |
|
3088
75936990a330
added 5th return item, clock time, to posix.times()
Guido van Rossum <guido@python.org>
parents:
2845
diff
changeset
|
1268 (double)0, |
|
1915
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
1269 (double)0); |
|
80818c106e3e
* Modules/xxmodule.c: integrated with xxobject.c by Jack
Guido van Rossum <guido@python.org>
parents:
1845
diff
changeset
|
1270 } |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
1271 #endif /* MS_WIN32 */ |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1272 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1273 #ifdef 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
|
1274 static object * |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1275 posix_setsid(self, args) |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1276 object *self; |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1277 object *args; |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1278 { |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1279 if (!getnoarg(args)) |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1280 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
|
1281 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
|
1282 return posix_error(); |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1283 INCREF(None); |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1284 return None; |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1285 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1286 #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
|
1287 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1288 #ifdef HAVE_SETPGID |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1289 static object * |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1290 posix_setpgid(self, args) |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1291 object *self; |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1292 object *args; |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1293 { |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1294 int pid, pgrp; |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1295 if (!getargs(args, "(ii)", &pid, &pgrp)) |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1296 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
|
1297 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
|
1298 return posix_error(); |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1299 INCREF(None); |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1300 return None; |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1301 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1302 #endif /* HAVE_SETPGID */ |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1303 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1304 #ifdef HAVE_TCGETPGRP |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1305 static object * |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1306 posix_tcgetpgrp(self, args) |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1307 object *self; |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1308 object *args; |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1309 { |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1310 int fd, pgid; |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1311 if (!getargs(args, "i", &fd)) |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1312 return NULL; |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1313 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
|
1314 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
|
1315 return posix_error(); |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1316 return newintobject((long)pgid); |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1317 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1318 #endif /* HAVE_TCGETPGRP */ |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1319 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1320 #ifdef HAVE_TCSETPGRP |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1321 static object * |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1322 posix_tcsetpgrp(self, args) |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1323 object *self; |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1324 object *args; |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1325 { |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1326 int fd, pgid; |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1327 if (!getargs(args, "(ii)", &fd, &pgid)) |
|
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1328 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
|
1329 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
|
1330 return posix_error(); |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1331 INCREF(None); |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1332 return None; |
|
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1333 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1334 #endif /* HAVE_TCSETPGRP */ |
|
793
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
1335 |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1336 /* 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
|
1337 |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1287
diff
changeset
|
1338 static object * |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1339 posix_open(self, args) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1340 object *self; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1341 object *args; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1342 { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1343 char *file; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1344 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
|
1345 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
|
1346 int fd; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1347 if (!getargs(args, "(si)", &file, &flag)) { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1348 err_clear(); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1349 if (!getargs(args, "(sii)", &file, &flag, &mode)) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1350 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
|
1351 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1352 BGN_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1353 fd = open(file, flag, mode); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1354 END_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1355 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
|
1356 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
|
1357 return newintobject((long)fd); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1358 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1359 |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1287
diff
changeset
|
1360 static object * |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1361 posix_close(self, args) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1362 object *self; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1363 object *args; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1364 { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1365 int fd, res; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1366 if (!getargs(args, "i", &fd)) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1367 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
|
1368 BGN_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1369 res = close(fd); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1370 END_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1371 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
|
1372 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
|
1373 INCREF(None); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1374 return None; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1375 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1376 |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1287
diff
changeset
|
1377 static object * |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1378 posix_dup(self, args) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1379 object *self; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1380 object *args; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1381 { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1382 int fd; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1383 if (!getargs(args, "i", &fd)) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1384 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
|
1385 BGN_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1386 fd = dup(fd); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1387 END_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1388 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
|
1389 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
|
1390 return newintobject((long)fd); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1391 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1392 |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1287
diff
changeset
|
1393 static object * |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1394 posix_dup2(self, args) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1395 object *self; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1396 object *args; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1397 { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1398 int fd, fd2, res; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1399 if (!getargs(args, "(ii)", &fd, &fd2)) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1400 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
|
1401 BGN_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1402 res = dup2(fd, fd2); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1403 END_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1404 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
|
1405 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
|
1406 INCREF(None); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1407 return None; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1408 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1409 |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1287
diff
changeset
|
1410 static object * |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1411 posix_lseek(self, args) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1412 object *self; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1413 object *args; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1414 { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1415 int fd, how; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1416 long pos, res; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1417 if (!getargs(args, "(ili)", &fd, &pos, &how)) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1418 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
|
1419 #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
|
1420 /* 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
|
1421 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
|
1422 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
|
1423 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
|
1424 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
|
1425 } |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1426 #endif /* SEEK_END */ |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1427 BGN_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1428 res = lseek(fd, pos, how); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1429 END_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1430 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
|
1431 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
|
1432 return newintobject(res); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1433 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1434 |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1287
diff
changeset
|
1435 static object * |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1436 posix_read(self, args) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1437 object *self; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1438 object *args; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1439 { |
|
3667
eabbb3c1818f
Avoid core dump in resizestring() on read() with 0 bytes.
Guido van Rossum <guido@python.org>
parents:
3622
diff
changeset
|
1440 int fd, size, 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
|
1441 object *buffer; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1442 if (!getargs(args, "(ii)", &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
|
1443 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
|
1444 buffer = newsizedstringobject((char *)NULL, size); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1445 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
|
1446 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
|
1447 BGN_SAVE |
|
3667
eabbb3c1818f
Avoid core dump in resizestring() on read() with 0 bytes.
Guido van Rossum <guido@python.org>
parents:
3622
diff
changeset
|
1448 n = read(fd, getstringvalue(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
|
1449 END_SAVE |
|
3667
eabbb3c1818f
Avoid core dump in resizestring() on read() with 0 bytes.
Guido van Rossum <guido@python.org>
parents:
3622
diff
changeset
|
1450 if (n < 0) { |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1451 DECREF(buffer); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1452 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
|
1453 } |
|
3667
eabbb3c1818f
Avoid core dump in resizestring() on read() with 0 bytes.
Guido van Rossum <guido@python.org>
parents:
3622
diff
changeset
|
1454 if (n != size) |
|
eabbb3c1818f
Avoid core dump in resizestring() on read() with 0 bytes.
Guido van Rossum <guido@python.org>
parents:
3622
diff
changeset
|
1455 resizestring(&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
|
1456 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
|
1457 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1458 |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1287
diff
changeset
|
1459 static object * |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1460 posix_write(self, args) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1461 object *self; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1462 object *args; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1463 { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1464 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
|
1465 char *buffer; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1466 if (!getargs(args, "(is#)", &fd, &buffer, &size)) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1467 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
|
1468 BGN_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1469 size = write(fd, buffer, size); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1470 END_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1471 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
|
1472 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
|
1473 return newintobject((long)size); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1474 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1475 |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1287
diff
changeset
|
1476 static object * |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1477 posix_fstat(self, args) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1478 object *self; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1479 object *args; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1480 { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1481 int fd; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1482 struct stat st; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1483 int res; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1484 if (!getargs(args, "i", &fd)) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1485 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
|
1486 BGN_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1487 res = fstat(fd, &st); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1488 END_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1489 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
|
1490 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
|
1491 return mkvalue("(llllllllll)", |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1492 (long)st.st_mode, |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1493 (long)st.st_ino, |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1494 (long)st.st_dev, |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1495 (long)st.st_nlink, |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1496 (long)st.st_uid, |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1497 (long)st.st_gid, |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1498 (long)st.st_size, |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1499 (long)st.st_atime, |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1500 (long)st.st_mtime, |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1501 (long)st.st_ctime); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1502 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1503 |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1504 static object * |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1505 posix_fdopen(self, args) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1506 object *self; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1507 object *args; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1508 { |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1509 extern int fclose PROTO((FILE *)); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1510 int fd; |
|
2114
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1511 char *mode = "r"; |
|
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1512 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
|
1513 FILE *fp; |
|
2114
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1514 object *f; |
|
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1515 if (!newgetargs(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
|
1516 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
|
1517 BGN_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1518 fp = fdopen(fd, mode); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1519 END_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1520 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
|
1521 return posix_error(); |
|
2114
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1522 f = newopenfileobject(fp, "(fdopen)", mode, fclose); |
|
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1523 if (f != NULL) |
|
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1524 setfilebufsize(f, bufsize); |
|
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1525 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
|
1526 } |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1527 |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1528 #ifdef HAVE_PIPE |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1287
diff
changeset
|
1529 static object * |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1530 posix_pipe(self, args) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1531 object *self; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1532 object *args; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1533 { |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
1534 #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
|
1535 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
|
1536 int res; |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1537 if (!getargs(args, "")) |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1538 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
|
1539 BGN_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1540 res = pipe(fds); |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1541 END_SAVE |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1542 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
|
1543 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
|
1544 return mkvalue("(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
|
1545 #else /* MS_WIN32 */ |
|
1815
6353fe25cdce
* Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents:
1792
diff
changeset
|
1546 HANDLE read, write; |
|
6353fe25cdce
* Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents:
1792
diff
changeset
|
1547 BOOL ok; |
|
6353fe25cdce
* Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents:
1792
diff
changeset
|
1548 if (!getargs(args, "")) |
|
6353fe25cdce
* Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents:
1792
diff
changeset
|
1549 return NULL; |
|
6353fe25cdce
* Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents:
1792
diff
changeset
|
1550 BGN_SAVE |
|
6353fe25cdce
* Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents:
1792
diff
changeset
|
1551 ok = CreatePipe( &read, &write, NULL, 0); |
|
6353fe25cdce
* Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents:
1792
diff
changeset
|
1552 END_SAVE |
|
6353fe25cdce
* Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents:
1792
diff
changeset
|
1553 if (!ok) |
|
6353fe25cdce
* Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents:
1792
diff
changeset
|
1554 return posix_error(); |
|
6353fe25cdce
* Modules/posixmodule.c: some more NT changes
Guido van Rossum <guido@python.org>
parents:
1792
diff
changeset
|
1555 return mkvalue("(ii)", read, write); |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
1556 #endif /* 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
|
1557 } |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1558 #endif /* HAVE_PIPE */ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1559 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1560 #ifdef HAVE_MKFIFO |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1561 static object * |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1562 posix_mkfifo(self, args) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1563 object *self; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1564 object *args; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1565 { |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1566 char *file; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1567 int mode = 0666; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1568 int res; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1569 if (!newgetargs(args, "s|i", &file, &mode)) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1570 return NULL; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1571 BGN_SAVE |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1572 res = mkfifo(file, mode); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1573 END_SAVE |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1574 if (res < 0) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1575 return posix_error(); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1576 INCREF(None); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1577 return None; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1578 } |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1579 #endif |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1580 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1581 #ifdef HAVE_FTRUNCATE |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1582 static object * |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1583 posix_ftruncate(self, args) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1584 object *self; /* Not used */ |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1585 object *args; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1586 { |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1587 int fd; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1588 long length; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1589 int res; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1590 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1591 if (!getargs(args, "(il)", &fd, &length)) |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1592 return NULL; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1593 |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1594 BGN_SAVE |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1595 res = ftruncate(fd, length); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1596 END_SAVE |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1597 if (res < 0) { |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1598 err_errno(IOError); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1599 return NULL; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1600 } |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1601 INCREF(None); |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1602 return None; |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1603 } |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1604 #endif |
|
793
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
1605 |
|
3801
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1606 #ifdef HAVE_PUTENV |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1607 static object * |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1608 posix_putenv(self,args) |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1609 object *self; |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1610 object *args; |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1611 { |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1612 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
|
1613 char *new; |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1614 |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1615 if (!newgetargs(args, "ss", &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
|
1616 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
|
1617 /* XXX This leaks memory -- not easy to fix :-( */ |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1618 if ((new = malloc(strlen(s1) + strlen(s2) + 2)) == NULL) |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1619 return err_nomem(); |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1620 (void) sprintf(new, "%s=%s", s1, s2); |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1621 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
|
1622 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
|
1623 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
|
1624 } |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1625 INCREF(None); |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1626 return None; |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1627 } |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1628 #endif |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1629 |
| 6 | 1630 static struct methodlist posix_methods[] = { |
| 1631 {"chdir", posix_chdir}, | |
| 1632 {"chmod", posix_chmod}, | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1633 #ifdef HAVE_CHOWN |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1634 {"chown", posix_chown}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1635 #endif /* HAVE_CHOWN */ |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
1636 #ifdef HAVE_GETCWD |
| 6 | 1637 {"getcwd", posix_getcwd}, |
|
2740
3e370a4b103b
sys/wait.h; NeXT changes (no unistd, utime; getcwd?)
Guido van Rossum <guido@python.org>
parents:
2615
diff
changeset
|
1638 #endif |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1639 #ifdef HAVE_LINK |
| 6 | 1640 {"link", posix_link}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1641 #endif /* HAVE_LINK */ |
| 6 | 1642 {"listdir", posix_listdir}, |
|
658
5b521fe4d1f6
Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents:
643
diff
changeset
|
1643 {"lstat", posix_lstat}, |
|
3418
0ac5fbaf8aef
Made 2nd arg to mkdir optional
Guido van Rossum <guido@python.org>
parents:
3387
diff
changeset
|
1644 {"mkdir", posix_mkdir, 1}, |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1645 #ifdef HAVE_NICE |
|
1181
950cd37fcddc
* Makefile: use cp -r to install the library
Guido van Rossum <guido@python.org>
parents:
1177
diff
changeset
|
1646 {"nice", posix_nice}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1647 #endif /* HAVE_NICE */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1648 #ifdef HAVE_READLINK |
|
658
5b521fe4d1f6
Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents:
643
diff
changeset
|
1649 {"readlink", posix_readlink}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1650 #endif /* HAVE_READLINK */ |
| 6 | 1651 {"rename", posix_rename}, |
| 1652 {"rmdir", posix_rmdir}, | |
| 1653 {"stat", posix_stat}, | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1654 #ifdef HAVE_SYMLINK |
|
658
5b521fe4d1f6
Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents:
643
diff
changeset
|
1655 {"symlink", posix_symlink}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1656 #endif /* HAVE_SYMLINK */ |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1657 #ifdef HAVE_SYSTEM |
| 6 | 1658 {"system", posix_system}, |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1659 #endif |
| 6 | 1660 {"umask", posix_umask}, |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1661 #ifdef HAVE_UNAME |
|
658
5b521fe4d1f6
Added uname. Made lstat/readlink/symlink unconditional (the latter
Guido van Rossum <guido@python.org>
parents:
643
diff
changeset
|
1662 {"uname", posix_uname}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1663 #endif /* HAVE_UNAME */ |
| 6 | 1664 {"unlink", posix_unlink}, |
|
3387
9fa2228bb096
add remove==unlink; mark strftime as varargs
Guido van Rossum <guido@python.org>
parents:
3088
diff
changeset
|
1665 {"remove", posix_unlink}, |
|
199
0a3e33cfd4a9
Made utime use much more portable.
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
1666 {"utime", posix_utime}, |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1667 #ifdef HAVE_TIMES |
|
793
cbf0ef998a4a
Added times() (from time)
Guido van Rossum <guido@python.org>
parents:
731
diff
changeset
|
1668 {"times", posix_times}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1669 #endif /* HAVE_TIMES */ |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1670 {"_exit", posix__exit}, |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1671 #ifdef HAVE_EXECV |
|
1360
1808ca5d8883
* import.c (MAGIC): Changed magic word to avoid confusion about exec
Guido van Rossum <guido@python.org>
parents:
1329
diff
changeset
|
1672 {"execv", posix_execv}, |
|
1395
be61e072a505
Added execve; change getstrarg into getargs with "s" format
Guido van Rossum <guido@python.org>
parents:
1388
diff
changeset
|
1673 {"execve", posix_execve}, |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1674 #endif /* HAVE_EXECV */ |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1675 #ifdef HAVE_FORK |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1676 {"fork", posix_fork}, |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1677 #endif /* HAVE_FORK */ |
|
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1678 #ifdef HAVE_GETEGID |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1679 {"getegid", posix_getegid}, |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1680 #endif /* HAVE_GETEGID */ |
|
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1681 #ifdef HAVE_GETEUID |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1682 {"geteuid", posix_geteuid}, |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1683 #endif /* HAVE_GETEUID */ |
|
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1684 #ifdef HAVE_GETGID |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1685 {"getgid", posix_getgid}, |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1686 #endif /* HAVE_GETGID */ |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1687 {"getpid", posix_getpid}, |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1688 #ifdef HAVE_GETPGRP |
|
273
af1c8f5d0b37
Added getpgrp(); fixed buggy calls to getnoarg().
Guido van Rossum <guido@python.org>
parents:
264
diff
changeset
|
1689 {"getpgrp", posix_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
|
1690 #endif /* HAVE_GETPGRP */ |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1691 #ifdef HAVE_GETPPID |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1692 {"getppid", posix_getppid}, |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1693 #endif /* HAVE_GETPPID */ |
|
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1694 #ifdef HAVE_GETUID |
|
861
76095a8b96ca
Added gete?[gu]id functions
Guido van Rossum <guido@python.org>
parents:
793
diff
changeset
|
1695 {"getuid", posix_getuid}, |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1696 #endif /* HAVE_GETUID */ |
|
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1697 #ifdef HAVE_KILL |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1698 {"kill", posix_kill}, |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1699 #endif /* HAVE_KILL */ |
|
3735
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1700 #ifdef HAVE_PLOCK |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1701 {"plock", posix_plock}, |
|
4692cb46008e
Added plock() system call.
Guido van Rossum <guido@python.org>
parents:
3702
diff
changeset
|
1702 #endif /* HAVE_PLOCK */ |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1703 #ifdef HAVE_POPEN |
|
2114
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1704 {"popen", posix_popen, 1}, |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1705 #endif /* HAVE_POPEN */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1706 #ifdef HAVE_SETUID |
|
1405
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1707 {"setuid", posix_setuid}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1708 #endif /* HAVE_SETUID */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1709 #ifdef HAVE_SETGID |
|
1405
90c5e2bb4da5
* posixmodule.c: added set{uid,gid}.
Guido van Rossum <guido@python.org>
parents:
1395
diff
changeset
|
1710 {"setgid", posix_setgid}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1711 #endif /* HAVE_SETGID */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1712 #ifdef HAVE_SETPGRP |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1713 {"setpgrp", posix_setpgrp}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1714 #endif /* HAVE_SETPGRP */ |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1715 #ifdef HAVE_WAIT |
|
257
a46558ad0bed
Removed utimes() compatibility hack.
Guido van Rossum <guido@python.org>
parents:
200
diff
changeset
|
1716 {"wait", posix_wait}, |
|
2456
bc03225a4493
changes for NT/Borland C
Guido van Rossum <guido@python.org>
parents:
2370
diff
changeset
|
1717 #endif /* HAVE_WAIT */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1718 #ifdef HAVE_WAITPID |
|
931
d8608ed1cc3b
Makefile, Configure.py: ##ask --> ##[el]if[yes|no]
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1719 {"waitpid", posix_waitpid}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1720 #endif /* HAVE_WAITPID */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1721 #ifdef 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
|
1722 {"setsid", posix_setsid}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1723 #endif /* HAVE_SETSID */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1724 #ifdef HAVE_SETPGID |
|
1050
f49d2311776b
posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
Guido van Rossum <guido@python.org>
parents:
943
diff
changeset
|
1725 {"setpgid", posix_setpgid}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1726 #endif /* HAVE_SETPGID */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1727 #ifdef HAVE_TCGETPGRP |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1728 {"tcgetpgrp", posix_tcgetpgrp}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1729 #endif /* HAVE_TCGETPGRP */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1730 #ifdef HAVE_TCSETPGRP |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1050
diff
changeset
|
1731 {"tcsetpgrp", posix_tcsetpgrp}, |
|
1792
a584b4bbbc59
Changes to make it work and compile on NT, by Mark Hammond.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
1732 #endif /* HAVE_TCSETPGRP */ |
|
1287
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1733 {"open", posix_open}, |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1734 {"close", posix_close}, |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1735 {"dup", posix_dup}, |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1736 {"dup2", posix_dup2}, |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1737 {"lseek", posix_lseek}, |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1738 {"read", posix_read}, |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1739 {"write", posix_write}, |
|
673dd9bbdbf1
New posix functions open, close, dup, dup2, lseek, read, write, fstat, pipe.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1740 {"fstat", posix_fstat}, |
|
2114
7947c0d16ca0
added bufsize parameter to fdopen and popen
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
1741 {"fdopen", posix_fdopen, 1}, |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1742 #ifdef HAVE_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
|
1743 {"pipe", posix_pipe}, |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1744 #endif |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1745 #ifdef HAVE_MKFIFO |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1746 {"mkfifo", posix_mkfifo, 1}, |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1747 #endif |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1748 #ifdef HAVE_FTRUNCATE |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1749 {"ftruncate", posix_ftruncate, 1}, |
|
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1750 #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
|
1751 #ifdef HAVE_PUTENV |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1752 {"putenv", posix_putenv, 1}, |
|
843121a226ca
Added simple-minded (i.e. leaking :-) putenv() interface, if os has it.
Guido van Rossum <guido@python.org>
parents:
3735
diff
changeset
|
1753 #endif |
| 6 | 1754 {NULL, NULL} /* Sentinel */ |
| 1755 }; | |
| 1756 | |
| 1757 | |
|
3622
b75edc0e6333
Changed NT -> MSC or WATCOM
Guido van Rossum <guido@python.org>
parents:
3601
diff
changeset
|
1758 #if defined(_MSC_VER) || defined(__WATCOMC__) |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1759 void |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1760 initnt() |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1761 { |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1762 object *m, *d, *v; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1763 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1764 m = initmodule("nt", posix_methods); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1765 d = getmoduledict(m); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1766 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1767 /* Initialize nt.environ dictionary */ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1768 v = convertenviron(); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1769 if (v == NULL || dictinsert(d, "environ", v) != 0) |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1770 fatal("can't define nt.environ"); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1771 DECREF(v); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1772 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1773 /* Initialize nt.error exception */ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1774 PosixError = newstringobject("nt.error"); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1775 if (PosixError == NULL || dictinsert(d, "error", PosixError) != 0) |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1776 fatal("can't define nt.error"); |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
1777 } |
|
3702
3408756ec601
changed windows test symbols; removed debug printf from sockets
Guido van Rossum <guido@python.org>
parents:
3695
diff
changeset
|
1778 #else /* not a PC port */ |
| 6 | 1779 void |
| 1780 initposix() | |
| 1781 { | |
| 1782 object *m, *d, *v; | |
| 1783 | |
| 1784 m = initmodule("posix", posix_methods); | |
| 1785 d = getmoduledict(m); | |
| 1786 | |
| 1787 /* Initialize posix.environ dictionary */ | |
| 1788 v = convertenviron(); | |
| 1789 if (v == NULL || dictinsert(d, "environ", v) != 0) | |
| 1790 fatal("can't define posix.environ"); | |
| 1791 DECREF(v); | |
| 1792 | |
| 2615 | 1793 #ifdef WNOHANG |
| 1794 /* Export WNOHANG symbol */ | |
| 1795 v = newintobject((long)WNOHANG); | |
| 1796 if (v == NULL || dictinsert(d, "WNOHANG", v) != 0) | |
| 1797 fatal("can't define posix.WNOHANG"); | |
| 1798 DECREF(v); | |
| 1799 #endif | |
| 1800 | |
| 6 | 1801 /* Initialize posix.error exception */ |
| 1802 PosixError = newstringobject("posix.error"); | |
| 1803 if (PosixError == NULL || dictinsert(d, "error", PosixError) != 0) | |
| 1804 fatal("can't define posix.error"); | |
| 1805 } | |
|
3601
5a7a76166e7e
Added mkfifo, ftruncate. Windows/PC changes.
Guido van Rossum <guido@python.org>
parents:
3418
diff
changeset
|
1806 #endif /* !_MSC_VER */ |
