Mercurial > pidgin.yaz
comparison src/win_gaim.c @ 7477:29d69daa1ede
[gaim-migrate @ 8090]
Some better error checking and fix for #777647. Global file mode set to binary.
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Tue, 11 Nov 2003 19:51:47 +0000 |
parents | 0da73a46f7ae |
children | 07156f873116 |
comparison
equal
deleted
inserted
replaced
7476:b7b1d416ff44 | 7477:29d69daa1ede |
---|---|
21 * along with this program; if not, write to the Free Software | 21 * along with this program; if not, write to the Free Software |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 * | 23 * |
24 */ | 24 */ |
25 #include <windows.h> | 25 #include <windows.h> |
26 #include <fcntl.h> | |
26 #include <stdlib.h> | 27 #include <stdlib.h> |
27 #include <string.h> | 28 #include <string.h> |
28 #include <stdio.h> | 29 #include <stdio.h> |
29 | 30 |
30 /* | 31 /* |
215 WinMain (struct HINSTANCE__ *hInstance, | 216 WinMain (struct HINSTANCE__ *hInstance, |
216 struct HINSTANCE__ *hPrevInstance, | 217 struct HINSTANCE__ *hPrevInstance, |
217 char *lpszCmdLine, | 218 char *lpszCmdLine, |
218 int nCmdShow) | 219 int nCmdShow) |
219 { | 220 { |
221 char errbuf[512]; | |
220 char gaimdir[MAX_PATH]; | 222 char gaimdir[MAX_PATH]; |
221 char *point; | |
222 HMODULE hmod; | 223 HMODULE hmod; |
223 | 224 |
224 /* If GAIM_NO_DLL_CHECK is set, don't run the dll check */ | 225 /* If GAIM_NO_DLL_CHECK is set, don't run the dll check */ |
225 if(!getenv("GAIM_NO_DLL_CHECK")) | 226 if(!getenv("GAIM_NO_DLL_CHECK")) |
226 run_dll_prep(); | 227 run_dll_prep(); |
227 | 228 |
228 /* Load exception handler if we have it */ | 229 /* Load exception handler if we have it */ |
229 GetModuleFileName(NULL, gaimdir, MAX_PATH); | 230 if(GetModuleFileName(NULL, gaimdir, MAX_PATH) != 0) { |
230 if((point=strstr(gaimdir, "gaim.exe"))) { | 231 char *tmp = gaimdir; |
231 point[0] = '\0'; | 232 char *prev = NULL; |
232 strcat(gaimdir, "exchndl.dll"); | 233 |
233 LoadLibrary(gaimdir); | 234 while((tmp=strchr(tmp, '\\'))) { |
234 } | 235 prev = tmp; |
235 | 236 tmp+=1; |
237 } | |
238 if(prev) { | |
239 prev[0] = '\0'; | |
240 strcat(gaimdir, "\\exchndl.dll"); | |
241 LoadLibrary(gaimdir); | |
242 } | |
243 } | |
244 else { | |
245 snprintf(errbuf, 512, "Error getting module filename. Error: %u", (UINT)GetLastError()); | |
246 MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST); | |
247 } | |
248 | |
236 /* Set Gaim locale */ | 249 /* Set Gaim locale */ |
237 wgaim_set_locale(); | 250 wgaim_set_locale(); |
251 | |
252 /* Set global file mode to binary so that we don't do any dos file translations */ | |
253 _fmode = _O_BINARY; | |
238 | 254 |
239 /* Now we are ready for Gaim .. */ | 255 /* Now we are ready for Gaim .. */ |
240 if((hmod=LoadLibrary("gaim.dll"))) { | 256 if((hmod=LoadLibrary("gaim.dll"))) { |
241 gaim_main = (void*)GetProcAddress(hmod, "gaim_main"); | 257 gaim_main = (void*)GetProcAddress(hmod, "gaim_main"); |
242 } | 258 } |
243 | 259 |
244 if(!gaim_main) { | 260 if(!gaim_main) { |
245 char errbuf[256]; | 261 snprintf(errbuf, 512, "Error loading gaim.dll. Error: %u", (UINT)GetLastError()); |
246 sprintf(errbuf, "Error loading gaim.dll entry point. Error: %d", GetLastError()); | |
247 MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST); | 262 MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST); |
248 return 0; | 263 return 0; |
249 } | 264 } |
250 else | 265 else |
251 return gaim_main (hInstance, __argc, __argv); | 266 return gaim_main (hInstance, __argc, __argv); |