Mercurial > vim
comparison src/os_w32exe.c @ 7:3fc0f57ecb91 v7.0001
updated for version 7.0001
author | vimboss |
---|---|
date | Sun, 13 Jun 2004 20:20:40 +0000 |
parents | |
children | 3f44e9abe4ec |
comparison
equal
deleted
inserted
replaced
6:c2daee826b8f | 7:3fc0f57ecb91 |
---|---|
1 /* vi:set ts=8 sts=4 sw=4: | |
2 * | |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * GUI support by Robert Webb | |
5 * | |
6 * Do ":help uganda" in Vim to read copying and usage conditions. | |
7 * Do ":help credits" in Vim to see a list of people who contributed. | |
8 * See README.txt for an overview of the Vim source code. | |
9 */ | |
10 /* | |
11 * Windows GUI: main program (EXE) entry point: | |
12 * | |
13 * Ron Aaron <ronaharon@yahoo.com> wrote this and the DLL support code. | |
14 */ | |
15 #include "vim.h" | |
16 | |
17 #ifdef __MINGW32__ | |
18 # ifndef _cdecl | |
19 # define _cdecl | |
20 # endif | |
21 #endif | |
22 | |
23 /* cproto doesn't create a prototype for main() */ | |
24 int _cdecl | |
25 #if defined(FEAT_GUI_W32) | |
26 VimMain | |
27 #else | |
28 main | |
29 #endif | |
30 __ARGS((int argc, char **argv)); | |
31 int (_cdecl *pmain)(int, char **); | |
32 | |
33 #ifndef PROTO | |
34 #ifdef FEAT_GUI | |
35 #ifndef VIMDLL | |
36 void _cdecl SaveInst(HINSTANCE hInst); | |
37 #endif | |
38 void (_cdecl *pSaveInst)(HINSTANCE); | |
39 #endif | |
40 | |
41 int WINAPI | |
42 WinMain( | |
43 HINSTANCE hInstance, | |
44 HINSTANCE hPrevInst, | |
45 LPSTR lpszCmdLine, | |
46 int nCmdShow) | |
47 { | |
48 int argc; | |
49 char **argv; | |
50 char *tofree; | |
51 char prog[256]; | |
52 #ifdef VIMDLL | |
53 char *p; | |
54 HANDLE hLib; | |
55 #endif | |
56 | |
57 /* Ron: added full path name so that the $VIM variable will get set to our | |
58 * startup path (so the .vimrc file can be found w/o a VIM env. var.) */ | |
59 GetModuleFileName(NULL, prog, 255); | |
60 | |
61 /* Separate the command line into arguments. */ | |
62 argc = get_cmd_args(prog, (char *)lpszCmdLine, &argv, &tofree); | |
63 if (argc == 0) | |
64 { | |
65 MessageBox(0, _("Could not allocate memory for command line."), | |
66 _("VIM Error"), 0); | |
67 return 0; | |
68 } | |
69 | |
70 #ifdef DYNAMIC_GETTEXT | |
71 /* Initialize gettext library */ | |
72 dyn_libintl_init(NULL); | |
73 #endif | |
74 | |
75 #ifdef VIMDLL | |
76 // LoadLibrary - get name of dll to load in here: | |
77 p = strrchr(prog, '\\'); | |
78 if (p != NULL) | |
79 { | |
80 # ifdef DEBUG | |
81 strcpy(p+1, "vim32d.dll"); | |
82 # else | |
83 strcpy(p+1, "vim32.dll"); | |
84 # endif | |
85 } | |
86 hLib = LoadLibrary(prog); | |
87 if (hLib == NULL) | |
88 { | |
89 MessageBox(0, _("Could not load vim32.dll!"), _("VIM Error"), 0); | |
90 goto errout; | |
91 } | |
92 // fix up the function pointers | |
93 # ifdef FEAT_GUI | |
94 pSaveInst = GetProcAddress(hLib, (LPCSTR)2); | |
95 # endif | |
96 pmain = GetProcAddress(hLib, (LPCSTR)1); | |
97 if (pmain == NULL) | |
98 { | |
99 MessageBox(0, _("Could not fix up function pointers to the DLL!"), | |
100 _("VIM Error"),0); | |
101 goto errout; | |
102 } | |
103 #else | |
104 # ifdef FEAT_GUI | |
105 pSaveInst = SaveInst; | |
106 # endif | |
107 pmain = | |
108 # if defined(FEAT_GUI_W32) | |
109 //&& defined(__MINGW32__) | |
110 VimMain | |
111 # else | |
112 main | |
113 # endif | |
114 ; | |
115 #endif | |
116 #ifdef FEAT_GUI | |
117 pSaveInst( | |
118 #ifdef __MINGW32__ | |
119 GetModuleHandle(NULL) | |
120 #else | |
121 hInstance | |
122 #endif | |
123 ); | |
124 #endif | |
125 pmain(argc, argv); | |
126 | |
127 #ifdef VIMDLL | |
128 FreeLibrary(hLib); | |
129 errout: | |
130 #endif | |
131 free(argv); | |
132 free(tofree); | |
133 | |
134 return 0; | |
135 } | |
136 #endif |