Commit b8383bb61d0ad5e2ad93b56826a614ea9156396e
1 parent
64b52c6e
Exists in
master
and in
3 other branches
Adding method to get active trace handler.
Showing
3 changed files
with
22 additions
and
4 deletions
Show diff stats
src/include/lib3270/trace.h
... | ... | @@ -44,9 +44,8 @@ |
44 | 44 | |
45 | 45 | typedef void (*LIB3270_TRACE_HANDLER)(H3270 *, void *, const char *, va_list); |
46 | 46 | |
47 | - | |
48 | 47 | /** |
49 | - * Set trace handle callback. | |
48 | + * @brief Set trace handle callback. | |
50 | 49 | * |
51 | 50 | * @param hSession TN3270 Session handle. |
52 | 51 | * @param handler Callback to write in trace file or show trace window (NULL send all trace to stdout/syslog). |
... | ... | @@ -56,6 +55,16 @@ |
56 | 55 | LIB3270_EXPORT void lib3270_set_trace_handler(H3270 *hSession, LIB3270_TRACE_HANDLER handler, void *userdata); |
57 | 56 | |
58 | 57 | /** |
58 | + * @brief Get trace handle callback. | |
59 | + * | |
60 | + * @param hSession TN3270 Session handle. | |
61 | + * @param handler Callback to write in trace file or show trace window (NULL send all trace to stdout/syslog). | |
62 | + * @param userdata User data to pass to the trace handler. | |
63 | + * | |
64 | + */ | |
65 | + LIB3270_EXPORT void lib3270_get_trace_handler(H3270 *hSession, LIB3270_TRACE_HANDLER *handler, void **userdata); | |
66 | + | |
67 | + /** | |
59 | 68 | * Write on trace file. |
60 | 69 | * |
61 | 70 | * Write text on trace file, if DStrace is enabled. | ... | ... |
src/lib3270/session.c
... | ... | @@ -327,10 +327,19 @@ LIB3270_EXPORT void lib3270_set_trace_handler(H3270 *hSession, LIB3270_TRACE_HAN |
327 | 327 | { |
328 | 328 | CHECK_SESSION_HANDLE(hSession); |
329 | 329 | |
330 | - hSession->trace.handler = handler ? handler : def_trace; | |
330 | + hSession->trace.handler = handler ? handler : def_trace; | |
331 | 331 | hSession->trace.userdata = userdata; |
332 | 332 | } |
333 | 333 | |
334 | +LIB3270_EXPORT void lib3270_get_trace_handler(H3270 *hSession, LIB3270_TRACE_HANDLER *handler, void **userdata) | |
335 | +{ | |
336 | + CHECK_SESSION_HANDLE(hSession); | |
337 | + | |
338 | + *handler = hSession->trace.handler; | |
339 | + *userdata = hSession->trace.userdata; | |
340 | + | |
341 | +} | |
342 | + | |
334 | 343 | LIB3270_EXPORT void lib3270_set_popup_handler(H3270 *session, void (*handler)(H3270 *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list)) { |
335 | 344 | session->cbk.popup = handler ? handler : def_popup; |
336 | 345 | } | ... | ... |
src/lib3270/testprogram/testprogram.c
... | ... | @@ -17,7 +17,7 @@ int main(int numpar, char *param[]) |
17 | 17 | h = lib3270_session_new(""); |
18 | 18 | printf("3270 session %p created\n]",h); |
19 | 19 | |
20 | -// lib3270_set_toggle(session,LIB3270_TOGGLE_DS_TRACE,1); | |
20 | + lib3270_set_toggle(h,LIB3270_TOGGLE_DS_TRACE,1); | |
21 | 21 | |
22 | 22 | lib3270_set_url(h,url ? url : "tn3270://fandezhi.efglobe.com"); |
23 | 23 | rc = lib3270_connect(h,120); | ... | ... |