source: rtems/cpukit/libmisc/dumpbuf/dumpbuf.c @ aed742c

4.104.114.84.95
Last change on this file since aed742c was aed742c, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/16/04 at 12:06:28

Remove stray white spaces.

  • 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.rtems.com/license/LICENSE.
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.