%% options copyright owner = Dirk Krause copyright year = 2015-xxxx license = bsd %% module #ifndef DK4APP_H_INCLUDED #include "dk4app.h" #endif #ifndef DK4CONST_H_INCLUDED #include "dk4const.h" #endif #ifndef DK4TIME_H_INCLUDED #include "dk4time.h" #endif #ifndef DK4TIMEDK_H_INCLUDED #include "dk4timedk.h" #endif #ifndef DK4MAODD_H_INCLUDED #include "dk4maodd.h" #endif #ifndef DK4FPUT_H_INCLUDED #include "dk4fput.h" #endif #ifndef DK4MEM_H_INCLUDED #include "dk4mem.h" #endif #ifndef DK4FOP8_H_INCLUDED #include "dk4fopc8.h" #endif #ifndef DK4FOPD_H_INCLUDED #include "dk4fopd.h" #endif #ifndef DK4MAODD_H_INCLUDED #include "dk4maodd.h" #endif #ifndef DK4ENC_H_INCLUDED #include "dk4enc.h" #endif #ifndef DK4APPMKDH_H_INCLUDED #include "dk4appmkdh.h" #endif #ifndef DK4MPL_H_INCLUDED #include "dk4mpl.h" #endif #ifndef DK4FS_H_INCLUDED #include "dk4fs.h" #endif $!trace-include /** Constant char texts used by the module, not localized. */ static const dkChar * const dk4app_log_kwnl[] = { $!string-table macro=dkT # # 0 1 File opening modes # w a # # 2 Name of debug string table file # dk4debug.str # # 3 4 Indicator for missing information or deactivated option # - + # # 5 ... 13 Encoding names # ascii ansi utf-8 utf-16 utf-16-le utf-16-be c32 c32-le c32-be # # 14 15 # dk3pref.conf dk4pref.conf $!end }; /** The message texts for the base log domain, nearly always loaded. */ static const dkChar * const dk4app_def_msg_base[] = { $!string-table macro=dkT # # 0 Log level: Never reached. # NONE # # 1 Log level: Panic - Should shut down computer # Panic # # 2 Log level: Fatal error - Should abort program # Fatal # # 3 Log level: Error # Error # # 4 Log level: Warning # Warning # # 5 Log level: Information # Info # # 6 Log level: Progress message # Progress # # 7 Log level: Debug message # Debug # # 8 Log level: Ignore message, do not write text # Ignore # # 9 10 ERROR: Illegal option! # Illegal option: " "! # # 11 12 ERROR: Option requires argument! # Option " " requires argument! # # 13 14 15 ERROR: Option requires boolean argument... # Option " " requires a boolean argument!\n\tRejected text: " "! # # 16 17 18 ERROR: Option requires size argument... # Option " " requires a size argument!\n\tRejected text: " "! # # 19 20 21 ERROR: Option requires integer argument... # Option " " requires integer argument!\n\tRejected text: " "! # # 22 23 24 ERROR: Option requires unsigned integer argument... # Option " " requires unsigned integer argument!\n\tRejected text: " "! # # 25 26 27 ERROR: Option requires double argument... # Option " " requires floating point (double) argument!\n\tRejected text: " "! # # 28 ERROR: Long option requires argument # Option "-- # # 29 ERROR: Long option requires double argument # Option "-- # # 30 ERROR: Long option requires unsigned integer argument # Option "-- # # 31 ERROR: Long option requires integer argument # Option "-- # # 32 ERROR: Long option requires size specification # Option "-- # # 33 ERROR: Long option requires boolean argument # Option "-- # # 34 35 36 ERROR: Failed to save preference value # Failed to save preference value!\n\t" "=" "! # # 37 38 ERROR: Value required for preference. # Value required for command line preference " "! # # 39 40 ERROR: Option too long # Option too long!\n\t" "! # # 41 # Failed to remove file:\n\t" # # 42 ENAMETOOLONG Reason for error # "!\n\tPath name too long. # # 43 44 45 # Failed to create directory:\n\t" "!\n\tPath exists, but is not a directory! \n\tLocal network interface is down! # # 46 47 # Failed to create directory:\n\t" "!\n\tIllegal path. # # 48 Reason for error # "!\n\tFile or directory in use. # # 49 Reason for error # "!\n\tPath already exists. # # 50 Reason for error # "!\n\tPath name points outside accessible address space. # # 51 ENOENT Reason for error. # "!\n\tPath not found (one path component does not exist). # # 52 Reason for error # "!\n\tPath specifies a directory. # # 53 Reason for error # "!\n\tNo function for wide-char mkdir available. # # 54 # No wide-char function to remove files available. # # 55 EACCESS ERROR_ACCESS_DENIED # "!\n\tInsufficient permissions. # # 56 57 # "!\n\tFile system is mounted read-only. "!\n\tConflict with extended attribute. # # 58 59 # "!\n\tNot allowed for this file system type. "!\n\tI/O error on device. # # 60 # "!\n\tDisk space or quota problem. # # 61 ELOOP Too many symbolic links in path # "!\n\tToo many symbolic links in path (probably symlink loop). # # 62 63 # "!\n\tInsufficient kernel memory. "!\n\tToo many entries in parent directory. # # 64 65 # "!\n\tFile server not available. "!\n\tName too long. # # 66 67 # Failed to remove directory:\n\t" "!\n\tDirectory not empty. # # 68 69 # "!\n\tInvalid path name. "!\n\tWindows error code: # # 70 71 # (0x ). # # 72 73 # "! "!\n\tParent directory not found (device or server share)! # # 74 75 # "!\n\tBad network resource name (share name)! "!\n\tBad network resource name (server name)! # # 76 77 # \n\tNo route to network destination available! "! # # 78 EOVERFLOW # \n\tAttempt to read from outside file! # # 79 80 # "!\n\tError code: . # # 81 # Options --help, --version, and --license are mutually exclusive! # # 82 83 84 85 # Numeric overflow in size calculation! Numeric overflow in size calculation!\n\t elements of bytes. # # 86 87 88 89 # Memory allocation failed! Invalid size(s) specified. Memory allocation failed! Invalid size(s) specified.\n\tNumber of elements: , element size: . # # 90 91 92 93 # Not enough memory! Allcation failed. Not enough memory! Allcation failed.\n\tNumber of elements: , element size: . # # 94 95 # Further file removal attempts failed in:\n\t" "! # # 96 97 # Further subdirectory removal attempts failed in:\n\t" "! # # 98 99 # File or directory name too long:\n\t" "! # # 100 101 102 103 104 105 106 107 # Failed to expand file name:\n\t" "! "!\n\tNo function for directory traversal available! "!\n\tMemory allocation failed! "!\n\tFailed to open directory for traversal! "!\n\tDirectory or file name too large! "!\n\tMultiple matching files! "!\n\tNo matching file! # # 108 ERROR: Failed to open file... # Failed to open file:\n\t" # # 109 110 111 112 113 114 115 116 Error: Not a regular file # "!\n\tNot a regular file! "!\n\tPath contains symbolic links! "!\n\tPath is a symbolic link! "!\n\tSymbolic link owner is not target owner! "!\n\tSignal received! "!\n\tToo many open files in process! "!\n\tToo many open files on system! "!\n\tDevice for special file does not exist! # # 117 EOVERFLOW # "!\n\tFile size too large for off_t data type! # # 118 119 120 Read operation failed # Read operation failed! Read operation failed, error code: . # # 121 EAGAIN / EWOULDBLOCK # \n\tOperation would block! # # 122 EBADF # \n\tBad file descriptor (bug)! # # 123 EFAULT # \n\tBuffer is outside usable address space (bug)! # # 124 EINTR # \n\tSignal received! # # 125 EINVAL # \n\tFile descriptor attached to unsuitable object (bug)! # # 126 EIO # \n\tI/O error! # # 127 EISDIR # \n\tFile descriptor attachted to directory (bug)! # # 128 - 130 Error: Write operation failed # Write operation failed! Write operation failed, error code: . # # 131 ENOSPC # \n\tNo space left on device! # # 132 EFBIG # \n\tFile size would exceed limits! # # 133 EPIPE # \n\tNo reader attached to pipe or socket! # # 134 ECONNRESET # \n\tSocket not connected! # # 135 ERANGE # \n\tBuffer size outside supported range! # # 136 ENOBUFS # \n\tInsufficient system resources available! # # 137 ENXIO # \n\tNonexistent or incapable device! # # 138 EACCES # \n\tInsufficient permissions! # # 139 EBADMSG # \n\tUnexpected control part in normal-mode message! # # 140 ECONNRESET # \n\tConnection reset by peer! # # 141 ETIMEDOUT # \n\tTimed out! # # 142 ENOMEM # \n\tInsufficient memory available! # # 143 ESPIPE # \n\tFile descriptor is socket or FIFO! # # 144 Failed to open directory! # Failed to open directory:\n\t" # # 145 146 147 148 DK4_E_NOT_SUPPORTED # "!\n\tNo function found for directory traversal! "!\n\tNumeric overflow in size calculation! "!\n\tPath not found! "!\n\tDirectory does not exist! # # 149 Failed to obtain information about file or directory # Failed to obtain information about file/directory:\n\t" # # 150 ENOTDIR # "!\n\tOne path component is not a directory. # # 151 ERROR_SHARING_VIOLATION # "!\n\tCurrently used by another process. # # 152 153 ERROR: Not a directory # Not a directory:\n\t" "! # # 154 ERROR text ... in ... # " in " # # 155 156 157 158 # Failed to change file buffering! Failed to change buffering for file\n" "! Neither setvbuf() nor setbuffer() function available! # # 159 # Syntax error, expected line:\n"name = width height [border-left border-right border-top border-bottom]" # # 160 161 162 # Preference value found: " "=" ". # # 163 164 165 # Preference value too long: " "=" "! # # 166 167 # Preference value not found: " "! $!end }; static const dkChar * const dk4app_def_msg_debug[] = { $!string-table macro=dkT # # 0 ... 20 Log texts to show at startup # Host name: User name: Home directory: Language: Region: Encoding: Encoding expected on standard input: Encoding expected on files: Program name: Program group: Directory etc: Directory bin: Directory share: Directory lib: Directory var: Directory tmp: Logging enabled: Log file: Log level to log on stderr: Log level to log to file: Log level to keep log file: # # 21 22 23 Debug messages for data file search. # Data file search for " " failed. " succeeded.\n\t # # 24 Debug messages for configuration file search. # Configuration file search for " # # 25 26 27 Delete directory or file. # Delete directory: Delete file: Delete file or directory: # # 28 29 Preference files: , empty string # Preference files: UNUSED # # 30 31 # + - # # 32 33 34 35 # Search for data file " Search for configuration file " " (compression allowed): " (no compression allowed): # # 36 Collecting paper size data # Collecting paper size data. # # 37 38 39 Compression types allowed # " (gzip compression allowed): " (bzip2 compression allowed): " (gzip/bzip2 compression allowed): # # 40 41 # String copy allocated: " ". # # 42 43 # Successfully converted to integer. Not an integer! # # 44 45 # Successfully converted to unsigned integer. Not an unsigned integer! # # 46 47 # Successfully converted to boolean. Not a boolean! # # 48 49 # Successfully converted to size specification. Not a size specification! $!end }; /** Ensure the messages texts for the base log domain are loaded. @param app Application structure. @param logdom Log text domain. */ static void dk4app_log_load_base_texts(dk4_app_t *app) { $? "+ dk4app_log_load_base_texts" if (NULL != app) { $? ". app" if ((NULL == app->msg_base) || (0 == app->sz_msg_base)) { $? ". read string table" app->sz_msg_base = dk4app_string_table_size(dk4app_def_msg_base); app->msg_base = dk4app_string_table( app, dkT("dk4base.str"), dk4app_def_msg_base ); } else { $? ". already available" } } else { $? "! app" } $? "- dk4app_log_load_base_texts" } /** Check whether there is at least one non-NULL pointer in array. CRT on Windows: Not used. @param msg Array to check. @param sz Size of array. @return 1 if any valid pointer was found, 0 otherwise. */ static int dk4app_log_any_non_null(const dkChar * const *msg, size_t sz) { size_t i; int back = 0; for (i = 0; ((i < sz) && (0 == back)); i++) { if (NULL != msg[i]) { back = 1; } } return back; } int dk4app_log_do(dk4_app_t *app, int ll) { int back = 0; if (NULL != app) { #if (!(DK4_ON_WINDOWS && DK4_WIN_DENY_CRT)) if (0 != app->log_enabled) { if (app->ll_stderr >= ll) { back = 1; } if (app->ll_file >= ll) { back = 1; } } #endif } return back; } /** Log multi part message to one file. CRT on Windows: Required. @param app Application structure, may be NULL. @param priority Log priority. @param msg Pointer to message parts array. @param sz Number of message parts. @param outfile Output file @param showtime Flag: Show timestamp. @param timer Timestamp of previous log message if any. @param havetime Flag: Timer already contains a value. */ static void dk4app_log_msg_to_file( dk4_app_t *app, int priority, const dkChar * const *msg, size_t sz, FILE *outfile, int showtime, dk4_time_t *timer, int *havetime ) { #if (!(DK4_ON_WINDOWS && DK4_WIN_DENY_CRT)) dkChar lnb[64]; dkChar buf[64]; size_t i; dk4_time_t ct; int res; dk4time_get(&ct); /* Print timestamp */ if ((0 != showtime) && ((0 == *havetime) || (ct != *timer))) { *havetime = 1; *timer = ct; if (0 != dk4time_as_text(buf, DK4_SIZEOF(buf,dkChar), &ct, NULL)) { dk4fputs(dkT("# "), outfile, NULL); dk4fputs(buf, outfile, NULL); dk4fputc(dkT('\n'), outfile, NULL); } } /* Print error position */ if (NULL != app->source_file_name) { dk4fputs(app->source_file_name, outfile, NULL); dk4fputc(dkT(':'), outfile, NULL); if ((dk4_um_t)0UL != app->source_file_line) { res = dk4ma_write_decimal_unsigned( lnb, DK4_SIZEOF(lnb,dkChar), app->source_file_line, 0, NULL ); if (0 != res) { dk4fputs(lnb, outfile, NULL); dk4fputc(dkT(':'), outfile, NULL); } } dk4fputc(dkT(' '), outfile, NULL); } /* Print message */ switch (priority) { case DK4_LL_PANIC: case DK4_LL_FATAL: case DK4_LL_ERROR: case DK4_LL_WARNING: { dk4fputs((app->msg_base)[priority], outfile, NULL); dk4fputs(dkT(": "), outfile, NULL); } break; } for (i = 0; i < sz; i++) { dk4fputs(msg[i], outfile, NULL); } dk4fputc(dkT('\n'), outfile, NULL); fflush(outfile); #endif } void dk4app_log_msg( dk4_app_t *app, int priority, const dkChar * const *msg, size_t sz ) { FILE *fipo; if (NULL != app) { if (0 != dk4app_log_do(app, priority)) { dk4app_log_load_base_texts(app); if (0 != dk4app_log_any_non_null(msg, sz)) { #if (!(DK4_ON_WINDOWS && DK4_WIN_DENY_CRT)) if (app->ll_stderr >= priority) { if (0 == app->have_stderr_init) { dk4fput_initialize_stderr(); app->have_stderr_init = 1; } dk4app_log_msg_to_file( app, priority, msg, sz, stderr, app->log_stderr_time, &(app->timer_stderr), &(app->have_stderr_time) ); } if (app->ll_file >= priority) { if (NULL != app->log_file_name) { #if VERSION_BEFORE_20160127 #else if (0 == app->have_file_opened) { (void)dk4app_mkdir_hierarchy(app->log_file_name, 0, NULL); } #endif fipo = dk4fopen( app->log_file_name, dk4app_log_kwnl[(0 != app->have_file_opened) ? 1 : 0], (DK4_FOPEN_SC_WR_SYMLINK_OWNER | DK4_FOPEN_SC_IS_REGULAR), NULL ); app->have_file_opened = 1; if (NULL != fipo) { dk4app_log_msg_to_file( app, priority, msg, sz, fipo, app->log_stderr_time, &(app->timer_file), &(app->have_file_time) ); fclose(fipo); } } } if (priority < app->ll_found) { app->ll_found = priority; } #endif } } } } void dk4app_log_1( dk4_app_t *app, const dkChar * const *msg, size_t sz_msg, int priority, size_t msgind ) { const dkChar *msgtext; if (NULL != app) { if (0 != dk4app_log_do(app, priority)) { dk4app_log_load_base_texts(app); if ((NULL != msg) && (0 < sz_msg) && (msgind < sz_msg)) { msgtext = msg[msgind]; dk4app_log_msg(app, priority, &msgtext, 1); } } } } void dk4app_log_2( dk4_app_t *app, const dkChar * const *msg, size_t sz_msg, int priority, size_t i1, const dkChar *t1 ) { const dkChar *msgtext[3]; if (NULL != app) { if (0 != dk4app_log_do(app, priority)) { dk4app_log_load_base_texts(app); if ((NULL != msg) && (0 < sz_msg) && (i1 < sz_msg)) { msgtext[0] = msg[i1]; msgtext[1] = t1; dk4app_log_msg(app, priority, msgtext, 2); } } } } void dk4app_log_3( dk4_app_t *app, const dkChar * const *msg, size_t sz_msg, int priority, size_t i1, size_t i2, const dkChar *t1 ) { const dkChar *msgtext[3]; if (NULL != app) { if (0 != dk4app_log_do(app, priority)) { dk4app_log_load_base_texts(app); if ((NULL != msg) && (0 < sz_msg) && (i1 < sz_msg) && (i2 < sz_msg)) { msgtext[0] = msg[i1]; msgtext[1] = t1; msgtext[2] = msg[i2]; dk4app_log_msg(app, priority, msgtext, 3); } } } } void dk4app_log_5( dk4_app_t *app, const dkChar * const *msg, size_t sz_msg, int priority, size_t i1, size_t i2, size_t i3, const dkChar *t1, const dkChar *t2 ) { const dkChar *msgtext[5]; if (NULL != app) { if (0 != dk4app_log_do(app, priority)) { dk4app_log_load_base_texts(app); if ((NULL != msg) && (0 < sz_msg) && (i1 < sz_msg) && (i2 < sz_msg)) { msgtext[0] = msg[i1]; msgtext[1] = t1; msgtext[2] = msg[i2]; msgtext[3] = t2; msgtext[4] = msg[i3]; dk4app_log_msg(app, priority, msgtext, 5); } } } } void dk4app_log_7( dk4_app_t *app, const dkChar * const *msg, size_t sz_msg, int priority, size_t i1, size_t i2, size_t i3, size_t i4, const dkChar *t1, const dkChar *t2, const dkChar *t3 ) { const dkChar *msgtext[7]; if (NULL != app) { if (0 != dk4app_log_do(app, priority)) { dk4app_log_load_base_texts(app); if ( (NULL != msg) && (0 < sz_msg) && (i1 < sz_msg) && (i2 < sz_msg) && (i3 < sz_msg) ) { msgtext[0] = msg[i1]; msgtext[1] = t1; msgtext[2] = msg[i2]; msgtext[3] = t2; msgtext[4] = msg[i3]; msgtext[5] = t3; msgtext[6] = msg[i4]; dk4app_log_msg(app, priority, msgtext, 7); } } } } void dk4app_log_base1( dk4_app_t *app, int priority, size_t msgind ) { if (NULL != app) { if (0 != dk4app_log_do(app, priority)) { dk4app_log_load_base_texts(app); dk4app_log_1(app, app->msg_base, app->sz_msg_base, priority, msgind); } } } void dk4app_log_base2( dk4_app_t *app, int priority, size_t i1, const dkChar *t1 ) { if (NULL != app) { if (0 != dk4app_log_do(app, priority)) { dk4app_log_load_base_texts(app); dk4app_log_2(app,app->msg_base,app->sz_msg_base,priority,i1,t1); } } } void dk4app_log_base2c( dk4_app_t *app, int priority, size_t i1, size_t i2 ) { const dkChar *msgptr[2]; if (NULL != app) { if (0 != dk4app_log_do(app, priority)) { if ((app->sz_msg_base > i1) && (app->sz_msg_base > i2)) { dk4app_log_load_base_texts(app); msgptr[0] = (app->msg_base)[i1]; msgptr[1] = (app->msg_base)[i2]; dk4app_log_msg(app, priority, msgptr, 2); } } } } void dk4app_log_base3( dk4_app_t *app, int priority, size_t i1, size_t i2, const dkChar *t1 ) { if (NULL != app) { if (0 != dk4app_log_do(app, priority)) { dk4app_log_load_base_texts(app); dk4app_log_3(app,app->msg_base,app->sz_msg_base,priority,i1,i2,t1); } } } void dk4app_log_base5( dk4_app_t *app, int priority, size_t i1, size_t i2, size_t i3, const dkChar *t1, const dkChar *t2 ) { if (NULL != app) { if (0 != dk4app_log_do(app, priority)) { dk4app_log_load_base_texts(app); dk4app_log_5(app,app->msg_base,app->sz_msg_base,priority,i1,i2,i3,t1,t2); } } } void dk4app_log_base7( dk4_app_t *app, int priority, size_t i1, size_t i2, size_t i3, size_t i4, const dkChar *t1, const dkChar *t2, const dkChar *t3 ) { if (NULL != app) { if (0 != dk4app_log_do(app, priority)) { dk4app_log_load_base_texts(app); dk4app_log_7( app,app->msg_base,app->sz_msg_base,priority,i1,i2,i3,i4,t1,t2,t3 ); } } } void dk4app_log_with_errno( dk4_app_t *app, int priority, size_t i1, size_t i2, size_t i3, size_t i4, size_t i5, const dkChar *t1, int errn ) { dkChar enb[64]; int res; if (NULL != app) { res = dk4ma_write_decimal_signed( enb, DK4_SIZEOF(enb,dkChar), (dk4_im_t)errn, 0, NULL ); if (0 != res) { dk4app_log_base5(app, priority, i1, i2, i3, t1, enb); } else { dk4app_log_base3(app, priority, i4, i5, t1); } } } const dkChar * dk4app_get_log_source_file(dk4_app_t *app) { const dkChar *back = NULL; if (NULL != app) { back = app->source_file_name; } return back; } dk4_um_t dk4app_get_log_source_line(dk4_app_t *app) { dk4_um_t back = (dk4_um_t)0UL; if (NULL != app) { back = app->source_file_line; } return back; } void dk4app_set_log_source_file(dk4_app_t *app, const dkChar *fn) { if (NULL != app) { app->source_file_name = fn; } } void dk4app_set_log_source_line(dk4_app_t *app, dk4_um_t lineno) { if (NULL != app) { app->source_file_line = lineno; } } const dkChar * const * dk4app_log_debug_texts(dk4_app_t *app, size_t *szptr) { const dkChar * const *back = NULL; $? "+ dk4app_log_debug_texts" if (NULL != app) { $? ". app" dk4app_log_load_base_texts(app); if ((NULL != app->msg_debug) && (0 < app->sz_msg_debug)) { back = app->msg_debug; $? ". already loaded" } else { $? ". must load" app->msg_debug = dk4app_string_table( app, dk4app_log_kwnl[2], dk4app_def_msg_debug ); app->sz_msg_debug = dk4app_string_table_size(app->msg_debug); back = app->msg_debug; } } else { $? "! app" back = dk4app_def_msg_debug; } if (NULL != szptr) { *szptr = dk4app_string_table_size(dk4app_def_msg_debug); } $? "- dk4app_log_debug_texts" return back; } static void dk4app_log_two_strings_at_startup( dk4_app_t *app, const dkChar *title, const dkChar *value ) { const dkChar *msg[3]; msg[0] = title; msg[1] = value; if (NULL == value) { msg[1] = dk4app_log_kwnl[3]; } msg[2] = NULL; dk4app_log_msg(app, DK4_LL_DEBUG, msg, 2); } static void dk4app_log_startup_log_level( dk4_app_t *app, const dkChar *title, int ll ) { const dkChar *llstr = NULL; if ((DK4_LL_NONE <= ll) && (DK4_LL_IGNORE >= ll)) { llstr = (app->msg_base)[(size_t)ll]; } dk4app_log_two_strings_at_startup(app, title, llstr); } static void dk4app_log_startup_encoding( dk4_app_t *app, const dkChar *title, int enc, int isfileenc ) { const dkChar *encstr = NULL; if (0 != isfileenc) { switch (enc) { case DK4_FILE_ENCODING_ASCII : { encstr = dk4app_log_kwnl[5]; } break; case DK4_FILE_ENCODING_ANSI : { encstr = dk4app_log_kwnl[6]; } break; case DK4_FILE_ENCODING_UTF8 : { encstr = dk4app_log_kwnl[7]; } break; case DK4_FILE_ENCODING_UTF16_LE : { encstr = dk4app_log_kwnl[9]; } break; case DK4_FILE_ENCODING_UTF16_BE : { encstr = dk4app_log_kwnl[10]; } break; case DK4_FILE_ENCODING_32_LE : { encstr = dk4app_log_kwnl[12]; } break; case DK4_FILE_ENCODING_32_BE : { encstr = dk4app_log_kwnl[13]; } break; } } else { switch (enc) { case DK4_ENCODING_ASCII : { encstr = dk4app_log_kwnl[5]; } break; case DK4_ENCODING_ANSI : { encstr = dk4app_log_kwnl[6]; } break; case DK4_ENCODING_UTF8 : { encstr = dk4app_log_kwnl[7]; } break; case DK4_ENCODING_UTF16 : { encstr = dk4app_log_kwnl[8]; } break; case DK4_ENCODING_32 : { encstr = dk4app_log_kwnl[11]; } break; } } dk4app_log_two_strings_at_startup(app, title, encstr); } void dk4app_log_startup_debug(dk4_app_t *app) { dkChar fnb[DK4_MAX_PATH]; dk4_er_t er; const dkChar *msgtxt[3]; const dkChar * const *debmsg = NULL; size_t szdebmsg = 0; int res = 0; int pn = 0; $? "+ dk4app_log_startup_debug" if (NULL != app) { if (0 != dk4app_log_do(app, DK4_LL_DEBUG)) { /* Obtain localized texts */ dk4app_log_load_base_texts(app); debmsg = dk4app_log_debug_texts(app, &szdebmsg); /* 0 Host name */ dk4app_log_two_strings_at_startup(app, debmsg[0], app->host_name); /* 1 User name */ dk4app_log_two_strings_at_startup(app, debmsg[1], app->user_name); /* 2 Home dir */ dk4app_log_two_strings_at_startup(app, debmsg[2], app->user_home); /* 3 Language */ dk4app_log_two_strings_at_startup(app, debmsg[3], app->language); /* 4 Region */ dk4app_log_two_strings_at_startup(app, debmsg[4], app->region); /* 5 Encoding */ dk4app_log_startup_encoding(app, debmsg[5], app->encoding, 0); /* 6 Encoding stdin */ dk4app_log_startup_encoding(app, debmsg[6], app->enc_in_std, 1); /* 7 Encoding files */ dk4app_log_startup_encoding(app, debmsg[7], app->enc_in_file, 1); /* 8 Program name */ dk4app_log_two_strings_at_startup(app, debmsg[8], app->prog_name); /* 9 Program group */ dk4app_log_two_strings_at_startup(app, debmsg[9], app->group_name); /* 10 etc */ dk4app_log_two_strings_at_startup(app, debmsg[10], app->dir_etc); /* 11 bin */ dk4app_log_two_strings_at_startup(app, debmsg[11], app->dir_bin); /* 12 share */ dk4app_log_two_strings_at_startup(app, debmsg[12], app->dir_share); /* 13 lib */ dk4app_log_two_strings_at_startup(app, debmsg[13], app->dir_lib); /* 14 var */ dk4app_log_two_strings_at_startup(app, debmsg[14], app->dir_var); /* 15 tmp */ dk4app_log_two_strings_at_startup(app, debmsg[15], app->dir_tmp); /* 17 Log file */ dk4app_log_two_strings_at_startup(app, debmsg[17], app->log_file_name); /* 16 Logging enabled */ dk4app_log_two_strings_at_startup( app, debmsg[16], dk4app_log_kwnl[(0 != app->log_enabled) ? 4 : 3] ); /* 18 Log level stderr */ dk4app_log_startup_log_level(app, debmsg[18], app->ll_stderr); /* 19 Log level file */ dk4app_log_startup_log_level(app, debmsg[19], app->ll_file); /* 20 Log level keep */ dk4app_log_startup_log_level(app, debmsg[20], app->ll_file_keep); /* Preferences files */ dk4app_log_1(app, debmsg, szdebmsg, DK4_LL_DEBUG, 28); for (pn = 0; (pn <= DK4_FS_CONF_MAX); pn++) { #if DK4_HAVE_COMPATDKTOOLS3 dk4error_init(&er); res = dk4fs_config_construct_compat_one( fnb, DK4_SIZEOF(fnb,dkChar), dk4app_log_kwnl[14], app->dir_share, app->dir_etc, app->user_home, app->prog_name, app->group_name, pn, 1, &er ); if (0 != res) { res = dk4fs_attempt_file_name(fnb, DK4_SIZEOF(fnb,dkChar), 1, NULL); if (0 != res) { msgtxt[0] = debmsg[30]; msgtxt[1] = fnb; dk4app_log_msg(app, DK4_LL_DEBUG, msgtxt, 2); } else { msgtxt[0] = debmsg[31]; msgtxt[1] = fnb; dk4app_log_msg(app, DK4_LL_DEBUG, msgtxt, 2); } } #endif dk4error_init(&er); res = dk4fs_config_construct_compat_one( fnb, DK4_SIZEOF(fnb,dkChar), dk4app_log_kwnl[15], app->dir_share, app->dir_etc, app->user_home, app->prog_name, app->group_name, pn, 0, &er ); if (0 != res) { res = dk4fs_attempt_file_name(fnb, DK4_SIZEOF(fnb,dkChar), 1, NULL); if (0 != res) { msgtxt[0] = debmsg[30]; msgtxt[1] = fnb; dk4app_log_msg(app, DK4_LL_DEBUG, msgtxt, 2); } else { msgtxt[0] = debmsg[31]; msgtxt[1] = fnb; dk4app_log_msg(app, DK4_LL_DEBUG, msgtxt, 2); } } } #if VERSION_BEFORE_2017_03_13 dk4app_log_1(app, debmsg, szdebmsg, DK4_LL_DEBUG, 29); #endif } } $? "- dk4app_log_startup_debug" }