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