X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fbio%2Fb_dump.c;h=7cbe4f22b51e55ec51748455c41d2d50095ae3ab;hb=e6629837a9794e25570f4fa3f2d90b51e00762e1;hp=287aff2a5e6710b703d5306477455e3a5c3385a3;hpb=eda1f21f1af8b6f77327e7b37573af9c1ba73726;p=oweals%2Fopenssl.git diff --git a/crypto/bio/b_dump.c b/crypto/bio/b_dump.c index 287aff2a5e..7cbe4f22b5 100644 --- a/crypto/bio/b_dump.c +++ b/crypto/bio/b_dump.c @@ -1,5 +1,5 @@ /* crypto/bio/b_dump.c */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written @@ -62,20 +62,24 @@ #include #include "cryptlib.h" -#include "bio.h" +#include #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,s,len) -BIO *bio; -char *s; -int len; +int BIO_dump(BIO *bio, const char *s, int len) + { + 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[160+1],tmp[20]; + char buf[288+1],tmp[20],str[128+1]; int i,j,rows,trunc; unsigned char ch; + int dump_width; trunc=0; @@ -84,28 +88,44 @@ int len; trunc++; #endif - rows=(len/DUMP_WIDTH); - if ((rows*DUMP_WIDTH) 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) { + strcpy(buf,str); + sprintf(tmp,"%04x - ",i*dump_width); + strcat(buf,tmp); + for(j=0;j=len) { strcat(buf," "); } else { - ch=((unsigned char)*((char *)(s)+i*DUMP_WIDTH+j)) & 0xff; + 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) + for(j=0;j=len) break; - ch=((unsigned char)*((char *)(s)+i*DUMP_WIDTH+j)) & 0xff; + ch=((unsigned char)*(s+i*dump_width+j)) & 0xff; +#ifndef CHARSET_EBCDIC sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.'); +#else + sprintf(tmp,"%c",((ch>=os_toascii[' '])&&(ch<=os_toascii['~'])) + ? os_toebcdic[ch] + : '.'); +#endif strcat(buf,tmp); } strcat(buf,"\n"); @@ -116,7 +136,7 @@ int len; } #ifdef TRUNCATE if (trunc > 0) { - sprintf(buf,"%04x - \n",len+trunc); + sprintf(buf,"%s%04x - \n",str,len+trunc); ret+=BIO_write(bio,(char *)buf,strlen(buf)); } #endif