Mercurial > emacs
annotate src/w32.c @ 16873:205ec6c5d8f3
* (interrupt_signal): Make emergency exit work on MSDOS
frames. Block further SIGINTs while `interrupt_signal' runs.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Thu, 16 Jan 1997 13:12:51 +0000 |
parents | 1c792ac8facd |
children | 36babc489b0c |
rev | line source |
---|---|
9803 | 1 /* Utility and Unix shadow routines for GNU Emacs on Windows NT. |
11384 | 2 Copyright (C) 1994, 1995 Free Software Foundation, Inc. |
9803 | 3 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13932
diff
changeset
|
4 This file is part of GNU Emacs. |
9803 | 5 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13932
diff
changeset
|
6 GNU Emacs is free software; you can redistribute it and/or modify |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13932
diff
changeset
|
7 it under the terms of the GNU General Public License as published by |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13932
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13932
diff
changeset
|
9 any later version. |
9803 | 10 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13932
diff
changeset
|
11 GNU Emacs is distributed in the hope that it will be useful, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13932
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13932
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13932
diff
changeset
|
14 GNU General Public License for more details. |
9803 | 15 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13932
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13932
diff
changeset
|
17 along with GNU Emacs; see the file COPYING. If not, write to |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13932
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13932
diff
changeset
|
19 Boston, MA 02111-1307, USA. |
9803 | 20 |
21 Geoff Voelker (voelker@cs.washington.edu) 7-29-94 | |
22 */ | |
23 | |
14246
ebdd1b50daba
(nt_stat): Use alloca instead of xmalloc.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
24 |
9803 | 25 #include <stdlib.h> |
26 #include <stdio.h> | |
27 #include <io.h> | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
28 #include <errno.h> |
9803 | 29 #include <fcntl.h> |
30 #include <ctype.h> | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
31 #include <signal.h> |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
32 #include <sys/time.h> |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
33 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
34 /* must include CRT headers *before* config.h */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
35 #include "config.h" |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
36 #undef access |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
37 #undef chdir |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
38 #undef chmod |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
39 #undef creat |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
40 #undef ctime |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
41 #undef fopen |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
42 #undef link |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
43 #undef mkdir |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
44 #undef mktemp |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
45 #undef open |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
46 #undef rename |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
47 #undef rmdir |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
48 #undef unlink |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
49 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
50 #undef close |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
51 #undef dup |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
52 #undef dup2 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
53 #undef pipe |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
54 #undef read |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
55 #undef write |
9803 | 56 |
57 #define getwd _getwd | |
58 #include "lisp.h" | |
59 #undef getwd | |
60 | |
61 #include <pwd.h> | |
62 | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
63 #include <windows.h> |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
64 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
65 #ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
66 #include <sys/socket.h> |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
67 #undef socket |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
68 #undef bind |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
69 #undef connect |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
70 #undef htons |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
71 #undef ntohs |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
72 #undef inet_addr |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
73 #undef gethostname |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
74 #undef gethostbyname |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
75 #undef getservbyname |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
76 #endif |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
77 |
16593
4ed80eda6fac
Use new names for w32 files
Geoff Voelker <voelker@cs.washington.edu>
parents:
16588
diff
changeset
|
78 #include "w32.h" |
9803 | 79 #include "ndir.h" |
16593
4ed80eda6fac
Use new names for w32 files
Geoff Voelker <voelker@cs.washington.edu>
parents:
16588
diff
changeset
|
80 #include "w32heap.h" |
9803 | 81 |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
82 /* Get the current working directory. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
83 char * |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
84 getwd (char *dir) |
14246
ebdd1b50daba
(nt_stat): Use alloca instead of xmalloc.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
85 { |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
86 if (GetCurrentDirectory (MAXPATHLEN, dir) > 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
87 return dir; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
88 return NULL; |
14246
ebdd1b50daba
(nt_stat): Use alloca instead of xmalloc.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
89 } |
ebdd1b50daba
(nt_stat): Use alloca instead of xmalloc.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
90 |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
91 #ifndef HAVE_SOCKETS |
9803 | 92 /* Emulate gethostname. */ |
93 int | |
94 gethostname (char *buffer, int size) | |
95 { | |
96 /* NT only allows small host names, so the buffer is | |
97 certainly large enough. */ | |
98 return !GetComputerName (buffer, &size); | |
99 } | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
100 #endif /* HAVE_SOCKETS */ |
9803 | 101 |
102 /* Emulate getloadavg. */ | |
103 int | |
104 getloadavg (double loadavg[], int nelem) | |
105 { | |
106 int i; | |
107 | |
108 /* A faithful emulation is going to have to be saved for a rainy day. */ | |
109 for (i = 0; i < nelem; i++) | |
110 { | |
111 loadavg[i] = 0.0; | |
112 } | |
113 return i; | |
114 } | |
115 | |
116 /* Emulate the Unix directory procedures opendir, closedir, | |
117 and readdir. We can't use the procedures supplied in sysdep.c, | |
118 so we provide them here. */ | |
119 | |
120 struct direct dir_static; /* simulated directory contents */ | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
121 static HANDLE dir_find_handle = INVALID_HANDLE_VALUE; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
122 static int dir_is_fat; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
123 static char dir_pathname[MAXPATHLEN+1]; |
9803 | 124 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
125 extern Lisp_Object Vw32_downcase_file_names; |
15326
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
126 |
9803 | 127 DIR * |
128 opendir (char *filename) | |
129 { | |
130 DIR *dirp; | |
131 | |
132 /* Opening is done by FindFirstFile. However, a read is inherent to | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
133 this operation, so we defer the open until read time. */ |
9803 | 134 |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
135 if (!(dirp = (DIR *) malloc (sizeof (DIR)))) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
136 return NULL; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
137 if (dir_find_handle != INVALID_HANDLE_VALUE) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
138 return NULL; |
9803 | 139 |
140 dirp->dd_fd = 0; | |
141 dirp->dd_loc = 0; | |
142 dirp->dd_size = 0; | |
143 | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
144 strncpy (dir_pathname, filename, MAXPATHLEN); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
145 dir_pathname[MAXPATHLEN] = '\0'; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
146 dir_is_fat = is_fat_volume (filename, NULL); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
147 |
9803 | 148 return dirp; |
149 } | |
150 | |
151 void | |
152 closedir (DIR *dirp) | |
153 { | |
154 /* If we have a find-handle open, close it. */ | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
155 if (dir_find_handle != INVALID_HANDLE_VALUE) |
9803 | 156 { |
157 FindClose (dir_find_handle); | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
158 dir_find_handle = INVALID_HANDLE_VALUE; |
9803 | 159 } |
160 xfree ((char *) dirp); | |
161 } | |
162 | |
163 struct direct * | |
164 readdir (DIR *dirp) | |
165 { | |
166 WIN32_FIND_DATA find_data; | |
167 | |
168 /* If we aren't dir_finding, do a find-first, otherwise do a find-next. */ | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
169 if (dir_find_handle == INVALID_HANDLE_VALUE) |
9803 | 170 { |
171 char filename[MAXNAMLEN + 3]; | |
172 int ln; | |
173 | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
174 strcpy (filename, dir_pathname); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
175 ln = strlen (filename) - 1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
176 if (!IS_DIRECTORY_SEP (filename[ln])) |
9803 | 177 strcat (filename, "\\"); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
178 strcat (filename, "*"); |
9803 | 179 |
180 dir_find_handle = FindFirstFile (filename, &find_data); | |
181 | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
182 if (dir_find_handle == INVALID_HANDLE_VALUE) |
9803 | 183 return NULL; |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
184 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
185 else |
9803 | 186 { |
187 if (!FindNextFile (dir_find_handle, &find_data)) | |
188 return NULL; | |
189 } | |
190 | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
191 /* Emacs never uses this value, so don't bother making it match |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
192 value returned by stat(). */ |
9803 | 193 dir_static.d_ino = 1; |
194 | |
195 dir_static.d_reclen = sizeof (struct direct) - MAXNAMLEN + 3 + | |
196 dir_static.d_namlen - dir_static.d_namlen % 4; | |
197 | |
198 dir_static.d_namlen = strlen (find_data.cFileName); | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
199 strcpy (dir_static.d_name, find_data.cFileName); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
200 if (dir_is_fat) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
201 _strlwr (dir_static.d_name); |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
202 else if (!NILP (Vw32_downcase_file_names)) |
15326
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
203 { |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
204 register char *p; |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
205 for (p = dir_static.d_name; *p; p++) |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
206 if (*p >= 'a' && *p <= 'z') |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
207 break; |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
208 if (!*p) |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
209 _strlwr (dir_static.d_name); |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
210 } |
9803 | 211 |
212 return &dir_static; | |
213 } | |
214 | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
215 /* Emulate getpwuid, getpwnam and others. */ |
9803 | 216 |
12451
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
217 #define PASSWD_FIELD_SIZE 256 |
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
218 |
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
219 static char the_passwd_name[PASSWD_FIELD_SIZE]; |
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
220 static char the_passwd_passwd[PASSWD_FIELD_SIZE]; |
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
221 static char the_passwd_gecos[PASSWD_FIELD_SIZE]; |
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
222 static char the_passwd_dir[PASSWD_FIELD_SIZE]; |
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
223 static char the_passwd_shell[PASSWD_FIELD_SIZE]; |
9803 | 224 |
225 static struct passwd the_passwd = | |
226 { | |
227 the_passwd_name, | |
228 the_passwd_passwd, | |
229 0, | |
230 0, | |
231 0, | |
232 the_passwd_gecos, | |
233 the_passwd_dir, | |
234 the_passwd_shell, | |
235 }; | |
236 | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
237 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
238 getuid () |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
239 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
240 return the_passwd.pw_uid; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
241 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
242 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
243 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
244 geteuid () |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
245 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
246 /* I could imagine arguing for checking to see whether the user is |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
247 in the Administrators group and returning a UID of 0 for that |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
248 case, but I don't know how wise that would be in the long run. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
249 return getuid (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
250 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
251 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
252 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
253 getgid () |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
254 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
255 return the_passwd.pw_gid; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
256 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
257 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
258 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
259 getegid () |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
260 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
261 return getgid (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
262 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
263 |
9803 | 264 struct passwd * |
265 getpwuid (int uid) | |
266 { | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
267 if (uid == the_passwd.pw_uid) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
268 return &the_passwd; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
269 return NULL; |
9803 | 270 } |
271 | |
272 struct passwd * | |
273 getpwnam (char *name) | |
274 { | |
275 struct passwd *pw; | |
276 | |
277 pw = getpwuid (getuid ()); | |
278 if (!pw) | |
279 return pw; | |
280 | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
281 if (stricmp (name, pw->pw_name)) |
9803 | 282 return NULL; |
283 | |
284 return pw; | |
285 } | |
286 | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
287 void |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
288 init_user_info () |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
289 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
290 /* Find the user's real name by opening the process token and |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
291 looking up the name associated with the user-sid in that token. |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
292 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
293 Use the relative portion of the identifier authority value from |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
294 the user-sid as the user id value (same for group id using the |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
295 primary group sid from the process token). */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
296 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
297 char user_sid[256], name[256], domain[256]; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
298 DWORD length = sizeof (name), dlength = sizeof (domain), trash; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
299 HANDLE token = NULL; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
300 SID_NAME_USE user_type; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
301 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
302 if (OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &token) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
303 && GetTokenInformation (token, TokenUser, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
304 (PVOID) user_sid, sizeof (user_sid), &trash) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
305 && LookupAccountSid (NULL, *((PSID *) user_sid), name, &length, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
306 domain, &dlength, &user_type)) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
307 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
308 strcpy (the_passwd.pw_name, name); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
309 /* Determine a reasonable uid value. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
310 if (stricmp ("administrator", name) == 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
311 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
312 the_passwd.pw_uid = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
313 the_passwd.pw_gid = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
314 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
315 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
316 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
317 SID_IDENTIFIER_AUTHORITY * pSIA; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
318 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
319 pSIA = GetSidIdentifierAuthority (*((PSID *) user_sid)); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
320 /* I believe the relative portion is the last 4 bytes (of 6) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
321 with msb first. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
322 the_passwd.pw_uid = ((pSIA->Value[2] << 24) + |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
323 (pSIA->Value[3] << 16) + |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
324 (pSIA->Value[4] << 8) + |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
325 (pSIA->Value[5] << 0)); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
326 /* restrict to conventional uid range for normal users */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
327 the_passwd.pw_uid = the_passwd.pw_uid % 60001; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
328 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
329 /* Get group id */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
330 if (GetTokenInformation (token, TokenPrimaryGroup, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
331 (PVOID) user_sid, sizeof (user_sid), &trash)) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
332 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
333 SID_IDENTIFIER_AUTHORITY * pSIA; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
334 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
335 pSIA = GetSidIdentifierAuthority (*((PSID *) user_sid)); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
336 the_passwd.pw_gid = ((pSIA->Value[2] << 24) + |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
337 (pSIA->Value[3] << 16) + |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
338 (pSIA->Value[4] << 8) + |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
339 (pSIA->Value[5] << 0)); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
340 /* I don't know if this is necessary, but for safety... */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
341 the_passwd.pw_gid = the_passwd.pw_gid % 60001; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
342 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
343 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
344 the_passwd.pw_gid = the_passwd.pw_uid; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
345 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
346 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
347 /* If security calls are not supported (presumably because we |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
348 are running under Windows 95), fallback to this. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
349 else if (GetUserName (name, &length)) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
350 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
351 strcpy (the_passwd.pw_name, name); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
352 if (stricmp ("administrator", name) == 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
353 the_passwd.pw_uid = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
354 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
355 the_passwd.pw_uid = 123; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
356 the_passwd.pw_gid = the_passwd.pw_uid; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
357 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
358 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
359 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
360 strcpy (the_passwd.pw_name, "unknown"); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
361 the_passwd.pw_uid = 123; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
362 the_passwd.pw_gid = 123; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
363 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
364 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
365 /* Ensure HOME and SHELL are defined. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
366 if (getenv ("HOME") == NULL) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
367 putenv ("HOME=c:/"); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
368 if (getenv ("SHELL") == NULL) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
369 putenv ((GetVersion () & 0x80000000) ? "SHELL=command" : "SHELL=cmd"); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
370 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
371 /* Set dir and shell from environment variables. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
372 strcpy (the_passwd.pw_dir, getenv ("HOME")); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
373 strcpy (the_passwd.pw_shell, getenv ("SHELL")); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
374 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
375 if (token) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
376 CloseHandle (token); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
377 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
378 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
379 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
380 random () |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
381 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
382 /* rand () on NT gives us 15 random bits...hack together 30 bits. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
383 return ((rand () << 15) | rand ()); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
384 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
385 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
386 void |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
387 srandom (int seed) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
388 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
389 srand (seed); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
390 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
391 |
15326
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
392 /* Normalize filename by converting all path separators to |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
393 the specified separator. Also conditionally convert upper |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
394 case path name components to lower case. */ |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
395 |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
396 static void |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
397 normalize_filename (fp, path_sep) |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
398 register char *fp; |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
399 char path_sep; |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
400 { |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
401 char sep; |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
402 char *elem; |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
403 |
15615
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
404 /* Always lower-case drive letters a-z, even if the filesystem |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
405 preserves case in filenames. |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
406 This is so filenames can be compared by string comparison |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
407 functions that are case-sensitive. Even case-preserving filesystems |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
408 do not distinguish case in drive letters. */ |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
409 if (fp[1] == ':' && *fp >= 'A' && *fp <= 'Z') |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
410 { |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
411 *fp += 'a' - 'A'; |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
412 fp += 2; |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
413 } |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
414 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
415 if (NILP (Vw32_downcase_file_names)) |
15326
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
416 { |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
417 while (*fp) |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
418 { |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
419 if (*fp == '/' || *fp == '\\') |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
420 *fp = path_sep; |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
421 fp++; |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
422 } |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
423 return; |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
424 } |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
425 |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
426 sep = path_sep; /* convert to this path separator */ |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
427 elem = fp; /* start of current path element */ |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
428 |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
429 do { |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
430 if (*fp >= 'a' && *fp <= 'z') |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
431 elem = 0; /* don't convert this element */ |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
432 |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
433 if (*fp == 0 || *fp == ':') |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
434 { |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
435 sep = *fp; /* restore current separator (or 0) */ |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
436 *fp = '/'; /* after conversion of this element */ |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
437 } |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
438 |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
439 if (*fp == '/' || *fp == '\\') |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
440 { |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
441 if (elem && elem != fp) |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
442 { |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
443 *fp = 0; /* temporary end of string */ |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
444 _strlwr (elem); /* while we convert to lower case */ |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
445 } |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
446 *fp = sep; /* convert (or restore) path separator */ |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
447 elem = fp + 1; /* next element starts after separator */ |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
448 sep = path_sep; |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
449 } |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
450 } while (*fp++); |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
451 } |
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
452 |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
453 /* Destructively turn backslashes into slashes. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
454 void |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
455 dostounix_filename (p) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
456 register char *p; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
457 { |
15326
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
458 normalize_filename (p, '/'); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
459 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
460 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
461 /* Destructively turn slashes into backslashes. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
462 void |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
463 unixtodos_filename (p) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
464 register char *p; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
465 { |
15326
ea444efb0b95
(normalize_filename): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15279
diff
changeset
|
466 normalize_filename (p, '\\'); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
467 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
468 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
469 /* Remove all CR's that are followed by a LF. |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
470 (From msdos.c...probably should figure out a way to share it, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
471 although this code isn't going to ever change.) */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
472 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
473 crlf_to_lf (n, buf) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
474 register int n; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
475 register unsigned char *buf; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
476 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
477 unsigned char *np = buf; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
478 unsigned char *startp = buf; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
479 unsigned char *endp = buf + n; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
480 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
481 if (n == 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
482 return n; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
483 while (buf < endp - 1) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
484 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
485 if (*buf == 0x0d) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
486 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
487 if (*(++buf) != 0x0a) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
488 *np++ = 0x0d; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
489 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
490 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
491 *np++ = *buf++; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
492 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
493 if (buf < endp) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
494 *np++ = *buf++; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
495 return np - startp; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
496 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
497 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
498 /* Routines that are no-ops on NT but are defined to get Emacs to compile. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
499 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
500 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
501 sigsetmask (int signal_mask) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
502 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
503 return 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
504 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
505 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
506 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
507 sigblock (int sig) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
508 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
509 return 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
510 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
511 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
512 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
513 setpgrp (int pid, int gid) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
514 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
515 return 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
516 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
517 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
518 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
519 alarm (int seconds) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
520 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
521 return 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
522 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
523 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
524 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
525 unrequest_sigio (void) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
526 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
527 return 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
528 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
529 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
530 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
531 request_sigio (void) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
532 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
533 return 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
534 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
535 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
536 #define REG_ROOT "SOFTWARE\\GNU\\Emacs" |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
537 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
538 LPBYTE |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
539 w32_get_resource (key, lpdwtype) |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
540 char *key; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
541 LPDWORD lpdwtype; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
542 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
543 LPBYTE lpvalue; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
544 HKEY hrootkey = NULL; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
545 DWORD cbData; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
546 BOOL ok = FALSE; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
547 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
548 /* Check both the current user and the local machine to see if |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
549 we have any resources. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
550 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
551 if (RegOpenKeyEx (HKEY_CURRENT_USER, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
552 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
553 lpvalue = NULL; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
554 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
555 if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
556 && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
557 && RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) == ERROR_SUCCESS) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
558 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
559 return (lpvalue); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
560 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
561 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
562 if (lpvalue) xfree (lpvalue); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
563 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
564 RegCloseKey (hrootkey); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
565 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
566 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
567 if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
568 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
569 lpvalue = NULL; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
570 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
571 if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS && |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
572 (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL && |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
573 RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) == ERROR_SUCCESS) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
574 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
575 return (lpvalue); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
576 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
577 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
578 if (lpvalue) xfree (lpvalue); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
579 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
580 RegCloseKey (hrootkey); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
581 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
582 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
583 return (NULL); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
584 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
585 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
586 void |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
587 init_environment () |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
588 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
589 /* Check for environment variables and use registry if they don't exist */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
590 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
591 int i; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
592 LPBYTE lpval; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
593 DWORD dwType; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
594 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
595 static char * env_vars[] = |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
596 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
597 "HOME", |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
598 "PRELOAD_WINSOCK", |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
599 "emacs_dir", |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
600 "EMACSLOADPATH", |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
601 "SHELL", |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
602 "EMACSDATA", |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
603 "EMACSPATH", |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
604 "EMACSLOCKDIR", |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
605 "INFOPATH", |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
606 "EMACSDOC", |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
607 "TERM", |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
608 }; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
609 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
610 for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
611 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
612 if (!getenv (env_vars[i]) && |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
613 (lpval = w32_get_resource (env_vars[i], &dwType)) != NULL) |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
614 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
615 if (dwType == REG_EXPAND_SZ) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
616 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
617 char buf1[500], buf2[500]; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
618 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
619 ExpandEnvironmentStrings ((LPSTR) lpval, buf1, 500); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
620 _snprintf (buf2, 499, "%s=%s", env_vars[i], buf1); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
621 putenv (strdup (buf2)); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
622 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
623 else if (dwType == REG_SZ) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
624 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
625 char buf[500]; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
626 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
627 _snprintf (buf, 499, "%s=%s", env_vars[i], lpval); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
628 putenv (strdup (buf)); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
629 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
630 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
631 xfree (lpval); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
632 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
633 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
634 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
635 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
636 init_user_info (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
637 } |
9803 | 638 |
639 /* We don't have scripts to automatically determine the system configuration | |
640 for Emacs before it's compiled, and we don't want to have to make the | |
641 user enter it, so we define EMACS_CONFIGURATION to invoke this runtime | |
642 routine. */ | |
643 | |
11941
cb26a4ca0e10
(configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents:
11384
diff
changeset
|
644 static char configuration_buffer[32]; |
9803 | 645 |
646 char * | |
647 get_emacs_configuration (void) | |
648 { | |
13156 | 649 char *arch, *oem, *os; |
9803 | 650 |
13156 | 651 /* Determine the processor type. */ |
652 switch (get_processor_type ()) | |
653 { | |
12451
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
654 |
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
655 #ifdef PROCESSOR_INTEL_386 |
13156 | 656 case PROCESSOR_INTEL_386: |
657 case PROCESSOR_INTEL_486: | |
658 case PROCESSOR_INTEL_PENTIUM: | |
659 arch = "i386"; | |
660 break; | |
12451
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
661 #endif |
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
662 |
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
663 #ifdef PROCESSOR_INTEL_860 |
13156 | 664 case PROCESSOR_INTEL_860: |
665 arch = "i860"; | |
666 break; | |
12451
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
667 #endif |
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
668 |
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
669 #ifdef PROCESSOR_MIPS_R2000 |
13156 | 670 case PROCESSOR_MIPS_R2000: |
671 case PROCESSOR_MIPS_R3000: | |
672 case PROCESSOR_MIPS_R4000: | |
673 arch = "mips"; | |
674 break; | |
12451
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
675 #endif |
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
676 |
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
677 #ifdef PROCESSOR_ALPHA_21064 |
13156 | 678 case PROCESSOR_ALPHA_21064: |
679 arch = "alpha"; | |
680 break; | |
12451
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
681 #endif |
4439dcb1496a
(PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12183
diff
changeset
|
682 |
13156 | 683 default: |
684 arch = "unknown"; | |
685 break; | |
686 } | |
9803 | 687 |
13156 | 688 /* Let oem be "*" until we figure out how to decode the OEM field. */ |
689 oem = "*"; | |
9803 | 690 |
16867
1c792ac8facd
(get_emacs_configuration): Return windows95 instead of win95.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
691 os = (GetVersion () & 0x80000000) ? "windows95" : "nt"; |
11941
cb26a4ca0e10
(configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents:
11384
diff
changeset
|
692 |
13156 | 693 sprintf (configuration_buffer, "%s-%s-%s%d.%d", arch, oem, os, |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
694 get_w32_major_version (), get_w32_minor_version ()); |
13156 | 695 return configuration_buffer; |
9803 | 696 } |
697 | |
11384 | 698 #include <sys/timeb.h> |
699 | |
700 /* Emulate gettimeofday (Ulrich Leodolter, 1/11/95). */ | |
701 void | |
702 gettimeofday (struct timeval *tv, struct timezone *tz) | |
703 { | |
704 struct _timeb tb; | |
705 _ftime (&tb); | |
706 | |
707 tv->tv_sec = tb.time; | |
708 tv->tv_usec = tb.millitm * 1000L; | |
709 if (tz) | |
710 { | |
711 tz->tz_minuteswest = tb.timezone; /* minutes west of Greenwich */ | |
712 tz->tz_dsttime = tb.dstflag; /* type of dst correction */ | |
713 } | |
714 } | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
715 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
716 /* ------------------------------------------------------------------------- */ |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
717 /* IO support and wrapper functions for W32 API. */ |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
718 /* ------------------------------------------------------------------------- */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
719 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
720 /* Place a wrapper around the MSVC version of ctime. It returns NULL |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
721 on network directories, so we handle that case here. |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
722 (Ulrich Leodolter, 1/11/95). */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
723 char * |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
724 sys_ctime (const time_t *t) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
725 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
726 char *str = (char *) ctime (t); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
727 return (str ? str : "Sun Jan 01 00:00:00 1970"); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
728 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
729 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
730 /* Emulate sleep...we could have done this with a define, but that |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
731 would necessitate including windows.h in the files that used it. |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
732 This is much easier. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
733 void |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
734 sys_sleep (int seconds) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
735 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
736 Sleep (seconds * 1000); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
737 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
738 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
739 /* Internal MSVC data and functions for low-level descriptor munging */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
740 #if (_MSC_VER == 900) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
741 extern char _osfile[]; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
742 #endif |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
743 extern int __cdecl _set_osfhnd (int fd, long h); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
744 extern int __cdecl _free_osfhnd (int fd); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
745 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
746 /* parallel array of private info on file handles */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
747 filedesc fd_info [ MAXDESC ]; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
748 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
749 static struct { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
750 DWORD serialnum; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
751 DWORD maxcomp; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
752 DWORD flags; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
753 char name[32]; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
754 char type[32]; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
755 } volume_info; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
756 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
757 /* Get information on the volume where name is held; set path pointer to |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
758 start of pathname in name (past UNC header\volume header if present). */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
759 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
760 get_volume_info (const char * name, const char ** pPath) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
761 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
762 char temp[MAX_PATH]; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
763 char *rootname = NULL; /* default to current volume */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
764 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
765 if (name == NULL) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
766 return FALSE; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
767 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
768 /* find the root name of the volume if given */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
769 if (isalpha (name[0]) && name[1] == ':') |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
770 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
771 rootname = temp; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
772 temp[0] = *name++; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
773 temp[1] = *name++; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
774 temp[2] = '\\'; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
775 temp[3] = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
776 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
777 else if (IS_DIRECTORY_SEP (name[0]) && IS_DIRECTORY_SEP (name[1])) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
778 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
779 char *str = temp; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
780 int slashes = 4; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
781 rootname = temp; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
782 do |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
783 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
784 if (IS_DIRECTORY_SEP (*name) && --slashes == 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
785 break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
786 *str++ = *name++; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
787 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
788 while ( *name ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
789 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
790 *str++ = '\\'; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
791 *str = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
792 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
793 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
794 if (pPath) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
795 *pPath = name; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
796 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
797 if (GetVolumeInformation (rootname, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
798 volume_info.name, 32, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
799 &volume_info.serialnum, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
800 &volume_info.maxcomp, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
801 &volume_info.flags, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
802 volume_info.type, 32)) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
803 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
804 return TRUE; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
805 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
806 return FALSE; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
807 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
808 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
809 /* Determine if volume is FAT format (ie. only supports short 8.3 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
810 names); also set path pointer to start of pathname in name. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
811 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
812 is_fat_volume (const char * name, const char ** pPath) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
813 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
814 if (get_volume_info (name, pPath)) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
815 return (volume_info.maxcomp == 12); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
816 return FALSE; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
817 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
818 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
819 /* Map filename to a legal 8.3 name if necessary. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
820 const char * |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
821 map_w32_filename (const char * name, const char ** pPath) |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
822 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
823 static char shortname[MAX_PATH]; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
824 char * str = shortname; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
825 char c; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
826 char * path; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
827 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
828 if (is_fat_volume (name, &path)) /* truncate to 8.3 */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
829 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
830 register int left = 8; /* maximum number of chars in part */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
831 register int extn = 0; /* extension added? */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
832 register int dots = 2; /* maximum number of dots allowed */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
833 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
834 while (name < path) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
835 *str++ = *name++; /* skip past UNC header */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
836 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
837 while ((c = *name++)) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
838 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
839 switch ( c ) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
840 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
841 case '\\': |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
842 case '/': |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
843 *str++ = '\\'; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
844 extn = 0; /* reset extension flags */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
845 dots = 2; /* max 2 dots */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
846 left = 8; /* max length 8 for main part */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
847 break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
848 case ':': |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
849 *str++ = ':'; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
850 extn = 0; /* reset extension flags */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
851 dots = 2; /* max 2 dots */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
852 left = 8; /* max length 8 for main part */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
853 break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
854 case '.': |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
855 if ( dots ) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
856 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
857 /* Convert path components of the form .xxx to _xxx, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
858 but leave . and .. as they are. This allows .emacs |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
859 to be read as _emacs, for example. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
860 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
861 if (! *name || |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
862 *name == '.' || |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
863 IS_DIRECTORY_SEP (*name)) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
864 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
865 *str++ = '.'; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
866 dots--; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
867 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
868 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
869 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
870 *str++ = '_'; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
871 left--; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
872 dots = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
873 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
874 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
875 else if ( !extn ) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
876 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
877 *str++ = '.'; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
878 extn = 1; /* we've got an extension */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
879 left = 3; /* 3 chars in extension */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
880 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
881 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
882 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
883 /* any embedded dots after the first are converted to _ */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
884 *str++ = '_'; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
885 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
886 break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
887 case '~': |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
888 case '#': /* don't lose these, they're important */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
889 if ( ! left ) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
890 str[-1] = c; /* replace last character of part */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
891 /* FALLTHRU */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
892 default: |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
893 if ( left ) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
894 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
895 *str++ = tolower (c); /* map to lower case (looks nicer) */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
896 left--; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
897 dots = 0; /* started a path component */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
898 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
899 break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
900 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
901 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
902 *str = '\0'; |
15213
867e4ead88d9
(map_win32_filename): If not a fat volume, cvt name to dos.
Richard M. Stallman <rms@gnu.org>
parents:
15141
diff
changeset
|
903 } |
867e4ead88d9
(map_win32_filename): If not a fat volume, cvt name to dos.
Richard M. Stallman <rms@gnu.org>
parents:
15141
diff
changeset
|
904 else |
867e4ead88d9
(map_win32_filename): If not a fat volume, cvt name to dos.
Richard M. Stallman <rms@gnu.org>
parents:
15141
diff
changeset
|
905 { |
867e4ead88d9
(map_win32_filename): If not a fat volume, cvt name to dos.
Richard M. Stallman <rms@gnu.org>
parents:
15141
diff
changeset
|
906 strcpy (shortname, name); |
867e4ead88d9
(map_win32_filename): If not a fat volume, cvt name to dos.
Richard M. Stallman <rms@gnu.org>
parents:
15141
diff
changeset
|
907 unixtodos_filename (shortname); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
908 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
909 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
910 if (pPath) |
15213
867e4ead88d9
(map_win32_filename): If not a fat volume, cvt name to dos.
Richard M. Stallman <rms@gnu.org>
parents:
15141
diff
changeset
|
911 *pPath = shortname + (path - name); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
912 |
15213
867e4ead88d9
(map_win32_filename): If not a fat volume, cvt name to dos.
Richard M. Stallman <rms@gnu.org>
parents:
15141
diff
changeset
|
913 return shortname; |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
914 } |
11384 | 915 |
9803 | 916 |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
917 /* Shadow some MSVC runtime functions to map requests for long filenames |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
918 to reasonable short names if necessary. This was originally added to |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
919 permit running Emacs on NT 3.1 on a FAT partition, which doesn't support |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
920 long file names. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
921 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
922 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
923 sys_access (const char * path, int mode) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
924 { |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
925 return _access (map_w32_filename (path, NULL), mode); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
926 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
927 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
928 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
929 sys_chdir (const char * path) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
930 { |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
931 return _chdir (map_w32_filename (path, NULL)); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
932 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
933 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
934 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
935 sys_chmod (const char * path, int mode) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
936 { |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
937 return _chmod (map_w32_filename (path, NULL), mode); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
938 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
939 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
940 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
941 sys_creat (const char * path, int mode) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
942 { |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
943 return _creat (map_w32_filename (path, NULL), mode); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
944 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
945 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
946 FILE * |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
947 sys_fopen(const char * path, const char * mode) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
948 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
949 int fd; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
950 int oflag; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
951 const char * mode_save = mode; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
952 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
953 /* Force all file handles to be non-inheritable. This is necessary to |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
954 ensure child processes don't unwittingly inherit handles that might |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
955 prevent future file access. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
956 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
957 if (mode[0] == 'r') |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
958 oflag = O_RDONLY; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
959 else if (mode[0] == 'w' || mode[0] == 'a') |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
960 oflag = O_WRONLY | O_CREAT | O_TRUNC; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
961 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
962 return NULL; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
963 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
964 /* Only do simplistic option parsing. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
965 while (*++mode) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
966 if (mode[0] == '+') |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
967 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
968 oflag &= ~(O_RDONLY | O_WRONLY); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
969 oflag |= O_RDWR; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
970 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
971 else if (mode[0] == 'b') |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
972 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
973 oflag &= ~O_TEXT; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
974 oflag |= O_BINARY; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
975 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
976 else if (mode[0] == 't') |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
977 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
978 oflag &= ~O_BINARY; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
979 oflag |= O_TEXT; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
980 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
981 else break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
982 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
983 fd = _open (map_w32_filename (path, NULL), oflag | _O_NOINHERIT, 0644); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
984 if (fd < 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
985 return NULL; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
986 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
987 return fdopen (fd, mode_save); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
988 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
989 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
990 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
991 sys_link (const char * path1, const char * path2) |
9803 | 992 { |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
993 errno = EINVAL; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
994 return -1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
995 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
996 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
997 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
998 sys_mkdir (const char * path) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
999 { |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
1000 return _mkdir (map_w32_filename (path, NULL)); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1001 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1002 |
15354
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1003 /* Because of long name mapping issues, we need to implement this |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1004 ourselves. Also, MSVC's _mktemp returns NULL when it can't generate |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1005 a unique name, instead of setting the input template to an empty |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1006 string. |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1007 |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1008 Standard algorithm seems to be use pid or tid with a letter on the |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1009 front (in place of the 6 X's) and cycle through the letters to find a |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1010 unique name. We extend that to allow any reasonable character as the |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1011 first of the 6 X's. */ |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1012 char * |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1013 sys_mktemp (char * template) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1014 { |
15354
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1015 char * p; |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1016 int i; |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1017 unsigned uid = GetCurrentThreadId (); |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1018 static char first_char[] = "abcdefghijklmnopqrstuvwyz0123456789!%-_@#"; |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1019 |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1020 if (template == NULL) |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1021 return NULL; |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1022 p = template + strlen (template); |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1023 i = 5; |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1024 /* replace up to the last 5 X's with uid in decimal */ |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1025 while (--p >= template && p[0] == 'X' && --i >= 0) |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1026 { |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1027 p[0] = '0' + uid % 10; |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1028 uid /= 10; |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1029 } |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1030 |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1031 if (i < 0 && p[0] == 'X') |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1032 { |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1033 i = 0; |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1034 do |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1035 { |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1036 int save_errno = errno; |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1037 p[0] = first_char[i]; |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1038 if (sys_access (template, 0) < 0) |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1039 { |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1040 errno = save_errno; |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1041 return template; |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1042 } |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1043 } |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1044 while (++i < sizeof (first_char)); |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1045 } |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1046 |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1047 /* Template is badly formed or else we can't generate a unique name, |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1048 so return empty string */ |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1049 template[0] = 0; |
0e45e7d8bfdf
(sys_mktemp): Complete rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
15342
diff
changeset
|
1050 return template; |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1051 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1052 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1053 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1054 sys_open (const char * path, int oflag, int mode) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1055 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1056 /* Force all file handles to be non-inheritable. */ |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
1057 return _open (map_w32_filename (path, NULL), oflag | _O_NOINHERIT, mode); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1058 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1059 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1060 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1061 sys_rename (const char * oldname, const char * newname) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1062 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1063 char temp[MAX_PATH]; |
15615
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1064 DWORD attr; |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1065 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1066 /* MoveFile on Win95 doesn't correctly change the short file name |
15615
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1067 alias in a number of circumstances (it is not easy to predict when |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1068 just by looking at oldname and newname, unfortunately). In these |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1069 cases, renaming through a temporary name avoids the problem. |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1070 |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1071 A second problem on Win95 is that renaming through a temp name when |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1072 newname is uppercase fails (the final long name ends up in |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1073 lowercase, although the short alias might be uppercase) UNLESS the |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1074 long temp name is not 8.3. |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1075 |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1076 So, on Win95 we always rename through a temp name, and we make sure |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1077 the temp name has a long extension to ensure correct renaming. */ |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1078 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
1079 strcpy (temp, map_w32_filename (oldname, NULL)); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1080 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1081 if (GetVersion () & 0x80000000) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1082 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1083 char * p; |
9803 | 1084 |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1085 if (p = strrchr (temp, '\\')) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1086 p++; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1087 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1088 p = temp; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1089 strcpy (p, "__XXXXXX"); |
15615
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1090 sys_mktemp (temp); |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1091 /* Force temp name to require a manufactured 8.3 alias - this |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1092 seems to make the second rename work properly. */ |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1093 strcat (temp, ".long"); |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
1094 if (rename (map_w32_filename (oldname, NULL), temp) < 0) |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1095 return -1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1096 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1097 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1098 /* Emulate Unix behaviour - newname is deleted if it already exists |
15615
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1099 (at least if it is a file; don't do this for directories). |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1100 However, don't do this if we are just changing the case of the file |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1101 name - we will end up deleting the file we are trying to rename! */ |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
1102 newname = map_w32_filename (newname, NULL); |
15615
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1103 if (stricmp (newname, temp) != 0 |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1104 && (attr = GetFileAttributes (newname)) != -1 |
124e347ce827
(normalize_filename): Always lower-case drive letters, even on systems
Miles Bader <miles@gnu.org>
parents:
15418
diff
changeset
|
1105 && (attr & FILE_ATTRIBUTE_DIRECTORY) == 0) |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1106 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1107 _chmod (newname, 0666); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1108 _unlink (newname); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1109 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1110 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1111 return rename (temp, newname); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1112 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1113 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1114 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1115 sys_rmdir (const char * path) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1116 { |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
1117 return _rmdir (map_w32_filename (path, NULL)); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1118 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1119 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1120 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1121 sys_unlink (const char * path) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1122 { |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
1123 return _unlink (map_w32_filename (path, NULL)); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1124 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1125 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1126 static FILETIME utc_base_ft; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1127 static long double utc_base; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1128 static int init = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1129 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1130 static time_t |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1131 convert_time (FILETIME ft) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1132 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1133 long double ret; |
9803 | 1134 |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1135 if (!init) |
9803 | 1136 { |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1137 /* Determine the delta between 1-Jan-1601 and 1-Jan-1970. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1138 SYSTEMTIME st; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1139 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1140 st.wYear = 1970; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1141 st.wMonth = 1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1142 st.wDay = 1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1143 st.wHour = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1144 st.wMinute = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1145 st.wSecond = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1146 st.wMilliseconds = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1147 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1148 SystemTimeToFileTime (&st, &utc_base_ft); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1149 utc_base = (long double) utc_base_ft.dwHighDateTime |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1150 * 4096 * 1024 * 1024 + utc_base_ft.dwLowDateTime; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1151 init = 1; |
9803 | 1152 } |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1153 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1154 if (CompareFileTime (&ft, &utc_base_ft) < 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1155 return 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1156 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1157 ret = (long double) ft.dwHighDateTime * 4096 * 1024 * 1024 + ft.dwLowDateTime; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1158 ret -= utc_base; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1159 return (time_t) (ret * 1e-7); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1160 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1161 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1162 #if 0 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1163 /* in case we ever have need of this */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1164 void |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1165 convert_from_time_t (time_t time, FILETIME * pft) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1166 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1167 long double tmp; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1168 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1169 if (!init) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1170 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1171 /* Determine the delta between 1-Jan-1601 and 1-Jan-1970. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1172 SYSTEMTIME st; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1173 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1174 st.wYear = 1970; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1175 st.wMonth = 1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1176 st.wDay = 1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1177 st.wHour = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1178 st.wMinute = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1179 st.wSecond = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1180 st.wMilliseconds = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1181 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1182 SystemTimeToFileTime (&st, &utc_base_ft); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1183 utc_base = (long double) utc_base_ft.dwHighDateTime |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1184 * 4096 * 1024 * 1024 + utc_base_ft.dwLowDateTime; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1185 init = 1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1186 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1187 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1188 /* time in 100ns units since 1-Jan-1601 */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1189 tmp = (long double) time * 1e7 + utc_base; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1190 pft->dwHighDateTime = (DWORD) (tmp / (4096.0 * 1024 * 1024)); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1191 pft->dwLowDateTime = (DWORD) (tmp - pft->dwHighDateTime); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1192 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1193 #endif |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1194 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1195 /* "PJW" algorithm (see the "Dragon" compiler book). */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1196 static unsigned |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1197 hashval (const char * str) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1198 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1199 unsigned h = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1200 unsigned g; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1201 while (*str) |
9803 | 1202 { |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1203 h = (h << 4) + *str++; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1204 if ((g = h & 0xf0000000) != 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1205 h = (h ^ (g >> 24)) & 0x0fffffff; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1206 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1207 return h; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1208 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1209 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1210 /* Return the hash value of the canonical pathname, excluding the |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1211 drive/UNC header, to get a hopefully unique inode number. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1212 static _ino_t |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1213 generate_inode_val (const char * name) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1214 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1215 char fullname[ MAX_PATH ]; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1216 char * p; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1217 unsigned hash; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1218 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1219 GetFullPathName (name, sizeof (fullname), fullname, &p); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1220 get_volume_info (fullname, &p); |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
1221 /* Normal W32 filesystems are still case insensitive. */ |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1222 _strlwr (p); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1223 hash = hashval (p); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1224 return (_ino_t) (hash ^ (hash >> 16)); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1225 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1226 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1227 /* MSVC stat function can't cope with UNC names and has other bugs, so |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1228 replace it with our own. This also allows us to calculate consistent |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1229 inode values without hacks in the main Emacs code. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1230 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1231 stat (const char * path, struct stat * buf) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1232 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1233 char * name; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1234 WIN32_FIND_DATA wfd; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1235 HANDLE fh; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1236 int permission; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1237 int len; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1238 int rootdir = FALSE; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1239 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1240 if (path == NULL || buf == NULL) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1241 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1242 errno = EFAULT; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1243 return -1; |
9803 | 1244 } |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1245 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
1246 name = (char *) map_w32_filename (path, &path); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1247 /* must be valid filename, no wild cards */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1248 if (strchr (name, '*') || strchr (name, '?')) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1249 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1250 errno = ENOENT; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1251 return -1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1252 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1253 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1254 /* Remove trailing directory separator, unless name is the root |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1255 directory of a drive or UNC volume in which case ensure there |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1256 is a trailing separator. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1257 len = strlen (name); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1258 rootdir = (path >= name + len - 1 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1259 && (IS_DIRECTORY_SEP (*path) || *path == 0)); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1260 name = strcpy (alloca (len + 2), name); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1261 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1262 if (rootdir) |
9803 | 1263 { |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1264 if (!IS_DIRECTORY_SEP (name[len-1])) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1265 strcat (name, "\\"); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1266 if (GetDriveType (name) < 2) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1267 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1268 errno = ENOENT; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1269 return -1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1270 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1271 memset (&wfd, 0, sizeof (wfd)); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1272 wfd.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1273 wfd.ftCreationTime = utc_base_ft; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1274 wfd.ftLastAccessTime = utc_base_ft; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1275 wfd.ftLastWriteTime = utc_base_ft; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1276 strcpy (wfd.cFileName, name); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1277 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1278 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1279 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1280 if (IS_DIRECTORY_SEP (name[len-1])) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1281 name[len - 1] = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1282 fh = FindFirstFile (name, &wfd); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1283 if (fh == INVALID_HANDLE_VALUE) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1284 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1285 errno = ENOENT; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1286 return -1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1287 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1288 FindClose (fh); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1289 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1290 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1291 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1292 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1293 buf->st_mode = _S_IFDIR; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1294 buf->st_nlink = 2; /* doesn't really matter */ |
9803 | 1295 } |
1296 else | |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1297 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1298 #if 0 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1299 /* This is more accurate in terms of gettting the correct number |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1300 of links, but is quite slow (it is noticable when Emacs is |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1301 making a list of file name completions). */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1302 BY_HANDLE_FILE_INFORMATION info; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1303 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1304 fh = CreateFile (name, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1305 NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1306 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1307 if (GetFileInformationByHandle (fh, &info)) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1308 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1309 switch (GetFileType (fh)) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1310 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1311 case FILE_TYPE_DISK: |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1312 buf->st_mode = _S_IFREG; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1313 break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1314 case FILE_TYPE_PIPE: |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1315 buf->st_mode = _S_IFIFO; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1316 break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1317 case FILE_TYPE_CHAR: |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1318 case FILE_TYPE_UNKNOWN: |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1319 default: |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1320 buf->st_mode = _S_IFCHR; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1321 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1322 buf->st_nlink = info.nNumberOfLinks; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1323 /* Could use file index, but this is not guaranteed to be |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1324 unique unless we keep a handle open all the time. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1325 /* buf->st_ino = info.nFileIndexLow ^ info.nFileIndexHigh; */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1326 CloseHandle (fh); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1327 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1328 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1329 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1330 errno = EACCES; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1331 return -1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1332 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1333 #else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1334 buf->st_mode = _S_IFREG; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1335 buf->st_nlink = 1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1336 #endif |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1337 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1338 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1339 /* consider files to belong to current user */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1340 buf->st_uid = the_passwd.pw_uid; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1341 buf->st_gid = the_passwd.pw_gid; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1342 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
1343 /* volume_info is set indirectly by map_w32_filename */ |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1344 buf->st_dev = volume_info.serialnum; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1345 buf->st_rdev = volume_info.serialnum; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1346 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1347 buf->st_ino = generate_inode_val (name); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1348 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1349 buf->st_size = wfd.nFileSizeLow; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1350 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1351 /* Convert timestamps to Unix format. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1352 buf->st_mtime = convert_time (wfd.ftLastWriteTime); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1353 buf->st_atime = convert_time (wfd.ftLastAccessTime); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1354 if (buf->st_atime == 0) buf->st_atime = buf->st_mtime; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1355 buf->st_ctime = convert_time (wfd.ftCreationTime); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1356 if (buf->st_ctime == 0) buf->st_ctime = buf->st_mtime; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1357 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1358 /* determine rwx permissions */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1359 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1360 permission = _S_IREAD; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1361 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1362 permission = _S_IREAD | _S_IWRITE; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1363 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1364 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1365 permission |= _S_IEXEC; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1366 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1367 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1368 char * p = strrchr (name, '.'); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1369 if (p != NULL && |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1370 (stricmp (p, ".exe") == 0 || |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1371 stricmp (p, ".com") == 0 || |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1372 stricmp (p, ".bat") == 0 || |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1373 stricmp (p, ".cmd") == 0)) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1374 permission |= _S_IEXEC; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1375 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1376 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1377 buf->st_mode |= permission | (permission >> 3) | (permission >> 6); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1378 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1379 return 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1380 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1381 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1382 #ifdef HAVE_SOCKETS |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1383 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1384 /* Wrappers for winsock functions to map between our file descriptors |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1385 and winsock's handles; also set h_errno for convenience. |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1386 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1387 To allow Emacs to run on systems which don't have winsock support |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1388 installed, we dynamically link to winsock on startup if present, and |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1389 otherwise provide the minimum necessary functionality |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1390 (eg. gethostname). */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1391 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1392 /* function pointers for relevant socket functions */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1393 int (PASCAL *pfn_WSAStartup) (WORD wVersionRequired, LPWSADATA lpWSAData); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1394 void (PASCAL *pfn_WSASetLastError) (int iError); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1395 int (PASCAL *pfn_WSAGetLastError) (void); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1396 int (PASCAL *pfn_socket) (int af, int type, int protocol); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1397 int (PASCAL *pfn_bind) (SOCKET s, const struct sockaddr *addr, int namelen); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1398 int (PASCAL *pfn_connect) (SOCKET s, const struct sockaddr *addr, int namelen); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1399 int (PASCAL *pfn_ioctlsocket) (SOCKET s, long cmd, u_long *argp); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1400 int (PASCAL *pfn_recv) (SOCKET s, char * buf, int len, int flags); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1401 int (PASCAL *pfn_send) (SOCKET s, const char * buf, int len, int flags); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1402 int (PASCAL *pfn_closesocket) (SOCKET s); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1403 int (PASCAL *pfn_shutdown) (SOCKET s, int how); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1404 int (PASCAL *pfn_WSACleanup) (void); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1405 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1406 u_short (PASCAL *pfn_htons) (u_short hostshort); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1407 u_short (PASCAL *pfn_ntohs) (u_short netshort); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1408 unsigned long (PASCAL *pfn_inet_addr) (const char * cp); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1409 int (PASCAL *pfn_gethostname) (char * name, int namelen); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1410 struct hostent * (PASCAL *pfn_gethostbyname) (const char * name); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1411 struct servent * (PASCAL *pfn_getservbyname) (const char * name, const char * proto); |
15342
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1412 |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1413 /* SetHandleInformation is only needed to make sockets non-inheritable. */ |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1414 BOOL (WINAPI *pfn_SetHandleInformation) (HANDLE object, DWORD mask, DWORD flags); |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1415 #ifndef HANDLE_FLAG_INHERIT |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1416 #define HANDLE_FLAG_INHERIT 1 |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1417 #endif |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1418 |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1419 HANDLE winsock_lib; |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1420 static int winsock_inuse; |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1421 |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1422 BOOL |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1423 term_winsock (void) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1424 { |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1425 if (winsock_lib != NULL && winsock_inuse == 0) |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1426 { |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1427 /* Not sure what would cause WSAENETDOWN, or even if it can happen |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1428 after WSAStartup returns successfully, but it seems reasonable |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1429 to allow unloading winsock anyway in that case. */ |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1430 if (pfn_WSACleanup () == 0 || |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1431 pfn_WSAGetLastError () == WSAENETDOWN) |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1432 { |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1433 if (FreeLibrary (winsock_lib)) |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1434 winsock_lib = NULL; |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1435 return TRUE; |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1436 } |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1437 } |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1438 return FALSE; |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1439 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1440 |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1441 BOOL |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1442 init_winsock (int load_now) |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1443 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1444 WSADATA winsockData; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1445 |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1446 if (winsock_lib != NULL) |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1447 return TRUE; |
15342
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1448 |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1449 pfn_SetHandleInformation = NULL; |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1450 pfn_SetHandleInformation |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1451 = (void *) GetProcAddress (GetModuleHandle ("kernel32.dll"), |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1452 "SetHandleInformation"); |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1453 |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1454 winsock_lib = LoadLibrary ("wsock32.dll"); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1455 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1456 if (winsock_lib != NULL) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1457 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1458 /* dynamically link to socket functions */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1459 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1460 #define LOAD_PROC(fn) \ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1461 if ((pfn_##fn = (void *) GetProcAddress (winsock_lib, #fn)) == NULL) \ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1462 goto fail; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1463 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1464 LOAD_PROC( WSAStartup ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1465 LOAD_PROC( WSASetLastError ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1466 LOAD_PROC( WSAGetLastError ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1467 LOAD_PROC( socket ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1468 LOAD_PROC( bind ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1469 LOAD_PROC( connect ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1470 LOAD_PROC( ioctlsocket ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1471 LOAD_PROC( recv ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1472 LOAD_PROC( send ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1473 LOAD_PROC( closesocket ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1474 LOAD_PROC( shutdown ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1475 LOAD_PROC( htons ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1476 LOAD_PROC( ntohs ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1477 LOAD_PROC( inet_addr ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1478 LOAD_PROC( gethostname ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1479 LOAD_PROC( gethostbyname ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1480 LOAD_PROC( getservbyname ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1481 LOAD_PROC( WSACleanup ); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1482 |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1483 #undef LOAD_PROC |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1484 |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1485 /* specify version 1.1 of winsock */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1486 if (pfn_WSAStartup (0x101, &winsockData) == 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1487 { |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1488 if (winsockData.wVersion != 0x101) |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1489 goto fail; |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1490 |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1491 if (!load_now) |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1492 { |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1493 /* Report that winsock exists and is usable, but leave |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1494 socket functions disabled. I am assuming that calling |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1495 WSAStartup does not require any network interaction, |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1496 and in particular does not cause or require a dial-up |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1497 connection to be established. */ |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1498 |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1499 pfn_WSACleanup (); |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1500 FreeLibrary (winsock_lib); |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1501 winsock_lib = NULL; |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1502 } |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1503 winsock_inuse = 0; |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1504 return TRUE; |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1505 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1506 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1507 fail: |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1508 FreeLibrary (winsock_lib); |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1509 winsock_lib = NULL; |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1510 } |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1511 |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1512 return FALSE; |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1513 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1514 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1515 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1516 int h_errno = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1517 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1518 /* function to set h_errno for compatability; map winsock error codes to |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1519 normal system codes where they overlap (non-overlapping definitions |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1520 are already in <sys/socket.h> */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1521 static void set_errno () |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1522 { |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1523 if (winsock_lib == NULL) |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1524 h_errno = EINVAL; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1525 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1526 h_errno = pfn_WSAGetLastError (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1527 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1528 switch (h_errno) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1529 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1530 case WSAEACCES: h_errno = EACCES; break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1531 case WSAEBADF: h_errno = EBADF; break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1532 case WSAEFAULT: h_errno = EFAULT; break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1533 case WSAEINTR: h_errno = EINTR; break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1534 case WSAEINVAL: h_errno = EINVAL; break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1535 case WSAEMFILE: h_errno = EMFILE; break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1536 case WSAENAMETOOLONG: h_errno = ENAMETOOLONG; break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1537 case WSAENOTEMPTY: h_errno = ENOTEMPTY; break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1538 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1539 errno = h_errno; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1540 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1541 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1542 static void check_errno () |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1543 { |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1544 if (h_errno == 0 && winsock_lib != NULL) |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1545 pfn_WSASetLastError (0); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1546 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1547 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1548 /* [andrewi 3-May-96] I've had conflicting results using both methods, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1549 but I believe the method of keeping the socket handle separate (and |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1550 insuring it is not inheritable) is the correct one. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1551 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1552 //#define SOCK_REPLACE_HANDLE |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1553 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1554 #ifdef SOCK_REPLACE_HANDLE |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1555 #define SOCK_HANDLE(fd) ((SOCKET) _get_osfhandle (fd)) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1556 #else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1557 #define SOCK_HANDLE(fd) ((SOCKET) fd_info[fd].hnd) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1558 #endif |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1559 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1560 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1561 sys_socket(int af, int type, int protocol) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1562 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1563 int fd; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1564 long s; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1565 child_process * cp; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1566 |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1567 if (winsock_lib == NULL) |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1568 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1569 h_errno = ENETDOWN; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1570 return INVALID_SOCKET; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1571 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1572 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1573 check_errno (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1574 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1575 /* call the real socket function */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1576 s = (long) pfn_socket (af, type, protocol); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1577 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1578 if (s != INVALID_SOCKET) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1579 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1580 /* Although under NT 3.5 _open_osfhandle will accept a socket |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1581 handle, if opened with SO_OPENTYPE == SO_SYNCHRONOUS_NONALERT, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1582 that does not work under NT 3.1. However, we can get the same |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1583 effect by using a backdoor function to replace an existing |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1584 descriptor handle with the one we want. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1585 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1586 /* allocate a file descriptor (with appropriate flags) */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1587 fd = _open ("NUL:", _O_RDWR); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1588 if (fd >= 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1589 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1590 #ifdef SOCK_REPLACE_HANDLE |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1591 /* now replace handle to NUL with our socket handle */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1592 CloseHandle ((HANDLE) _get_osfhandle (fd)); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1593 _free_osfhnd (fd); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1594 _set_osfhnd (fd, s); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1595 /* setmode (fd, _O_BINARY); */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1596 #else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1597 /* Make a non-inheritable copy of the socket handle. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1598 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1599 HANDLE parent; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1600 HANDLE new_s = INVALID_HANDLE_VALUE; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1601 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1602 parent = GetCurrentProcess (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1603 |
15342
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1604 /* Apparently there is a bug in NT 3.51 with some service |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1605 packs, which prevents using DuplicateHandle to make a |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1606 socket handle non-inheritable (causes WSACleanup to |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1607 hang). The work-around is to use SetHandleInformation |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1608 instead if it is available and implemented. */ |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1609 if (!pfn_SetHandleInformation |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1610 || !pfn_SetHandleInformation ((HANDLE) s, |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1611 HANDLE_FLAG_INHERIT, |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1612 HANDLE_FLAG_INHERIT)) |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1613 { |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1614 DuplicateHandle (parent, |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1615 (HANDLE) s, |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1616 parent, |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1617 &new_s, |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1618 0, |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1619 FALSE, |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1620 DUPLICATE_SAME_ACCESS); |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1621 pfn_closesocket (s); |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1622 s = (SOCKET) new_s; |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1623 } |
e64bd8310edc
(init_winsock): Dynamically link to SetHandleInformation.
Richard M. Stallman <rms@gnu.org>
parents:
15326
diff
changeset
|
1624 fd_info[fd].hnd = (HANDLE) s; |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1625 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1626 #endif |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1627 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1628 /* set our own internal flags */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1629 fd_info[fd].flags = FILE_SOCKET | FILE_BINARY | FILE_READ | FILE_WRITE; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1630 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1631 cp = new_child (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1632 if (cp) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1633 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1634 cp->fd = fd; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1635 cp->status = STATUS_READ_ACKNOWLEDGED; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1636 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1637 /* attach child_process to fd_info */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1638 if (fd_info[ fd ].cp != NULL) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1639 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1640 DebPrint (("sys_socket: fd_info[%d] apparently in use!\n", fd)); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1641 abort (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1642 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1643 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1644 fd_info[ fd ].cp = cp; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1645 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1646 /* success! */ |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1647 winsock_inuse++; /* count open sockets */ |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1648 return fd; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1649 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1650 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1651 /* clean up */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1652 _close (fd); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1653 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1654 pfn_closesocket (s); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1655 h_errno = EMFILE; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1656 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1657 set_errno (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1658 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1659 return -1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1660 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1661 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1662 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1663 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1664 sys_bind (int s, const struct sockaddr * addr, int namelen) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1665 { |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1666 if (winsock_lib == NULL) |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1667 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1668 h_errno = ENOTSOCK; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1669 return SOCKET_ERROR; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1670 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1671 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1672 check_errno (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1673 if (fd_info[s].flags & FILE_SOCKET) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1674 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1675 int rc = pfn_bind (SOCK_HANDLE (s), addr, namelen); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1676 if (rc == SOCKET_ERROR) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1677 set_errno (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1678 return rc; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1679 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1680 h_errno = ENOTSOCK; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1681 return SOCKET_ERROR; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1682 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1683 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1684 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1685 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1686 sys_connect (int s, const struct sockaddr * name, int namelen) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1687 { |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1688 if (winsock_lib == NULL) |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1689 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1690 h_errno = ENOTSOCK; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1691 return SOCKET_ERROR; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1692 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1693 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1694 check_errno (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1695 if (fd_info[s].flags & FILE_SOCKET) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1696 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1697 int rc = pfn_connect (SOCK_HANDLE (s), name, namelen); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1698 if (rc == SOCKET_ERROR) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1699 set_errno (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1700 return rc; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1701 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1702 h_errno = ENOTSOCK; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1703 return SOCKET_ERROR; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1704 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1705 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1706 u_short |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1707 sys_htons (u_short hostshort) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1708 { |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1709 return (winsock_lib != NULL) ? |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1710 pfn_htons (hostshort) : hostshort; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1711 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1712 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1713 u_short |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1714 sys_ntohs (u_short netshort) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1715 { |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1716 return (winsock_lib != NULL) ? |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1717 pfn_ntohs (netshort) : netshort; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1718 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1719 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1720 unsigned long |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1721 sys_inet_addr (const char * cp) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1722 { |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1723 return (winsock_lib != NULL) ? |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1724 pfn_inet_addr (cp) : INADDR_NONE; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1725 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1726 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1727 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1728 sys_gethostname (char * name, int namelen) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1729 { |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1730 if (winsock_lib != NULL) |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1731 return pfn_gethostname (name, namelen); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1732 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1733 if (namelen > MAX_COMPUTERNAME_LENGTH) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1734 return !GetComputerName (name, &namelen); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1735 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1736 h_errno = EFAULT; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1737 return SOCKET_ERROR; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1738 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1739 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1740 struct hostent * |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1741 sys_gethostbyname(const char * name) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1742 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1743 struct hostent * host; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1744 |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1745 if (winsock_lib == NULL) |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1746 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1747 h_errno = ENETDOWN; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1748 return NULL; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1749 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1750 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1751 check_errno (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1752 host = pfn_gethostbyname (name); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1753 if (!host) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1754 set_errno (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1755 return host; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1756 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1757 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1758 struct servent * |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1759 sys_getservbyname(const char * name, const char * proto) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1760 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1761 struct servent * serv; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1762 |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1763 if (winsock_lib == NULL) |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1764 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1765 h_errno = ENETDOWN; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1766 return NULL; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1767 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1768 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1769 check_errno (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1770 serv = pfn_getservbyname (name, proto); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1771 if (!serv) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1772 set_errno (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1773 return serv; |
9803 | 1774 } |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1775 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1776 #endif /* HAVE_SOCKETS */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1777 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1778 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1779 /* Shadow main io functions: we need to handle pipes and sockets more |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1780 intelligently, and implement non-blocking mode as well. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1781 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1782 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1783 sys_close (int fd) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1784 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1785 int rc; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1786 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1787 if (fd < 0 || fd >= MAXDESC) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1788 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1789 errno = EBADF; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1790 return -1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1791 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1792 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1793 if (fd_info[fd].cp) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1794 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1795 child_process * cp = fd_info[fd].cp; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1796 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1797 fd_info[fd].cp = NULL; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1798 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1799 if (CHILD_ACTIVE (cp)) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1800 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1801 /* if last descriptor to active child_process then cleanup */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1802 int i; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1803 for (i = 0; i < MAXDESC; i++) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1804 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1805 if (i == fd) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1806 continue; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1807 if (fd_info[i].cp == cp) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1808 break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1809 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1810 if (i == MAXDESC) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1811 { |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1812 #ifdef HAVE_SOCKETS |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1813 if (fd_info[fd].flags & FILE_SOCKET) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1814 { |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1815 #ifndef SOCK_REPLACE_HANDLE |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1816 if (winsock_lib == NULL) abort (); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1817 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1818 pfn_shutdown (SOCK_HANDLE (fd), 2); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1819 rc = pfn_closesocket (SOCK_HANDLE (fd)); |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1820 #endif |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
1821 winsock_inuse--; /* count open sockets */ |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1822 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1823 #endif |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1824 delete_child (cp); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1825 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1826 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1827 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1828 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1829 /* Note that sockets do not need special treatment here (at least on |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1830 NT and Win95 using the standard tcp/ip stacks) - it appears that |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1831 closesocket is equivalent to CloseHandle, which is to be expected |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1832 because socket handles are fully fledged kernel handles. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1833 rc = _close (fd); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1834 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1835 if (rc == 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1836 fd_info[fd].flags = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1837 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1838 return rc; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1839 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1840 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1841 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1842 sys_dup (int fd) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1843 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1844 int new_fd; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1845 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1846 new_fd = _dup (fd); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1847 if (new_fd >= 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1848 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1849 /* duplicate our internal info as well */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1850 fd_info[new_fd] = fd_info[fd]; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1851 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1852 return new_fd; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1853 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1854 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1855 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1856 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1857 sys_dup2 (int src, int dst) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1858 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1859 int rc; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1860 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1861 if (dst < 0 || dst >= MAXDESC) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1862 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1863 errno = EBADF; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1864 return -1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1865 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1866 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1867 /* make sure we close the destination first if it's a pipe or socket */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1868 if (src != dst && fd_info[dst].flags != 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1869 sys_close (dst); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1870 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1871 rc = _dup2 (src, dst); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1872 if (rc == 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1873 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1874 /* duplicate our internal info as well */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1875 fd_info[dst] = fd_info[src]; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1876 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1877 return rc; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1878 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1879 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1880 /* From callproc.c */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1881 extern Lisp_Object Vbinary_process_input; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1882 extern Lisp_Object Vbinary_process_output; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1883 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1884 /* Unix pipe() has only one arg */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1885 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1886 sys_pipe (int * phandles) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1887 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1888 int rc; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1889 unsigned flags; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1890 child_process * cp; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1891 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1892 /* make pipe handles non-inheritable; when we spawn a child, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1893 we replace the relevant handle with an inheritable one. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1894 rc = _pipe (phandles, 0, _O_NOINHERIT); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1895 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1896 if (rc == 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1897 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1898 /* set internal flags, and put read and write handles into binary |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1899 mode as necessary; if not in binary mode, set the MSVC internal |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1900 FDEV (0x40) flag to prevent _read from treating ^Z as eof (this |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1901 could otherwise allow Emacs to hang because it then waits |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1902 indefinitely for the child process to exit, when it might not be |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1903 finished). */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1904 flags = FILE_PIPE | FILE_READ; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1905 if (!NILP (Vbinary_process_output)) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1906 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1907 flags |= FILE_BINARY; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1908 setmode (phandles[0], _O_BINARY); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1909 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1910 #if (_MSC_VER == 900) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1911 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1912 _osfile[phandles[0]] |= 0x40; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1913 #endif |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1914 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1915 fd_info[phandles[0]].flags = flags; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1916 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1917 flags = FILE_PIPE | FILE_WRITE; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1918 if (!NILP (Vbinary_process_input)) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1919 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1920 flags |= FILE_BINARY; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1921 setmode (phandles[1], _O_BINARY); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1922 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1923 #if (_MSC_VER == 900) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1924 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1925 _osfile[phandles[1]] |= 0x40; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1926 #endif |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1927 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1928 fd_info[phandles[1]].flags = flags; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1929 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1930 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1931 return rc; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1932 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1933 |
15249
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1934 /* From ntproc.c */ |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
1935 extern Lisp_Object Vw32_pipe_read_delay; |
15249
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1936 |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1937 /* Function to do blocking read of one byte, needed to implement |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1938 select. It is only allowed on sockets and pipes. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1939 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1940 _sys_read_ahead (int fd) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1941 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1942 child_process * cp; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1943 int rc; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1944 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1945 if (fd < 0 || fd >= MAXDESC) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1946 return STATUS_READ_ERROR; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1947 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1948 cp = fd_info[fd].cp; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1949 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1950 if (cp == NULL || cp->fd != fd || cp->status != STATUS_READ_READY) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1951 return STATUS_READ_ERROR; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1952 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1953 if ((fd_info[fd].flags & (FILE_PIPE | FILE_SOCKET)) == 0 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1954 || (fd_info[fd].flags & FILE_READ) == 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1955 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1956 DebPrint (("_sys_read_ahead: internal error: fd %d is not a pipe or socket!\n", fd)); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1957 abort (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1958 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1959 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1960 cp->status = STATUS_READ_IN_PROGRESS; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1961 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1962 if (fd_info[fd].flags & FILE_PIPE) |
15249
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1963 { |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1964 /* Use read to get CRLF translation */ |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1965 rc = _read (fd, &cp->chr, sizeof (char)); |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1966 |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1967 /* Give subprocess time to buffer some more output for us before |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1968 reporting that input is available; we need this because Win95 |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1969 connects DOS programs to pipes by making the pipe appear to be |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1970 the normal console stdout - as a result most DOS programs will |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1971 write to stdout without buffering, ie. one character at a |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
1972 time. Even some W32 programs do this - "dir" in a command |
15249
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1973 shell on NT is very slow if we don't do this. */ |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1974 if (rc > 0) |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1975 { |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
1976 int wait = XINT (Vw32_pipe_read_delay); |
15249
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1977 |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1978 if (wait > 0) |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1979 Sleep (wait); |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1980 else if (wait < 0) |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1981 while (++wait <= 0) |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1982 /* Yield remainder of our time slice, effectively giving a |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1983 temporary priority boost to the child process. */ |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1984 Sleep (0); |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1985 } |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
1986 } |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1987 #ifdef HAVE_SOCKETS |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1988 else if (fd_info[fd].flags & FILE_SOCKET) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1989 rc = pfn_recv (SOCK_HANDLE (fd), &cp->chr, sizeof (char), 0); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1990 #endif |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1991 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1992 if (rc == sizeof (char)) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1993 cp->status = STATUS_READ_SUCCEEDED; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1994 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1995 cp->status = STATUS_READ_FAILED; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1996 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1997 return cp->status; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1998 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
1999 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2000 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2001 sys_read (int fd, char * buffer, unsigned int count) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2002 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2003 int nchars; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2004 int extra = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2005 int to_read; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2006 DWORD waiting; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2007 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2008 if (fd < 0 || fd >= MAXDESC) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2009 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2010 errno = EBADF; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2011 return -1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2012 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2013 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2014 if (fd_info[fd].flags & (FILE_PIPE | FILE_SOCKET)) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2015 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2016 child_process *cp = fd_info[fd].cp; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2017 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2018 if ((fd_info[fd].flags & FILE_READ) == 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2019 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2020 errno = EBADF; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2021 return -1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2022 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2023 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2024 /* presence of a child_process structure means we are operating in |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2025 non-blocking mode - otherwise we just call _read directly. |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2026 Note that the child_process structure might be missing because |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2027 reap_subprocess has been called; in this case the pipe is |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2028 already broken, so calling _read on it is okay. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2029 if (cp) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2030 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2031 int current_status = cp->status; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2032 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2033 switch (current_status) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2034 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2035 case STATUS_READ_FAILED: |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2036 case STATUS_READ_ERROR: |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2037 /* report normal EOF */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2038 return 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2039 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2040 case STATUS_READ_READY: |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2041 case STATUS_READ_IN_PROGRESS: |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2042 DebPrint (("sys_read called when read is in progress\n")); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2043 errno = EWOULDBLOCK; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2044 return -1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2045 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2046 case STATUS_READ_SUCCEEDED: |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2047 /* consume read-ahead char */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2048 *buffer++ = cp->chr; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2049 count--; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2050 extra = 1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2051 cp->status = STATUS_READ_ACKNOWLEDGED; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2052 ResetEvent (cp->char_avail); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2053 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2054 case STATUS_READ_ACKNOWLEDGED: |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2055 break; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2056 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2057 default: |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2058 DebPrint (("sys_read: bad status %d\n", current_status)); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2059 errno = EBADF; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2060 return -1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2061 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2062 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2063 if (fd_info[fd].flags & FILE_PIPE) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2064 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2065 PeekNamedPipe ((HANDLE) _get_osfhandle (fd), NULL, 0, NULL, &waiting, NULL); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2066 to_read = min (waiting, (DWORD) count); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2067 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2068 /* Use read to get CRLF translation */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2069 nchars = _read (fd, buffer, to_read); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2070 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2071 #ifdef HAVE_SOCKETS |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2072 else /* FILE_SOCKET */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2073 { |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
2074 if (winsock_lib == NULL) abort (); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2075 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2076 /* do the equivalent of a non-blocking read */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2077 pfn_ioctlsocket (SOCK_HANDLE (fd), FIONREAD, &waiting); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2078 if (waiting == 0 && extra == 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2079 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2080 h_errno = errno = EWOULDBLOCK; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2081 return -1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2082 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2083 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2084 nchars = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2085 if (waiting) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2086 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2087 /* always use binary mode for sockets */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2088 nchars = pfn_recv (SOCK_HANDLE (fd), buffer, count, 0); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2089 if (nchars == SOCKET_ERROR) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2090 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2091 DebPrint(("sys_read.recv failed with error %d on socket %ld\n", |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2092 pfn_WSAGetLastError (), SOCK_HANDLE (fd))); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2093 if (extra == 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2094 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2095 set_errno (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2096 return -1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2097 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2098 nchars = 0; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2099 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2100 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2101 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2102 #endif |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2103 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2104 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2105 nchars = _read (fd, buffer, count); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2106 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2107 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2108 nchars = _read (fd, buffer, count); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2109 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2110 return nchars + extra; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2111 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2112 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2113 /* For now, don't bother with a non-blocking mode */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2114 int |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2115 sys_write (int fd, const void * buffer, unsigned int count) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2116 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2117 int nchars; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2118 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2119 if (fd < 0 || fd >= MAXDESC) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2120 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2121 errno = EBADF; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2122 return -1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2123 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2124 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2125 if (fd_info[fd].flags & (FILE_PIPE | FILE_SOCKET)) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2126 if ((fd_info[fd].flags & FILE_WRITE) == 0) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2127 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2128 errno = EBADF; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2129 return -1; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2130 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2131 #ifdef HAVE_SOCKETS |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2132 if (fd_info[fd].flags & FILE_SOCKET) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2133 { |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
2134 if (winsock_lib == NULL) abort (); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2135 nchars = pfn_send (SOCK_HANDLE (fd), buffer, count, 0); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2136 if (nchars == SOCKET_ERROR) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2137 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2138 DebPrint(("sys_read.send failed with error %d on socket %ld\n", |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2139 pfn_WSAGetLastError (), SOCK_HANDLE (fd))); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2140 set_errno (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2141 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2142 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2143 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2144 #endif |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2145 nchars = _write (fd, buffer, count); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2146 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2147 return nchars; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2148 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2149 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2150 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2151 void |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2152 term_ntproc () |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2153 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2154 #ifdef HAVE_SOCKETS |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2155 /* shutdown the socket interface if necessary */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2156 term_winsock (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2157 #endif |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2158 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2159 |
15249
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
2160 extern BOOL dos_process_running; |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
2161 |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2162 void |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2163 init_ntproc () |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2164 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2165 #ifdef HAVE_SOCKETS |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
2166 /* Initialise the socket interface now if available and requested by |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
2167 the user by defining PRELOAD_WINSOCK; otherwise loading will be |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
2168 delayed until open-network-stream is called (w32-has-winsock can |
15357
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
2169 also be used to dynamically load or reload winsock). |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
2170 |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
2171 Conveniently, init_environment is called before us, so |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
2172 PRELOAD_WINSOCK can be set in the registry. */ |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
2173 |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
2174 /* Always initialize this correctly. */ |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
2175 winsock_lib = NULL; |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
2176 |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
2177 if (getenv ("PRELOAD_WINSOCK") != NULL) |
6686192ea2b3
(init_environment): Read PRELOAD_WINSOCK from registry if
Richard M. Stallman <rms@gnu.org>
parents:
15354
diff
changeset
|
2178 init_winsock (TRUE); |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2179 #endif |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2180 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2181 /* Initial preparation for subprocess support: replace our standard |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2182 handles with non-inheritable versions. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2183 { |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2184 HANDLE parent; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2185 HANDLE stdin_save = INVALID_HANDLE_VALUE; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2186 HANDLE stdout_save = INVALID_HANDLE_VALUE; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2187 HANDLE stderr_save = INVALID_HANDLE_VALUE; |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2188 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2189 parent = GetCurrentProcess (); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2190 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2191 /* ignore errors when duplicating and closing; typically the |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2192 handles will be invalid when running as a gui program. */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2193 DuplicateHandle (parent, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2194 GetStdHandle (STD_INPUT_HANDLE), |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2195 parent, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2196 &stdin_save, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2197 0, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2198 FALSE, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2199 DUPLICATE_SAME_ACCESS); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2200 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2201 DuplicateHandle (parent, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2202 GetStdHandle (STD_OUTPUT_HANDLE), |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2203 parent, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2204 &stdout_save, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2205 0, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2206 FALSE, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2207 DUPLICATE_SAME_ACCESS); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2208 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2209 DuplicateHandle (parent, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2210 GetStdHandle (STD_ERROR_HANDLE), |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2211 parent, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2212 &stderr_save, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2213 0, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2214 FALSE, |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2215 DUPLICATE_SAME_ACCESS); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2216 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2217 fclose (stdin); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2218 fclose (stdout); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2219 fclose (stderr); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2220 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2221 if (stdin_save != INVALID_HANDLE_VALUE) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2222 _open_osfhandle ((long) stdin_save, O_TEXT); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2223 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2224 open ("nul", O_TEXT | O_NOINHERIT | O_RDONLY); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2225 fdopen (0, "r"); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2226 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2227 if (stdout_save != INVALID_HANDLE_VALUE) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2228 _open_osfhandle ((long) stdout_save, O_TEXT); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2229 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2230 open ("nul", O_TEXT | O_NOINHERIT | O_WRONLY); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2231 fdopen (1, "w"); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2232 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2233 if (stderr_save != INVALID_HANDLE_VALUE) |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2234 _open_osfhandle ((long) stderr_save, O_TEXT); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2235 else |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2236 open ("nul", O_TEXT | O_NOINHERIT | O_WRONLY); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2237 fdopen (2, "w"); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2238 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2239 |
15418
6344f92ddba2
Delete restrict_dos_process.
Richard M. Stallman <rms@gnu.org>
parents:
15414
diff
changeset
|
2240 /* Restrict Emacs to running only one DOS program at a time (with any |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15615
diff
changeset
|
2241 number of W32 programs). This is to prevent the user from |
15418
6344f92ddba2
Delete restrict_dos_process.
Richard M. Stallman <rms@gnu.org>
parents:
15414
diff
changeset
|
2242 running into problems with DOS programs being run in the same VDM |
6344f92ddba2
Delete restrict_dos_process.
Richard M. Stallman <rms@gnu.org>
parents:
15414
diff
changeset
|
2243 under both Windows 95 and Windows NT. |
15414
81cf9a7fd6ca
(restrict_dos_process): Renamed from can_run_dos_process.
Richard M. Stallman <rms@gnu.org>
parents:
15357
diff
changeset
|
2244 |
81cf9a7fd6ca
(restrict_dos_process): Renamed from can_run_dos_process.
Richard M. Stallman <rms@gnu.org>
parents:
15357
diff
changeset
|
2245 Note that it is possible for Emacs to run DOS programs in separate |
15418
6344f92ddba2
Delete restrict_dos_process.
Richard M. Stallman <rms@gnu.org>
parents:
15414
diff
changeset
|
2246 VDMs, but unfortunately the pipe implementation on Windows 95 then |
15414
81cf9a7fd6ca
(restrict_dos_process): Renamed from can_run_dos_process.
Richard M. Stallman <rms@gnu.org>
parents:
15357
diff
changeset
|
2247 fails to report when the DOS process exits (which is supposed to |
81cf9a7fd6ca
(restrict_dos_process): Renamed from can_run_dos_process.
Richard M. Stallman <rms@gnu.org>
parents:
15357
diff
changeset
|
2248 break the pipe). Until this bug is fixed, or we can devise a |
81cf9a7fd6ca
(restrict_dos_process): Renamed from can_run_dos_process.
Richard M. Stallman <rms@gnu.org>
parents:
15357
diff
changeset
|
2249 work-around, we must try to avoid letting the user start more than |
81cf9a7fd6ca
(restrict_dos_process): Renamed from can_run_dos_process.
Richard M. Stallman <rms@gnu.org>
parents:
15357
diff
changeset
|
2250 one DOS program if possible. */ |
81cf9a7fd6ca
(restrict_dos_process): Renamed from can_run_dos_process.
Richard M. Stallman <rms@gnu.org>
parents:
15357
diff
changeset
|
2251 |
15249
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
2252 dos_process_running = FALSE; |
53bb2499db2a
(_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents:
15237
diff
changeset
|
2253 |
15141
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2254 /* unfortunately, atexit depends on implementation of malloc */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2255 /* atexit (term_ntproc); */ |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2256 signal (SIGABRT, term_ntproc); |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2257 } |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2258 |
6565b268b12a
(nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14912
diff
changeset
|
2259 /* end of nt.c */ |