Commit 6f550f75d8dd782e1787b65bee8aa0fc3d1817ba
1 parent
914af0b7
Exists in
master
and in
2 other branches
Adding 'tracefile' property (still incomplete).
Showing
7 changed files
with
51 additions
and
14 deletions
Show diff stats
src/core/log.c
| ... | ... | @@ -53,7 +53,7 @@ static void (*loghandler)(H3270 *session, const char *module, int rc, const char |
| 53 | 53 | |
| 54 | 54 | static void logfile(H3270 *session, const char *module, int rc, const char *fmt, va_list arg_ptr) { |
| 55 | 55 | |
| 56 | - FILE *f = fopen(session->logfile, "a"); | |
| 56 | + FILE *f = fopen(session->file.log, "a"); | |
| 57 | 57 | |
| 58 | 58 | if(f) { |
| 59 | 59 | |
| ... | ... | @@ -81,20 +81,21 @@ static void logfile(H3270 *session, const char *module, int rc, const char *fmt, |
| 81 | 81 | |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | -LIB3270_EXPORT const char * lib3270_get_log_filename(H3270 * hSession) { | |
| 85 | - return hSession->logfile; | |
| 84 | +LIB3270_EXPORT const char * lib3270_get_log_filename(const H3270 * hSession) { | |
| 85 | + return hSession->file.log; | |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | LIB3270_EXPORT int lib3270_set_log_filename(H3270 * hSession, const char *filename) { |
| 89 | 89 | |
| 90 | - if(hSession->logfile) { | |
| 91 | - lib3270_free(hSession->logfile); | |
| 90 | + if(hSession->file.log) { | |
| 91 | + lib3270_free(hSession->file.log); | |
| 92 | + hSession->file.log = NULL; | |
| 92 | 93 | } |
| 93 | 94 | |
| 94 | 95 | if(filename && *filename) { |
| 95 | - hSession->logfile = lib3270_strdup(filename); | |
| 96 | + hSession->file.log = lib3270_strdup(filename); | |
| 96 | 97 | } else { |
| 97 | - hSession->logfile = NULL; | |
| 98 | + hSession->file.log = NULL; | |
| 98 | 99 | } |
| 99 | 100 | |
| 100 | 101 | return 0; |
| ... | ... | @@ -109,7 +110,7 @@ LIB3270_EXPORT int lib3270_write_log(H3270 *session, const char *module, const c |
| 109 | 110 | va_list arg_ptr; |
| 110 | 111 | va_start(arg_ptr, fmt); |
| 111 | 112 | |
| 112 | - if(session && session->logfile) { | |
| 113 | + if(session && session->file.log) { | |
| 113 | 114 | logfile(session,module ? module : LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),0,fmt,arg_ptr); |
| 114 | 115 | } else { |
| 115 | 116 | loghandler(session,module ? module : LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),0,fmt,arg_ptr); |
| ... | ... | @@ -123,7 +124,7 @@ LIB3270_EXPORT int lib3270_write_rc(H3270 *session, const char *module, int rc, |
| 123 | 124 | va_list arg_ptr; |
| 124 | 125 | va_start(arg_ptr, fmt); |
| 125 | 126 | |
| 126 | - if(session && session->logfile) { | |
| 127 | + if(session && session->file.log) { | |
| 127 | 128 | logfile(session,module ? module : LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),rc,fmt,arg_ptr); |
| 128 | 129 | } else { |
| 129 | 130 | loghandler(session,module ? module : LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),rc,fmt,arg_ptr); |
| ... | ... | @@ -134,7 +135,7 @@ LIB3270_EXPORT int lib3270_write_rc(H3270 *session, const char *module, int rc, |
| 134 | 135 | } |
| 135 | 136 | |
| 136 | 137 | LIB3270_EXPORT void lib3270_write_va_log(H3270 *session, const char *module, const char *fmt, va_list arg) { |
| 137 | - if(session && session->logfile) { | |
| 138 | + if(session && session->file.log) { | |
| 138 | 139 | logfile(session,module ? module : LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),0,fmt,arg); |
| 139 | 140 | } else { |
| 140 | 141 | loghandler(session,module ? module : LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),0,fmt,arg); | ... | ... |
src/core/properties/string.c
| ... | ... | @@ -191,6 +191,14 @@ LIB3270_EXPORT const LIB3270_STRING_PROPERTY * lib3270_get_string_properties_lis |
| 191 | 191 | }, |
| 192 | 192 | |
| 193 | 193 | { |
| 194 | + .name = "tracefile", // Property name. | |
| 195 | + .group = LIB3270_ACTION_GROUP_NONE, // Property group. | |
| 196 | + .description = N_( "The trace file name"), // Property description. | |
| 197 | + .get = lib3270_get_trace_filename, // Get value. | |
| 198 | + .set = lib3270_set_trace_filename // Set value. | |
| 199 | + }, | |
| 200 | + | |
| 201 | + { | |
| 194 | 202 | .name = NULL, |
| 195 | 203 | .description = NULL, |
| 196 | 204 | .get = NULL, | ... | ... |
src/core/properties/unsigned.c
| ... | ... | @@ -67,6 +67,7 @@ LIB3270_EXPORT unsigned int lib3270_get_auto_reconnect(const H3270 *hSession) { |
| 67 | 67 | |
| 68 | 68 | LIB3270_EXPORT int lib3270_set_auto_reconnect(H3270 *hSession, unsigned int timer) { |
| 69 | 69 | hSession->connection.retry = timer; |
| 70 | + return 0; | |
| 70 | 71 | } |
| 71 | 72 | |
| 72 | 73 | const LIB3270_UINT_PROPERTY * lib3270_get_unsigned_properties_list(void) { | ... | ... |
src/core/session.c
| ... | ... | @@ -148,7 +148,8 @@ void lib3270_session_free(H3270 *h) { |
| 148 | 148 | lib3270_linked_list_free(&h->input.list); |
| 149 | 149 | |
| 150 | 150 | // Release logfile |
| 151 | - release_pointer(h->logfile); | |
| 151 | + release_pointer(h->file.log); | |
| 152 | + release_pointer(h->file.trace); | |
| 152 | 153 | lib3270_free(h); |
| 153 | 154 | |
| 154 | 155 | } | ... | ... |
src/core/trace_ds.c
| ... | ... | @@ -348,4 +348,25 @@ void lib3270_trace_data(H3270 *hSession, const char *msg, const unsigned char *d |
| 348 | 348 | |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | +LIB3270_EXPORT const char * lib3270_get_trace_filename(H3270 * hSession) { | |
| 352 | + return hSession->file.trace; | |
| 353 | +} | |
| 354 | + | |
| 355 | +LIB3270_EXPORT int lib3270_set_trace_filename(H3270 * hSession, const char *filename) { | |
| 356 | + | |
| 357 | + if(hSession->file.trace) { | |
| 358 | + lib3270_free(hSession->file.trace); | |
| 359 | + hSession->file.trace = NULL; | |
| 360 | + } | |
| 361 | + | |
| 362 | + if(filename && *filename) { | |
| 363 | + hSession->file.trace = lib3270_strdup(filename); | |
| 364 | + } else { | |
| 365 | + hSession->file.trace = NULL; | |
| 366 | + } | |
| 367 | + | |
| 368 | + return 0; | |
| 369 | + | |
| 370 | +} | |
| 371 | + | |
| 351 | 372 | #endif | ... | ... |
src/include/internals.h
| ... | ... | @@ -653,8 +653,10 @@ struct _h3270 { |
| 653 | 653 | |
| 654 | 654 | unsigned int tasks; |
| 655 | 655 | |
| 656 | - /// @brief Log file name (if set) | |
| 657 | - char *logfile; | |
| 656 | + struct { | |
| 657 | + char *log; ///< @brief Log file name (if set). | |
| 658 | + char *trace; ///< @brief Trace file name (if set). | |
| 659 | + } file; | |
| 658 | 660 | |
| 659 | 661 | }; |
| 660 | 662 | ... | ... |
src/include/lib3270/log.h
| ... | ... | @@ -58,7 +58,10 @@ LIB3270_EXPORT int lib3270_write_rc(H3270 *session, const char *module, int rc |
| 58 | 58 | LIB3270_EXPORT void lib3270_write_va_log(H3270 *session, const char *module, const char *fmt, va_list arg); |
| 59 | 59 | |
| 60 | 60 | LIB3270_EXPORT int lib3270_set_log_filename(H3270 * hSession, const char *name); |
| 61 | -LIB3270_EXPORT const char * lib3270_get_log_filename(H3270 * hSession); | |
| 61 | +LIB3270_EXPORT const char * lib3270_get_log_filename(const H3270 * hSession); | |
| 62 | + | |
| 63 | +LIB3270_EXPORT int lib3270_set_trace_filename(H3270 * hSession, const char *name); | |
| 64 | +LIB3270_EXPORT const char * lib3270_get_trace_filename(const H3270 * hSession); | |
| 62 | 65 | |
| 63 | 66 | /** |
| 64 | 67 | * @brief Send logs to system log (if available) | ... | ... |