Commit bb46dd50b342f2a3738327da601c61f88c18f7a5
1 parent
481d1bfc
Exists in
master
and in
3 other branches
Working on windows event log.
Showing
5 changed files
with
46 additions
and
30 deletions
Show diff stats
lib3270.cbp
| ... | ... | @@ -212,9 +212,6 @@ |
| 212 | 212 | <Unit filename="src/core/util.c"> |
| 213 | 213 | <Option compilerVar="CC" /> |
| 214 | 214 | </Unit> |
| 215 | - <Unit filename="src/core/version.c"> | |
| 216 | - <Option compilerVar="CC" /> | |
| 217 | - </Unit> | |
| 218 | 215 | <Unit filename="src/core/wait.c"> |
| 219 | 216 | <Option compilerVar="CC" /> |
| 220 | 217 | </Unit> |
| ... | ... | @@ -233,7 +230,9 @@ |
| 233 | 230 | <Unit filename="src/core/windows/registry.c"> |
| 234 | 231 | <Option compilerVar="CC" /> |
| 235 | 232 | </Unit> |
| 236 | - <Unit filename="src/core/windows/resources.rc" /> | |
| 233 | + <Unit filename="src/core/windows/resources.rc"> | |
| 234 | + <Option compilerVar="WINDRES" /> | |
| 235 | + </Unit> | |
| 237 | 236 | <Unit filename="src/core/windows/util.c"> |
| 238 | 237 | <Option compilerVar="CC" /> |
| 239 | 238 | </Unit> | ... | ... |
src/core/init.c
| ... | ... | @@ -160,23 +160,30 @@ int lib3270_unloaded(void) |
| 160 | 160 | |
| 161 | 161 | BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwcallpurpose, LPVOID GNUC_UNUSED(lpvResvd)) |
| 162 | 162 | { |
| 163 | + debug("%s starts",__FUNCTION__); | |
| 164 | + | |
| 163 | 165 | switch(dwcallpurpose) |
| 164 | 166 | { |
| 165 | 167 | case DLL_PROCESS_ATTACH: |
| 166 | 168 | hModule = hInstance; |
| 167 | - hEventLog = RegisterEventSource(NULL, LIB3270_STRINGIZE_VALUE_OF(LIB3270_NAME)); | |
| 169 | + hEventLog = RegisterEventSource(NULL, LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME)); | |
| 168 | 170 | get_version_info(); |
| 169 | 171 | lib3270_loaded(); |
| 170 | 172 | break; |
| 171 | 173 | |
| 172 | 174 | case DLL_PROCESS_DETACH: |
| 173 | 175 | lib3270_unloaded(); |
| 174 | - DeregisterEventSource(hEventLog); | |
| 175 | - hEventLog = 0; | |
| 176 | + if(hEventLog) | |
| 177 | + { | |
| 178 | + DeregisterEventSource(hEventLog); | |
| 179 | + } | |
| 180 | + hEventLog = NULL; | |
| 176 | 181 | break; |
| 177 | 182 | |
| 178 | 183 | } |
| 179 | 184 | |
| 185 | + debug("%s ends",__FUNCTION__); | |
| 186 | + | |
| 180 | 187 | return TRUE; |
| 181 | 188 | } |
| 182 | 189 | ... | ... |
src/core/windows/connect.c
src/core/windows/log.c
| ... | ... | @@ -43,31 +43,38 @@ |
| 43 | 43 | |
| 44 | 44 | void default_log_writer(H3270 GNUC_UNUSED(*session), const char *module, int rc, const char *fmt, va_list arg_ptr) |
| 45 | 45 | { |
| 46 | - lib3270_autoptr(char) username = lib3270_get_user_name(); | |
| 47 | 46 | lib3270_autoptr(char) msg = lib3270_vsprintf(fmt,arg_ptr); |
| 48 | 47 | |
| 49 | - const char *outMsg[] = { | |
| 50 | - username, | |
| 51 | - module, | |
| 52 | - msg | |
| 53 | - }; | |
| 48 | + debug("%s",msg); | |
| 54 | 49 | |
| 55 | -#ifdef DEBUG | |
| 56 | - fprintf(stderr,"LOG(%s): %s\n",module,msg); | |
| 57 | - fflush(stderr); | |
| 58 | -#endif // DEBUG | |
| 50 | + if(hEventLog) | |
| 51 | + { | |
| 52 | + lib3270_autoptr(char) username = lib3270_get_user_name(); | |
| 59 | 53 | |
| 60 | - ReportEvent( | |
| 61 | - hEventLog, | |
| 62 | - (rc == 0 ? EVENTLOG_INFORMATION_TYPE : EVENTLOG_ERROR_TYPE), | |
| 63 | - 1, | |
| 64 | - 0, | |
| 65 | - NULL, | |
| 66 | - 3, | |
| 67 | - 0, | |
| 68 | - outMsg, | |
| 69 | - NULL | |
| 70 | - ); | |
| 54 | + const char *outMsg[] = { | |
| 55 | + username, | |
| 56 | + module, | |
| 57 | + msg | |
| 58 | + }; | |
| 59 | + | |
| 60 | + #ifdef DEBUG | |
| 61 | + fprintf(stderr,"LOG(%s): %s\n",module,msg); | |
| 62 | + fflush(stderr); | |
| 63 | + #endif // DEBUG | |
| 64 | + | |
| 65 | + ReportEvent( | |
| 66 | + hEventLog, | |
| 67 | + (rc == 0 ? EVENTLOG_INFORMATION_TYPE : EVENTLOG_ERROR_TYPE), | |
| 68 | + 1, | |
| 69 | + 0, | |
| 70 | + NULL, | |
| 71 | + 3, | |
| 72 | + 0, | |
| 73 | + outMsg, | |
| 74 | + NULL | |
| 75 | + ); | |
| 76 | + | |
| 77 | + } | |
| 71 | 78 | |
| 72 | 79 | } |
| 73 | 80 | ... | ... |
src/testprogram/testprogram.c
| ... | ... | @@ -36,9 +36,9 @@ static void online_group_state_changed(H3270 GNUC_UNUSED(*hSession), void GNUC_U |
| 36 | 36 | |
| 37 | 37 | int main(int argc, char *argv[]) |
| 38 | 38 | { |
| 39 | -#ifdef _WIN32 | |
| 39 | +#ifdef DEBUG | |
| 40 | 40 | printf("Process %s running on pid %u\n",argv[0],(unsigned int) GetCurrentProcessId()); |
| 41 | -#endif // _WIN32 | |
| 41 | +#endif // DEBUG | |
| 42 | 42 | |
| 43 | 43 | #ifdef LC_ALL |
| 44 | 44 | setlocale( LC_ALL, "" ); |
| ... | ... | @@ -61,6 +61,8 @@ int main(int argc, char *argv[]) |
| 61 | 61 | H3270 * h = lib3270_session_new(""); |
| 62 | 62 | int rc = 0; |
| 63 | 63 | |
| 64 | + lib3270_write_log(h,"TEST","Testprogram %s starts (%s)",argv[0],LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME)); | |
| 65 | + | |
| 64 | 66 | lib3270_autoptr(char) version_info = lib3270_get_version_info(); |
| 65 | 67 | printf("3270 session %p created\n%s\n]",h,version_info); |
| 66 | 68 | ... | ... |