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
|
|
|
|
* GUI support by Robert Webb
|
|
|
|
*
|
|
|
|
* Do ":help uganda" in Vim to read copying and usage conditions.
|
|
|
|
* Do ":help credits" in Vim to see a list of people who contributed.
|
|
|
|
* See README.txt for an overview of the Vim source code.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Windows GUI: main program (EXE) entry point:
|
|
|
|
*
|
|
|
|
* Ron Aaron <ronaharon@yahoo.com> wrote this and the DLL support code.
|
|
|
|
*/
|
|
|
|
#include "vim.h"
|
|
|
|
|
|
|
|
#ifdef __MINGW32__
|
|
|
|
# ifndef _cdecl
|
|
|
|
# define _cdecl
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* cproto doesn't create a prototype for main() */
|
|
|
|
int _cdecl
|
|
|
|
#if defined(FEAT_GUI_W32)
|
|
|
|
VimMain
|
|
|
|
#else
|
|
|
|
main
|
|
|
|
#endif
|
2016-01-29 22:47:03 +01:00
|
|
|
(int argc, char **argv);
|
2005-06-30 22:06:41 +00:00
|
|
|
static int (_cdecl *pmain)(int, char **);
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
#ifndef PROTO
|
|
|
|
#ifdef FEAT_GUI
|
|
|
|
#ifndef VIMDLL
|
|
|
|
void _cdecl SaveInst(HINSTANCE hInst);
|
|
|
|
#endif
|
2005-06-30 22:06:41 +00:00
|
|
|
static void (_cdecl *pSaveInst)(HINSTANCE);
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
int WINAPI
|
|
|
|
WinMain(
|
2017-02-01 13:43:36 +01:00
|
|
|
HINSTANCE hInstance UNUSED,
|
|
|
|
HINSTANCE hPrevInst UNUSED,
|
2004-06-13 20:20:40 +00:00
|
|
|
LPSTR lpszCmdLine,
|
2017-02-01 13:43:36 +01:00
|
|
|
int nCmdShow UNUSED)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2004-09-06 17:44:46 +00:00
|
|
|
int argc = 0;
|
2004-06-13 20:20:40 +00:00
|
|
|
char **argv;
|
|
|
|
char *tofree;
|
|
|
|
char prog[256];
|
|
|
|
#ifdef VIMDLL
|
|
|
|
char *p;
|
|
|
|
HANDLE hLib;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Ron: added full path name so that the $VIM variable will get set to our
|
|
|
|
* startup path (so the .vimrc file can be found w/o a VIM env. var.) */
|
|
|
|
GetModuleFileName(NULL, prog, 255);
|
|
|
|
|
2004-10-07 21:02:47 +00:00
|
|
|
argc = get_cmd_args(prog, (char *)lpszCmdLine, &argv, &tofree);
|
2004-06-13 20:20:40 +00:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2004-10-07 21:02:47 +00:00
|
|
|
MessageBox(0, "Could not allocate memory for command line.",
|
|
|
|
"VIM Error", 0);
|
|
|
|
return 0;
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DYNAMIC_GETTEXT
|
|
|
|
/* Initialize gettext library */
|
2016-01-16 18:05:50 +01:00
|
|
|
dyn_libintl_init();
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef VIMDLL
|
|
|
|
// LoadLibrary - get name of dll to load in here:
|
|
|
|
p = strrchr(prog, '\\');
|
|
|
|
if (p != NULL)
|
|
|
|
{
|
|
|
|
# ifdef DEBUG
|
|
|
|
strcpy(p+1, "vim32d.dll");
|
|
|
|
# else
|
|
|
|
strcpy(p+1, "vim32.dll");
|
|
|
|
# endif
|
|
|
|
}
|
|
|
|
hLib = LoadLibrary(prog);
|
|
|
|
if (hLib == NULL)
|
|
|
|
{
|
|
|
|
MessageBox(0, _("Could not load vim32.dll!"), _("VIM Error"), 0);
|
|
|
|
goto errout;
|
|
|
|
}
|
|
|
|
// fix up the function pointers
|
|
|
|
# ifdef FEAT_GUI
|
|
|
|
pSaveInst = GetProcAddress(hLib, (LPCSTR)2);
|
|
|
|
# endif
|
|
|
|
pmain = GetProcAddress(hLib, (LPCSTR)1);
|
|
|
|
if (pmain == NULL)
|
|
|
|
{
|
|
|
|
MessageBox(0, _("Could not fix up function pointers to the DLL!"),
|
|
|
|
_("VIM Error"),0);
|
|
|
|
goto errout;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# ifdef FEAT_GUI
|
|
|
|
pSaveInst = SaveInst;
|
|
|
|
# endif
|
|
|
|
pmain =
|
|
|
|
# if defined(FEAT_GUI_W32)
|
|
|
|
//&& defined(__MINGW32__)
|
|
|
|
VimMain
|
|
|
|
# else
|
|
|
|
main
|
|
|
|
# endif
|
|
|
|
;
|
|
|
|
#endif
|
|
|
|
#ifdef FEAT_GUI
|
|
|
|
pSaveInst(
|
|
|
|
#ifdef __MINGW32__
|
|
|
|
GetModuleHandle(NULL)
|
|
|
|
#else
|
|
|
|
hInstance
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
#endif
|
|
|
|
pmain(argc, argv);
|
|
|
|
|
|
|
|
#ifdef VIMDLL
|
|
|
|
FreeLibrary(hLib);
|
|
|
|
errout:
|
|
|
|
#endif
|
|
|
|
free(argv);
|
2008-11-12 12:36:30 +00:00
|
|
|
if (tofree != NULL)
|
|
|
|
free(tofree);
|
2004-09-06 17:44:46 +00:00
|
|
|
#ifdef FEAT_MBYTE
|
2004-10-07 21:02:47 +00:00
|
|
|
free_cmd_argsW();
|
2004-09-06 17:44:46 +00:00
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|