forked from Imagelibrary/rtems
* libmisc/capture/capture-cli.c, libmisc/cpuuse/cpuuse.c, libmisc/dumpbuf/dumpbuf.c, libmisc/fsmount/fsmount.c, libmisc/monitor/mon-command.c, libmisc/monitor/mon-config.c, libmisc/monitor/mon-dname.c, libmisc/monitor/mon-driver.c, libmisc/monitor/mon-extension.c, libmisc/monitor/mon-itask.c, libmisc/monitor/mon-monitor.c, libmisc/monitor/mon-mpci.c, libmisc/monitor/mon-object.c, libmisc/monitor/mon-prmisc.c, libmisc/monitor/mon-queue.c, libmisc/monitor/mon-symbols.c, libmisc/monitor/mon-task.c, libmisc/rtmonuse/rtmonuse.c, libmisc/shell/cmds.c, libmisc/shell/shell.c, libmisc/shell/shell.h, libmisc/stackchk/check.c, libmisc/untar/untar.c: Use fprintf(stdout,...) instead of printf.
80 lines
1.4 KiB
C
80 lines
1.4 KiB
C
/*
|
|
* COPYRIGHT (c) 1997.
|
|
* On-Line Applications Research Corporation (OAR).
|
|
*
|
|
* The license and distribution terms for this file may in
|
|
* the file LICENSE in this distribution or at
|
|
* http://www.rtems.com/license/LICENSE.
|
|
*
|
|
* $Id$
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
#include <rtems/dumpbuf.h>
|
|
|
|
/*
|
|
* Put the body below Dump_Buffer so it won't get inlined.
|
|
*/
|
|
|
|
static inline void Dump_Line(
|
|
unsigned char *buffer,
|
|
int length
|
|
);
|
|
|
|
void Dump_Buffer(
|
|
unsigned char *buffer,
|
|
int length
|
|
)
|
|
{
|
|
|
|
int i, mod, max;
|
|
|
|
if ( !length ) return;
|
|
|
|
mod = length % 16;
|
|
|
|
max = length - mod;
|
|
|
|
for ( i=0 ; i<max ; i+=16 )
|
|
Dump_Line( &buffer[ i ], 16 );
|
|
|
|
if ( mod )
|
|
Dump_Line( &buffer[ max ], mod );
|
|
}
|
|
|
|
static inline void Dump_Line(
|
|
unsigned char *buffer,
|
|
int length
|
|
)
|
|
{
|
|
|
|
int i;
|
|
char line_buffer[120];
|
|
|
|
line_buffer[0] = '\0';
|
|
|
|
for( i=0 ; i<length ; i++ )
|
|
sprintf( line_buffer, "%s%02x ", line_buffer, buffer[ i ] );
|
|
|
|
for( ; i<16 ; i++ )
|
|
strcat( line_buffer, " " );
|
|
|
|
strcat( line_buffer, "|" );
|
|
for( i=0 ; i<length ; i++ )
|
|
sprintf( line_buffer, "%s%c", line_buffer,
|
|
isprint( buffer[ i ] ) ? buffer[ i ] : '.' );
|
|
|
|
for( ; i<16 ; i++ )
|
|
strcat( line_buffer, " " );
|
|
|
|
strcat( line_buffer, "|\n" );
|
|
|
|
fprintf(stdout, line_buffer );
|
|
}
|