#include "vim.h"
#ifdef __MINGW32__
# ifndef _cdecl
# define _cdecl
# endif
#endif
int _cdecl
#if defined(FEAT_GUI_W32)
VimMain
#else
main
#endif
(int argc, char **argv);
static int (_cdecl *pmain)(int, char **);
#ifndef PROTO
#ifdef FEAT_GUI
#ifndef VIMDLL
void _cdecl SaveInst(HINSTANCE hInst);
#endif
static void (_cdecl *pSaveInst)(HINSTANCE);
#endif
int WINAPI
WinMain(
HINSTANCE hInstance UNUSED,
HINSTANCE hPrevInst UNUSED,
LPSTR lpszCmdLine,
int nCmdShow UNUSED)
{
int argc = 0;
char **argv;
char *tofree;
char prog[256];
#ifdef VIMDLL
char *p;
HANDLE hLib;
#endif
GetModuleFileName(NULL, prog, 255);
argc = get_cmd_args(prog, (char *)lpszCmdLine, &argv, &tofree);
if (argc == 0)
{
MessageBox(0, "Could not allocate memory for command line.",
"VIM Error", 0);
return 0;
}
#ifdef DYNAMIC_GETTEXT
dyn_libintl_init();
#endif
#ifdef VIMDLL
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;
}
# 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)
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);
if (tofree != NULL)
free(tofree);
#ifdef FEAT_MBYTE
free_cmd_argsW();
#endif
return 0;
}
#endif