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