annotate src/w32.c @ 15249:53bb2499db2a

(_sys_read_ahead): Handle sleep here. (sys_read): Not here. (init_ntproc): Initialize can_run_dos_process, dos_process_running.
author Karl Heuer <kwzh@gnu.org>
date Fri, 17 May 1996 21:45:30 +0000
parents e44ef00f509f
children a073669046b1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 /* Utility and Unix shadow routines for GNU Emacs on Windows NT.
11384
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
2 Copyright (C) 1994, 1995 Free Software Foundation, Inc.
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 Geoff Voelker (voelker@cs.washington.edu) 7-29-94
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
14246
ebdd1b50daba (nt_stat): Use alloca instead of xmalloc.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
24
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 #include <stdlib.h>
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 #include <stdio.h>
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 #include <fcntl.h>
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 #define getwd _getwd
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 #include "lisp.h"
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 #undef getwd
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 #include <pwd.h>
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
78 #include "nt.h"
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 #include "ndir.h"
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 #include "ntheap.h"
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 /* Emulate gethostname. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 gethostname (char *buffer, int size)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 /* NT only allows small host names, so the buffer is
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 certainly large enough. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 return !GetComputerName (buffer, &size);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 }
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
100 #endif /* HAVE_SOCKETS */
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 /* Emulate getloadavg. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 getloadavg (double loadavg[], int nelem)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 int i;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 /* A faithful emulation is going to have to be saved for a rainy day. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 for (i = 0; i < nelem; i++)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 loadavg[i] = 0.0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 return i;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 /* Emulate the Unix directory procedures opendir, closedir,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 and readdir. We can't use the procedures supplied in sysdep.c,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 so we provide them here. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 DIR *
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 opendir (char *filename)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 DIR *dirp;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 /* 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
131 this operation, so we defer the open until read time. */
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
133 if (!(dirp = (DIR *) malloc (sizeof (DIR))))
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
134 return NULL;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
135 if (dir_find_handle != INVALID_HANDLE_VALUE)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
136 return NULL;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 dirp->dd_fd = 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 dirp->dd_loc = 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 dirp->dd_size = 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
142 strncpy (dir_pathname, filename, MAXPATHLEN);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
143 dir_pathname[MAXPATHLEN] = '\0';
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
144 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
145
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 return dirp;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 void
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 closedir (DIR *dirp)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 /* 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
153 if (dir_find_handle != INVALID_HANDLE_VALUE)
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 FindClose (dir_find_handle);
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
156 dir_find_handle = INVALID_HANDLE_VALUE;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 xfree ((char *) dirp);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 struct direct *
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 readdir (DIR *dirp)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 WIN32_FIND_DATA find_data;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 /* 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
167 if (dir_find_handle == INVALID_HANDLE_VALUE)
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 char filename[MAXNAMLEN + 3];
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 int ln;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
172 strcpy (filename, dir_pathname);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
173 ln = strlen (filename) - 1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
174 if (!IS_DIRECTORY_SEP (filename[ln]))
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 strcat (filename, "\\");
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
176 strcat (filename, "*");
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 dir_find_handle = FindFirstFile (filename, &find_data);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
180 if (dir_find_handle == INVALID_HANDLE_VALUE)
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 return NULL;
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
182 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
183 else
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 if (!FindNextFile (dir_find_handle, &find_data))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 return NULL;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
189 /* 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
190 value returned by stat(). */
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 dir_static.d_ino = 1;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 dir_static.d_reclen = sizeof (struct direct) - MAXNAMLEN + 3 +
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 dir_static.d_namlen - dir_static.d_namlen % 4;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 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
197 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
198 if (dir_is_fat)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
199 _strlwr (dir_static.d_name);
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 return &dir_static;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
204 /* Emulate getpwuid, getpwnam and others. */
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205
12451
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
206 #define PASSWD_FIELD_SIZE 256
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
207
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
208 static char the_passwd_name[PASSWD_FIELD_SIZE];
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
209 static char the_passwd_passwd[PASSWD_FIELD_SIZE];
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
210 static char the_passwd_gecos[PASSWD_FIELD_SIZE];
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
211 static char the_passwd_dir[PASSWD_FIELD_SIZE];
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
212 static char the_passwd_shell[PASSWD_FIELD_SIZE];
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 static struct passwd the_passwd =
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 the_passwd_name,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 the_passwd_passwd,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 0,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 0,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 0,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 the_passwd_gecos,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 the_passwd_dir,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 the_passwd_shell,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 };
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
226 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
227 getuid ()
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
228 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
229 return the_passwd.pw_uid;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
230 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
231
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
232 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
233 geteuid ()
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
234 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
235 /* 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
236 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
237 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
238 return 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
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
241 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
242 getgid ()
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
243 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
244 return the_passwd.pw_gid;
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
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
247 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
248 getegid ()
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
249 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
250 return getgid ();
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
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 struct passwd *
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 getpwuid (int uid)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 {
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
256 if (uid == the_passwd.pw_uid)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
257 return &the_passwd;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
258 return NULL;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 struct passwd *
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 getpwnam (char *name)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 struct passwd *pw;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 pw = getpwuid (getuid ());
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 if (!pw)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 return pw;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
270 if (stricmp (name, pw->pw_name))
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 return NULL;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 return pw;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
276 void
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
277 init_user_info ()
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
278 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
279 /* 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
280 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
281
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
282 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
283 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
284 primary group sid from the process token). */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
285
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
286 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
287 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
288 HANDLE token = NULL;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
289 SID_NAME_USE user_type;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
290
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
291 if (OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &token)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
292 && GetTokenInformation (token, TokenUser,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
293 (PVOID) user_sid, sizeof (user_sid), &trash)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
294 && LookupAccountSid (NULL, *((PSID *) user_sid), name, &length,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
295 domain, &dlength, &user_type))
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 strcpy (the_passwd.pw_name, name);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
298 /* Determine a reasonable uid value. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
299 if (stricmp ("administrator", name) == 0)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
300 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
301 the_passwd.pw_uid = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
302 the_passwd.pw_gid = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
303 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
304 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
305 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
306 SID_IDENTIFIER_AUTHORITY * pSIA;
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 pSIA = GetSidIdentifierAuthority (*((PSID *) user_sid));
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
309 /* 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
310 with msb first. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
311 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
312 (pSIA->Value[3] << 16) +
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
313 (pSIA->Value[4] << 8) +
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
314 (pSIA->Value[5] << 0));
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
315 /* 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
316 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
317
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
318 /* Get group id */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
319 if (GetTokenInformation (token, TokenPrimaryGroup,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
320 (PVOID) user_sid, sizeof (user_sid), &trash))
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
321 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
322 SID_IDENTIFIER_AUTHORITY * pSIA;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
323
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
324 pSIA = GetSidIdentifierAuthority (*((PSID *) user_sid));
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
325 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
326 (pSIA->Value[3] << 16) +
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
327 (pSIA->Value[4] << 8) +
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
328 (pSIA->Value[5] << 0));
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
329 /* 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
330 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
331 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
332 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
333 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
334 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
335 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
336 /* 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
337 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
338 else if (GetUserName (name, &length))
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
339 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
340 strcpy (the_passwd.pw_name, name);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
341 if (stricmp ("administrator", name) == 0)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
342 the_passwd.pw_uid = 0;
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_uid = 123;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
345 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
346 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
347 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
348 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
349 strcpy (the_passwd.pw_name, "unknown");
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
350 the_passwd.pw_uid = 123;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
351 the_passwd.pw_gid = 123;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
352 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
353
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
354 /* Ensure HOME and SHELL are defined. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
355 if (getenv ("HOME") == NULL)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
356 putenv ("HOME=c:/");
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
357 if (getenv ("SHELL") == NULL)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
358 putenv ((GetVersion () & 0x80000000) ? "SHELL=command" : "SHELL=cmd");
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 /* Set dir and shell from environment variables. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
361 strcpy (the_passwd.pw_dir, getenv ("HOME"));
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
362 strcpy (the_passwd.pw_shell, getenv ("SHELL"));
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 if (token)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
365 CloseHandle (token);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
366 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
367
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
368 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
369 random ()
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 /* 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
372 return ((rand () << 15) | rand ());
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
373 }
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 void
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
376 srandom (int seed)
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 srand (seed);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
379 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
380
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
381 /* Destructively turn backslashes into slashes. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
382 void
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
383 dostounix_filename (p)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
384 register char *p;
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 while (*p)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
387 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
388 if (*p == '\\')
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
389 *p = '/';
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
390 p++;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
391 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
392 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
393
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
394 /* Destructively turn slashes into backslashes. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
395 void
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
396 unixtodos_filename (p)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
397 register char *p;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
398 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
399 while (*p)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
400 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
401 if (*p == '/')
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
402 *p = '\\';
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
403 p++;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
404 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
405 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
406
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
407 /* 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
408 (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
409 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
410 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
411 crlf_to_lf (n, buf)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
412 register int n;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
413 register unsigned char *buf;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
414 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
415 unsigned char *np = buf;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
416 unsigned char *startp = buf;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
417 unsigned char *endp = buf + n;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
418
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
419 if (n == 0)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
420 return n;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
421 while (buf < endp - 1)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
422 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
423 if (*buf == 0x0d)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
424 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
425 if (*(++buf) != 0x0a)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
426 *np++ = 0x0d;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
427 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
428 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
429 *np++ = *buf++;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
430 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
431 if (buf < endp)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
432 *np++ = *buf++;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
433 return np - startp;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
434 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
435
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
436 /* 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
437
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
438 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
439 sigsetmask (int signal_mask)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
440 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
441 return 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
442 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
443
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
444 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
445 sigblock (int sig)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
446 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
447 return 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
448 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
449
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
450 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
451 setpgrp (int pid, int gid)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
452 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
453 return 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
454 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
455
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
456 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
457 alarm (int seconds)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
458 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
459 return 0;
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
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
462 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
463 unrequest_sigio (void)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
464 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
465 return 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
466 }
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 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
469 request_sigio (void)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
470 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
471 return 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
472 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
473
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
474 #define REG_ROOT "SOFTWARE\\GNU\\Emacs"
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
475
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
476 LPBYTE
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
477 nt_get_resource (key, lpdwtype)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
478 char *key;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
479 LPDWORD lpdwtype;
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 LPBYTE lpvalue;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
482 HKEY hrootkey = NULL;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
483 DWORD cbData;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
484 BOOL ok = FALSE;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
485
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
486 /* 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
487 we have any resources. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
488
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
489 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
490 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
491 lpvalue = NULL;
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 (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
494 && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
495 && 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
496 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
497 return (lpvalue);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
498 }
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 if (lpvalue) xfree (lpvalue);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
501
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
502 RegCloseKey (hrootkey);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
503 }
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 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
506 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
507 lpvalue = NULL;
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 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
510 (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL &&
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
511 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
512 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
513 return (lpvalue);
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
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
516 if (lpvalue) xfree (lpvalue);
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 RegCloseKey (hrootkey);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
519 }
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 (NULL);
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 void
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
525 init_environment ()
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 /* 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
528 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
529 int i;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
530 LPBYTE lpval;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
531 DWORD dwType;
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 static char * env_vars[] =
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 "HOME",
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
536 "emacs_dir",
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
537 "EMACSLOADPATH",
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
538 "SHELL",
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
539 "EMACSDATA",
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
540 "EMACSPATH",
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
541 "EMACSLOCKDIR",
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
542 "INFOPATH",
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
543 "EMACSDOC",
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
544 "TERM",
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
545 };
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
546
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
547 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
548 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
549 if (!getenv (env_vars[i]) &&
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
550 (lpval = nt_get_resource (env_vars[i], &dwType)) != NULL)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
551 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
552 if (dwType == REG_EXPAND_SZ)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
553 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
554 char buf1[500], buf2[500];
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
555
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
556 ExpandEnvironmentStrings ((LPSTR) lpval, buf1, 500);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
557 _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
558 putenv (strdup (buf2));
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
559 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
560 else if (dwType == REG_SZ)
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 char buf[500];
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 _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
565 putenv (strdup (buf));
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
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
568 xfree (lpval);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
569 }
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 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
572
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
573 init_user_info ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
574 }
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 /* We don't have scripts to automatically determine the system configuration
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 for Emacs before it's compiled, and we don't want to have to make the
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 user enter it, so we define EMACS_CONFIGURATION to invoke this runtime
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 routine. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580
11941
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
581 static char configuration_buffer[32];
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 char *
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 get_emacs_configuration (void)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 {
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
586 char *arch, *oem, *os;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
588 /* Determine the processor type. */
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
589 switch (get_processor_type ())
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
590 {
12451
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
591
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
592 #ifdef PROCESSOR_INTEL_386
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
593 case PROCESSOR_INTEL_386:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
594 case PROCESSOR_INTEL_486:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
595 case PROCESSOR_INTEL_PENTIUM:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
596 arch = "i386";
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
597 break;
12451
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
598 #endif
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
599
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
600 #ifdef PROCESSOR_INTEL_860
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
601 case PROCESSOR_INTEL_860:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
602 arch = "i860";
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
603 break;
12451
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
604 #endif
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
605
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
606 #ifdef PROCESSOR_MIPS_R2000
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
607 case PROCESSOR_MIPS_R2000:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
608 case PROCESSOR_MIPS_R3000:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
609 case PROCESSOR_MIPS_R4000:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
610 arch = "mips";
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
611 break;
12451
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
612 #endif
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
613
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
614 #ifdef PROCESSOR_ALPHA_21064
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
615 case PROCESSOR_ALPHA_21064:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
616 arch = "alpha";
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
617 break;
12451
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
618 #endif
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
619
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
620 default:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
621 arch = "unknown";
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
622 break;
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
623 }
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
625 /* Let oem be "*" until we figure out how to decode the OEM field. */
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
626 oem = "*";
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
628 os = (GetVersion () & 0x80000000) ? "win95" : "nt";
11941
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
629
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
630 sprintf (configuration_buffer, "%s-%s-%s%d.%d", arch, oem, os,
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
631 get_nt_major_version (), get_nt_minor_version ());
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
632 return configuration_buffer;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634
11384
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
635 #include <sys/timeb.h>
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
636
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
637 /* Emulate gettimeofday (Ulrich Leodolter, 1/11/95). */
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
638 void
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
639 gettimeofday (struct timeval *tv, struct timezone *tz)
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
640 {
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
641 struct _timeb tb;
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
642 _ftime (&tb);
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
643
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
644 tv->tv_sec = tb.time;
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
645 tv->tv_usec = tb.millitm * 1000L;
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
646 if (tz)
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
647 {
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
648 tz->tz_minuteswest = tb.timezone; /* minutes west of Greenwich */
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
649 tz->tz_dsttime = tb.dstflag; /* type of dst correction */
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
650 }
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
651 }
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
652
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
653 /* ------------------------------------------------------------------------- */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
654 /* IO support and wrapper functions for Win32 API. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
655 /* ------------------------------------------------------------------------- */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
656
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
657 /* 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
658 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
659 (Ulrich Leodolter, 1/11/95). */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
660 char *
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
661 sys_ctime (const time_t *t)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
662 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
663 char *str = (char *) ctime (t);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
664 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
665 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
666
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
667 /* 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
668 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
669 This is much easier. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
670 void
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
671 sys_sleep (int seconds)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
672 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
673 Sleep (seconds * 1000);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
674 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
675
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
676 /* 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
677 #if (_MSC_VER == 900)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
678 extern char _osfile[];
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
679 #endif
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
680 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
681 extern int __cdecl _free_osfhnd (int fd);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
682
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
683 /* 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
684 filedesc fd_info [ MAXDESC ];
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
685
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
686 static struct {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
687 DWORD serialnum;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
688 DWORD maxcomp;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
689 DWORD flags;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
690 char name[32];
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
691 char type[32];
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
692 } volume_info;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
693
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
694 /* 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
695 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
696 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
697 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
698 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
699 char temp[MAX_PATH];
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
700 char *rootname = NULL; /* default to current volume */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
701
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
702 if (name == NULL)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
703 return FALSE;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
704
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
705 /* 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
706 if (isalpha (name[0]) && name[1] == ':')
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
707 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
708 rootname = temp;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
709 temp[0] = *name++;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
710 temp[1] = *name++;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
711 temp[2] = '\\';
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
712 temp[3] = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
713 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
714 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
715 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
716 char *str = temp;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
717 int slashes = 4;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
718 rootname = temp;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
719 do
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
720 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
721 if (IS_DIRECTORY_SEP (*name) && --slashes == 0)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
722 break;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
723 *str++ = *name++;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
724 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
725 while ( *name );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
726
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
727 if (slashes > 1)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
728 return FALSE;
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 *str++ = '\\';
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
731 *str = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
732 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
733
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
734 if (pPath)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
735 *pPath = name;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
736
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
737 if (GetVolumeInformation (rootname,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
738 volume_info.name, 32,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
739 &volume_info.serialnum,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
740 &volume_info.maxcomp,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
741 &volume_info.flags,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
742 volume_info.type, 32))
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
743 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
744 return TRUE;
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 return FALSE;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
747 }
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 /* 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
750 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
751 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
752 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
753 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
754 if (get_volume_info (name, pPath))
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
755 return (volume_info.maxcomp == 12);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
756 return FALSE;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
757 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
758
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
759 /* 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
760 const char *
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
761 map_win32_filename (const char * name, const char ** pPath)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
762 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
763 static char shortname[MAX_PATH];
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
764 char * str = shortname;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
765 char c;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
766 char * path;
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 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
769 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
770 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
771 register int extn = 0; /* extension added? */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
772 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
773
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
774 while (name < path)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
775 *str++ = *name++; /* skip past UNC header */
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 while ((c = *name++))
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 switch ( c )
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
780 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
781 case '\\':
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
782 case '/':
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
783 *str++ = '\\';
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
784 extn = 0; /* reset extension flags */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
785 dots = 2; /* max 2 dots */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
786 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
787 break;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
788 case ':':
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
789 *str++ = ':';
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
790 extn = 0; /* reset extension flags */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
791 dots = 2; /* max 2 dots */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
792 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
793 break;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
794 case '.':
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
795 if ( dots )
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 /* 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
798 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
799 to be read as _emacs, for example. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
800
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
801 if (! *name ||
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
802 *name == '.' ||
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
803 IS_DIRECTORY_SEP (*name))
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
804 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
805 *str++ = '.';
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
806 dots--;
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 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
809 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
810 *str++ = '_';
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
811 left--;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
812 dots = 0;
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 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
815 else if ( !extn )
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
816 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
817 *str++ = '.';
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
818 extn = 1; /* we've got an extension */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
819 left = 3; /* 3 chars in extension */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
820 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
821 else
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 /* 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
824 *str++ = '_';
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
825 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
826 break;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
827 case '~':
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
828 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
829 if ( ! left )
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
830 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
831 /* FALLTHRU */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
832 default:
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
833 if ( left )
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
834 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
835 *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
836 left--;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
837 dots = 0; /* started a path component */
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 break;
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 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
842 *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
843 }
867e4ead88d9 (map_win32_filename): If not a fat volume, cvt name to dos.
Richard M. Stallman <rms@gnu.org>
parents: 15141
diff changeset
844 else
867e4ead88d9 (map_win32_filename): If not a fat volume, cvt name to dos.
Richard M. Stallman <rms@gnu.org>
parents: 15141
diff changeset
845 {
867e4ead88d9 (map_win32_filename): If not a fat volume, cvt name to dos.
Richard M. Stallman <rms@gnu.org>
parents: 15141
diff changeset
846 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
847 unixtodos_filename (shortname);
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
848 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
849
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
850 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
851 *pPath = shortname + (path - name);
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
852
15213
867e4ead88d9 (map_win32_filename): If not a fat volume, cvt name to dos.
Richard M. Stallman <rms@gnu.org>
parents: 15141
diff changeset
853 return shortname;
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
854 }
11384
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
855
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
857 /* 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
858 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
859 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
860 long file names. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
861
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
862 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
863 sys_access (const char * path, int mode)
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 return _access (map_win32_filename (path, NULL), mode);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
866 }
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 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
869 sys_chdir (const char * path)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
870 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
871 return _chdir (map_win32_filename (path, NULL));
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
872 }
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 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
875 sys_chmod (const char * path, int mode)
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 return _chmod (map_win32_filename (path, NULL), mode);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
878 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
879
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
880 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
881 sys_creat (const char * path, int mode)
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 return _creat (map_win32_filename (path, NULL), mode);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
884 }
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 FILE *
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
887 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
888 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
889 int fd;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
890 int oflag;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
891 const char * mode_save = mode;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
892
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
893 /* 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
894 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
895 prevent future file access. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
896
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
897 if (mode[0] == 'r')
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
898 oflag = O_RDONLY;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
899 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
900 oflag = O_WRONLY | O_CREAT | O_TRUNC;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
901 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
902 return NULL;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
903
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
904 /* Only do simplistic option parsing. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
905 while (*++mode)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
906 if (mode[0] == '+')
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
907 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
908 oflag &= ~(O_RDONLY | O_WRONLY);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
909 oflag |= O_RDWR;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
910 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
911 else if (mode[0] == 'b')
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
912 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
913 oflag &= ~O_TEXT;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
914 oflag |= O_BINARY;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
915 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
916 else if (mode[0] == 't')
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
917 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
918 oflag &= ~O_BINARY;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
919 oflag |= O_TEXT;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
920 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
921 else break;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
922
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
923 fd = _open (map_win32_filename (path, NULL), oflag | _O_NOINHERIT, 0644);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
924 if (fd < 0)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
925 return NULL;
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 return fdopen (fd, mode_save);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
928 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
929
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
930 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
931 sys_link (const char * path1, const char * path2)
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932 {
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
933 errno = EINVAL;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
934 return -1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
935 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
936
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
937 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
938 sys_mkdir (const char * path)
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 return _mkdir (map_win32_filename (path, NULL));
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
941 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
942
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
943 char *
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
944 sys_mktemp (char * template)
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 return (char *) map_win32_filename ((const char *) _mktemp (template), NULL);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
947 }
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
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
950 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
951 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
952 /* Force all file handles to be non-inheritable. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
953 return _open (map_win32_filename (path, NULL), oflag | _O_NOINHERIT, mode);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
954 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
955
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
956 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
957 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
958 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
959 char temp[MAX_PATH];
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
960
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
961 /* MoveFile on Win95 doesn't correctly change the short file name
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
962 alias when oldname has a three char extension and newname has the
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
963 same first three chars in its extension. To avoid problems, on
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
964 Win95 we rename to a temporary name first. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
965
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
966 strcpy (temp, map_win32_filename (oldname, NULL));
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 if (GetVersion () & 0x80000000)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
969 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
970 char * p;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
971
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
972 unixtodos_filename (temp);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
973 if (p = strrchr (temp, '\\'))
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
974 p++;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
975 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
976 p = temp;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
977 strcpy (p, "__XXXXXX");
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
978 _mktemp (temp);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
979 if (rename (map_win32_filename (oldname, NULL), temp) < 0)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
980 return -1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
981 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
982
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
983 /* Emulate Unix behaviour - newname is deleted if it already exists
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
984 (at least if it is a file; don't do this for directories). */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
985 newname = map_win32_filename (newname, NULL);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
986 if (GetFileAttributes (newname) != -1)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
987 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
988 _chmod (newname, 0666);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
989 _unlink (newname);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
990 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
991
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
992 return rename (temp, newname);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
993 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
994
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
995 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
996 sys_rmdir (const char * path)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
997 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
998 return _rmdir (map_win32_filename (path, NULL));
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
999 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1000
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1001 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1002 sys_unlink (const char * path)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1003 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1004 return _unlink (map_win32_filename (path, NULL));
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1005 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1006
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1007 static FILETIME utc_base_ft;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1008 static long double utc_base;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1009 static int init = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1010
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1011 static time_t
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1012 convert_time (FILETIME ft)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1013 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1014 long double ret;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1015
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1016 if (!init)
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1017 {
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1018 /* 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
1019 SYSTEMTIME st;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1020
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1021 st.wYear = 1970;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1022 st.wMonth = 1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1023 st.wDay = 1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1024 st.wHour = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1025 st.wMinute = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1026 st.wSecond = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1027 st.wMilliseconds = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1028
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1029 SystemTimeToFileTime (&st, &utc_base_ft);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1030 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
1031 * 4096 * 1024 * 1024 + utc_base_ft.dwLowDateTime;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1032 init = 1;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1033 }
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1034
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1035 if (CompareFileTime (&ft, &utc_base_ft) < 0)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1036 return 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1037
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1038 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
1039 ret -= utc_base;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1040 return (time_t) (ret * 1e-7);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1041 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1042
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1043 #if 0
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1044 /* 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
1045 void
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1046 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
1047 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1048 long double tmp;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1049
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1050 if (!init)
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 /* 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
1053 SYSTEMTIME st;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1054
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1055 st.wYear = 1970;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1056 st.wMonth = 1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1057 st.wDay = 1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1058 st.wHour = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1059 st.wMinute = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1060 st.wSecond = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1061 st.wMilliseconds = 0;
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 SystemTimeToFileTime (&st, &utc_base_ft);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1064 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
1065 * 4096 * 1024 * 1024 + utc_base_ft.dwLowDateTime;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1066 init = 1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1067 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1068
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1069 /* 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
1070 tmp = (long double) time * 1e7 + utc_base;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1071 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
1072 pft->dwLowDateTime = (DWORD) (tmp - pft->dwHighDateTime);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1073 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1074 #endif
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1075
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1076 /* "PJW" algorithm (see the "Dragon" compiler book). */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1077 static unsigned
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1078 hashval (const char * str)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1079 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1080 unsigned h = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1081 unsigned g;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1082 while (*str)
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1083 {
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1084 h = (h << 4) + *str++;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1085 if ((g = h & 0xf0000000) != 0)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1086 h = (h ^ (g >> 24)) & 0x0fffffff;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1087 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1088 return h;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1089 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1090
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1091 /* 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
1092 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
1093 static _ino_t
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1094 generate_inode_val (const char * name)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1095 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1096 char fullname[ MAX_PATH ];
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1097 char * p;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1098 unsigned hash;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1099
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1100 GetFullPathName (name, sizeof (fullname), fullname, &p);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1101 get_volume_info (fullname, &p);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1102 /* Normal Win32 filesystems are still case insensitive. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1103 _strlwr (p);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1104 hash = hashval (p);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1105 return (_ino_t) (hash ^ (hash >> 16));
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
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1108 /* 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
1109 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
1110 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
1111 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1112 stat (const char * path, struct stat * buf)
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 char * name;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1115 WIN32_FIND_DATA wfd;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1116 HANDLE fh;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1117 int permission;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1118 int len;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1119 int rootdir = FALSE;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1120
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1121 if (path == NULL || buf == NULL)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1122 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1123 errno = EFAULT;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1124 return -1;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1125 }
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1126
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1127 name = (char *) map_win32_filename (path, &path);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1128 /* must be valid filename, no wild cards */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1129 if (strchr (name, '*') || strchr (name, '?'))
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1130 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1131 errno = ENOENT;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1132 return -1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1133 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1134
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1135 /* 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
1136 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
1137 is a trailing separator. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1138 len = strlen (name);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1139 rootdir = (path >= name + len - 1
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1140 && (IS_DIRECTORY_SEP (*path) || *path == 0));
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1141 name = strcpy (alloca (len + 2), name);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1142
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1143 if (rootdir)
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1144 {
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1145 if (!IS_DIRECTORY_SEP (name[len-1]))
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1146 strcat (name, "\\");
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1147 if (GetDriveType (name) < 2)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1148 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1149 errno = ENOENT;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1150 return -1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1151 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1152 memset (&wfd, 0, sizeof (wfd));
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1153 wfd.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1154 wfd.ftCreationTime = utc_base_ft;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1155 wfd.ftLastAccessTime = utc_base_ft;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1156 wfd.ftLastWriteTime = utc_base_ft;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1157 strcpy (wfd.cFileName, name);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1158 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1159 else
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 if (IS_DIRECTORY_SEP (name[len-1]))
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1162 name[len - 1] = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1163 fh = FindFirstFile (name, &wfd);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1164 if (fh == INVALID_HANDLE_VALUE)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1165 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1166 errno = ENOENT;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1167 return -1;
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 FindClose (fh);
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
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1172 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
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 buf->st_mode = _S_IFDIR;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1175 buf->st_nlink = 2; /* doesn't really matter */
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1176 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1177 else
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1178 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1179 #if 0
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1180 /* 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
1181 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
1182 making a list of file name completions). */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1183 BY_HANDLE_FILE_INFORMATION info;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1184
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1185 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
1186 NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
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 if (GetFileInformationByHandle (fh, &info))
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1189 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1190 switch (GetFileType (fh))
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1191 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1192 case FILE_TYPE_DISK:
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1193 buf->st_mode = _S_IFREG;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1194 break;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1195 case FILE_TYPE_PIPE:
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1196 buf->st_mode = _S_IFIFO;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1197 break;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1198 case FILE_TYPE_CHAR:
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1199 case FILE_TYPE_UNKNOWN:
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1200 default:
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1201 buf->st_mode = _S_IFCHR;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1202 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1203 buf->st_nlink = info.nNumberOfLinks;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1204 /* 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
1205 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
1206 /* buf->st_ino = info.nFileIndexLow ^ info.nFileIndexHigh; */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1207 CloseHandle (fh);
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 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1210 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1211 errno = EACCES;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1212 return -1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1213 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1214 #else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1215 buf->st_mode = _S_IFREG;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1216 buf->st_nlink = 1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1217 #endif
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
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1220 /* consider files to belong to current user */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1221 buf->st_uid = the_passwd.pw_uid;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1222 buf->st_gid = the_passwd.pw_gid;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1223
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1224 /* volume_info is set indirectly by map_win32_filename */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1225 buf->st_dev = volume_info.serialnum;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1226 buf->st_rdev = volume_info.serialnum;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1227
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1228 buf->st_ino = generate_inode_val (name);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1229
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1230 buf->st_size = wfd.nFileSizeLow;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1231
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1232 /* Convert timestamps to Unix format. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1233 buf->st_mtime = convert_time (wfd.ftLastWriteTime);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1234 buf->st_atime = convert_time (wfd.ftLastAccessTime);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1235 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
1236 buf->st_ctime = convert_time (wfd.ftCreationTime);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1237 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
1238
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1239 /* determine rwx permissions */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1240 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1241 permission = _S_IREAD;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1242 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1243 permission = _S_IREAD | _S_IWRITE;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1244
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1245 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1246 permission |= _S_IEXEC;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1247 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1248 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1249 char * p = strrchr (name, '.');
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1250 if (p != NULL &&
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1251 (stricmp (p, ".exe") == 0 ||
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1252 stricmp (p, ".com") == 0 ||
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1253 stricmp (p, ".bat") == 0 ||
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1254 stricmp (p, ".cmd") == 0))
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1255 permission |= _S_IEXEC;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1256 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1257
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1258 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
1259
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1260 return 0;
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
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1263 #ifdef HAVE_SOCKETS
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1264
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1265 /* 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
1266 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
1267
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1268 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
1269 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
1270 otherwise provide the minimum necessary functionality
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1271 (eg. gethostname). */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1272
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1273 /* function pointers for relevant socket functions */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1274 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
1275 void (PASCAL *pfn_WSASetLastError) (int iError);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1276 int (PASCAL *pfn_WSAGetLastError) (void);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1277 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
1278 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
1279 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
1280 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
1281 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
1282 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
1283 int (PASCAL *pfn_closesocket) (SOCKET s);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1284 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
1285 int (PASCAL *pfn_WSACleanup) (void);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1286
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1287 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
1288 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
1289 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
1290 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
1291 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
1292 struct servent * (PASCAL *pfn_getservbyname) (const char * name, const char * proto);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1293
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1294 static int have_winsock;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1295 static HANDLE winsock_lib;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1296
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1297 static void
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1298 term_winsock (void)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1299 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1300 if (have_winsock)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1301 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1302 pfn_WSACleanup ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1303 FreeLibrary (winsock_lib);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1304 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1305 }
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 static void
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1308 init_winsock ()
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1309 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1310 WSADATA winsockData;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1311
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1312 winsock_lib = LoadLibrary ("wsock32.dll");
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1313
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1314 if (winsock_lib != NULL)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1315 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1316 /* dynamically link to socket functions */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1317
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1318 #define LOAD_PROC(fn) \
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1319 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
1320 goto fail;
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 LOAD_PROC( WSAStartup );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1323 LOAD_PROC( WSASetLastError );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1324 LOAD_PROC( WSAGetLastError );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1325 LOAD_PROC( socket );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1326 LOAD_PROC( bind );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1327 LOAD_PROC( connect );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1328 LOAD_PROC( ioctlsocket );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1329 LOAD_PROC( recv );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1330 LOAD_PROC( send );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1331 LOAD_PROC( closesocket );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1332 LOAD_PROC( shutdown );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1333 LOAD_PROC( htons );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1334 LOAD_PROC( ntohs );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1335 LOAD_PROC( inet_addr );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1336 LOAD_PROC( gethostname );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1337 LOAD_PROC( gethostbyname );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1338 LOAD_PROC( getservbyname );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1339 LOAD_PROC( WSACleanup );
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1340
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1341 /* specify version 1.1 of winsock */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1342 if (pfn_WSAStartup (0x101, &winsockData) == 0)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1343 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1344 have_winsock = TRUE;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1345 return;
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
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1348 fail:
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1349 FreeLibrary (winsock_lib);
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 have_winsock = FALSE;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1352 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1353
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1354
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1355 int h_errno = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1356
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1357 /* 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
1358 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
1359 are already in <sys/socket.h> */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1360 static void set_errno ()
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1361 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1362 if (!have_winsock)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1363 h_errno = EINVAL;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1364 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1365 h_errno = pfn_WSAGetLastError ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1366
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1367 switch (h_errno)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1368 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1369 case WSAEACCES: h_errno = EACCES; break;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1370 case WSAEBADF: h_errno = EBADF; break;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1371 case WSAEFAULT: h_errno = EFAULT; break;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1372 case WSAEINTR: h_errno = EINTR; break;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1373 case WSAEINVAL: h_errno = EINVAL; break;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1374 case WSAEMFILE: h_errno = EMFILE; break;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1375 case WSAENAMETOOLONG: h_errno = ENAMETOOLONG; break;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1376 case WSAENOTEMPTY: h_errno = ENOTEMPTY; break;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1377 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1378 errno = h_errno;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1379 }
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 static void check_errno ()
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1382 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1383 if (h_errno == 0 && have_winsock)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1384 pfn_WSASetLastError (0);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1385 }
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 /* [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
1388 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
1389 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
1390
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1391 //#define SOCK_REPLACE_HANDLE
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1392
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1393 #ifdef SOCK_REPLACE_HANDLE
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1394 #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
1395 #else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1396 #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
1397 #endif
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1398
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1399 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1400 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
1401 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1402 int fd;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1403 long s;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1404 child_process * cp;
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 if (!have_winsock)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1407 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1408 h_errno = ENETDOWN;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1409 return INVALID_SOCKET;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1410 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1411
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1412 check_errno ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1413
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1414 /* call the real socket function */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1415 s = (long) pfn_socket (af, type, protocol);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1416
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1417 if (s != INVALID_SOCKET)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1418 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1419 /* 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
1420 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
1421 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
1422 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
1423 descriptor handle with the one we want. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1424
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1425 /* allocate a file descriptor (with appropriate flags) */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1426 fd = _open ("NUL:", _O_RDWR);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1427 if (fd >= 0)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1428 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1429 #ifdef SOCK_REPLACE_HANDLE
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1430 /* 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
1431 CloseHandle ((HANDLE) _get_osfhandle (fd));
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1432 _free_osfhnd (fd);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1433 _set_osfhnd (fd, s);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1434 /* setmode (fd, _O_BINARY); */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1435 #else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1436 /* 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
1437 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1438 HANDLE parent;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1439 HANDLE new_s = INVALID_HANDLE_VALUE;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1440
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1441 parent = GetCurrentProcess ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1442
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1443 DuplicateHandle (parent,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1444 (HANDLE) s,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1445 parent,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1446 &new_s,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1447 0,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1448 FALSE,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1449 DUPLICATE_SAME_ACCESS);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1450 pfn_closesocket (s);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1451 fd_info[fd].hnd = new_s;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1452 s = (SOCKET) new_s;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1453 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1454 #endif
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 /* set our own internal flags */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1457 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
1458
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1459 cp = new_child ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1460 if (cp)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1461 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1462 cp->fd = fd;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1463 cp->status = STATUS_READ_ACKNOWLEDGED;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1464
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1465 /* attach child_process to fd_info */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1466 if (fd_info[ fd ].cp != NULL)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1467 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1468 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
1469 abort ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1470 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1471
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1472 fd_info[ fd ].cp = cp;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1473
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1474 /* success! */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1475 return fd;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1476 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1477
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1478 /* clean up */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1479 _close (fd);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1480 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1481 pfn_closesocket (s);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1482 h_errno = EMFILE;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1483 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1484 set_errno ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1485
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1486 return -1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1487 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1488
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1489
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1490 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1491 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
1492 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1493 if (!have_winsock)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1494 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1495 h_errno = ENOTSOCK;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1496 return SOCKET_ERROR;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1497 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1498
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1499 check_errno ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1500 if (fd_info[s].flags & FILE_SOCKET)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1501 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1502 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
1503 if (rc == SOCKET_ERROR)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1504 set_errno ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1505 return rc;
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 h_errno = ENOTSOCK;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1508 return SOCKET_ERROR;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1509 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1510
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1511
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1512 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1513 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
1514 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1515 if (!have_winsock)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1516 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1517 h_errno = ENOTSOCK;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1518 return SOCKET_ERROR;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1519 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1520
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1521 check_errno ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1522 if (fd_info[s].flags & FILE_SOCKET)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1523 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1524 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
1525 if (rc == SOCKET_ERROR)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1526 set_errno ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1527 return rc;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1528 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1529 h_errno = ENOTSOCK;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1530 return SOCKET_ERROR;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1531 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1532
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1533 u_short
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1534 sys_htons (u_short hostshort)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1535 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1536 return (have_winsock) ?
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1537 pfn_htons (hostshort) : hostshort;
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
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1540 u_short
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1541 sys_ntohs (u_short netshort)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1542 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1543 return (have_winsock) ?
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1544 pfn_ntohs (netshort) : netshort;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1545 }
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 unsigned long
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1548 sys_inet_addr (const char * cp)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1549 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1550 return (have_winsock) ?
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1551 pfn_inet_addr (cp) : INADDR_NONE;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1552 }
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 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1555 sys_gethostname (char * name, int namelen)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1556 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1557 if (have_winsock)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1558 return pfn_gethostname (name, namelen);
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 if (namelen > MAX_COMPUTERNAME_LENGTH)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1561 return !GetComputerName (name, &namelen);
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 h_errno = EFAULT;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1564 return SOCKET_ERROR;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1565 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1566
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1567 struct hostent *
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1568 sys_gethostbyname(const char * name)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1569 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1570 struct hostent * host;
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 if (!have_winsock)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1573 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1574 h_errno = ENETDOWN;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1575 return NULL;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1576 }
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 check_errno ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1579 host = pfn_gethostbyname (name);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1580 if (!host)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1581 set_errno ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1582 return host;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1583 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1584
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1585 struct servent *
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1586 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
1587 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1588 struct servent * serv;
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 if (!have_winsock)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1591 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1592 h_errno = ENETDOWN;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1593 return NULL;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1594 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1595
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1596 check_errno ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1597 serv = pfn_getservbyname (name, proto);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1598 if (!serv)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1599 set_errno ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1600 return serv;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1601 }
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1602
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1603 #endif /* HAVE_SOCKETS */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1604
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1605
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1606 /* 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
1607 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
1608
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1609 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1610 sys_close (int fd)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1611 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1612 int rc;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1613
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1614 if (fd < 0 || fd >= MAXDESC)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1615 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1616 errno = EBADF;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1617 return -1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1618 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1619
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1620 if (fd_info[fd].cp)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1621 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1622 child_process * cp = fd_info[fd].cp;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1623
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1624 fd_info[fd].cp = NULL;
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 if (CHILD_ACTIVE (cp))
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 /* 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
1629 int i;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1630 for (i = 0; i < MAXDESC; i++)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1631 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1632 if (i == fd)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1633 continue;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1634 if (fd_info[i].cp == cp)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1635 break;
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 if (i == MAXDESC)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1638 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1639 #if defined (HAVE_SOCKETS) && !defined (SOCK_REPLACE_HANDLE)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1640 if (fd_info[fd].flags & FILE_SOCKET)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1641 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1642 if (!have_winsock) abort ();
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 pfn_shutdown (SOCK_HANDLE (fd), 2);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1645 rc = pfn_closesocket (SOCK_HANDLE (fd));
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1646 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1647 #endif
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1648 delete_child (cp);
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 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1652
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1653 /* 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
1654 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
1655 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
1656 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
1657 rc = _close (fd);
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 if (rc == 0)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1660 fd_info[fd].flags = 0;
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 return rc;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1663 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1664
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1665 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1666 sys_dup (int fd)
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 int new_fd;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1669
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1670 new_fd = _dup (fd);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1671 if (new_fd >= 0)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1672 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1673 /* duplicate our internal info as well */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1674 fd_info[new_fd] = fd_info[fd];
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1675 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1676 return new_fd;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1677 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1678
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 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1681 sys_dup2 (int src, int dst)
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 int rc;
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 if (dst < 0 || dst >= MAXDESC)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1686 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1687 errno = EBADF;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1688 return -1;
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
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1691 /* 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
1692 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
1693 sys_close (dst);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1694
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1695 rc = _dup2 (src, dst);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1696 if (rc == 0)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1697 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1698 /* duplicate our internal info as well */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1699 fd_info[dst] = fd_info[src];
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1700 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1701 return rc;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1702 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1703
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1704 /* From callproc.c */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1705 extern Lisp_Object Vbinary_process_input;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1706 extern Lisp_Object Vbinary_process_output;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1707
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1708 /* Unix pipe() has only one arg */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1709 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1710 sys_pipe (int * phandles)
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 int rc;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1713 unsigned flags;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1714 child_process * cp;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1715
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1716 /* 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
1717 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
1718 rc = _pipe (phandles, 0, _O_NOINHERIT);
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 if (rc == 0)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1721 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1722 /* 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
1723 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
1724 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
1725 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
1726 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
1727 finished). */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1728 flags = FILE_PIPE | FILE_READ;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1729 if (!NILP (Vbinary_process_output))
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1730 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1731 flags |= FILE_BINARY;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1732 setmode (phandles[0], _O_BINARY);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1733 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1734 #if (_MSC_VER == 900)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1735 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1736 _osfile[phandles[0]] |= 0x40;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1737 #endif
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 fd_info[phandles[0]].flags = flags;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1740
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1741 flags = FILE_PIPE | FILE_WRITE;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1742 if (!NILP (Vbinary_process_input))
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1743 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1744 flags |= FILE_BINARY;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1745 setmode (phandles[1], _O_BINARY);
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 #if (_MSC_VER == 900)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1748 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1749 _osfile[phandles[1]] |= 0x40;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1750 #endif
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1751
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1752 fd_info[phandles[1]].flags = flags;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1753 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1754
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1755 return rc;
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
15249
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1758 /* From ntproc.c */
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1759 extern Lisp_Object Vwin32_pipe_read_delay;
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1760
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1761 /* 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
1762 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
1763 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1764 _sys_read_ahead (int fd)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1765 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1766 child_process * cp;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1767 int rc;
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 if (fd < 0 || fd >= MAXDESC)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1770 return STATUS_READ_ERROR;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1771
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1772 cp = fd_info[fd].cp;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1773
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1774 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
1775 return STATUS_READ_ERROR;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1776
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1777 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
1778 || (fd_info[fd].flags & FILE_READ) == 0)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1779 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1780 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
1781 abort ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1782 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1783
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1784 cp->status = STATUS_READ_IN_PROGRESS;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1785
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1786 if (fd_info[fd].flags & FILE_PIPE)
15249
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1787 {
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1788 /* Use read to get CRLF translation */
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1789 rc = _read (fd, &cp->chr, sizeof (char));
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1790
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1791 /* 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
1792 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
1793 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
1794 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
1795 write to stdout without buffering, ie. one character at a
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1796 time. Even some Win32 programs do this - "dir" in a command
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1797 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
1798 if (rc > 0)
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1799 {
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1800 int wait = XINT (Vwin32_pipe_read_delay);
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1801
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1802 if (wait > 0)
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1803 Sleep (wait);
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1804 else if (wait < 0)
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1805 while (++wait <= 0)
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1806 /* 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
1807 temporary priority boost to the child process. */
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1808 Sleep (0);
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1809 }
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1810 }
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1811 #ifdef HAVE_SOCKETS
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1812 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
1813 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
1814 #endif
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1815
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1816 if (rc == sizeof (char))
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1817 cp->status = STATUS_READ_SUCCEEDED;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1818 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1819 cp->status = STATUS_READ_FAILED;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1820
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1821 return cp->status;
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
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1824 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1825 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
1826 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1827 int nchars;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1828 int extra = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1829 int to_read;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1830 DWORD waiting;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1831
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1832 if (fd < 0 || fd >= MAXDESC)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1833 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1834 errno = EBADF;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1835 return -1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1836 }
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 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
1839 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1840 child_process *cp = fd_info[fd].cp;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1841
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1842 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
1843 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1844 errno = EBADF;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1845 return -1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1846 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1847
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1848 /* 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
1849 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
1850 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
1851 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
1852 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
1853 if (cp)
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 int current_status = cp->status;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1856
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1857 switch (current_status)
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 case STATUS_READ_FAILED:
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1860 case STATUS_READ_ERROR:
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1861 /* report normal EOF */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1862 return 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1863
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1864 case STATUS_READ_READY:
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1865 case STATUS_READ_IN_PROGRESS:
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1866 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
1867 errno = EWOULDBLOCK;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1868 return -1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1869
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1870 case STATUS_READ_SUCCEEDED:
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1871 /* consume read-ahead char */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1872 *buffer++ = cp->chr;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1873 count--;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1874 extra = 1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1875 cp->status = STATUS_READ_ACKNOWLEDGED;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1876 ResetEvent (cp->char_avail);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1877
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1878 case STATUS_READ_ACKNOWLEDGED:
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1879 break;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1880
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1881 default:
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1882 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
1883 errno = EBADF;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1884 return -1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1885 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1886
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1887 if (fd_info[fd].flags & FILE_PIPE)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1888 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1889 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
1890 to_read = min (waiting, (DWORD) count);
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 /* Use read to get CRLF translation */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1893 nchars = _read (fd, buffer, to_read);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1894 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1895 #ifdef HAVE_SOCKETS
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1896 else /* FILE_SOCKET */
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 if (!have_winsock) abort ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1899
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1900 /* 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
1901 pfn_ioctlsocket (SOCK_HANDLE (fd), FIONREAD, &waiting);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1902 if (waiting == 0 && extra == 0)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1903 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1904 h_errno = errno = EWOULDBLOCK;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1905 return -1;
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
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1908 nchars = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1909 if (waiting)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1910 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1911 /* always use binary mode for sockets */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1912 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
1913 if (nchars == SOCKET_ERROR)
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 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
1916 pfn_WSAGetLastError (), SOCK_HANDLE (fd)));
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1917 if (extra == 0)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1918 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1919 set_errno ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1920 return -1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1921 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1922 nchars = 0;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1923 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1924 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1925 }
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 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1929 nchars = _read (fd, buffer, count);
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 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1932 nchars = _read (fd, buffer, count);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1933
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1934 return nchars + extra;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1935 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1936
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1937 /* 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
1938 int
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1939 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
1940 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1941 int nchars;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1942
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1943 if (fd < 0 || fd >= MAXDESC)
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 errno = EBADF;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1946 return -1;
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
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1949 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
1950 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
1951 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1952 errno = EBADF;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1953 return -1;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1954 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1955 #ifdef HAVE_SOCKETS
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1956 if (fd_info[fd].flags & FILE_SOCKET)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1957 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1958 if (!have_winsock) abort ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1959 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
1960 if (nchars == SOCKET_ERROR)
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 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
1963 pfn_WSAGetLastError (), SOCK_HANDLE (fd)));
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1964 set_errno ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1965 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1966 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1967 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1968 #endif
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1969 nchars = _write (fd, buffer, count);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1970
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1971 return nchars;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1972 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1973
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1974
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1975 void
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1976 term_ntproc ()
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1977 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1978 #ifdef HAVE_SOCKETS
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1979 /* shutdown the socket interface if necessary */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1980 term_winsock ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1981 #endif
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1982 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1983
15249
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1984 extern BOOL can_run_dos_process;
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
1985 extern BOOL dos_process_running;
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 void
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1988 init_ntproc ()
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1989 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1990 #ifdef HAVE_SOCKETS
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1991 /* initialise the socket interface if available */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1992 init_winsock ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1993 #endif
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1994
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1995 /* 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
1996 handles with non-inheritable versions. */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1997 {
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1998 HANDLE parent;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
1999 HANDLE stdin_save = INVALID_HANDLE_VALUE;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2000 HANDLE stdout_save = INVALID_HANDLE_VALUE;
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2001 HANDLE stderr_save = INVALID_HANDLE_VALUE;
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 parent = GetCurrentProcess ();
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2004
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2005 /* 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
2006 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
2007 DuplicateHandle (parent,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2008 GetStdHandle (STD_INPUT_HANDLE),
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2009 parent,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2010 &stdin_save,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2011 0,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2012 FALSE,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2013 DUPLICATE_SAME_ACCESS);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2014
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2015 DuplicateHandle (parent,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2016 GetStdHandle (STD_OUTPUT_HANDLE),
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2017 parent,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2018 &stdout_save,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2019 0,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2020 FALSE,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2021 DUPLICATE_SAME_ACCESS);
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 DuplicateHandle (parent,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2024 GetStdHandle (STD_ERROR_HANDLE),
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2025 parent,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2026 &stderr_save,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2027 0,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2028 FALSE,
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2029 DUPLICATE_SAME_ACCESS);
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 fclose (stdin);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2032 fclose (stdout);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2033 fclose (stderr);
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 if (stdin_save != INVALID_HANDLE_VALUE)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2036 _open_osfhandle ((long) stdin_save, O_TEXT);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2037 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2038 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
2039 fdopen (0, "r");
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2040
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2041 if (stdout_save != INVALID_HANDLE_VALUE)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2042 _open_osfhandle ((long) stdout_save, O_TEXT);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2043 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2044 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
2045 fdopen (1, "w");
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2046
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2047 if (stderr_save != INVALID_HANDLE_VALUE)
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2048 _open_osfhandle ((long) stderr_save, O_TEXT);
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2049 else
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2050 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
2051 fdopen (2, "w");
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2052 }
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2053
15249
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
2054 /* Only allow Emacs to run DOS programs on Win95. */
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
2055 can_run_dos_process = (GetVersion () & 0x80000000);
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
2056 dos_process_running = FALSE;
53bb2499db2a (_sys_read_ahead): Handle sleep here.
Karl Heuer <kwzh@gnu.org>
parents: 15237
diff changeset
2057
15141
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2058 /* unfortunately, atexit depends on implementation of malloc */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2059 /* atexit (term_ntproc); */
6565b268b12a (nt_stat, nt_ctime): Functions deleted.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14912
diff changeset
2060 signal (SIGABRT, term_ntproc);
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 /* end of nt.c */