Mercurial > pidgin
changeset 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 | b7b1d416ff44 |
children | 3c21f3084ff0 |
files | src/win_gaim.c |
diffstat | 1 files changed, 24 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/win_gaim.c Tue Nov 11 07:26:35 2003 +0000 +++ b/src/win_gaim.c Tue Nov 11 19:51:47 2003 +0000 @@ -23,6 +23,7 @@ * */ #include <windows.h> +#include <fcntl.h> #include <stdlib.h> #include <string.h> #include <stdio.h> @@ -217,8 +218,8 @@ char *lpszCmdLine, int nCmdShow) { + char errbuf[512]; char gaimdir[MAX_PATH]; - char *point; HMODULE hmod; /* If GAIM_NO_DLL_CHECK is set, don't run the dll check */ @@ -226,24 +227,38 @@ run_dll_prep(); /* Load exception handler if we have it */ - GetModuleFileName(NULL, gaimdir, MAX_PATH); - if((point=strstr(gaimdir, "gaim.exe"))) { - point[0] = '\0'; - strcat(gaimdir, "exchndl.dll"); - LoadLibrary(gaimdir); + if(GetModuleFileName(NULL, gaimdir, MAX_PATH) != 0) { + char *tmp = gaimdir; + char *prev = NULL; + + while((tmp=strchr(tmp, '\\'))) { + prev = tmp; + tmp+=1; + } + if(prev) { + prev[0] = '\0'; + strcat(gaimdir, "\\exchndl.dll"); + LoadLibrary(gaimdir); + } } - + else { + snprintf(errbuf, 512, "Error getting module filename. Error: %u", (UINT)GetLastError()); + MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST); + } + /* Set Gaim locale */ wgaim_set_locale(); + /* Set global file mode to binary so that we don't do any dos file translations */ + _fmode = _O_BINARY; + /* Now we are ready for Gaim .. */ if((hmod=LoadLibrary("gaim.dll"))) { gaim_main = (void*)GetProcAddress(hmod, "gaim_main"); } if(!gaim_main) { - char errbuf[256]; - sprintf(errbuf, "Error loading gaim.dll entry point. Error: %d", GetLastError()); + snprintf(errbuf, 512, "Error loading gaim.dll. Error: %u", (UINT)GetLastError()); MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST); return 0; }