annotate lib-src/ntlib.c @ 22758:dbd9ecc9dbac

Added next-buffer/previous-buffer keybindings (bound to M-n/M-p). (crisp-unbury-buffer): New function. Fixed bogus XEmacs/Lucid string-match checking. Made modeline entry mouse2-able. (crisp-mode-map): Make this a sparse keymap parented from current-global-map. (crisp-mode-original-keymap): Don't copy the keymap. (crisp-last-last-command): Renamed from last-last-command. defvar it. (crisp-mode): Honor ARG. (crisp-kill-line, crisp-copy-line): When a region isn't highlighted, use the region from point to eol. Honor prefix argument. (crisp-submit-bug-report): New command, taken from cc-mode. Shortened the version numbering, removed the release-version tracking (crisp-version): New function. New keybindings `C-home', `C-end', `M-home', `M-end', `C-f', `M-l', `M-m'. (crisp-copy-line): No need to save point. Removed S-right and S-left bindings. Abstract the marking and selection interfaces so that we can be compatible with both Emacs and XEmacs. And try and make the behavior as close as possible under both environments so that there are no surprises.
author Karl Heuer <kwzh@gnu.org>
date Tue, 14 Jul 1998 22:17:35 +0000
parents b58a79fe0af2
children 1fd32e8a2fad
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.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 Copyright (C) 1994 Free Software Foundation, Inc.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
4 This file is part of GNU Emacs.
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
7 it under the terms of the GNU General Public License as published by
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
9 any later version.
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
14 GNU General Public License for more details.
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
16 You should have received a copy of the GNU General Public License
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 9803
diff changeset
19 Boston, MA 02111-1307, USA.
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 Geoff Voelker (voelker@cs.washington.edu) 10-8-94
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 #include <windows.h>
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 #include <stdlib.h>
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 #include <stdio.h>
15138
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
27 #include <time.h>
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
28 #include <direct.h>
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
29
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
30 #include "ntlib.h"
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 #define MAXPATHLEN _MAX_PATH
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 /* Emulate sleep...we could have done this with a define, but that
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 would necessitate including windows.h in the files that used it.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 This is much easier. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 void
15138
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
38 sleep(int seconds)
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 Sleep (seconds * 1000);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 }
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 /* Get the current working directory. */
15675
e5b420bac4e9 (getwd): Correct return type.
Karl Heuer <kwzh@gnu.org>
parents: 15138
diff changeset
44 char *
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 getwd (char *dir)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 {
15138
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
47 if (GetCurrentDirectory (MAXPATHLEN, dir) > 0)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
48 return dir;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
49 return NULL;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 }
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 static HANDLE getppid_parent;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 static int getppid_ppid;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 int
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 getppid(void)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 char *ppid;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 DWORD result;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60
22296
b58a79fe0af2 (getppid): Look for EM_PARENT_PROCESS_ID.
Geoff Voelker <voelker@cs.washington.edu>
parents: 19694
diff changeset
61 ppid = getenv ("EM_PARENT_PROCESS_ID");
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 if (!ppid)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 printf("no pid.\n");
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 return 0;
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 else
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 getppid_ppid = atoi (ppid);
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
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 if (!getppid_parent)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 getppid_parent = OpenProcess (SYNCHRONIZE, FALSE, atoi(ppid));
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 if (!getppid_parent)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 printf ("Failed to open handle to parent process: %d\n",
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 GetLastError());
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 exit (1);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 }
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 result = WaitForSingleObject (getppid_parent, 0);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 switch (result)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 case WAIT_TIMEOUT:
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 /* The parent is still alive. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 return getppid_ppid;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 case WAIT_OBJECT_0:
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 /* The parent is gone. Return the pid of Unix init (1). */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 return 1;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 case WAIT_FAILED:
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 default:
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 printf ("Checking parent status failed: %d\n", GetLastError());
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 exit (1);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 }
15138
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
98
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
99 char *
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
100 getlogin ()
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
101 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
102 static char user_name[256];
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
103 DWORD length = sizeof (user_name);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
104
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
105 if (GetUserName (user_name, &length))
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
106 return user_name;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
107 return NULL;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
108 }
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 char *
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
111 cuserid (char * s)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
112 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
113 char * name = getlogin ();
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
114 if (s)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
115 return strcpy (s, name ? name : "");
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
116 return name;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
117 }
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 int
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
120 getuid ()
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
121 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
122 return 0;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
123 }
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 int
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
126 setuid (int uid)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
127 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
128 return 0;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
129 }
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 struct passwd *
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
132 getpwuid (int uid)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
133 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
134 return NULL;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
135 }
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 char *
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
138 getpass (const char * prompt)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
139 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
140 static char input[256];
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
141 HANDLE in;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
142 HANDLE err;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
143 DWORD count;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
144
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
145 in = GetStdHandle (STD_INPUT_HANDLE);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
146 err = GetStdHandle (STD_ERROR_HANDLE);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
147
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
148 if (in == INVALID_HANDLE_VALUE || err == INVALID_HANDLE_VALUE)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
149 return NULL;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
150
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
151 if (WriteFile (err, prompt, strlen (prompt), &count, NULL))
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
152 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
153 int istty = (GetFileType (in) == FILE_TYPE_CHAR);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
154 DWORD old_flags;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
155 int rc;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
156
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
157 if (istty)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
158 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
159 if (GetConsoleMode (in, &old_flags))
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
160 SetConsoleMode (in, ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
161 else
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
162 istty = 0;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
163 }
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
164 rc = ReadFile (in, input, sizeof (input), &count, NULL);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
165 if (count >= 2 && input[count - 2] == '\r')
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
166 input[count - 2] = '\0';
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
167 else
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
168 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
169 char buf[256];
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
170 while (ReadFile (in, buf, sizeof (buf), &count, NULL) > 0)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
171 if (count >= 2 && buf[count - 2] == '\r')
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
172 break;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
173 }
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
174 WriteFile (err, "\r\n", 2, &count, NULL);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
175 if (istty)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
176 SetConsoleMode (in, old_flags);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
177 if (rc)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
178 return input;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
179 }
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 return NULL;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
182 }
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 int
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
185 fchown (int fd, int uid, int gid)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
186 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
187 return 0;
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
188 }
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 /* Place a wrapper around the MSVC version of ctime. It returns NULL
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
191 on network directories, so we handle that case here.
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
192 (Ulrich Leodolter, 1/11/95). */
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
193 char *
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
194 sys_ctime (const time_t *t)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
195 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
196 char *str = (char *) ctime (t);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
197 return (str ? str : "Sun Jan 01 00:00:00 1970");
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
198 }
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 FILE *
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
201 sys_fopen(const char * path, const char * mode)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
202 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
203 return fopen (path, mode);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
204 }
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 int
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
207 sys_chdir (const char * path)
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
208 {
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
209 return _chdir (path);
92326afec2a6 Include ntlib.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14837
diff changeset
210 }