2016-08-29 22:49:24 +02:00
|
|
|
/* vi:set ts=8 sts=4 sw=4 noet:
|
2004-06-13 20:20:40 +00:00
|
|
|
*
|
|
|
|
* VIM - Vi IMproved by Bram Moolenaar
|
|
|
|
*
|
|
|
|
* Do ":help uganda" in Vim to read copying and usage conditions.
|
|
|
|
* Do ":help credits" in Vim to see a list of people who contributed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Win32 (Windows NT and Windows 95) machine-dependent things.
|
|
|
|
*/
|
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
#include "os_dos.h" // common MS-DOS and Win32 stuff
|
2004-06-13 20:20:40 +00:00
|
|
|
#ifndef __CYGWIN__
|
2019-11-30 19:44:38 +01:00
|
|
|
// cproto fails on missing include files
|
2012-11-20 16:53:39 +01:00
|
|
|
# ifndef PROTO
|
2019-11-30 19:44:38 +01:00
|
|
|
# include <direct.h> // for _mkdir()
|
2012-11-20 16:53:39 +01:00
|
|
|
# endif
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define BINARY_FILE_IO
|
2019-11-30 19:44:38 +01:00
|
|
|
#define USE_EXE_NAME // use argv[0] for $VIM
|
2004-06-13 20:20:40 +00:00
|
|
|
#define USE_TERM_CONSOLE
|
|
|
|
#ifndef HAVE_STRING_H
|
|
|
|
# define HAVE_STRING_H
|
|
|
|
#endif
|
2008-06-24 21:16:56 +00:00
|
|
|
#ifndef HAVE_MATH_H
|
|
|
|
# define HAVE_MATH_H
|
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
#define HAVE_STRCSPN
|
|
|
|
#ifndef __GNUC__
|
|
|
|
#define HAVE_STRICMP
|
|
|
|
#define HAVE_STRNICMP
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_STRFTIME
|
2019-11-30 19:44:38 +01:00
|
|
|
# define HAVE_STRFTIME // guessed
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
#define HAVE_MEMSET
|
|
|
|
#ifndef HAVE_LOCALE_H
|
|
|
|
# define HAVE_LOCALE_H 1
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_FCNTL_H
|
|
|
|
# define HAVE_FCNTL_H
|
|
|
|
#endif
|
|
|
|
#define HAVE_QSORT
|
2019-11-30 19:44:38 +01:00
|
|
|
#define HAVE_ST_MODE // have stat.st_mode
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
#define FEAT_SHORTCUT // resolve shortcuts
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2019-05-09 15:12:55 +02:00
|
|
|
#if (!defined(_MSC_VER) || _MSC_VER > 1020)
|
2004-06-13 20:20:40 +00:00
|
|
|
/*
|
|
|
|
* Access Control List (actually security info).
|
2019-05-09 15:12:55 +02:00
|
|
|
* MSVC has acl stuff only in 5.0, not in 4.2, don't know about 4.3.
|
2004-06-13 20:20:40 +00:00
|
|
|
*/
|
|
|
|
# define HAVE_ACL
|
|
|
|
#endif
|
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
#define USE_FNAME_CASE // adjust case of file names
|
2019-10-17 23:00:07 +02:00
|
|
|
#if !defined(FEAT_CLIPBOARD)
|
2019-11-30 19:44:38 +01:00
|
|
|
# define FEAT_CLIPBOARD // include clipboard support
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
#if defined(__DATE__) && defined(__TIME__)
|
|
|
|
# define HAVE_DATE_TIME
|
|
|
|
#endif
|
2019-11-30 19:44:38 +01:00
|
|
|
#ifndef FEAT_GUI_MSWIN // GUI works different
|
|
|
|
# define BREAKCHECK_SKIP 1 // call mch_breakcheck() each time, it's fast
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
2016-01-02 21:11:51 +01:00
|
|
|
#define HAVE_TOTAL_MEM
|
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
#define HAVE_PUTENV // at least Bcc 5.2 and MSC have it
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2019-04-28 19:46:49 +02:00
|
|
|
#if defined(FEAT_GUI_MSWIN) && !defined(VIMDLL)
|
2019-11-30 19:44:38 +01:00
|
|
|
# define NO_CONSOLE // don't included console-only code
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
// toupper() is not really broken, but it's very slow. Probably because of
|
|
|
|
// using Unicode characters on Windows NT
|
2004-06-13 20:20:40 +00:00
|
|
|
#define BROKEN_TOUPPER
|
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
#define FNAME_ILLEGAL "\"*?><|" // illegal characters in a file name
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2018-08-21 19:47:48 +02:00
|
|
|
#include <signal.h>
|
2004-06-13 20:20:40 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <time.h>
|
2010-05-31 21:59:46 +02:00
|
|
|
#include <sys/types.h>
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
#ifndef STRICT
|
|
|
|
# define STRICT
|
|
|
|
#endif
|
|
|
|
#ifndef COBJMACROS
|
2019-11-30 19:44:38 +01:00
|
|
|
# define COBJMACROS // For OLE: Enable "friendlier" access to objects
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
2012-11-20 16:53:39 +01:00
|
|
|
#ifndef PROTO
|
|
|
|
# include <windows.h>
|
2013-07-21 17:53:58 +02:00
|
|
|
# ifndef SM_CXPADDEDBORDER
|
|
|
|
# define SM_CXPADDEDBORDER 92
|
|
|
|
# endif
|
2012-11-20 16:53:39 +01:00
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Win32 has plenty of memory, use large buffers
|
|
|
|
*/
|
2019-11-30 19:44:38 +01:00
|
|
|
#define CMDBUFFSIZE 1024 // size of the command processing buffer
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
// _MAX_PATH is only 260 (stdlib.h), but we want more for the 'path' option,
|
|
|
|
// thus use a larger number.
|
2004-06-13 20:20:40 +00:00
|
|
|
#define MAXPATHL 1024
|
|
|
|
|
|
|
|
#ifndef BASENAMELEN
|
2019-11-30 19:44:38 +01:00
|
|
|
# define BASENAMELEN (_MAX_PATH - 5) // length of base of file name
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
#define TEMPNAMELEN _MAX_PATH // length of temp file name path
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
#ifndef DFLT_MAXMEM
|
2019-11-30 19:44:38 +01:00
|
|
|
# define DFLT_MAXMEM (2*1024) // use up to 2 Mbyte for a buffer
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef DFLT_MAXMEMTOT
|
2019-11-30 19:44:38 +01:00
|
|
|
# define DFLT_MAXMEMTOT (5*1024) // use up to 5 Mbyte for Vim
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
2013-09-25 19:13:38 +02:00
|
|
|
/*
|
|
|
|
* Reparse Point
|
|
|
|
*/
|
|
|
|
#ifndef FILE_ATTRIBUTE_REPARSE_POINT
|
|
|
|
# define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
|
|
|
|
#endif
|
|
|
|
#ifndef IO_REPARSE_TAG_MOUNT_POINT
|
|
|
|
# define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
|
|
|
|
#endif
|
|
|
|
#ifndef IO_REPARSE_TAG_SYMLINK
|
|
|
|
# define IO_REPARSE_TAG_SYMLINK 0xA000000C
|
|
|
|
#endif
|
|
|
|
|
2019-05-09 15:12:55 +02:00
|
|
|
#if defined(_MSC_VER)
|
2019-11-30 19:44:38 +01:00
|
|
|
// Support for __try / __except. All versions of MSVC are
|
|
|
|
// expected to have this. Any other compilers that support it?
|
2004-06-13 20:20:40 +00:00
|
|
|
# define HAVE_TRY_EXCEPT 1
|
2019-11-30 19:44:38 +01:00
|
|
|
# include <malloc.h> // for _resetstkoflw()
|
2004-06-13 20:20:40 +00:00
|
|
|
# if defined(_MSC_VER) && (_MSC_VER >= 1300)
|
|
|
|
# define RESETSTKOFLW _resetstkoflw
|
|
|
|
# else
|
|
|
|
# define RESETSTKOFLW myresetstkoflw
|
|
|
|
# define MYRESETSTKOFLW
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some simple debugging macros that look and behave a lot like their
|
|
|
|
* namesakes in MFC.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
|
|
|
# if defined(_MSC_VER) && (_MSC_VER >= 1000)
|
2019-11-30 19:44:38 +01:00
|
|
|
// Use the new debugging tools in Visual C++ 4.x
|
2004-06-13 20:20:40 +00:00
|
|
|
# include <crtdbg.h>
|
|
|
|
# define ASSERT(f) _ASSERT(f)
|
|
|
|
# else
|
|
|
|
# include <assert.h>
|
|
|
|
# define ASSERT(f) assert(f)
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# define TRACE Trace
|
|
|
|
# define TRACE0(sz) Trace(_T("%s"), _T(sz))
|
|
|
|
# define TRACE1(sz, p1) Trace(_T(sz), p1)
|
|
|
|
# define TRACE2(sz, p1, p2) Trace(_T(sz), p1, p2)
|
|
|
|
# define TRACE3(sz, p1, p2, p3) Trace(_T(sz), p1, p2, p3)
|
|
|
|
# define TRACE4(sz, p1, p2, p3, p4) Trace(_T(sz), p1, p2, p3, p4)
|
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
// In debug version, writes trace messages to debug stream
|
2004-06-13 20:20:40 +00:00
|
|
|
void __cdecl
|
|
|
|
Trace(char *pszFormat, ...);
|
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
#else // !_DEBUG
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
// These macros should all compile away to nothing
|
2004-06-13 20:20:40 +00:00
|
|
|
# define ASSERT(f) ((void)0)
|
|
|
|
# define TRACE 1 ? (void)0 : printf
|
|
|
|
# define TRACE0(sz)
|
|
|
|
# define TRACE1(sz, p1)
|
|
|
|
# define TRACE2(sz, p1, p2)
|
|
|
|
# define TRACE3(sz, p1, p2, p3)
|
|
|
|
# define TRACE4(sz, p1, p2, p3, p4)
|
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
#endif // !_DEBUG
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define ASSERT_POINTER(p, type) \
|
|
|
|
ASSERT(((p) != NULL) && IsValidAddress((p), sizeof(type), FALSE))
|
|
|
|
|
|
|
|
#define ASSERT_NULL_OR_POINTER(p, type) \
|
|
|
|
ASSERT(((p) == NULL) || IsValidAddress((p), sizeof(type), FALSE))
|
|
|
|
|
2017-02-01 13:14:16 +01:00
|
|
|
#ifndef HAVE_SETENV
|
|
|
|
# define HAVE_SETENV
|
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
#define mch_getenv(x) (char_u *)getenv((char *)(x))
|
2019-05-09 15:12:55 +02:00
|
|
|
#define vim_mkdir(x, y) mch_mkdir(x)
|
2011-08-10 17:08:03 +02:00
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
// Enable common dialogs input unicode from IME if possible.
|
2019-01-24 17:18:42 +01:00
|
|
|
#define pDispatchMessage DispatchMessageW
|
|
|
|
#define pGetMessage GetMessageW
|
|
|
|
#define pIsDialogMessage IsDialogMessageW
|
|
|
|
#define pPeekMessage PeekMessageW
|