Global SO_PATH variable removed.

This commit is contained in:
Kolan Sh 2016-06-21 13:31:12 +03:00
parent e94a91ba7e
commit deb9c6e111
1 changed files with 22 additions and 8 deletions

View File

@ -12,10 +12,25 @@
#include "gettext-config.h"
char SO_PATH[FILENAME_MAX];
#if defined(_WIN32) || defined(_WIN64)
HINSTANCE hCurrentModuleInstance;
#endif
@LC_GLOB_VARS@
gboolean get_library_path (gchar *so_path, void *addr)
{
gboolean ret;
#if defined(_WIN32) || defined(_WIN64)
ret = 0 != GetModuleFileName (hCurrentModuleInstance, so_path, FILENAME_MAX);
#elif defined(linux) || defined(UNIX) || defined(__unix__)
Dl_info dl_info;
ret = 0 != dladdr(addr, &dl_info);
strcpy (so_path, dl_info.dli_fname);
#endif
return ret;
}
#if defined(_WIN32) || defined(_WIN64)
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
#elif defined(linux) || defined(UNIX) || defined(__unix__)
@ -25,19 +40,18 @@ void __attribute__ ((constructor)) load_library (void)
gchar *soDir, *localePath;
@LC_VARS@
gchar *so_path = g_new (gchar, FILENAME_MAX);
#if defined(_WIN32) || defined(_WIN64)
GetModuleFileName (hInstance, SO_PATH, FILENAME_MAX);
get_library_path (so_path, NULL);
hCurrentModuleInstance = hInstance;
@LC_WIN32_CODE@
#elif defined(linux) || defined(UNIX) || defined(__unix__)
Dl_info dl_info;
dladdr(load_library, &dl_info);
strcpy (SO_PATH, dl_info.dli_fname);
get_library_path (so_path, load_library);
@LC_UNIX_CODE@
#endif
soDir = g_path_get_dirname (SO_PATH);
soDir = g_path_get_dirname (so_path);
g_free (so_path);
localePath = g_build_filename (soDir, "@LC_RELATIVE_PREFIX@/share/locale", NULL);
g_free (soDir);
bindtextdomain (GETTEXT_PACKAGE, localePath);