annotate src/w32.c @ 14001:be4f869af091

(remote-compile-run-before): Doc fix.
author Karl Heuer <kwzh@gnu.org>
date Thu, 04 Jan 1996 23:46:40 +0000
parents de7851688890
children ee40177f6c68
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
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 This file is part of GNU Emacs.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify it
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
11384
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any later
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 version.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful, but WITHOUT
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 more details.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License along
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 with GNU Emacs; see the file COPYING. If not, write to the Free Software
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 Geoff Voelker (voelker@cs.washington.edu) 7-29-94
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
11384
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
23 /* Define stat before including config.h. */
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
24 #include <string.h>
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
25 #include <sys/stat.h>
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
26 int
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
27 nt_stat (char *filename, struct stat *statbuf)
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
28 {
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
29 int r, l = strlen (filename);
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
30 char *str = NULL;
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
31 extern long *xmalloc ();
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
32 extern void xfree ();
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
33
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
34 /* stat has a bug when passed a name of a directory with a trailing
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
35 backslash (but a trailing forward slash works fine). */
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
36 if (filename[l - 1] == '\\')
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
37 {
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
38 str = (char *) xmalloc (l + 1);
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
39 strcpy (str, filename);
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
40 str[l - 1] = '/';
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
41 r = stat (str, statbuf);
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
42 xfree (str);
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
43 return r;
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
44 }
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
45 else
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
46 return stat (filename, statbuf);
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
47 }
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
48
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
49 /* Place a wrapper around the NT version of ctime. It returns NULL
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
50 on network directories, so we handle that case here.
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
51 Define it before including config.h. (Ulrich Leodolter, 1/11/95). */
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
52 char *
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
53 nt_ctime (const time_t *t)
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
54 {
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
55 char *str = (char *) ctime (t);
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
56 return (str ? str : "Sun Jan 01 00:00:00 1970");
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
57 }
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
58
12183
47685fb0fbd1 Include config.h before stdio.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12025
diff changeset
59 #include <config.h>
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 #include <windows.h>
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 #include <stdlib.h>
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 #include <stdio.h>
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 #include <io.h>
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 #include <fcntl.h>
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 #include <ctype.h>
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 #define getwd _getwd
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 #include "lisp.h"
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 #undef getwd
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 #include <pwd.h>
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 #include "ndir.h"
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 #include "ntheap.h"
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 extern int report_file_error (char *, Lisp_Object);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 /* Get the current working directory. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 getwd (char *dir)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 return GetCurrentDirectory (MAXPATHLEN, dir);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 /* Emulate gethostname. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 gethostname (char *buffer, int size)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 /* NT only allows small host names, so the buffer is
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 certainly large enough. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 return !GetComputerName (buffer, &size);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 /* Emulate getloadavg. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 getloadavg (double loadavg[], int nelem)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 int i;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 /* 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
101 for (i = 0; i < nelem; i++)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 loadavg[i] = 0.0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 return i;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 }
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 /* Emulate sleep...we could have done this with a define, but that
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 would necessitate including windows.h in the files that used it.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 This is much easier. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 void
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 nt_sleep (int seconds)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 Sleep (seconds * 1000);
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
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 /* Emulate the Unix directory procedures opendir, closedir,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 and readdir. We can't use the procedures supplied in sysdep.c,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 so we provide them here. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 struct direct dir_static; /* simulated directory contents */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 static int dir_finding;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 static HANDLE dir_find_handle;
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
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 this operation, so we have a flag to handle the open at read
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 time. This flag essentially means "there is a find-handle open and
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 it needs to be closed." */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 if (!(dirp = (DIR *) malloc (sizeof (DIR))))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 return 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 dirp->dd_fd = 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 dirp->dd_loc = 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 dirp->dd_size = 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 /* This is tacky, but we need the directory name for our
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 implementation of readdir. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 strncpy (dirp->dd_buf, filename, DIRBLKSIZ);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 return dirp;
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
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 void
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 closedir (DIR *dirp)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 /* If we have a find-handle open, close it. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 if (dir_finding)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 FindClose (dir_find_handle);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 dir_finding = 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 xfree ((char *) dirp);
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
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 struct direct *
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 readdir (DIR *dirp)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 WIN32_FIND_DATA find_data;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 /* If we aren't dir_finding, do a find-first, otherwise do a find-next. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 if (!dir_finding)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 char filename[MAXNAMLEN + 3];
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 int ln;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 strncpy (filename, dirp->dd_buf, MAXNAMLEN);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 ln = strlen (filename)-1;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 if (filename[ln] != '\\' && filename[ln] != ':')
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 strcat (filename, "\\");
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 strcat (filename, "*.*");
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 dir_find_handle = FindFirstFile (filename, &find_data);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 if (dir_find_handle == INVALID_HANDLE_VALUE)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 return NULL;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 dir_finding = 1;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 else
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 if (!FindNextFile (dir_find_handle, &find_data))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 return NULL;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 /* NT's unique ID for a file is 64 bits, so we have to fake it here.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 This should work as long as we never use 0. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 dir_static.d_ino = 1;
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_reclen = sizeof (struct direct) - MAXNAMLEN + 3 +
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 dir_static.d_namlen - dir_static.d_namlen % 4;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 dir_static.d_namlen = strlen (find_data.cFileName);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 strncpy (dir_static.d_name, find_data.cFileName, MAXNAMLEN);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 return &dir_static;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 /* Emulate getpwuid and getpwnam. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 int getuid (); /* forward declaration */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208
12451
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
209 #define PASSWD_FIELD_SIZE 256
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
210
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
211 static char the_passwd_name[PASSWD_FIELD_SIZE];
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
212 static char the_passwd_passwd[PASSWD_FIELD_SIZE];
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
213 static char the_passwd_gecos[PASSWD_FIELD_SIZE];
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
214 static char the_passwd_dir[PASSWD_FIELD_SIZE];
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
215 static char the_passwd_shell[PASSWD_FIELD_SIZE];
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 static struct passwd the_passwd =
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 the_passwd_name,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 the_passwd_passwd,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 0,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 0,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 0,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 the_passwd_gecos,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 the_passwd_dir,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 the_passwd_shell,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 };
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 struct passwd *
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 getpwuid (int uid)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 {
12451
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
232 int size = PASSWD_FIELD_SIZE;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 if (!GetUserName (the_passwd.pw_name, &size))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 return NULL;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 the_passwd.pw_passwd[0] = '\0';
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 the_passwd.pw_uid = 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 the_passwd.pw_gid = 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 strcpy (the_passwd.pw_gecos, the_passwd.pw_name);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 the_passwd.pw_dir[0] = '\0';
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 the_passwd.pw_shell[0] = '\0';
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 return &the_passwd;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 struct passwd *
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 getpwnam (char *name)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 struct passwd *pw;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 pw = getpwuid (getuid ());
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 if (!pw)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 return pw;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 if (strcmp (name, pw->pw_name))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 return NULL;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 return pw;
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
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 /* We don't have scripts to automatically determine the system configuration
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 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
265 user enter it, so we define EMACS_CONFIGURATION to invoke this runtime
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 routine. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267
11941
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
268 static char configuration_buffer[32];
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 char *
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 get_emacs_configuration (void)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 {
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
273 char *arch, *oem, *os;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
275 /* Determine the processor type. */
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
276 switch (get_processor_type ())
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
277 {
12451
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
278
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
279 #ifdef PROCESSOR_INTEL_386
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
280 case PROCESSOR_INTEL_386:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
281 case PROCESSOR_INTEL_486:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
282 case PROCESSOR_INTEL_PENTIUM:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
283 arch = "i386";
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
284 break;
12451
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
285 #endif
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
286
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
287 #ifdef PROCESSOR_INTEL_860
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
288 case PROCESSOR_INTEL_860:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
289 arch = "i860";
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
290 break;
12451
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
291 #endif
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
292
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
293 #ifdef PROCESSOR_MIPS_R2000
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
294 case PROCESSOR_MIPS_R2000:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
295 case PROCESSOR_MIPS_R3000:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
296 case PROCESSOR_MIPS_R4000:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
297 arch = "mips";
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
298 break;
12451
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
299 #endif
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
300
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
301 #ifdef PROCESSOR_ALPHA_21064
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
302 case PROCESSOR_ALPHA_21064:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
303 arch = "alpha";
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
304 break;
12451
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
305 #endif
4439dcb1496a (PASSWD_FIELD_SIZE): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12183
diff changeset
306
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
307 default:
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
308 arch = "unknown";
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
309 break;
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
310 }
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
312 /* 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
313 oem = "*";
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314
11941
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
315 #ifdef WINDOWS95
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
316 os = "win";
11941
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
317 #else
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
318 os = "nt";
11941
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
319 #endif
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
320
13156
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
321 sprintf (configuration_buffer, "%s-%s-%s%d.%d", arch, oem, os,
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
322 get_nt_major_version (), get_nt_minor_version ());
a398dbd2b945 Indentation change.
Richard M. Stallman <rms@gnu.org>
parents: 12451
diff changeset
323 return configuration_buffer;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 /* Conjure up inode and device numbers that will serve the purpose
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 of Emacs. Return 1 upon success, 0 upon failure. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 get_inode_and_device_vals (Lisp_Object filename, Lisp_Object *p_inode,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 Lisp_Object *p_device)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 /* File uids on NT are found using a handle to a file, which
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 implies that it has been opened. Since we want to be able
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 to stat an arbitrary file, we must open it, get the info,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 and then close it.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 Also, NT file uids are 64-bits. This is a problem. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 HANDLE handle;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 BOOL result;
11384
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
341 DWORD attrs;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 BY_HANDLE_FILE_INFORMATION info;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343
11384
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
344 /* We have to stat files and directories differently, so check
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
345 to see what filename references. */
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
346 attrs = GetFileAttributes (XSTRING (filename)->data);
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
347 if (attrs == 0xFFFFFFFF) {
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
348 return 0;
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
349 }
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
350 if (attrs & FILE_ATTRIBUTE_DIRECTORY) {
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
351 /* Conjure up bogus, but unique, values. */
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
352 attrs = GetTickCount ();
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
353 *p_inode = make_number (attrs);
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
354 *p_device = make_number (attrs);
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
355 return 1;
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
356 }
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
357
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 /* FIXME: It shouldn't be opened without READ access, but NT on x86
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 doesn't allow GetFileInfo in that case (NT on mips does). */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 handle = CreateFile (XSTRING (filename)->data,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 GENERIC_READ,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 FILE_SHARE_READ | FILE_SHARE_WRITE,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 NULL,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 OPEN_EXISTING,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 FILE_ATTRIBUTE_NORMAL,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 NULL);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 if (handle == INVALID_HANDLE_VALUE)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 return 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 result = GetFileInformationByHandle (handle, &info);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 CloseHandle (handle);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 if (!result)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 return 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 *p_inode = make_number (info.nFileIndexLow); /* use the low value */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 *p_device = make_number (info.dwVolumeSerialNumber);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 return 1;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 /* The following pipe routines are used to support our fork emulation.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 Since NT's crt dup always creates inherited handles, we
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 must be careful in setting up pipes. First create
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 non-inherited pipe handles, then create an inherited handle
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 to the write end by dup-ing it, and then close the non-inherited
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 end that was just duped. This gives us one non-inherited handle
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 on the read end and one inherited handle to the write end. As
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 the parent, we close the inherited handle to the write end after
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 spawning the child. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 /* From callproc.c */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 extern Lisp_Object Vbinary_process_input;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 extern Lisp_Object Vbinary_process_output;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 void
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 pipe_with_inherited_out (int fds[2])
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 int inherit_out;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 unsigned int flags = _O_NOINHERIT;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 if (!NILP (Vbinary_process_output))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 flags |= _O_BINARY;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 _pipe (fds, 0, flags);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 inherit_out = dup (fds[1]);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 close (fds[1]);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 fds[1] = inherit_out;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 void
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 pipe_with_inherited_in (int fds[2])
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 int inherit_in;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 unsigned int flags = _O_NOINHERIT;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 if (!NILP (Vbinary_process_input))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 flags |= _O_BINARY;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 _pipe (fds, 0, flags);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 inherit_in = dup (fds[0]);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 close (fds[0]);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 fds[0] = inherit_in;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 /* The following two routines are used to manipulate stdin, stdout, and
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 stderr of our child processes.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 Assuming that in, out, and err are inherited, we make them stdin,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 stdout, and stderr of the child as follows:
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 - Save the parent's current standard handles.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 - Set the parent's standard handles to the handles being passed in.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (Note that _get_osfhandle is an io.h procedure that
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 maps crt file descriptors to NT file handles.)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 - Spawn the child, which inherits in, out, and err as stdin,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 stdout, and stderr. (see Spawnve)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 - Reset the parent's standard handles to the saved handles.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 (see reset_standard_handles)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 We assume that the caller closes in, out, and err after calling us. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 void
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 prepare_standard_handles (int in, int out, int err, HANDLE handles[4])
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 HANDLE parent, stdin_save, stdout_save, stderr_save, err_handle;
11941
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
446
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
447 #ifdef WINDOWS95
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
448 /* The Win95 beta doesn't set the standard handles correctly.
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
449 Handicap subprocesses until we get a version that works correctly.
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
450 Undefining the subprocesses macro reveals other incompatibilities,
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
451 so, since we're expecting subprocs to work in the near future,
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
452 disable them here. */
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
453 report_file_error ("Subprocesses currently disabled on Win95", Qnil);
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
454 #endif
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
455
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 parent = GetCurrentProcess ();
11941
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
457 stdin_save = GetStdHandle (STD_INPUT_HANDLE);
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
458 stdout_save = GetStdHandle (STD_OUTPUT_HANDLE);
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
459 stderr_save = GetStdHandle (STD_ERROR_HANDLE);
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
460
13427
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
461 #ifndef HAVE_NTGUI
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 if (!DuplicateHandle (parent,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 GetStdHandle (STD_INPUT_HANDLE),
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 parent,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 &stdin_save,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 0,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 FALSE,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 DUPLICATE_SAME_ACCESS))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 report_file_error ("Duplicating parent's input handle", Qnil);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 if (!DuplicateHandle (parent,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 GetStdHandle (STD_OUTPUT_HANDLE),
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 parent,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 &stdout_save,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 0,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 FALSE,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 DUPLICATE_SAME_ACCESS))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 report_file_error ("Duplicating parent's output handle", Qnil);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 if (!DuplicateHandle (parent,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 GetStdHandle (STD_ERROR_HANDLE),
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 parent,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 &stderr_save,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 0,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 FALSE,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 DUPLICATE_SAME_ACCESS))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 report_file_error ("Duplicating parent's error handle", Qnil);
13427
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
488 #endif /* !HAVE_NTGUI */
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 if (!SetStdHandle (STD_INPUT_HANDLE, (HANDLE) _get_osfhandle (in)))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 report_file_error ("Changing stdin handle", Qnil);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 if (!SetStdHandle (STD_OUTPUT_HANDLE, (HANDLE) _get_osfhandle (out)))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 report_file_error ("Changing stdout handle", Qnil);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 /* We lose data if we use the same handle to the pipe for stdout and
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 stderr, so make a duplicate. This took a while to find. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 if (out == err)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 if (!DuplicateHandle (parent,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 (HANDLE) _get_osfhandle (err),
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 parent,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 &err_handle,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 0,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 TRUE,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 DUPLICATE_SAME_ACCESS))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 report_file_error ("Duplicating out handle to make err handle.",
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 Qnil);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 else
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 err_handle = (HANDLE) _get_osfhandle (err);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 if (!SetStdHandle (STD_ERROR_HANDLE, err_handle))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 report_file_error ("Changing stderr handle", Qnil);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 handles[0] = stdin_save;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 handles[1] = stdout_save;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 handles[2] = stderr_save;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 handles[3] = err_handle;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 void
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 reset_standard_handles (int in, int out, int err, HANDLE handles[4])
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 HANDLE stdin_save = handles[0];
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 HANDLE stdout_save = handles[1];
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 HANDLE stderr_save = handles[2];
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 HANDLE err_handle = handles[3];
11941
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
531 int i;
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
532
13427
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
533 #ifndef HAVE_NTGUI
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 if (!SetStdHandle (STD_INPUT_HANDLE, stdin_save))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 report_file_error ("Resetting input handle", Qnil);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 if (!SetStdHandle (STD_OUTPUT_HANDLE, stdout_save))
11941
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
538 {
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
539 i = GetLastError ();
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
540 report_file_error ("Resetting output handle", Qnil);
cb26a4ca0e10 (configuration_buffer): Increase size.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11384
diff changeset
541 }
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 if (!SetStdHandle (STD_ERROR_HANDLE, stderr_save))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 report_file_error ("Resetting error handle", Qnil);
13427
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
545 #endif /* !HAVE_NTGUI */
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 if (out == err)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 /* If out and err are the same handle, then we duplicated out
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 and stuck it in err_handle. Close the duplicate to clean up. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 if (!CloseHandle (err_handle))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 report_file_error ("Closing error handle duplicated from out.",
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 Qnil);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556
11384
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
557 int
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
558 random ()
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
559 {
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
560 /* rand () on NT gives us 15 random bits...hack together 30 bits. */
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
561 return ((rand () << 15) | rand ());
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
562 }
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
563
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
564 void
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
565 srandom (int seed)
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
566 {
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
567 srand (seed);
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
568 }
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
569
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 /* Destructively turn backslashes into slashes. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 void
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 dostounix_filename (p)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 register char *p;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 while (*p)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 if (*p == '\\')
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 *p = '/';
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 p++;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 }
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 /* Routines that are no-ops on NT but are defined to get Emacs to compile. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 sigsetmask (int signal_mask)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 return 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 sigblock (int sig)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 return 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 kill (int pid, int signal)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 return 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 setpgrp (int pid, int gid)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 return 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 alarm (int seconds)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 return 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 unrequest_sigio (void)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 return 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 request_sigio (void)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 return 0;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 getuid ()
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 {
13932
de7851688890 (getuid): Only return root uid if Administrator.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13427
diff changeset
631 char buffer[256];
de7851688890 (getuid): Only return root uid if Administrator.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13427
diff changeset
632 int size = 256;
de7851688890 (getuid): Only return root uid if Administrator.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13427
diff changeset
633
de7851688890 (getuid): Only return root uid if Administrator.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13427
diff changeset
634 if (!GetUserName (buffer, &size))
de7851688890 (getuid): Only return root uid if Administrator.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13427
diff changeset
635 /* Assume all powers upon failure. */
de7851688890 (getuid): Only return root uid if Administrator.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13427
diff changeset
636 return 0;
de7851688890 (getuid): Only return root uid if Administrator.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13427
diff changeset
637
de7851688890 (getuid): Only return root uid if Administrator.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13427
diff changeset
638 if (!stricmp ("administrator", buffer))
de7851688890 (getuid): Only return root uid if Administrator.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13427
diff changeset
639 return 0;
de7851688890 (getuid): Only return root uid if Administrator.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13427
diff changeset
640 else
de7851688890 (getuid): Only return root uid if Administrator.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13427
diff changeset
641 /* A complete fabrication...is there anything to base it on? */
de7851688890 (getuid): Only return root uid if Administrator.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13427
diff changeset
642 return 123;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 geteuid ()
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 {
13932
de7851688890 (getuid): Only return root uid if Administrator.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13427
diff changeset
648 /* I could imagine arguing for checking to see whether the user is
de7851688890 (getuid): Only return root uid if Administrator.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13427
diff changeset
649 in the Administrators group and returning a UID of 0 for that
de7851688890 (getuid): Only return root uid if Administrator.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13427
diff changeset
650 case, but I don't know how wise that would be in the long run. */
de7851688890 (getuid): Only return root uid if Administrator.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13427
diff changeset
651 return getuid ();
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 /* Remove all CR's that are followed by a LF.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 (From msdos.c...probably should figure out a way to share it,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 although this code isn't going to ever change.) */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 crlf_to_lf (n, buf)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 register int n;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 register unsigned char *buf;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 unsigned char *np = buf;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 unsigned char *startp = buf;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 unsigned char *endp = buf + n;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 if (n == 0)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 return n;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 while (buf < endp - 1)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 if (*buf == 0x0d)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 if (*(++buf) != 0x0a)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 *np++ = 0x0d;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 else
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 *np++ = *buf++;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 if (buf < endp)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679 *np++ = *buf++;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 return np - startp;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682
13427
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
683 #define REG_ROOT "SOFTWARE\\GNU\\Emacs\\"
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
684
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
685 LPBYTE
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
686 nt_get_resource (key, lpdwtype)
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
687 char *key;
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
688 LPDWORD lpdwtype;
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
689 {
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
690 LPBYTE lpvalue;
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
691 HKEY hrootkey = NULL;
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
692 DWORD cbData;
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
693 BOOL ok = FALSE;
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
694
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
695 /* Check both the current user and the local machine to see if
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
696 we have any resources. */
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
697
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
698 if (RegOpenKeyEx (HKEY_CURRENT_USER, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS)
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
699 {
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
700 lpvalue = NULL;
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
701
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
702 if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
703 && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
704 && RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) == ERROR_SUCCESS)
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
705 {
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
706 return (lpvalue);
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
707 }
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
708
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
709 if (lpvalue) xfree (lpvalue);
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
710
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
711 RegCloseKey (hrootkey);
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
712 }
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
713
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
714 if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS)
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
715 {
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
716 lpvalue = NULL;
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
717
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
718 if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS &&
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
719 (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL &&
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
720 RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) == ERROR_SUCCESS)
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
721 {
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
722 return (lpvalue);
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
723 }
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
724
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
725 if (lpvalue) xfree (lpvalue);
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
726
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
727 RegCloseKey (hrootkey);
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
728 }
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
729
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
730 return (NULL);
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
731 }
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
732
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
733 void
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
734 init_environment ()
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
735 {
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
736 /* Open a console window to display messages during dumping. */
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
737 if (!initialized)
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
738 AllocConsole ();
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
739
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
740 /* Check for environment variables and use registry if they don't exist */
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
741 {
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
742 int i;
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
743 LPBYTE lpval;
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
744 DWORD dwType;
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
745
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
746 static char * env_vars[] =
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
747 {
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
748 "emacs_path",
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
749 "EMACSLOADPATH",
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
750 "SHELL",
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
751 "EMACSDATA",
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
752 "EMACSPATH",
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
753 "EMACSLOCKDIR",
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
754 "INFOPATH",
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
755 "EMACSDOC",
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
756 "TERM",
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
757 };
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
758
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
759 for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++)
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
760 {
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
761 if (!getenv (env_vars[i]) &&
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
762 (lpval = nt_get_resource (env_vars[i], &dwType)) != NULL)
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
763 {
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
764 if (dwType == REG_EXPAND_SZ)
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
765 {
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
766 char buf1[500], buf2[500];
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
767
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
768 ExpandEnvironmentStrings ((LPSTR) lpval, buf1, 500);
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
769 _snprintf (buf2, 499, "%s=%s", env_vars[i], buf1);
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
770 putenv (strdup (buf2));
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
771 }
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
772 else if (dwType == REG_SZ)
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
773 {
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
774 char buf[500];
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
775
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
776 _snprintf (buf, 499, "%s=%s", env_vars[i], lpval);
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
777 putenv (strdup (buf));
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
778 }
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
779
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
780 xfree (lpval);
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
781 }
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
782 }
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
783 }
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
784 }
71d734525d2c (nt_get_resource, init_environment): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 13156
diff changeset
785
11384
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
786 #ifdef HAVE_TIMEVAL
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
787 #include <sys/timeb.h>
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
788
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
789 /* Emulate gettimeofday (Ulrich Leodolter, 1/11/95). */
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
790 void
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
791 gettimeofday (struct timeval *tv, struct timezone *tz)
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
792 {
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
793 struct _timeb tb;
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
794 _ftime (&tb);
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
795
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
796 tv->tv_sec = tb.time;
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
797 tv->tv_usec = tb.millitm * 1000L;
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
798 if (tz)
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
799 {
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
800 tz->tz_minuteswest = tb.timezone; /* minutes west of Greenwich */
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
801 tz->tz_dsttime = tb.dstflag; /* type of dst correction */
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
802 }
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
803 }
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
804 #endif /* HAVE_TIMEVAL */
1b01db213663 (nt_ctime): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 9803
diff changeset
805
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 #ifdef PIGSFLY
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808 Keep this around...we might need it later.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
809 #ifdef WINDOWSNT
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811 /*
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
812 * Find the user's real name by opening the process token and looking
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813 * up the name associated with the user-sid in that token.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 char b[256], Name[256], RefD[256];
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 DWORD length = 256, rlength = 256, trash;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 HANDLE Token;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819 SID_NAME_USE User;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821 if (1)
12025
e804b43418f6 Change Vuser_real_name to Vuser_real_login_name.
Karl Heuer <kwzh@gnu.org>
parents: 11941
diff changeset
822 Vuser_real_login_name = build_string ("foo");
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 else if (!OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &Token))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 {
12025
e804b43418f6 Change Vuser_real_name to Vuser_real_login_name.
Karl Heuer <kwzh@gnu.org>
parents: 11941
diff changeset
825 Vuser_real_login_name = build_string ("unknown");
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 else if (!GetTokenInformation (Token, TokenUser, (PVOID)b, 256,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 &trash))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 CloseHandle (Token);
12025
e804b43418f6 Change Vuser_real_name to Vuser_real_login_name.
Karl Heuer <kwzh@gnu.org>
parents: 11941
diff changeset
831 Vuser_real_login_name = build_string ("unknown");
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 else if (!LookupAccountSid ((void *)0, (PSID)b, Name, &length, RefD,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 &rlength, &User))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 CloseHandle (Token);
12025
e804b43418f6 Change Vuser_real_name to Vuser_real_login_name.
Karl Heuer <kwzh@gnu.org>
parents: 11941
diff changeset
837 Vuser_real_login_name = build_string ("unknown");
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 else
12025
e804b43418f6 Change Vuser_real_name to Vuser_real_login_name.
Karl Heuer <kwzh@gnu.org>
parents: 11941
diff changeset
840 Vuser_real_login_name = build_string (Name);
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 #else /* not WINDOWSNT */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843 #endif /* not WINDOWSNT */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 #endif /* PIGSFLY */