forked from Imagelibrary/rtems
* capture/capture-cli.c: Add config-header support. * capture/capture.c: Add config-header support. * cpuuse/cpuuse.c: Add config-header support. * devnull/devnull.c: Add config-header support. * dummy/dummy.c: Add config-header support. * dumpbuf/dumpbuf.c: Add config-header support. * monitor/mon-command.c: Add config-header support. * monitor/mon-config.c: Add config-header support. * monitor/mon-dname.c: Add config-header support. * monitor/mon-driver.c: Add config-header support. * monitor/mon-extension.c: Add config-header support. * monitor/mon-itask.c: Add config-header support. * monitor/mon-manager.c: Add config-header support. * monitor/mon-monitor.c: Add config-header support. * monitor/mon-mpci.c: Add config-header support. * monitor/mon-object.c: Add config-header support. * monitor/mon-prmisc.c: Add config-header support. * monitor/mon-queue.c: Add config-header support. * monitor/mon-server.c: Add config-header support. * monitor/mon-symbols.c: Add config-header support. * monitor/mon-task.c: Add config-header support. * mw-fb/mw_fb.c: Add config-header support. * mw-fb/mw_uid.c: Add config-header support. * rtmonuse/rtmonuse.c: Add config-header support. * serdbg/serdbg.c: Add config-header support. * serdbg/serdbgio.c: Add config-header support. * serdbg/termios_printk.c: Add config-header support. * shell/cmds.c: Add config-header support. * stackchk/check.c: Add config-header support. * untar/untar.c: Add config-header support.
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.OARcorp.com/rtems/license.html.
|
|
*
|
|
* $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" );
|
|
|
|
printf( line_buffer );
|
|
}
|