annotate src/os_w32exe.c @ 3947:d08f05285dd1 v7.3.729

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