10 int main(
int argc,
char* argv[] )
20 fprintf( stderr,
"Usage: %s <filename>\n", argv[0] );
27 fprintf( stderr,
"%s: %s\n", argv[1],
mhdf_message( &status ) );
34 fprintf( stderr,
"%s: %s\n", argv[1],
mhdf_message( &status ) );
40 printf(
"%s:\n", argv[1] );
49 const char* vals_label,
50 const char* extra_label,
55 if( vals_label && (
int)strlen( vals_label ) > len ) len = strlen( vals_label );
56 if( extra_label && (
int)strlen( extra_label ) > len ) len = strlen( extra_label );
59 printf(
" %s (%s):\n", name, subname );
61 printf(
" %s:\n", name );
63 if( vals_label ) printf(
" %-*s: %d\n", len, vals_label, data->
vals_per_ent );
65 printf(
" %-*s: %ld [%ld - %ld]\n", len,
"entities", data->
count, data->
start_id,
68 if( extra_label ) printf(
" %-*s\n", len, extra_label );
80 const char* adj = data->
have_adj ?
"adjacencies" :
"no adjencies";
86 static const char opaque[] =
"opaque";
87 static const char integer[] =
"integer";
88 static const char real[] =
"real";
89 static const char bits[] =
"bit field";
90 static const char boolean[] =
"boolean";
91 static const char id[] =
"entity id";
92 static const char unknown[] =
"(UNKNOWN TYPE ID)";
114 const char* data = value;
117 const int* intptr = value;
118 const double* dblptr = value;
119 const unsigned long* idptr = value;
131 for( i = 0; i <
size; ++i )
132 if( !isprint( data[i] ) ) print = 0;
145 for( i = 0; i <
size; ++i )
146 offset += snprintf(
offset, 1024,
"%02x", (
unsigned int)data[i] );
157 for( i = 1; i <
size; ++i )
170 for( i = 1; i <
size; ++i )
177 offset += snprintf(
offset, 1024,
"(more than 8 bits)" );
180 for( i =
size - 1; i >= 0; --i )
181 *(
offset++ ) = (char)( *data & ( 1 << i ) ?
'1' :
'0' );
188 offset += snprintf(
offset, 1024,
"%s", data[0] ?
"true" :
"false" );
192 offset += snprintf(
offset, 1024,
"{%s", data[0] ?
"true" :
"false" );
193 for( i = 1; i <
size; ++i )
194 offset += snprintf(
offset, 1024,
",%s", data[i] ?
"true" :
"false" );
206 for( i = 1; i <
size; ++i )
212 strcpy(
buffer,
"(unknown data type)" );
221 static const char nodes[] =
"Nodes";
222 static const char sets[] =
"Sets";
223 static const char invalid[] =
"<INVALID INDEX!>";
224 if( idx == -2 )
return sets;
225 if( idx == -1 )
return nodes;
234 printf(
" \"%s\":\n", data->
name );
237 printf(
" %-*s: (variable)\n", width,
"size" );
239 printf(
" %-*s: %d (%d bytes)\n", width,
"size", data->
size, data->
bytes );
240 printf(
" %-*s: %x\n", width,
"flags", data->
storage );
242 printf(
" %-*s: %s\n", width,
"default",
245 printf(
" %-*s: %s\n", width,
"mesh val",
249 printf(
" %-*s: (sparse)", width,
"tables" );
261 printf(
" %-*s: (none)", width,
"tables" );
270 printf(
" Entities:\n" );
276 printf(
" Tags:\n" );