diff --git a/configure.ac b/configure.ac index 630c001..799e2fc 100644 --- a/configure.ac +++ b/configure.ac @@ -432,7 +432,7 @@ dnl --------------------------------------------------------------------------- AC_ARG_WITH([libname], [AS_HELP_STRING([--with-libname], [Setup library name])], [ app_cv_libname="$withval" ],[ app_cv_libname="3270" ]) -AC_DEFINE(LIB3270_NAME,$app_cv_libname) +AC_DEFINE_UNQUOTED(LIB3270_NAME,$app_cv_libname) AC_SUBST(LIB3270_NAME,$app_cv_libname) AC_ARG_WITH([sdk-version], [AS_HELP_STRING([--with-sdk-version], [Setup library version for SDK])], [ app_cv_sdkversion="$withval" ],[ app_cv_sdkversion=$VERSION ]) diff --git a/src/include/config.h.in b/src/include/config.h.in index 563d5e1..3bf894e 100644 --- a/src/include/config.h.in +++ b/src/include/config.h.in @@ -35,6 +35,7 @@ #undef PACKAGE_NAME #undef PACKAGE_VERSION #undef PACKAGE_RELEASE + #undef LIB3270_NAME /* Default settings */ diff --git a/src/lib3270/init.c b/src/lib3270/init.c index 0b61d9f..b7856f9 100644 --- a/src/lib3270/init.c +++ b/src/lib3270/init.c @@ -63,6 +63,11 @@ /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ +#ifdef _WIN32 +/// @brief Windows Event Log Handler. +HANDLE hEventLog = 0; +#endif // _WIN32 + /** * @brief Parse an stty control-character specification; a cheap, non-complaining implementation. */ @@ -128,10 +133,13 @@ BOOL WINAPI DllMain(HANDLE GNUC_UNUSED(hinst), DWORD dwcallpurpose, LPVOID GNUC_ case DLL_PROCESS_ATTACH: get_version_info(); lib3270_loaded(); + hEventLog = RegisterEventSource(NULL, LIB3270_STRINGIZE_VALUE_OF(LIB3270_NAME)); break; case DLL_PROCESS_DETACH: lib3270_unloaded(); + DeregisterEventSource(hEventLog); + hEventLog = 0; break; } diff --git a/src/lib3270/private.h b/src/lib3270/private.h index 9dbcba8..929fcf7 100644 --- a/src/lib3270/private.h +++ b/src/lib3270/private.h @@ -674,11 +674,6 @@ struct _h3270 struct lib3270_state_callback * last[LIB3270_STATE_USER]; } st; -#ifdef _WIN32 - /// @brief Windows Event Log Handler. - HANDLE hEventLog; -#endif // _WIN32 - }; #define SELECTION_LEFT 0x01 @@ -691,6 +686,11 @@ struct _h3270 #define SELECTION_ACTIVE 0x80 +#ifdef _WIN32 +/// @brief Windows Event Log Handler. +LIB3270_INTERNAL HANDLE hEventLog; +#endif // _WIN32 + /* Library internal calls */ LIB3270_INTERNAL int key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped); LIB3270_INTERNAL int cursor_move(H3270 *session, int baddr); diff --git a/src/lib3270/session.c b/src/lib3270/session.c index 6217885..92aa205 100644 --- a/src/lib3270/session.c +++ b/src/lib3270/session.c @@ -151,11 +151,6 @@ void lib3270_session_free(H3270 *h) lib3270_free(ip); } -#ifdef _WIN32 - DeregisterEventSource(h->hEventLog); - h->hEventLog = 0; -#endif // _WIN32 - trace("Releasing session %p",h); lib3270_free(h); @@ -413,10 +408,6 @@ H3270 * lib3270_session_new(const char *model) ft_init(hSession); #endif -#ifdef _WIN32 - hSession->hEventLog = RegisterEventSource(NULL, PACKAGE_NAME); -#endif // _WIN32 - trace("%s finished",__FUNCTION__); errno = 0; diff --git a/src/lib3270/windows/log.c b/src/lib3270/windows/log.c index 40ea3bd..d5d94cd 100644 --- a/src/lib3270/windows/log.c +++ b/src/lib3270/windows/log.c @@ -41,7 +41,7 @@ /*---[ Implement ]------------------------------------------------------------------------------------------*/ - void default_log_writer(H3270 *session, const char *module, int rc, const char *fmt, va_list arg_ptr) + void default_log_writer(H3270 GNUC_UNUSED(*session), const char *module, int rc, const char *fmt, va_list arg_ptr) { char username[UNLEN + 1]; DWORD szName = sizeof(username); @@ -60,19 +60,17 @@ msg }; - if(session->hEventLog) { - ReportEvent( - session->hEventLog, - (rc == 0 ? EVENTLOG_INFORMATION_TYPE : EVENTLOG_ERROR_TYPE), - 1, - 0, - NULL, - 3, - 0, - outMsg, - NULL - ); - } + ReportEvent( + hEventLog, + (rc == 0 ? EVENTLOG_INFORMATION_TYPE : EVENTLOG_ERROR_TYPE), + 1, + 0, + NULL, + 3, + 0, + outMsg, + NULL + ); } -- libgit2 0.21.2