annotate lib-src/ntlib.c @ 82222:c17afaa92484

(cvs-vc-command-advice): Handle the new fileset case.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 31 Jul 2007 15:23:27 +0000
parents 1f2482de3237
children 5714ff101fd9 f55f9811f5d7
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 support programs on NT.
75250
6d19c76d81c5 Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents: 68647
diff changeset
2 Copyright (C) 1994, 2001, 2002, 2003, 2004, 2005,
6d19c76d81c5 Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents: 68647
diff changeset
3 2006, 2007 Free Software Foundation, Inc.
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
5 This file is part of GNU Emacs.
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
7 GNU Emacs is free software; you can redistribute it and/or modify
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
8 it under the terms of the GNU General Public License as published by
78257
1f2482de3237 Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 75250
diff changeset
9 the Free Software Foundation; either version 3, or (at your option)
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
10 any later version.
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
12 GNU Emacs is distributed in the hope that it will be useful,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
15 GNU General Public License for more details.
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
17 You should have received a copy of the GNU General Public License
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
18 along with GNU Emacs; see the file COPYING. If not, write to
64083
23a17af379b1 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23a17af379b1 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
20 Boston, MA 02110-1301, USA.
9803
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 Geoff Voelker (voelker@cs.washington.edu) 10-8-94
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 #include <windows.h>
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 #include <stdlib.h>
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 #include <stdio.h>
15138
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
28 #include <time.h>
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
29 #include <direct.h>
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
30
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
31 #include "ntlib.h"
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 #define MAXPATHLEN _MAX_PATH
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 /* Emulate sleep...we could have done this with a define, but that
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 would necessitate including windows.h in the files that used it.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 This is much easier. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 void
31081
1fd32e8a2fad (sleep): Make argument unsigned long.
Andrew Innes <andrewi@gnu.org>
parents: 22296
diff changeset
39 sleep(unsigned long seconds)
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 Sleep (seconds * 1000);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 /* Get the current working directory. */
15675
e5b420bac4e9 (getwd): Correct return type.
Karl Heuer <kwzh@gnu.org>
parents: 15138
diff changeset
45 char *
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 getwd (char *dir)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 {
15138
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
48 if (GetCurrentDirectory (MAXPATHLEN, dir) > 0)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
49 return dir;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
50 return NULL;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 static HANDLE getppid_parent;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 static int getppid_ppid;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 getppid(void)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 char *ppid;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 DWORD result;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61
22296
b58a79fe0af2 (getppid): Look for EM_PARENT_PROCESS_ID.
Geoff Voelker <voelker@cs.washington.edu>
parents: 19694
diff changeset
62 ppid = getenv ("EM_PARENT_PROCESS_ID");
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 31081
diff changeset
63 if (!ppid)
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 printf("no pid.\n");
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 return 0;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 31081
diff changeset
67 }
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 31081
diff changeset
68 else
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 getppid_ppid = atoi (ppid);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 31081
diff changeset
73 if (!getppid_parent)
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 getppid_parent = OpenProcess (SYNCHRONIZE, FALSE, atoi(ppid));
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 31081
diff changeset
76 if (!getppid_parent)
9803
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 printf ("Failed to open handle to parent process: %d\n",
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 GetLastError());
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 exit (1);
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 }
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 result = WaitForSingleObject (getppid_parent, 0);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 31081
diff changeset
85 switch (result)
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 case WAIT_TIMEOUT:
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 /* The parent is still alive. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 return getppid_ppid;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 case WAIT_OBJECT_0:
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 /* The parent is gone. Return the pid of Unix init (1). */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 return 1;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 case WAIT_FAILED:
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 default:
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 printf ("Checking parent status failed: %d\n", GetLastError());
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 exit (1);
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 }
15138
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
99
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
100 char *
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
101 getlogin ()
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
102 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
103 static char user_name[256];
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
104 DWORD length = sizeof (user_name);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
105
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
106 if (GetUserName (user_name, &length))
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
107 return user_name;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
108 return NULL;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
109 }
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
110
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
111 char *
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
112 cuserid (char * s)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
113 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
114 char * name = getlogin ();
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
115 if (s)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
116 return strcpy (s, name ? name : "");
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
117 return name;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
118 }
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
119
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
120 int
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
121 getuid ()
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
122 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
123 return 0;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
124 }
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
125
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
126 int
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
127 setuid (int uid)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
128 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
129 return 0;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
130 }
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
131
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
132 struct passwd *
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
133 getpwuid (int uid)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
134 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
135 return NULL;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
136 }
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
137
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
138 char *
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
139 getpass (const char * prompt)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
140 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
141 static char input[256];
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
142 HANDLE in;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
143 HANDLE err;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
144 DWORD count;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
145
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
146 in = GetStdHandle (STD_INPUT_HANDLE);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
147 err = GetStdHandle (STD_ERROR_HANDLE);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
148
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
149 if (in == INVALID_HANDLE_VALUE || err == INVALID_HANDLE_VALUE)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
150 return NULL;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
151
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
152 if (WriteFile (err, prompt, strlen (prompt), &count, NULL))
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
153 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
154 int istty = (GetFileType (in) == FILE_TYPE_CHAR);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
155 DWORD old_flags;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
156 int rc;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
157
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
158 if (istty)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
159 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
160 if (GetConsoleMode (in, &old_flags))
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
161 SetConsoleMode (in, ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
162 else
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
163 istty = 0;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
164 }
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
165 rc = ReadFile (in, input, sizeof (input), &count, NULL);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
166 if (count >= 2 && input[count - 2] == '\r')
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
167 input[count - 2] = '\0';
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
168 else
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
169 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
170 char buf[256];
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
171 while (ReadFile (in, buf, sizeof (buf), &count, NULL) > 0)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
172 if (count >= 2 && buf[count - 2] == '\r')
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
173 break;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
174 }
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
175 WriteFile (err, "\r\n", 2, &count, NULL);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
176 if (istty)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
177 SetConsoleMode (in, old_flags);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
178 if (rc)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
179 return input;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
180 }
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
181
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
182 return NULL;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
183 }
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
184
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
185 int
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
186 fchown (int fd, int uid, int gid)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
187 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
188 return 0;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
189 }
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
190
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
191 /* Place a wrapper around the MSVC version of ctime. It returns NULL
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 31081
diff changeset
192 on network directories, so we handle that case here.
15138
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
193 (Ulrich Leodolter, 1/11/95). */
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
194 char *
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
195 sys_ctime (const time_t *t)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
196 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
197 char *str = (char *) ctime (t);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
198 return (str ? str : "Sun Jan 01 00:00:00 1970");
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
199 }
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
200
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
201 FILE *
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
202 sys_fopen(const char * path, const char * mode)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
203 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
204 return fopen (path, mode);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
205 }
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
206
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
207 int
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
208 sys_chdir (const char * path)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
209 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
210 return _chdir (path);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
211 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
212
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
213 /* arch-tag: 7b63fb83-70ee-4124-8822-54e53e5d0773
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
214 (do not change this comment) */