Library constructor template added.
This commit is contained in:
parent
1df5dd35c7
commit
02f3a0f7d9
|
@ -0,0 +1,47 @@
|
|||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include <windows.h>
|
||||
@LC_WIN32_INCLUDES@
|
||||
#elif defined(linux) || defined(UNIX) || defined(__unix__)
|
||||
#define _GNU_SOURCE
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
@LC_UNIX_INCLUDES@
|
||||
#endif
|
||||
|
||||
@LC_COMMON_INCLUDES@
|
||||
|
||||
#include "gettext-config.h"
|
||||
|
||||
char SO_PATH[FILENAME_MAX];
|
||||
|
||||
@LC_GLOB_VARS@
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
||||
#elif defined(linux) || defined(UNIX) || defined(__unix__)
|
||||
void __attribute__ ((constructor)) load_library (void)
|
||||
#endif
|
||||
{
|
||||
gchar *soDir, *localePath;
|
||||
@LC_VARS@
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
GetModuleFileName (hInstance, SO_PATH, FILENAME_MAX);
|
||||
|
||||
@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);
|
||||
|
||||
@LC_UNIX_CODE@
|
||||
#endif
|
||||
|
||||
soDir = g_path_get_dirname (SO_PATH);
|
||||
localePath = g_build_filename (soDir, "@LC_RELATIVE_PREFIX@/share/locale", NULL);
|
||||
g_free (soDir);
|
||||
bindtextdomain (GETTEXT_PACKAGE, localePath);
|
||||
g_free (localePath);
|
||||
|
||||
@LC_COMMON_CODE@
|
||||
}
|
Loading…
Reference in New Issue