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,9 +212,6 @@ | ||
212 | <Unit filename="src/core/util.c"> | 212 | <Unit filename="src/core/util.c"> |
213 | <Option compilerVar="CC" /> | 213 | <Option compilerVar="CC" /> |
214 | </Unit> | 214 | </Unit> |
215 | - <Unit filename="src/core/version.c"> | ||
216 | - <Option compilerVar="CC" /> | ||
217 | - </Unit> | ||
218 | <Unit filename="src/core/wait.c"> | 215 | <Unit filename="src/core/wait.c"> |
219 | <Option compilerVar="CC" /> | 216 | <Option compilerVar="CC" /> |
220 | </Unit> | 217 | </Unit> |
@@ -233,7 +230,9 @@ | @@ -233,7 +230,9 @@ | ||
233 | <Unit filename="src/core/windows/registry.c"> | 230 | <Unit filename="src/core/windows/registry.c"> |
234 | <Option compilerVar="CC" /> | 231 | <Option compilerVar="CC" /> |
235 | </Unit> | 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 | <Unit filename="src/core/windows/util.c"> | 236 | <Unit filename="src/core/windows/util.c"> |
238 | <Option compilerVar="CC" /> | 237 | <Option compilerVar="CC" /> |
239 | </Unit> | 238 | </Unit> |
src/core/init.c
@@ -160,23 +160,30 @@ int lib3270_unloaded(void) | @@ -160,23 +160,30 @@ int lib3270_unloaded(void) | ||
160 | 160 | ||
161 | BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwcallpurpose, LPVOID GNUC_UNUSED(lpvResvd)) | 161 | BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwcallpurpose, LPVOID GNUC_UNUSED(lpvResvd)) |
162 | { | 162 | { |
163 | + debug("%s starts",__FUNCTION__); | ||
164 | + | ||
163 | switch(dwcallpurpose) | 165 | switch(dwcallpurpose) |
164 | { | 166 | { |
165 | case DLL_PROCESS_ATTACH: | 167 | case DLL_PROCESS_ATTACH: |
166 | hModule = hInstance; | 168 | hModule = hInstance; |
167 | - hEventLog = RegisterEventSource(NULL, LIB3270_STRINGIZE_VALUE_OF(LIB3270_NAME)); | 169 | + hEventLog = RegisterEventSource(NULL, LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME)); |
168 | get_version_info(); | 170 | get_version_info(); |
169 | lib3270_loaded(); | 171 | lib3270_loaded(); |
170 | break; | 172 | break; |
171 | 173 | ||
172 | case DLL_PROCESS_DETACH: | 174 | case DLL_PROCESS_DETACH: |
173 | lib3270_unloaded(); | 175 | lib3270_unloaded(); |
174 | - DeregisterEventSource(hEventLog); | ||
175 | - hEventLog = 0; | 176 | + if(hEventLog) |
177 | + { | ||
178 | + DeregisterEventSource(hEventLog); | ||
179 | + } | ||
180 | + hEventLog = NULL; | ||
176 | break; | 181 | break; |
177 | 182 | ||
178 | } | 183 | } |
179 | 184 | ||
185 | + debug("%s ends",__FUNCTION__); | ||
186 | + | ||
180 | return TRUE; | 187 | return TRUE; |
181 | } | 188 | } |
182 | 189 |
src/core/windows/connect.c
@@ -238,6 +238,7 @@ int net_reconnect(H3270 *hSession, int seconds) | @@ -238,6 +238,7 @@ int net_reconnect(H3270 *hSession, int seconds) | ||
238 | 238 | ||
239 | debug("host.message=\"%s\"",host.message); | 239 | debug("host.message=\"%s\"",host.message); |
240 | 240 | ||
241 | + if(hEventLog) | ||
241 | { | 242 | { |
242 | // Register on event log | 243 | // Register on event log |
243 | lib3270_autoptr(char) username = lib3270_get_user_name(); | 244 | lib3270_autoptr(char) username = lib3270_get_user_name(); |
src/core/windows/log.c
@@ -43,31 +43,38 @@ | @@ -43,31 +43,38 @@ | ||
43 | 43 | ||
44 | void default_log_writer(H3270 GNUC_UNUSED(*session), const char *module, int rc, const char *fmt, va_list arg_ptr) | 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 | lib3270_autoptr(char) msg = lib3270_vsprintf(fmt,arg_ptr); | 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,9 +36,9 @@ static void online_group_state_changed(H3270 GNUC_UNUSED(*hSession), void GNUC_U | ||
36 | 36 | ||
37 | int main(int argc, char *argv[]) | 37 | int main(int argc, char *argv[]) |
38 | { | 38 | { |
39 | -#ifdef _WIN32 | 39 | +#ifdef DEBUG |
40 | printf("Process %s running on pid %u\n",argv[0],(unsigned int) GetCurrentProcessId()); | 40 | printf("Process %s running on pid %u\n",argv[0],(unsigned int) GetCurrentProcessId()); |
41 | -#endif // _WIN32 | 41 | +#endif // DEBUG |
42 | 42 | ||
43 | #ifdef LC_ALL | 43 | #ifdef LC_ALL |
44 | setlocale( LC_ALL, "" ); | 44 | setlocale( LC_ALL, "" ); |
@@ -61,6 +61,8 @@ int main(int argc, char *argv[]) | @@ -61,6 +61,8 @@ int main(int argc, char *argv[]) | ||
61 | H3270 * h = lib3270_session_new(""); | 61 | H3270 * h = lib3270_session_new(""); |
62 | int rc = 0; | 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 | lib3270_autoptr(char) version_info = lib3270_get_version_info(); | 66 | lib3270_autoptr(char) version_info = lib3270_get_version_info(); |
65 | printf("3270 session %p created\n%s\n]",h,version_info); | 67 | printf("3270 session %p created\n%s\n]",h,version_info); |
66 | 68 |