1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Copyright by The HDF Group. *
3 * Copyright by the Board of Trustees of the University of Illinois. *
4 * All rights reserved. *
5 * *
6 * This file is part of HDF5. The full HDF5 copyright notice, including *
7 * terms governing use, modification, and redistribution, is contained in *
8 * the COPYING file, which can be found at the root of the source code *
9 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
10 * If you do not have access to either file, you may request a copy from *
11 * help@hdfgroup.org. *
12 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13
14 /*-------------------------------------------------------------------------
15 *
16 * Created: H5dbg.c
17 * Mar 4 2006
18 * Quincey Koziol <koziol@ncsa.uiuc.edu>
19 *
20 * Purpose: Generic debugging routines
21 *
22 *-------------------------------------------------------------------------
23 */
24
25 /****************/
26 /* Module Setup */
27 /****************/
28
29 /***********/
30 /* Headers */
31 /***********/
32 #include "H5private.h" /* Generic Functions */
33
34 /****************/
35 /* Local Macros */
36 /****************/
37
38
39 /******************/
40 /* Local Typedefs */
41 /******************/
42
43
44 /********************/
45 /* Local Prototypes */
46 /********************/
47
48
49 /*********************/
50 /* Package Variables */
51 /*********************/
52
53
54 /*****************************/
55 /* Library Private Variables */
56 /*****************************/
57
58
59 /*******************/
60 /* Local Variables */
61 /*******************/
62
63
64
65 /*-------------------------------------------------------------------------
66 * Function: H5_buffer_dump
67 *
68 * Purpose: Dumps a buffer of memory in an octal dump form
69 *
70 * Return: Non-negative on success/Negative on failure
71 *
72 * Programmer: Quincey Koziol
73 * koziol@ncsa.uiuc.edu
74 * Mar 4 2006
75 *
76 *-------------------------------------------------------------------------
77 */
78 herr_t
H5_buffer_dump(FILE * stream,int indent,const uint8_t * buf,const uint8_t * marker,size_t buf_offset,size_t buf_size)79 H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf,
80 const uint8_t *marker, size_t buf_offset, size_t buf_size)
81 {
82 size_t u, v; /* Local index variable */
83
84 FUNC_ENTER_NOAPI_NOINIT_NOERR
85
86 /*
87 * Check arguments.
88 */
89 HDassert(stream);
90 HDassert(indent >= 0);
91 HDassert(buf);
92 HDassert(marker);
93 HDassert(buf_size > 0);
94
95 /*
96 * Print the buffer in a VMS-style octal dump.
97 */
98 HDfprintf(stream, "%*sData follows (`__' indicates free region)...\n",
99 indent, "");
100 for(u = 0; u < buf_size; u += 16) {
101 uint8_t c;
102
103 HDfprintf(stream, "%*s %8d: ", indent, "", u + buf_offset);
104
105 /* Print the hex values */
106 for(v = 0; v < 16; v++) {
107 if(u + v < buf_size) {
108 if(marker[u + v])
109 HDfprintf(stream, "__ ");
110 else {
111 c = buf[buf_offset + u + v];
112 HDfprintf(stream, "%02x ", c);
113 } /* end else */
114 } /* end if */
115 else
116 HDfprintf(stream, " ");
117 if(7 == v)
118 HDfputc(' ', stream);
119 } /* end for */
120 HDfputc(' ', stream);
121
122 /* Print the character values */
123 for(v = 0; v < 16; v++) {
124 if(u + v < buf_size) {
125 if(marker[u + v])
126 HDfputc(' ', stream);
127 else {
128 c = buf[buf_offset + u + v];
129 if(HDisprint(c))
130 HDfputc(c, stream);
131 else
132 HDfputc('.', stream);
133 } /* end else */
134 } /* end if */
135 if(7 == v)
136 HDfputc(' ', stream);
137 } /* end for */
138
139 HDfputc('\n', stream);
140 } /* end for */
141
142 FUNC_LEAVE_NOAPI(SUCCEED)
143 } /* end H5_buffer_dump() */
144
145