annotate src/os_win32.h @ 121:86d71ae0c85a v7.0042

updated for version 7.0042
author vimboss
date Wed, 19 Jan 2005 22:24:34 +0000
parents 3fc0f57ecb91
children 8273a51fc8dd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 * Win32 (Windows NT and Windows 95) machine-dependent things.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 #include "os_dos.h" /* common MS-DOS and Win32 stuff */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 #ifndef __CYGWIN__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 #include <direct.h> /* for _mkdir() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 #define BINARY_FILE_IO
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 #define USE_EXE_NAME /* use argv[0] for $VIM */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 #define NO_COOKED_INPUT /* mch_inchar() doesn't return whole lines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 #define SYNC_DUP_CLOSE /* sync() a file with dup() and close() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 #define USE_TERM_CONSOLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 #ifndef HAVE_STRING_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 # define HAVE_STRING_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 #define HAVE_STRCSPN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 #ifndef __GNUC__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 #define HAVE_STRICMP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 #define HAVE_STRNICMP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 #ifndef HAVE_STRFTIME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 # define HAVE_STRFTIME /* guessed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 #define HAVE_MEMSET
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 #ifndef HAVE_LOCALE_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 # define HAVE_LOCALE_H 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 #ifndef HAVE_FCNTL_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 # define HAVE_FCNTL_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 #ifndef HAVE_STDARG_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 # define HAVE_STDARG_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 #define HAVE_QSORT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 #define HAVE_ST_MODE /* have stat.st_mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 #define FEAT_SHORTCUT /* resolve shortcuts */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 #if !defined(__MINGW32__) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 && !defined(__CYGWIN__) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 && (!defined(__BORLANDC__) || __BORLANDC__ >= 0x550) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 && (!defined(_MSC_VER) || _MSC_VER > 1020)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 * Access Control List (actually security info).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 * Mingw and Cygwin don't have the acl stuff.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 * Borland only in version 5.5 and later.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 * MSVC in 5.0, not in 4.2, don't know about 4.3.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 # define HAVE_ACL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 #define USE_FNAME_CASE /* adjust case of file names */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 #if !defined(FEAT_CLIPBOARD) && defined(FEAT_VISUAL) && defined(FEAT_MOUSE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 # define FEAT_CLIPBOARD /* include clipboard support */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 #if defined(__DATE__) && defined(__TIME__)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 # define HAVE_DATE_TIME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 #ifndef FEAT_GUI_W32 /* GUI works different */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 # define BREAKCHECK_SKIP 1 /* call mch_breakcheck() each time, it's fast */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 #define HAVE_AVAIL_MEM
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 #define HAVE_PUTENV /* at least Bcc 5.2 and MSC have it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 #ifdef FEAT_GUI_W32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 # define NO_CONSOLE /* don't included console-only code */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 /* toupper() is not really broken, but it's very slow. Probably because of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 * using Unicode characters on Windows NT */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 #define BROKEN_TOUPPER
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 #define FNAME_ILLEGAL "\"*?><|" /* illegal characters in a file name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 #include <stdlib.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 #include <time.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 #ifndef STRICT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 # define STRICT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 #ifndef COBJMACROS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 # define COBJMACROS /* For OLE: Enable "friendlier" access to objects */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 #include <windows.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 * Win32 has plenty of memory, use large buffers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 #define CMDBUFFSIZE 1024 /* size of the command processing buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 /* _MAX_PATH is only 256 (stdlib.h), but we want more for the 'path' option,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 * thus use a larger number. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 #define MAXPATHL 1024
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 #ifndef BASENAMELEN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 # define BASENAMELEN (_MAX_PATH - 5) /* length of base of file name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 #define TEMPNAMELEN _MAX_PATH /* length of temp file name path */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 #ifndef DFLT_MAXMEM
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 # define DFLT_MAXMEM (2*1024) /* use up to 2 Mbyte for a buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 #ifndef DFLT_MAXMEMTOT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 # define DFLT_MAXMEMTOT (5*1024) /* use up to 5 Mbyte for Vim */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 #if defined(_MSC_VER) || defined(__BORLANDC__)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 /* Support for __try / __except. All versions of MSVC and Borland C are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 * expected to have this. Any other compilers that support it? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 # define HAVE_TRY_EXCEPT 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 # include <malloc.h> /* for _resetstkoflw() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 # if defined(_MSC_VER) && (_MSC_VER >= 1300)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 # define RESETSTKOFLW _resetstkoflw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 # define RESETSTKOFLW myresetstkoflw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 # define MYRESETSTKOFLW
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 * Some simple debugging macros that look and behave a lot like their
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 * namesakes in MFC.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 #ifdef _DEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 # if defined(_MSC_VER) && (_MSC_VER >= 1000)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 /* Use the new debugging tools in Visual C++ 4.x */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 # include <crtdbg.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 # define ASSERT(f) _ASSERT(f)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 # include <assert.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 # define ASSERT(f) assert(f)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 # define VERIFY(f) ASSERT(f)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 # define DEBUG_ONLY(f) (f)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 # define TRACE Trace
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 # define TRACE0(sz) Trace(_T("%s"), _T(sz))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 # define TRACE1(sz, p1) Trace(_T(sz), p1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 # define TRACE2(sz, p1, p2) Trace(_T(sz), p1, p2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 # define TRACE3(sz, p1, p2, p3) Trace(_T(sz), p1, p2, p3)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 # define TRACE4(sz, p1, p2, p3, p4) Trace(_T(sz), p1, p2, p3, p4)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 /* In debug version, writes trace messages to debug stream */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 void __cdecl
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 Trace(char *pszFormat, ...);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 #else /* !_DEBUG */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 /* These macros should all compile away to nothing */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 # define ASSERT(f) ((void)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 # define VERIFY(f) ((void)f)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 # define DEBUG_ONLY(f) ((void)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 # define TRACE 1 ? (void)0 : printf
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 # define TRACE0(sz)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 # define TRACE1(sz, p1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 # define TRACE2(sz, p1, p2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 # define TRACE3(sz, p1, p2, p3)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 # define TRACE4(sz, p1, p2, p3, p4)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 #endif /* !_DEBUG */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 #define ASSERT_POINTER(p, type) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 ASSERT(((p) != NULL) && IsValidAddress((p), sizeof(type), FALSE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 #define ASSERT_NULL_OR_POINTER(p, type) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 ASSERT(((p) == NULL) || IsValidAddress((p), sizeof(type), FALSE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 #define mch_setenv(name, val, x) setenv(name, val, x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 #define mch_getenv(x) (char_u *)getenv((char *)(x))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 #ifdef __BORLANDC__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 # define vim_mkdir(x, y) mkdir(x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 # define vim_mkdir(x, y) _mkdir(x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 #endif