int main( int argc, char *argv[] ) { STRING src_filename, dest_filename; int n_objects; File_formats format; object_struct **object_list; polygons_struct *polygons; initialize_argument_processing( argc, argv ); if( !get_string_argument( NULL, &src_filename ) || !get_string_argument( NULL, &dest_filename ) ) { print_error( "Usage: %s input.obj output.obj\n", argv[0] ); return( 1 ); } if( input_graphics_file( src_filename, &format, &n_objects, &object_list ) != OK || n_objects != 1 || get_object_type(object_list[0]) != POLYGONS ) return( 1 ); polygons = get_polygons_ptr( object_list[0] ); create_2d_coordinates( polygons, 0 ); (void) output_graphics_file( dest_filename, format, 1, object_list ); return( 0 ); }
int main( int argc, char *argv[] ) { FILE *file; Status status; char *input_filename, *output_filename; int n_triangles, n_objects; Point centre; object_struct *object, **object_list; polygons_struct *polygons; Real x, y, z, rx, ry, rz; status = OK; initialize_argument_processing( argc, argv ); if( !get_string_argument( "", &input_filename ) || !get_string_argument( "", &output_filename ) ) { (void) fprintf( stderr, "Usage: input_filename output_filename [n_triangles]\n" ); return( 1 ); } (void) get_int_argument( 128, &n_triangles ); if( open_file( input_filename, READ_FILE, ASCII_FORMAT, &file ) != OK ) return( 1 ); n_objects = 0; while( input_real( file, &x ) == OK && input_real( file, &y ) == OK && input_real( file, &z ) == OK && input_real( file, &rx ) == OK && input_real( file, &ry ) == OK && input_real( file, &rz ) == OK ) { object = create_object( POLYGONS ); polygons = get_polygons_ptr(object); fill_Point( centre, x, y, z ); create_tetrahedral_sphere( ¢re, rx, ry, rz, n_triangles, polygons ); compute_polygon_normals( polygons ); ADD_ELEMENT_TO_ARRAY( object_list, n_objects, object, 10 ); } status = output_graphics_file( output_filename, BINARY_FORMAT, n_objects, object_list ); return( status != OK ); }
void do_rename_partition(partition_map_header *map) { partition_map * entry; long ix; char *name; if (map == NULL) { bad_input("No partition map exists"); return; } if (!rflag && map->writable == 0) { printf("The map is not writable.\n"); } if (get_number_argument("Partition number: ", &ix, kDefault) == 0) { bad_input("Bad partition number"); return; } if (get_string_argument("New name of partition: ", &name, 1) == 0) { bad_input("Bad name"); return; } // find partition and change it entry = find_entry_by_disk_address(ix, map); if (entry == NULL) { printf("No such partition\n"); } else { // stuff name into partition map entry data strncpy(entry->data->dpme_name, name, DPISTRLEN); map->changed = 1; } free(name); return; }
int main( int argc, char *argv[] ) { STRING input_filename; Real x, y, z, value; Volume volume; initialize_argument_processing( argc, argv ); if( !get_string_argument( "", &input_filename ) ) { return( 1 ); } if( input_volume( input_filename, 3, XYZ_dimension_names, NC_UNSPECIFIED, FALSE, 0.0, 0.0, TRUE, &volume, (minc_input_options *) NULL ) != OK ) return( 1 ); while( get_real_argument( 0.0, &x ) && get_real_argument( 0.0, &y ) && get_real_argument( 0.0, &z ) ) { evaluate_volume_in_world( volume, x, y, z, -1, FALSE, 0.0, &value, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); print( "%g\n", value ); } return( 0 ); }
int main( int argc, char *argv[] ) { STRING polygons_filename, dest_filename, lines_filename; int n_objects, n_l_objects; File_formats format; object_struct **object_list, **l_object_list; polygons_struct *polygons, *new_polygons; lines_struct *lines; initialize_argument_processing( argc, argv ); if( !get_string_argument( NULL, &polygons_filename ) || !get_string_argument( NULL, &lines_filename ) || !get_string_argument( NULL, &dest_filename ) ) { print_error( "Usage: %s polygons.obj lines.obj output.obj\n", argv[0] ); return( 1 ); } if( input_graphics_file( polygons_filename, &format, &n_objects, &object_list ) != OK || n_objects != 1 || get_object_type(object_list[0]) != POLYGONS ) return( 1 ); polygons = get_polygons_ptr( object_list[0] ); if( input_graphics_file( lines_filename, &format, &n_l_objects, &l_object_list ) != OK || n_l_objects != 1 || get_object_type(l_object_list[0]) != LINES ) return( 1 ); lines = get_lines_ptr( l_object_list[0] ); new_polygons = NULL; segment_polygons( polygons, lines, new_polygons ); (void) output_graphics_file( dest_filename, format, n_objects, object_list); return( 0 ); }
int main( int argc, char *argv[] ) { STRING input_filename, output_filename; int n_objects, start_poly; File_formats format; object_struct **object_list; polygons_struct *polygons; initialize_argument_processing( argc, argv ); if( !get_string_argument( NULL, &input_filename ) || !get_string_argument( NULL, &output_filename ) ) { print_error( "Usage: %s input.obj output.obj\n", argv[0] ); return( 1 ); } (void) get_int_argument( 0, &start_poly ); if( input_graphics_file( input_filename, &format, &n_objects, &object_list ) != OK || n_objects != 1 || get_object_type(object_list[0]) != POLYGONS ) { print_error( "Error reading %s.\n", input_filename ); return( 1 ); } polygons = get_polygons_ptr( object_list[0] ); check_polygons_neighbours_computed( polygons ); create_tristrip( polygons, start_poly ); return( 0 ); }
int main( int argc, char *argv[] ) { STRING src_filename, dest_filename; int n_objects, n_iters; File_formats format; object_struct **object_list; polygons_struct *polygons; Real step_ratio; initialize_argument_processing( argc, argv ); if( !get_string_argument( NULL, &src_filename ) || !get_string_argument( NULL, &dest_filename ) ) { print_error( "Usage: %s input.obj output.obj [step] [n_iters]\n", argv[0] ); return( 1 ); } (void) get_real_argument( 0.2, &step_ratio ); (void) get_int_argument( 1000, &n_iters ); if( input_graphics_file( src_filename, &format, &n_objects, &object_list ) != OK || n_objects != 1 || get_object_type(object_list[0]) != POLYGONS ) return( 1 ); polygons = get_polygons_ptr( object_list[0] ); flatten_polygons( polygons, step_ratio, n_iters ); (void) output_graphics_file( dest_filename, format, 1, object_list ); return( 0 ); }
int main( int argc, char *argv[] ) { Status status; STRING input_filename, output_filename; int n_objects; File_formats format; object_struct **object_list; status = OK; initialize_argument_processing( argc, argv ); if( !get_string_argument( NULL, &input_filename ) || !get_string_argument( NULL, &output_filename ) ) { print_error( "Toggle format of a .obj file from ASCII to BINARY, or vice-versa\n" ); print_error( "Usage: %s input.obj output.obj\n", argv[0] ); return( 1 ); } if( input_graphics_file( input_filename, &format, &n_objects, &object_list ) != OK ) { print( "Couldn't read input object %s.\n", input_filename ); return( 1 ); } if( format == ASCII_FORMAT ) { printf( "Converting object from ASCII to BINARY...\n" ); format = BINARY_FORMAT; } else { printf( "Converting object from BINARY to ASCII...\n" ); format = ASCII_FORMAT; } status = output_graphics_file( output_filename, format, n_objects, object_list ); return( status != OK ); }
int main( int argc, char *argv[] ) { char *input_filename; int i, n_objects; File_formats format; object_struct **object_list; Vector dir; Point eye; Real eye_x, eye_y, eye_z, dir_x, dir_y, dir_z; Real distance; int obj_index; BOOLEAN intersects; initialize_argument_processing( argc, argv ); if( !get_string_argument( "", &input_filename ) || !get_real_argument( 0.0, &eye_x ) || !get_real_argument( 0.0, &eye_y ) || !get_real_argument( 0.0, &eye_z ) || !get_real_argument( 0.0, &dir_x ) || !get_real_argument( 0.0, &dir_y ) || !get_real_argument( 0.0, &dir_z ) ) { print_error( "Usage\n" ); return( 1 ); } fill_Point( eye, eye_x, eye_y, eye_z ); fill_Vector( dir, dir_x, dir_y, dir_z ); NORMALIZE_VECTOR( dir, dir ); if( input_graphics_file( input_filename, &format, &n_objects, &object_list ) != OK ) return( 1 ); intersects = intersect_ray_with_object( &eye, &dir, object_list[0], &obj_index, &distance, NULL ); print( "%d: %g\n", intersects, distance ); return( 0 ); }
void do_change_type(partition_map_header *map) { partition_map * entry; long ix; char *type = NULL; if (map == NULL) { bad_input("No partition map exists"); return; } if (!rflag && map->writable == 0) { printf("The map is not writeable.\n"); } if (get_number_argument("Partition number: ", &ix, kDefault) == 0) { bad_input("Bad partition number"); return; } entry = find_entry_by_disk_address(ix, map); if (entry == NULL ) { printf("No such partition\n"); goto out; } printf("Existing partition type ``%s''.\n", entry->data->dpme_type); if (get_string_argument("New type of partition: ", &type, 1) == 0) { bad_input("Bad type"); goto out; } strncpy(entry->data->dpme_type, type, DPISTRLEN); do_update_dpme(entry); map->changed = 1; out: if (type) free(type); return; }
int main( int argc, char *argv[] ) { Volume volume; BOOLEAN world_space; int continuity; Real x, y, z; char *input_filename; static char *dim_names[] = { MIxspace, MIyspace, MIzspace }; initialize_argument_processing( argc, argv ); if( !get_string_argument( "", &input_filename ) ) { print( "Need args.\n" ); return( 1 ); } (void) get_int_argument( 0, &continuity ); world_space = (argc > 3); if( input_volume( input_filename, 3, dim_names, NC_UNSPECIFIED, FALSE, 0.0, 0.0, TRUE, &volume, (minc_input_options *) NULL ) != OK ) return( 1 ); print( "Enter x, y, z: " ); while( input_real( stdin, &x ) == OK && input_real( stdin, &y ) == OK && input_real( stdin, &z ) == OK ) { check( volume, world_space, continuity, x, y, z ); print( "\nEnter x, y, z: " ); } return( 0 ); }
int main( int argc, char *argv[] ) { STRING volume_filename; STRING output_filename; Real x, y, z, xc, yc, zc, xp, yp, zp, len, pos; Real value, scaling, min_value, max_value; int v[MAX_DIMENSIONS], sizes[MAX_DIMENSIONS]; Real voxel[MAX_DIMENSIONS], scale; Volume volume; initialize_argument_processing( argc, argv ); if( !get_string_argument( "", &volume_filename ) || !get_string_argument( "", &output_filename ) || !get_real_argument( 0.0, &x ) || !get_real_argument( 0.0, &y ) || !get_real_argument( 0.0, &z ) || !get_real_argument( 0.0, &scaling ) ) { return( 1 ); } len = sqrt( x * x + y * y + z * z ); x /= len; y /= len; z /= len; if( input_volume( volume_filename, 3, File_order_dimension_names, NC_UNSPECIFIED, FALSE, 0.0, 0.0, TRUE, &volume, NULL ) != OK ) return( 1 ); get_volume_sizes( volume, sizes ); get_volume_real_range( volume, &min_value, &max_value ); voxel[0] = (Real) (sizes[0]-1) / 2.0; voxel[1] = (Real) (sizes[1]-1) / 2.0; voxel[2] = (Real) (sizes[2]-1) / 2.0; convert_voxel_to_world( volume, voxel, &xc, &yc, &zc ); BEGIN_ALL_VOXELS( volume, v[0], v[1], v[2], v[3], v[4] ) voxel[0] = (Real) v[0]; voxel[1] = (Real) v[1]; voxel[2] = (Real) v[2]; convert_voxel_to_world( volume, voxel, &xp, &yp, &zp ); pos = (xp - xc) * x + (yp - yc) * y + (zp - zc) * z; scale = 1.0 + pos * scaling; value = get_volume_real_value( volume, v[0], v[1], v[2], v[3], v[4] ); value *= scale; if( value < min_value ) value = min_value; else if( value > max_value ) value = max_value; set_volume_real_value( volume, v[0], v[1], v[2], v[3], v[4], value ); END_ALL_VOXELS (void) output_modified_volume( output_filename, NC_UNSPECIFIED, FALSE, 0.0, 0.0, volume, volume_filename, "Scaled\n", NULL ); return( 0 ); }
void do_create_partition(partition_map_header *map, int get_type) { long base; long length; char *name = 0; char *type_name = 0; if (map == NULL) { bad_input("No partition map exists"); return; } if (!rflag && map->writable == 0) { printf("The map is not writable.\n"); } // XXX add help feature (i.e. '?' in any argument routine prints help string) if (get_base_argument(&base, map) == 0) { return; } if (get_size_argument(&length, map) == 0) { return; } if (get_string_argument("Name of partition: ", &name, 1) == 0) { bad_input("Bad name"); return; } if (get_type == 0) { add_partition_to_map(name, kUnixType, base, length, map); #if 0 /* this check is not found in linux fdisk-0.1 */ if (map->blocks_in_map > MAX_LINUX_MAP) { error(-1, "Map contains more than %d blocks - Linux may have trouble", MAX_LINUX_MAP); } goto xit1; #endif } else if (get_string_argument("Type of partition: ", &type_name, 1) == 0) { bad_input("Bad type"); goto xit1; } else { if (istrncmp(type_name, kFreeType, DPISTRLEN) == 0) { bad_input("Can't create a partition with the Free type"); goto xit2; } if (istrncmp(type_name, kMapType, DPISTRLEN) == 0) { bad_input("Can't create a partition with the Map type"); goto xit2; } add_partition_to_map(name, type_name, base, length, map); #if 0 /* this check is not found in linux fdisk-0.1 */ if (map->blocks_in_map > MAX_LINUX_MAP) { error(-1, "Map contains more than %d blocks - Linux may have trouble", MAX_LINUX_MAP); } #endif } do_update_dpme(find_entry_by_base(base,map)); xit2: if (type_name) free(type_name); xit1: if (name) free(name); return; }
int main( int argc, char *argv[] ) { STRING src_polygons_filename; File_formats format; int n_src_objects, poly; object_struct **src_objects; polygons_struct *polygons, unit_sphere; Real x, y, z, xs, ys, zs, u, v, dist; Point point, centre, unit_point, poly_point; initialize_argument_processing( argc, argv ); if( !get_string_argument( NULL, &src_polygons_filename ) || !get_real_argument( 0.0, &x ) || !get_real_argument( 0.0, &y ) || !get_real_argument( 0.0, &z ) ) { print_error( "Usage: %s input.obj x y z\n", argv[0] ); return( 1 ); } if( input_graphics_file( src_polygons_filename, &format, &n_src_objects, &src_objects ) != OK ) return( 1 ); if( n_src_objects != 1 || get_object_type( src_objects[0] ) != POLYGONS || !is_this_tetrahedral_topology( get_polygons_ptr(src_objects[0]) ) ) { print( "First argument must contain one tetrahedral mesh.\n" ); return( 1 ); } polygons = get_polygons_ptr(src_objects[0]); create_polygons_bintree( polygons, ROUND( (Real) polygons->n_items * BINTREE_FACTOR ) ); fill_Point( centre, 0.0, 0.0, 0.0 ); create_tetrahedral_sphere( ¢re, 1.0, 1.0, 1.0, polygons->n_items, &unit_sphere ); fill_Point( point, x, y, z ); poly = find_closest_polygon_point( &point, polygons, &poly_point ); dist = distance_between_points( &point, &poly_point ); if( dist > 1.0 ) print( "Warning point is %.1f millimetres from the surface.\n", dist ); map_point_to_unit_sphere( polygons, &point, &unit_sphere, &unit_point ); xs = RPoint_x( unit_point ); ys = RPoint_y( unit_point ); zs = RPoint_z( unit_point ); map_sphere_to_uv( xs, ys, zs, &u, &v ); print( "%g %g %g -> %g %g\n", x, y, z, u, v ); delete_object_list( n_src_objects, src_objects ); delete_polygons( &unit_sphere ); return( 0 ); }
index2tc valid_index_expr(get_bool_type(), valid_sym, ptr_obj); expr2tc falsity = gen_false_expr(); symex_assign(code_assign2tc(valid_index_expr, falsity), true); } void goto_symext::symex_printf( const expr2tc &lhs __attribute__((unused)), const expr2tc &rhs) { assert(is_code_printf2t(rhs)); code_printf2tc new_rhs(to_code_printf2t(rhs)); cur_state->rename(new_rhs); // The expr2tc in position 0 is the string format const irep_idt fmt = get_string_argument(new_rhs->operands[0]); // Now we pop the format new_rhs->operands.erase(new_rhs->operands.begin()); std::list<expr2tc> args; new_rhs->foreach_operand([this, &args](const expr2tc &e) { expr2tc tmp = e; do_simplify(tmp); args.push_back(tmp); }); target->output( cur_state->guard.as_expr(), cur_state->source, fmt.as_string(), args); }
virtual string get_parameter_name() { return get_string_argument(); }
void do_display_block(partition_map_header *map, char *alt_name) { MEDIA m; long number; char *name; static unsigned char *display_block; static int display_g; int g; static long next_number = -1; if (map != NULL) { name = 0; m = map->m; g = map->logical_block; } else { if (alt_name == 0) { if (get_string_argument("Name of device: ", &name, 1) == 0) { bad_input("Bad name"); return; } } else { name = strdup(alt_name); } m = open_pathname_as_media(name, O_RDONLY); if (m == 0) { error(errno, "can't open file '%s'", name); free(name); return; } g = media_granularity(m); if (g < PBLOCK_SIZE) { g = PBLOCK_SIZE; } } if (get_number_argument("Block number: ", &number, next_number) == 0) { bad_input("Bad block number"); goto xit; } if (display_block == NULL || display_g < g) { if (display_block != NULL) { free(display_block); display_g = 0; } display_block = (unsigned char *) malloc(g); if (display_block == NULL) { error(errno, "can't allocate memory for display block buffer"); goto xit; } display_g = g; } if (read_media(m, ((long long)number) * g, g, (char *)display_block) != 0) { printf("block %ld -", number); dump_block((unsigned char*) display_block, g); next_number = number + 1; } xit: if (name) { close_media(m); free(name); } return; }
int main( int argc, char *argv[] ) { STRING input_filename, output_filename; STRING model_filename; File_formats src_format, model_format; int n_src_objects, n_model_objects; object_struct **src_objects, **model_objects; polygons_struct *original, *model; Real movement_threshold, ratio; int n_iters, method, grid_size; initialize_argument_processing( argc, argv ); if( !get_string_argument( NULL, &input_filename ) || !get_string_argument( NULL, &model_filename ) || !get_string_argument( NULL, &output_filename ) ) { print_error( "Usage: %s input.obj model.obj output.obj\n", argv[0] ); return( 1 ); } (void) get_int_argument( 1, &n_iters ); (void) get_real_argument( 1.0, &ratio ); (void) get_int_argument( 0, &method ); (void) get_int_argument( 30, &grid_size ); (void) get_real_argument( 0.0, &movement_threshold ); if( input_graphics_file( input_filename, &src_format, &n_src_objects, &src_objects ) != OK || n_src_objects != 1 || get_object_type(src_objects[0]) != POLYGONS ) { print_error( "Error in %s\n", input_filename ); return( 1 ); } if( input_graphics_file( model_filename, &model_format, &n_model_objects, &model_objects ) != OK || n_model_objects != 1 || get_object_type(model_objects[0]) != POLYGONS ) { print_error( "Error in %s\n", model_filename ); return( 1 ); } original = get_polygons_ptr( src_objects[0] ); model = get_polygons_ptr( model_objects[0] ); if( !objects_are_same_topology( original->n_points, original->n_items, original->end_indices, original->indices, model->n_points, model->n_items, model->end_indices, model->indices ) ) { print_error( "Mismatched topology.\n" ); return( 1 ); } reparameterize( original, model, method, grid_size, ratio, movement_threshold, n_iters ); if( output_graphics_file( output_filename, src_format, n_src_objects, src_objects ) != OK ) return( 1 ); delete_object_list( n_src_objects, src_objects ); output_alloc_to_file( NULL ); return( 0 ); }
void interact() { char *name; int command; int ask_logical_size; while (get_command("Top level command (? for help): ", first_get, &command)) { first_get = 0; ask_logical_size = 0; switch (command) { case '?': print_top_notes(); // fall through case 'H': case 'h': printf("Commands are:\n"); printf(" h print help\n"); printf(" v print the version number and release date\n"); printf(" l list device's map\n"); #ifdef __linux__ printf(" L list all devices' maps\n"); #endif printf(" e edit device's map\n"); printf(" E (edit map with specified block size)\n"); printf(" r toggle readonly flag\n"); printf(" f toggle show filesystem name flag\n"); if (dflag) { printf(" a toggle abbreviate flag\n"); printf(" p toggle physical flag\n"); printf(" c toggle compute size flag\n"); printf(" d toggle debug flag\n"); printf(" x examine block n of device\n"); } printf(" q quit the program\n"); break; case 'Q': case 'q': return; break; case 'V': case 'v': printf("version " VERSION " (" RELEASE_DATE ")\n"); break; #ifdef __linux__ case 'L': list_all_disks(); break; #endif case 'l': if (get_string_argument("Name of device: ", &name, 1) == 0) { bad_input("Bad name"); break; } dump(name); free(name); break; case 'E': ask_logical_size = 1; case 'e': if (get_string_argument("Name of device: ", &name, 1) == 0) { bad_input("Bad name"); break; } edit(name, ask_logical_size); free(name); break; case 'R': case 'r': if (rflag) { rflag = 0; } else { rflag = 1; } printf("Now in %s mode.\n", (rflag)?"readonly":"read/write"); break; case 'F': case 'f': if (fflag) { fflag = 0; } else { fflag = 1; } printf("Now in show %s name mode.\n", (fflag)?"filesystem":"partition"); break; case 'A': case 'a': if (dflag) { if (aflag) { aflag = 0; } else { aflag = 1; } printf("Now in %s mode.\n", (aflag)?"abbreviate":"full type"); } else { goto do_error; } break; case 'P': case 'p': if (dflag) { if (pflag) { pflag = 0; } else { pflag = 1; } printf("Now in %s mode.\n", (pflag)?"physical":"logical"); } else { goto do_error; } break; case 'D': case 'd': if (dflag) { dflag = 0; } else { dflag = 1; } printf("Now in %s mode.\n", (dflag)?"debug":"normal"); break; case 'C': case 'c': if (dflag) { if (cflag) { cflag = 0; } else { cflag = 1; } printf("Now in %s device size mode.\n", (cflag)?"always compute":"use existing"); } else { goto do_error; } break; case 'X': case 'x': if (dflag) { do_display_block(0, 0); } else { goto do_error; } break; default: do_error: bad_input("No such command (%c)", command); break; } } }
void validate_map(partition_map_header *map) { range_list *list; char *name; unsigned int i; u32 limit; int printed; //printf("Validation not implemented yet.\n"); if (map == NULL) { the_map = 0; if (get_string_argument("Name of device: ", &name, 1) == 0) { bad_input("Bad name"); return; } the_media = open_pathname_as_media(name, O_RDONLY); if (the_media == 0) { error(errno, "can't open file '%s'", name); free(name); return; } g = media_granularity(the_media); if (g < PBLOCK_SIZE) { g = PBLOCK_SIZE; } the_media = open_deblock_media(PBLOCK_SIZE, the_media); buffer = malloc(PBLOCK_SIZE); if (buffer == NULL) { error(errno, "can't allocate memory for disk buffer"); goto done; } } else { name = 0; the_map = map; g = map->logical_block; } initialize_list(&list); // get block 0 if (get_block_zero() == 0) { printf("unable to read block 0\n"); goto check_map; } // XXX signature valid // XXX size & count match DeviceCapacity // XXX number of descriptors matches array size // XXX each descriptor wholly contained in a partition // XXX the range below here is in physical blocks but the map is in logical blocks!!! add_range(&list, 1, b0->sbBlkCount-1, 0); /* subtract one since args are base & len */ check_map: // compute size of map if (map != NULL) { limit = the_map->blocks_in_map; } else { if (get_block_n(1) == 0) { printf("unable to get first block\n"); goto done; } else { if (mb->dpme_signature != DPME_SIGNATURE) { limit = -1; } else { limit = mb->dpme_map_entries; } } } // for each entry for (i = 1; ; i++) { #if 0 if (limit < 0) { /* XXX what to use for end of list? */ if (i > 5) { break; } } else #endif if (i > limit) { break; } printf("block %d:\n", i); // get entry if (get_block_n(i) == 0) { printf("\tunable to get\n"); goto post_processing; } printed = 0; // signature matches if (mb->dpme_signature != DPME_SIGNATURE) { printed = 1; printf("\tsignature is 0x%x, should be 0x%x\n", mb->dpme_signature, DPME_SIGNATURE); } // reserved1 == 0 if (mb->dpme_reserved_1 != 0) { printed = 1; printf("\treserved word is 0x%x, should be 0\n", mb->dpme_reserved_1); } // entry count matches #if 0 if (limit < 0) { printed = 1; printf("\tentry count is 0x%lx, real value unknown\n", mb->dpme_map_entries); } else #endif if (mb->dpme_map_entries != limit) { printed = 1; printf("\tentry count is 0x%lx, should be %ld\n", mb->dpme_map_entries, limit); } // lblocks contained within physical if (mb->dpme_lblock_start >= mb->dpme_pblocks || mb->dpme_lblocks > mb->dpme_pblocks - mb->dpme_lblock_start) { printed = 1; printf("\tlogical blocks (%ld for %ld) not within physical size (%ld)\n", mb->dpme_lblock_start, mb->dpme_lblocks, mb->dpme_pblocks); } // remember stuff for post processing add_range(&list, mb->dpme_pblock_start, mb->dpme_pblocks, 1); // XXX type is known type? // XXX no unknown flags? // XXX boot blocks either within or outside of logical // XXX checksum matches contents // XXX other fields zero if boot_bytes is zero // XXX processor id is known value? // XXX no data in reserved3 if (printed == 0) { printf("\tokay\n"); } } post_processing: // properties of whole map // every block on disk in one & only one partition coalesce_list(list); print_range_list(list); // there is a partition for the map // map fits within partition that contains it // try to detect 512/2048 mixed partition map? done: if (map == NULL) { close_media(the_media); free(buffer); free(name); } }
int main( int argc, char *argv[] ) { Volume volume; STRING input_filename, output_filename; int n_slices, n_components; pixels_struct *pixels; nc_type vol_type; BOOLEAN two_d_allowed; initialize_argument_processing( argc, argv ); if( !get_string_argument( NULL, &output_filename ) || !get_int_argument( 0, &n_components ) ) { print( "Usage: %s output.mnc 3|4|23|24 input1.rgb input2.rgb ...\n", argv[0] ); return( 1 ); } if( n_components > 100 ) { vol_type = NC_FLOAT; n_components -= 100; } else vol_type = NC_BYTE; if( n_components > 20 ) { two_d_allowed = TRUE; n_components -= 20; } else { two_d_allowed = FALSE; } n_slices = 0; pixels = NULL; while( get_string_argument( "", &input_filename ) ) { SET_ARRAY_SIZE( pixels, n_slices, n_slices+1, DEFAULT_CHUNK_SIZE ); if( input_rgb_file( input_filename, &pixels[n_slices] ) != OK ) return( 1 ); ++n_slices; } volume = convert_pixels_to_volume( n_components, n_slices, (two_d_allowed && n_slices == 1) ? 2 : 3, vol_type, pixels ); if( volume != NULL ) { (void) output_volume( output_filename, NC_UNSPECIFIED, FALSE, 0.0, 0.0, volume, "Converted from pixels", (minc_output_options *) NULL ); delete_volume( volume ); } return( 0 ); }