9 if( mhdf_isError( &status ) ) \
11 fprintf( stderr, "mhdf error at %s:%d : \"%s\"\n", __FILE__, __LINE__, mhdf_message( &status ) ); \
17 void dump_set_contents(
long first,
long num_sets,
const int* flags,
const long* end_indices,
const long* contents );
23 int main(
int argc,
char* argv[] )
31 fprintf( stderr,
"Usage: %s <input_file>\n", argv[0] );
52 long *end_indices, *data, *new_data;
54 long num_sets,
first, num_data;
60 end_indices = malloc( num_sets *
sizeof(
long ) );
62 printf(
"\nSet IDs: %ld - %ld\n",
first,
first + num_sets - 1 );
65 flags = malloc( num_sets *
sizeof(
int ) );
72 data = malloc( num_data *
sizeof(
long ) );
80 puts(
"\nSet Children:\n" );
85 new_data = realloc( data, num_data *
sizeof(
long ) );
88 fprintf( stderr,
"dump_sets.c::dump_sets(): reallocation of data failed\n" );
105 puts(
"\nSet Parents:\n" );
110 new_data = realloc( data, num_data *
sizeof(
long ) );
113 fprintf( stderr,
"dump_sets.c::dump_sets(): reallocation of data failed\n" );
141 for( i = 0; i < num_sets; ++i )
143 end = end_indices[i];
146 fprintf( stderr,
"Invalid end index for set %ld (ID %ld): %ld following %ld\n", i,
first + i, end, prev );
167 printf(
"%*ld: %ld",
WIDTH,
id, array[0] );
168 for( i = 1; i < count; ++i )
169 printf(
", %ld", array[i] );
170 printf(
" (%ld)\n", count );
178 printf(
"%*ld:",
WIDTH,
id );
181 puts(
" <INVALID DATA LENGTH FOR RANGED LIST>\n" );
185 for( i = 0; i < count; i += 2 )
187 if( array[i + 1] > 1 )
188 printf(
" %ld-%ld", array[i], array[i] + array[i + 1] - 1 );
190 printf(
" %ld", array[i] );
191 if( i + 2 < count ) putchar(
',' );
194 printf(
" (%ld)\n", n );