X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fbio%2Fb_dump.c;h=8397cfab6a2cfbe5582f92e3cf1297c94ff26cbb;hb=001ab3abad45752c13af5396a47551f46a6ebfdb;hp=a7cd828978505ca1607cca7f84eb28a15466276f;hpb=f598cd13a3a194bf51bba32fc45751f392609898;p=oweals%2Fopenssl.git diff --git a/crypto/bio/b_dump.c b/crypto/bio/b_dump.c index a7cd828978..8397cfab6a 100644 --- a/crypto/bio/b_dump.c +++ b/crypto/bio/b_dump.c @@ -66,63 +66,87 @@ #define TRUNCATE #define DUMP_WIDTH 16 +#define DUMP_WIDTH_LESS_INDENT(i) (DUMP_WIDTH-((i-(i>6?6:i)+3)/4)) int BIO_dump(BIO *bio, const char *s, int len) -{ - int ret=0; - char buf[160+1],tmp[20]; - int i,j,rows,trunc; - unsigned char ch; - - trunc=0; + { + return BIO_dump_indent(bio, s, len, 0); + } +int BIO_dump_indent(BIO *bio, const char *s, int len, int indent) + { + int ret=0; + char buf[288+1],tmp[20],str[128+1]; + int i,j,rows,trunc; + unsigned char ch; + int dump_width; + + trunc=0; + #ifdef TRUNCATE - for(; (len > 0) && ((s[len-1] == ' ') || (s[len-1] == '\0')); len--) - trunc++; + for(; (len > 0) && ((s[len-1] == ' ') || (s[len-1] == '\0')); len--) + trunc++; #endif - rows=(len/DUMP_WIDTH); - if ((rows*DUMP_WIDTH)=len) { - strcat(buf," "); - } else { - ch=((unsigned char)*((char *)(s)+i*DUMP_WIDTH+j)) & 0xff; - sprintf(tmp,"%02x%c",ch,j==7?'-':' '); - strcat(buf,tmp); - } - } - strcat(buf," "); - for(j=0;j=len) - break; - ch=((unsigned char)*((char *)(s)+i*DUMP_WIDTH+j)) & 0xff; + if (indent < 0) + indent = 0; + if (indent) + { + if (indent > 128) indent=128; + memset(str,' ',indent); + } + str[indent]='\0'; + + dump_width=DUMP_WIDTH_LESS_INDENT(indent); + rows=(len/dump_width); + if ((rows*dump_width)=len) + { + strcat(buf," "); + } + else + { + ch=((unsigned char)*(s+i*dump_width+j)) & 0xff; + sprintf(tmp,"%02x%c",ch,j==7?'-':' '); + strcat(buf,tmp); + } + } + strcat(buf," "); + for(j=0;j=len) + break; + ch=((unsigned char)*(s+i*dump_width+j)) & 0xff; #ifndef CHARSET_EBCDIC - sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.'); + sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.'); #else - sprintf(tmp,"%c",((ch>=os_toascii[' '])&&(ch<=os_toascii['~'])) - ? os_toebcdic[ch] - : '.'); + sprintf(tmp,"%c",((ch>=os_toascii[' '])&&(ch<=os_toascii['~'])) + ? os_toebcdic[ch] + : '.'); #endif - strcat(buf,tmp); - } - strcat(buf,"\n"); - /* if this is the last call then update the ddt_dump thing so that - * we will move the selection point in the debug window - */ - ret+=BIO_write(bio,(char *)buf,strlen(buf)); - } + strcat(buf,tmp); + } + strcat(buf,"\n"); + /* if this is the last call then update the ddt_dump thing so that + * we will move the selection point in the debug window + */ + ret+=BIO_write(bio,(char *)buf,strlen(buf)); + } #ifdef TRUNCATE - if (trunc > 0) { - sprintf(buf,"%04x - \n",len+trunc); - ret+=BIO_write(bio,(char *)buf,strlen(buf)); - } + if (trunc > 0) + { + sprintf(buf,"%s%04x - \n",str,len+trunc); + ret+=BIO_write(bio,(char *)buf,strlen(buf)); + } #endif - return(ret); -} - + return(ret); + }