diff options
| author | Wiimm <wiimm@wiimm.de> | 2022-07-09 11:48:24 +0200 |
|---|---|---|
| committer | Wiimm <wiimm@wiimm.de> | 2022-07-09 11:48:24 +0200 |
| commit | 06ff18cd020779c226f7c25d22016e06b898f303 (patch) | |
| tree | b5c12ca4c6b9b0c86e63d2b6a965b8bd74dd0d86 /project/dclib/dclib-debug.c | |
| parent | f30e94a61fdc9fb13fd1fbd8b75502fedf5a2f71 (diff) | |
SZS v2.28a.beta
Diffstat (limited to '')
| -rw-r--r-- | project/dclib/dclib-debug.c | 225 |
1 files changed, 186 insertions, 39 deletions
diff --git a/project/dclib/dclib-debug.c b/project/dclib/dclib-debug.c index 6e23f6e..ed3a2d1 100644 --- a/project/dclib/dclib-debug.c +++ b/project/dclib/dclib-debug.c @@ -378,7 +378,11 @@ void ListErrorCodes /////////////// error handling /////////////// /////////////////////////////////////////////////////////////////////////////// -ProgInfo_t ProgInfo = {0}; +#ifdef EXTENDED_ERRORS + ProgInfo_t ProgInfo = { .error_level = ERRLEV_EXTENDED }; +#else + ProgInfo_t ProgInfo = { .error_level = ERRLEV_MINIMAL }; +#endif /////////////////////////////////////////////////////////////////////////////// @@ -409,6 +413,15 @@ enumError PrintErrorFile ( ccp func, ccp file, uint line, struct File_t *F, enumError PrintErrorArg ( ccp func, ccp file, unsigned int line, int syserr, enumError err_code, ccp format, va_list arg ) { + if ( err_code > ERR_OK ) + { + ProgInfo.error_count++; + + ProgInfo.last_error = err_code; + if ( ProgInfo.max_error < err_code ) + ProgInfo.max_error = err_code; + } + fflush(stdout); if (!stdwrn) { @@ -457,23 +470,22 @@ enumError PrintErrorArg ( ccp func, ccp file, unsigned int line, fflush(TRACE_FILE); #endif - #if defined(EXTENDED_ERRORS) - if ( err_code > ERR_WARNING ) - #else - if ( err_code >= ERR_NOT_IMPLEMENTED ) - #endif + ccp coln, col1, col0; + if (IsFileColorized(stdwrn)) + { + coln = GetTextMode(1,TTM_COL_INFO); + col1 = GetTextMode(1, err_code > ERR_WARNING ? TTM_COL_WARN : TTM_COL_HINT ); + col0 = TermTextModeReset; + } + else + coln = col1 = col0 = EmptyString; + + + if ( err_code >= ERR_NOT_IMPLEMENTED + || ProgInfo.error_level >= ERRLEV_HEADING && err_code > ERR_WARNING ) { - ccp coln = EmptyString; - ccp col1 = EmptyString; - ccp col0 = EmptyString; - if (IsFileColorized(stdwrn)) - { - coln = GetTextMode(1,TTM_COL_INFO); - col1 = GetTextMode(1, err_code > ERR_WARNING ? TTM_COL_WARN : TTM_COL_HINT ); - col0 = TermTextModeReset; - } - if ( stdwrn == stderr ) + if ( err_code >= ERR_NOT_IMPLEMENTED || ProgInfo.error_level >= ERRLEV_EXTENDED ) { if ( err_code > ERR_WARNING ) fprintf(stdwrn,"%s%s%s:%s ERROR #%d [%s] in %s() @ %s#%d%s\n", @@ -494,22 +506,23 @@ enumError PrintErrorArg ( ccp func, ccp file, unsigned int line, prefix, coln, ProgInfo.progname, col1, col0 ); } - #if defined(EXTENDED_ERRORS) && EXTENDED_ERRORS > 1 - #ifdef SVN_NEXT - fprintf(stdwrn,"%s -> %s/%s?annotate=%d#l%d\n", - prefix, URI_VIEWVC, file, SVN_NEXT, line ); - #elif defined(REVISION_NEXT) - fprintf(stdwrn,"%s -> %s/%s?annotate=%d#l%d\n", - prefix, URI_VIEWVC, file, REVISION_NEXT, line ); - #endif - #endif + if ( ProgInfo.error_level >= ERRLEV_ANNOTATE ) + { + #ifdef SVN_NEXT + fprintf(stdwrn,"%s -> %s/%s?annotate=%d#l%d\n", + prefix, URI_VIEWVC, file, SVN_NEXT, line ); + #elif defined(REVISION_NEXT) + fprintf(stdwrn,"%s -> %s/%s?annotate=%d#l%d\n", + prefix, URI_VIEWVC, file, REVISION_NEXT, line ); + #endif + } fputs(prefix,stdwrn); PutLines(stdwrn,plen,fw,0,prefix,msg,0); } else { - fprintf(stdwrn,"%s%s:",prefix,ProgInfo.progname); + fprintf(stdwrn,"%s%s%s:%s",prefix,coln,ProgInfo.progname,col0); PutLines(stdwrn,plen,fw,strlen(ProgInfo.progname)+1,prefix,msg,0); } @@ -521,18 +534,8 @@ enumError PrintErrorArg ( ccp func, ccp file, unsigned int line, } fflush(stdwrn); - if ( err_code > ERR_OK ) - { - ProgInfo.error_count++; - - ProgInfo.last_error = err_code; - if ( ProgInfo.max_error < err_code ) - ProgInfo.max_error = err_code; - - if ( err_code > ERR_NOT_IMPLEMENTED ) - exit(err_code); - } - + if ( err_code > ERR_NOT_IMPLEMENTED ) + exit(err_code); return err_code; } @@ -625,8 +628,152 @@ uint HexDump ( FILE * f, int indent, u64 addr, int addr_fw, int row_len, return stat < 0 ? 0 : stat; } +/////////////////////////////////////////////////////////////////////////////// + +uint HexDump16BE2 ( FILE * f, int indent, u64 addr, + const void * data, size_t count ) +{ + // return the number of printed lines + return HexDumpBE2(f,indent,addr,4,16,data,count); +} + +//----------------------------------------------------------------------------- + +uint HexDump20BE2 ( FILE * f, int indent, u64 addr, + const void * data, size_t count ) +{ + // return the number of printed lines + return HexDumpBE2(f,indent,addr,4,20,data,count); +} + +//----------------------------------------------------------------------------- + +uint HexDumpBE2 ( FILE * f, int indent, u64 addr, int addr_fw, int row_len, + const void * p_data, size_t count ) +{ + // return the number of printed lines + if ( !f || !p_data || !count ) + return 0; + + XDump_t xd; + InitializeXDumpEx(&xd,f,indent,addr,addr_fw,row_len); + xd.format = XDUMPF_INT_2; + xd.endian = DC_BIG_ENDIAN; + + const int stat = XDump(&xd,p_data,count,true); + return stat < 0 ? 0 : stat; +} + +/////////////////////////////////////////////////////////////////////////////// + +uint HexDump16LE2 ( FILE * f, int indent, u64 addr, + const void * data, size_t count ) +{ + // return the number of printed lines + return HexDumpLE2(f,indent,addr,4,16,data,count); +} + +//----------------------------------------------------------------------------- + +uint HexDump20LE2 ( FILE * f, int indent, u64 addr, + const void * data, size_t count ) +{ + // return the number of printed lines + return HexDumpLE2(f,indent,addr,4,20,data,count); +} + +//----------------------------------------------------------------------------- + +uint HexDumpLE2 ( FILE * f, int indent, u64 addr, int addr_fw, int row_len, + const void * p_data, size_t count ) +{ + // return the number of printed lines + if ( !f || !p_data || !count ) + return 0; + + XDump_t xd; + InitializeXDumpEx(&xd,f,indent,addr,addr_fw,row_len); + xd.format = XDUMPF_INT_2; + xd.endian = DC_LITTLE_ENDIAN; + + const int stat = XDump(&xd,p_data,count,true); + return stat < 0 ? 0 : stat; +} + +/////////////////////////////////////////////////////////////////////////////// + +uint HexDump16BE4 ( FILE * f, int indent, u64 addr, + const void * data, size_t count ) +{ + // return the number of printed lines + return HexDumpBE4(f,indent,addr,4,16,data,count); +} + +//----------------------------------------------------------------------------- + +uint HexDump20BE4 ( FILE * f, int indent, u64 addr, + const void * data, size_t count ) +{ + // return the number of printed lines + return HexDumpBE4(f,indent,addr,4,20,data,count); +} + //----------------------------------------------------------------------------- +uint HexDumpBE4 ( FILE * f, int indent, u64 addr, int addr_fw, int row_len, + const void * p_data, size_t count ) +{ + // return the number of printed lines + if ( !f || !p_data || !count ) + return 0; + + XDump_t xd; + InitializeXDumpEx(&xd,f,indent,addr,addr_fw,row_len); + xd.format = XDUMPF_INT_4; + xd.endian = DC_BIG_ENDIAN; + + const int stat = XDump(&xd,p_data,count,true); + return stat < 0 ? 0 : stat; +} + +/////////////////////////////////////////////////////////////////////////////// + +uint HexDump16LE4 ( FILE * f, int indent, u64 addr, + const void * data, size_t count ) +{ + // return the number of printed lines + return HexDumpLE4(f,indent,addr,4,16,data,count); +} + +//----------------------------------------------------------------------------- + +uint HexDump20LE4 ( FILE * f, int indent, u64 addr, + const void * data, size_t count ) +{ + // return the number of printed lines + return HexDumpLE4(f,indent,addr,4,20,data,count); +} + +//----------------------------------------------------------------------------- + +uint HexDumpLE4 ( FILE * f, int indent, u64 addr, int addr_fw, int row_len, + const void * p_data, size_t count ) +{ + // return the number of printed lines + if ( !f || !p_data || !count ) + return 0; + + XDump_t xd; + InitializeXDumpEx(&xd,f,indent,addr,addr_fw,row_len); + xd.format = XDUMPF_INT_4; + xd.endian = DC_LITTLE_ENDIAN; + + const int stat = XDump(&xd,p_data,count,true); + return stat < 0 ? 0 : stat; +} + +/////////////////////////////////////////////////////////////////////////////// + uint HexDump016 ( FILE * f, int indent, u64 addr, const void * data, size_t count ) { @@ -650,7 +797,7 @@ uint HexDump0 ( FILE * f, int indent, u64 addr, int addr_fw, int row_len, return stat < 0 ? 0 : stat; } -//----------------------------------------------------------------------------- +/////////////////////////////////////////////////////////////////////////////// void HexDiff16 ( FILE * f, int indent, u64 addr, const void * data1, size_t count1, |
