int main(int argc, char *argv[]) { char *infile, *outfile; Volume_Info volume_info; char *arg_string; int input_icvid, output_icvid; unsigned char *image; int islice; /* Get arguments */ if (argc != 3) { (void) fprintf(stderr, "Usage: %s <infile.mnc> <outfile.mnc>\n", argv[0]); exit(EXIT_FAILURE); } infile = argv[1]; outfile = argv[2]; /* Save list of arguments as string */ arg_string = time_stamp(argc, argv); /* Read in input volume information */ input_icvid = get_volume_info(infile, &volume_info); /* Print out volume information */ (void) printf("File %s:\n", infile); (void) printf(" maximum = %10g, minimum = %10g\n", volume_info.maximum, volume_info.minimum); (void) printf(" slices = %10s: n=%3d, step=%10g, start=%10g\n", volume_info.dimension_names[SLICE], (int) volume_info.nslices, volume_info.step[SLICE], volume_info.start[SLICE]); (void) printf(" rows = %10s: n=%3d, step=%10g, start=%10g\n", volume_info.dimension_names[ROW], (int) volume_info.nrows, volume_info.step[ROW], volume_info.start[ROW]); (void) printf(" columns = %10s: n=%3d, step=%10g, start=%10g\n", volume_info.dimension_names[COLUMN], (int) volume_info.ncolumns, volume_info.step[COLUMN], volume_info.start[COLUMN]); /* Save the volume, copying information from input file */ output_icvid = save_volume_info(input_icvid, outfile, arg_string, &volume_info); /* Loop through slices, copying them */ image = malloc(volume_info.nrows * volume_info.ncolumns * sizeof(*image)); for (islice=0; islice < volume_info.nslices; islice++) { get_volume_slice(input_icvid, &volume_info, islice, image); save_volume_slice(output_icvid, &volume_info, islice, image, volume_info.minimum, volume_info.maximum); } /* Free up image and close files */ close_volume(input_icvid); close_volume(output_icvid); free(image); exit(EXIT_SUCCESS); }
void free_volume(struct mfs_volume* stream) { if (stream->fp != NULL) { close_volume(stream); } free(stream); }
static RET_CODE on_exit_volume_soon(control_t *p_ctrl, u16 msg, u32 para1, u32 para2) { fw_notify_parent(ROOT_ID_VOLUME, NOTIFY_T_KEY, FALSE, para1, 0, 0); close_volume(); return SUCCESS; }
static RET_CODE on_exit_volume(control_t *p_ctrl, u16 msg, u32 para1, u32 para2) { close_volume(); return SUCCESS; }