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