Use consistent indentation,

This commit is contained in:
Bodo Möller 2000-09-04 15:38:02 +00:00
parent bbb8de0966
commit 397bd0938a

View File

@ -74,7 +74,7 @@ int BIO_dump(BIO *bio, const char *s, int len)
} }
int BIO_dump_indent(BIO *bio, const char *s, int len, int indent) int BIO_dump_indent(BIO *bio, const char *s, int len, int indent)
{ {
int ret=0; int ret=0;
char buf[288+1],tmp[20],str[128+1]; char buf[288+1],tmp[20],str[128+1];
int i,j,rows,trunc; int i,j,rows,trunc;
@ -90,7 +90,8 @@ int BIO_dump_indent(BIO *bio, const char *s, int len, int indent)
if (indent < 0) if (indent < 0)
indent = 0; indent = 0;
if (indent) { if (indent)
{
if (indent > 128) indent=128; if (indent > 128) indent=128;
memset(str,' ',indent); memset(str,' ',indent);
} }
@ -100,22 +101,28 @@ int BIO_dump_indent(BIO *bio, const char *s, int len, int indent)
rows=(len/dump_width); rows=(len/dump_width);
if ((rows*dump_width)<len) if ((rows*dump_width)<len)
rows++; rows++;
for(i=0;i<rows;i++) { for(i=0;i<rows;i++)
{
buf[0]='\0'; /* start with empty string */ buf[0]='\0'; /* start with empty string */
strcpy(buf,str); strcpy(buf,str);
sprintf(tmp,"%04x - ",i*dump_width); sprintf(tmp,"%04x - ",i*dump_width);
strcat(buf,tmp); strcat(buf,tmp);
for(j=0;j<dump_width;j++) { for(j=0;j<dump_width;j++)
if (((i*dump_width)+j)>=len) { {
if (((i*dump_width)+j)>=len)
{
strcat(buf," "); strcat(buf," ");
} else { }
else
{
ch=((unsigned char)*(s+i*dump_width+j)) & 0xff; ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
sprintf(tmp,"%02x%c",ch,j==7?'-':' '); sprintf(tmp,"%02x%c",ch,j==7?'-':' ');
strcat(buf,tmp); strcat(buf,tmp);
} }
} }
strcat(buf," "); strcat(buf," ");
for(j=0;j<dump_width;j++) { for(j=0;j<dump_width;j++)
{
if (((i*dump_width)+j)>=len) if (((i*dump_width)+j)>=len)
break; break;
ch=((unsigned char)*(s+i*dump_width+j)) & 0xff; ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
@ -135,11 +142,11 @@ int BIO_dump_indent(BIO *bio, const char *s, int len, int indent)
ret+=BIO_write(bio,(char *)buf,strlen(buf)); ret+=BIO_write(bio,(char *)buf,strlen(buf));
} }
#ifdef TRUNCATE #ifdef TRUNCATE
if (trunc > 0) { if (trunc > 0)
{
sprintf(buf,"%s%04x - <SPACES/NULS>\n",str,len+trunc); sprintf(buf,"%s%04x - <SPACES/NULS>\n",str,len+trunc);
ret+=BIO_write(bio,(char *)buf,strlen(buf)); ret+=BIO_write(bio,(char *)buf,strlen(buf));
} }
#endif #endif
return(ret); return(ret);
} }