source: rtems/cpukit/libmisc/dumpbuf/dumpbuf.c @ 2cc9367

4.104.114.84.95
Last change on this file since 2cc9367 was 550c3df7, checked in by Ralf Corsepius <ralf.corsepius@…>, on Jul 8, 2003 at 8:39:16 AM

2003-07-08 Ralf Corsepius <corsepiu@…>

  • 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.
  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 *  COPYRIGHT (c) 1997.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may in
6 *  the file LICENSE in this distribution or at
7 *  http://www.OARcorp.com/rtems/license.html.
8 *
9 *  $Id$
10 */
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <stdio.h>
17#include <string.h>
18#include <ctype.h>
19#include <rtems/dumpbuf.h>
20 
21/*
22 *  Put the body below Dump_Buffer so it won't get inlined.
23 */
24
25static inline void Dump_Line(
26  unsigned char *buffer, 
27  int            length
28);
29
30void Dump_Buffer(
31  unsigned char *buffer,
32  int            length
33)
34{
35 
36  int i, mod, max;
37 
38  if ( !length ) return;
39 
40  mod = length % 16;
41 
42  max = length - mod;
43 
44  for ( i=0 ; i<max ; i+=16 )
45    Dump_Line( &buffer[ i ], 16 );
46 
47  if ( mod )
48    Dump_Line( &buffer[ max ], mod );
49}
50
51static inline void Dump_Line(
52  unsigned char *buffer,
53  int            length
54)
55{
56 
57  int  i;
58  char line_buffer[120];
59 
60  line_buffer[0] = '\0';
61 
62  for( i=0 ; i<length ; i++ )
63    sprintf( line_buffer, "%s%02x ", line_buffer, buffer[ i ] );
64 
65  for( ; i<16 ; i++ )
66    strcat( line_buffer, "   " );
67 
68  strcat( line_buffer, "|" );
69  for( i=0 ; i<length ; i++ )
70    sprintf( line_buffer, "%s%c", line_buffer,
71             isprint( buffer[ i ] ) ? buffer[ i ] : '.' );
72 
73  for( ; i<16 ; i++ )
74    strcat( line_buffer, " " );
75 
76  strcat( line_buffer, "|\n" );
77 
78  printf( line_buffer );
79}
Note: See TracBrowser for help on using the repository browser.