2003-09-20 03:33:41 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
|
|
* is linked from the top-level documents page. It can also be found at *
|
|
|
|
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
2003-10-23 05:43:34 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include "h5repack.h"
|
2003-10-23 05:45:59 +08:00
|
|
|
|
2003-12-05 03:35:33 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* File: h5repack.c
|
|
|
|
* Purpose: Public API functions
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2003-10-23 05:45:59 +08:00
|
|
|
|
2003-12-05 03:35:33 +08:00
|
|
|
static int check_options(pack_opt_t *options);
|
2003-10-23 05:43:34 +08:00
|
|
|
|
2004-01-07 01:49:00 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: aux_initglb_filter
|
|
|
|
*
|
|
|
|
* Purpose: auxiliary function, initialize the options global filter
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static void aux_initglb_filter(pack_opt_t *options)
|
|
|
|
{
|
|
|
|
int k;
|
|
|
|
options->filter_g.filtn = -1;
|
|
|
|
for ( k=0; k<CDVALUES; k++)
|
|
|
|
options->filter_g.cd_values[k] = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-23 05:43:34 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5repack
|
|
|
|
*
|
|
|
|
* Purpose: locate all high-level HDF5 objects in the file
|
|
|
|
* and compress/chunk them using options
|
|
|
|
*
|
|
|
|
* Algorythm: 2 traversals are made to the file; the 1st builds a list of
|
|
|
|
* the objects, the 2nd makes a copy of them, using the options;
|
|
|
|
* the reason for the 1st traversal is to check for invalid
|
|
|
|
* object name requests
|
|
|
|
*
|
|
|
|
* Return: 0, ok, -1, fail
|
|
|
|
*
|
|
|
|
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
|
|
|
|
*
|
|
|
|
* Date: September, 22, 2003
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2003-11-11 04:59:32 +08:00
|
|
|
int h5repack(const char* infile,
|
|
|
|
const char* outfile,
|
2003-10-29 01:40:05 +08:00
|
|
|
pack_opt_t *options)
|
2003-09-20 03:33:41 +08:00
|
|
|
{
|
2003-12-05 03:35:33 +08:00
|
|
|
/* check input */
|
|
|
|
if (check_options(options)<0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* check for objects in input that are in the file */
|
|
|
|
if (check_objects(infile,options)<0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* copy the file */
|
|
|
|
if (copy_file(infile,outfile,options)<0)
|
|
|
|
return -1;
|
2003-12-17 22:07:41 +08:00
|
|
|
|
2003-12-05 03:35:33 +08:00
|
|
|
|
2003-09-20 03:33:41 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2003-10-23 05:43:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5repack_init
|
|
|
|
*
|
|
|
|
* Purpose: initialize options
|
|
|
|
*
|
|
|
|
* Return: 0, ok, -1, fail
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2003-10-29 01:40:05 +08:00
|
|
|
int h5repack_init (pack_opt_t *options,
|
2003-10-23 05:43:34 +08:00
|
|
|
int verbose)
|
|
|
|
{
|
2003-10-29 01:40:05 +08:00
|
|
|
memset(options,0,sizeof(pack_opt_t));
|
2003-10-23 05:43:34 +08:00
|
|
|
options->threshold = 1024;
|
|
|
|
options->verbose = verbose;
|
|
|
|
return (options_table_init(&(options->op_tbl)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5repack_end
|
|
|
|
*
|
|
|
|
* Purpose: free options table
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2003-10-29 01:40:05 +08:00
|
|
|
int h5repack_end (pack_opt_t *options)
|
2003-10-23 05:43:34 +08:00
|
|
|
{
|
|
|
|
return options_table_free(options->op_tbl);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2003-12-30 04:26:21 +08:00
|
|
|
* Function: h5repack_addfilter
|
2003-10-23 05:43:34 +08:00
|
|
|
*
|
|
|
|
* Purpose: add a compression -t option to table
|
|
|
|
* Example: -t "*:GZIP 6" , STR = "*:GZIP 6"
|
|
|
|
*
|
2003-12-05 03:35:33 +08:00
|
|
|
* Return: 0, ok, -1, fail
|
2003-10-23 05:43:34 +08:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2003-12-30 04:26:21 +08:00
|
|
|
int h5repack_addfilter(const char* str,
|
|
|
|
pack_opt_t *options)
|
2003-10-23 05:43:34 +08:00
|
|
|
{
|
2003-12-30 04:26:21 +08:00
|
|
|
obj_list_t *obj_list=NULL; /*one object list for the -f and -c option entry */
|
|
|
|
filter_info_t filt; /*filter info for the current -f option entry */
|
|
|
|
int n_objs; /*number of objects in the current -f or -c option entry */
|
2003-10-23 05:43:34 +08:00
|
|
|
|
2003-12-30 04:26:21 +08:00
|
|
|
if (options->all_filter==1){
|
|
|
|
printf("Error: Invalid compression input: all option is present \
|
|
|
|
with other objects <%s>\n",str);
|
2003-12-05 03:35:33 +08:00
|
|
|
return -1;
|
2003-10-23 05:43:34 +08:00
|
|
|
}
|
|
|
|
|
2003-12-30 04:26:21 +08:00
|
|
|
/* parse the -f option */
|
|
|
|
obj_list=parse_filter(str,&n_objs,&filt,options);
|
2003-11-11 04:59:32 +08:00
|
|
|
if (obj_list==NULL)
|
2003-10-23 05:43:34 +08:00
|
|
|
{
|
2003-12-30 04:26:21 +08:00
|
|
|
return -1;
|
2003-10-23 05:43:34 +08:00
|
|
|
}
|
|
|
|
|
2003-12-30 04:26:21 +08:00
|
|
|
if (options->all_filter==1)
|
2003-10-23 05:43:34 +08:00
|
|
|
{
|
2003-12-30 04:26:21 +08:00
|
|
|
/* if we are compressing all set the global filter type */
|
2004-01-07 01:49:00 +08:00
|
|
|
aux_initglb_filter(options);
|
2003-12-30 04:26:21 +08:00
|
|
|
options->filter_g=filt;
|
2003-10-23 05:43:34 +08:00
|
|
|
}
|
|
|
|
|
2003-12-30 04:26:21 +08:00
|
|
|
if (options->all_filter==0)
|
|
|
|
options_add_filter(obj_list,n_objs,filt,options->op_tbl);
|
2003-11-11 04:59:32 +08:00
|
|
|
|
|
|
|
free(obj_list);
|
2003-10-23 05:43:34 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2003-12-31 06:59:33 +08:00
|
|
|
* Function: h5repack_addlayout
|
2003-10-23 05:43:34 +08:00
|
|
|
*
|
2003-12-31 06:59:33 +08:00
|
|
|
* Purpose: add a layout option
|
2003-10-23 05:43:34 +08:00
|
|
|
*
|
|
|
|
* Return: 0, ok, -1, fail
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2003-12-31 06:59:33 +08:00
|
|
|
int h5repack_addlayout(const char* str,
|
|
|
|
pack_opt_t *options)
|
2003-10-23 05:43:34 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
obj_list_t *obj_list=NULL; /*one object list for the -t and -c option entry */
|
|
|
|
int n_objs; /*number of objects in the current -t or -c option entry */
|
2003-12-30 04:26:21 +08:00
|
|
|
int j;
|
2003-12-31 06:59:33 +08:00
|
|
|
pack_info_t pack; /*info about layout to extract from parse */
|
2003-10-23 05:43:34 +08:00
|
|
|
|
2003-12-31 06:59:33 +08:00
|
|
|
if (options->all_layout==1){
|
|
|
|
printf("Error: Invalid layout input: all option \
|
|
|
|
is present with other objects <%s>\n",str);
|
2003-12-05 03:35:33 +08:00
|
|
|
return -1;
|
2003-10-23 05:43:34 +08:00
|
|
|
}
|
|
|
|
|
2003-12-31 06:59:33 +08:00
|
|
|
/* parse the layout option */
|
|
|
|
obj_list=parse_layout(str,&n_objs,&pack,options);
|
2003-11-11 04:59:32 +08:00
|
|
|
if (obj_list==NULL)
|
|
|
|
return -1;
|
2003-10-23 05:43:34 +08:00
|
|
|
|
2003-12-31 06:59:33 +08:00
|
|
|
/* set global layout option */
|
|
|
|
if (options->all_layout==1 )
|
2003-10-23 05:43:34 +08:00
|
|
|
{
|
2003-12-31 06:59:33 +08:00
|
|
|
options->layout_g=pack.layout;
|
|
|
|
if (pack.layout==H5D_CHUNKED) {
|
|
|
|
/* if we are chunking all set the global chunking type */
|
|
|
|
options->chunk_g.rank=pack.chunk.rank;
|
|
|
|
for (j = 0; j < pack.chunk.rank; j++)
|
|
|
|
options->chunk_g.chunk_lengths[j] = pack.chunk.chunk_lengths[j];
|
|
|
|
}
|
2003-10-23 05:43:34 +08:00
|
|
|
}
|
|
|
|
|
2003-12-31 06:59:33 +08:00
|
|
|
if (options->all_layout==0)
|
|
|
|
options_add_layout(obj_list,
|
|
|
|
n_objs,
|
|
|
|
&pack,
|
|
|
|
options->op_tbl);
|
2003-10-23 05:43:34 +08:00
|
|
|
|
|
|
|
free(obj_list);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2003-12-05 03:35:33 +08:00
|
|
|
* Function: check_options
|
2003-10-23 05:43:34 +08:00
|
|
|
*
|
|
|
|
* Purpose: print options, checks for invalid options
|
|
|
|
*
|
2003-12-05 03:35:33 +08:00
|
|
|
* Return: void, return -1 on error
|
2003-10-23 05:43:34 +08:00
|
|
|
*
|
|
|
|
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
|
|
|
|
*
|
|
|
|
* Date: September, 22, 2003
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2003-12-05 03:35:33 +08:00
|
|
|
static int check_options(pack_opt_t *options)
|
2003-10-23 05:43:34 +08:00
|
|
|
{
|
|
|
|
int i, k, j, has_cp=0, has_ck=0;
|
|
|
|
|
2003-12-30 04:26:21 +08:00
|
|
|
unsigned szip_options_mask=H5_SZIP_NN_OPTION_MASK;
|
|
|
|
unsigned szip_pixels_per_block;
|
|
|
|
|
2003-10-23 05:43:34 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2003-12-31 06:59:33 +08:00
|
|
|
* objects to layout
|
2003-10-23 05:43:34 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
if (options->verbose)
|
|
|
|
{
|
|
|
|
printf("\n");
|
2003-12-31 06:59:33 +08:00
|
|
|
printf("Objects to modify are...\n");
|
|
|
|
if (options->all_layout==1) {
|
|
|
|
printf("\tApply layout to all\n ");
|
|
|
|
if (H5D_CHUNKED==options->layout_g) {
|
|
|
|
printf("with dimension [");
|
|
|
|
for ( j = 0; j < options->chunk_g.rank; j++)
|
|
|
|
printf("%d ",(int)options->chunk_g.chunk_lengths[j]);
|
|
|
|
printf("]\n");
|
|
|
|
}
|
2003-10-23 05:43:34 +08:00
|
|
|
}
|
|
|
|
}/* verbose */
|
|
|
|
|
|
|
|
for ( i = 0; i < options->op_tbl->nelems; i++)
|
|
|
|
{
|
2003-12-30 04:26:21 +08:00
|
|
|
char* name=options->op_tbl->objs[i].path;
|
2003-10-23 05:43:34 +08:00
|
|
|
|
|
|
|
if (options->op_tbl->objs[i].chunk.rank>0)
|
|
|
|
{
|
|
|
|
if (options->verbose){
|
2003-12-30 04:26:21 +08:00
|
|
|
printf("\t<%s> with chunk size ",name);
|
2003-10-23 05:43:34 +08:00
|
|
|
for ( k = 0; k < options->op_tbl->objs[i].chunk.rank; k++)
|
2003-11-11 05:32:01 +08:00
|
|
|
printf("%d ",(int)options->op_tbl->objs[i].chunk.chunk_lengths[k]);
|
2003-10-23 05:43:34 +08:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
has_ck=1;
|
|
|
|
}
|
|
|
|
else if (options->op_tbl->objs[i].chunk.rank==-2)
|
|
|
|
{
|
|
|
|
if (options->verbose)
|
2003-12-30 04:26:21 +08:00
|
|
|
printf("\t%s %s\n",name,"NONE");
|
2003-10-23 05:43:34 +08:00
|
|
|
has_ck=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-31 06:59:33 +08:00
|
|
|
if (options->all_layout==1 && has_ck){
|
2003-12-30 04:26:21 +08:00
|
|
|
printf("Error: Invalid chunking input: all option\
|
|
|
|
is present with other objects\n");
|
2003-12-05 03:35:33 +08:00
|
|
|
return -1;
|
2003-10-23 05:43:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* objects to compress/uncompress
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (options->verbose)
|
|
|
|
{
|
2003-12-30 04:26:21 +08:00
|
|
|
printf("Objects to filter are...\n");
|
|
|
|
if (options->all_filter==1)
|
2003-10-23 05:43:34 +08:00
|
|
|
{
|
2003-12-30 04:26:21 +08:00
|
|
|
H5Z_filter_t filtn=options->filter_g.filtn;
|
|
|
|
switch (filtn)
|
2003-10-23 05:43:34 +08:00
|
|
|
{
|
|
|
|
case H5Z_FILTER_NONE:
|
2003-12-30 04:26:21 +08:00
|
|
|
printf("\tUncompress all %s\n",get_sfilter(filtn));
|
2003-10-23 05:43:34 +08:00
|
|
|
break;
|
|
|
|
case H5Z_FILTER_SZIP:
|
2003-12-30 04:26:21 +08:00
|
|
|
printf("\tCompress all with %s compression\n",get_sfilter(filtn));
|
2003-10-23 05:43:34 +08:00
|
|
|
break;
|
|
|
|
case H5Z_FILTER_DEFLATE:
|
|
|
|
printf("\tCompress all with %s compression, parameter %d\n",
|
2003-12-30 04:26:21 +08:00
|
|
|
get_sfilter(filtn),
|
|
|
|
options->filter_g.cd_values[0]);
|
2003-10-23 05:43:34 +08:00
|
|
|
break;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
} /* verbose */
|
|
|
|
|
|
|
|
for ( i = 0; i < options->op_tbl->nelems; i++)
|
|
|
|
{
|
2003-12-31 06:59:33 +08:00
|
|
|
pack_info_t pack = options->op_tbl->objs[i];
|
|
|
|
char* name = pack.path;
|
2004-01-07 01:49:00 +08:00
|
|
|
|
|
|
|
for ( j=0; j<pack.nfilters; j++)
|
2003-10-23 05:43:34 +08:00
|
|
|
{
|
2003-12-30 04:26:21 +08:00
|
|
|
if (options->verbose)
|
|
|
|
{
|
|
|
|
printf("\t<%s> with %s filter",
|
|
|
|
name,
|
2004-01-07 01:49:00 +08:00
|
|
|
get_sfilter(pack.filter[j].filtn));
|
2003-10-23 05:43:34 +08:00
|
|
|
}
|
2004-01-07 01:49:00 +08:00
|
|
|
|
2003-10-23 05:43:34 +08:00
|
|
|
has_cp=1;
|
2003-12-30 04:26:21 +08:00
|
|
|
|
|
|
|
/*check for invalid combination of options */
|
2004-01-07 01:49:00 +08:00
|
|
|
switch (pack.filter[j].filtn)
|
2003-12-30 04:26:21 +08:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case H5Z_FILTER_SZIP:
|
|
|
|
|
2004-01-07 01:49:00 +08:00
|
|
|
szip_pixels_per_block=pack.filter[j].cd_values[0];
|
2003-12-30 04:26:21 +08:00
|
|
|
|
|
|
|
/* check szip parameters */
|
2003-12-31 06:59:33 +08:00
|
|
|
if (check_szip(pack.chunk.rank,
|
|
|
|
pack.chunk.chunk_lengths,
|
2003-12-30 04:26:21 +08:00
|
|
|
0, /* do not test size */
|
|
|
|
szip_options_mask,
|
|
|
|
szip_pixels_per_block)==0)
|
|
|
|
{
|
|
|
|
/* Return: 1=can apply the filter
|
|
|
|
0=cannot apply the filter
|
|
|
|
Reset this object filter info
|
|
|
|
*/
|
|
|
|
|
2004-01-07 01:49:00 +08:00
|
|
|
options->op_tbl->objs[i].filter[j].filtn=-1;
|
2003-12-30 04:26:21 +08:00
|
|
|
options->op_tbl->objs[i].chunk.rank=-1;
|
|
|
|
printf("\tObject <%s> cannot be filtered\n",name);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
} /* switch */
|
2004-01-07 01:49:00 +08:00
|
|
|
} /* j */
|
2003-12-30 04:26:21 +08:00
|
|
|
} /* i */
|
2003-10-23 05:43:34 +08:00
|
|
|
|
2003-12-30 04:26:21 +08:00
|
|
|
if (options->all_filter==1 && has_cp){
|
|
|
|
printf("Error: Invalid compression input: all option\
|
|
|
|
is present with other objects\n");
|
2003-12-05 03:35:33 +08:00
|
|
|
return -1;
|
2003-10-23 05:43:34 +08:00
|
|
|
}
|
2003-12-05 03:35:33 +08:00
|
|
|
return 0;
|
2003-10-23 05:43:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: read_info
|
|
|
|
*
|
|
|
|
* Purpose: read comp and chunk options from file
|
|
|
|
*
|
|
|
|
* Return: void, exit on error
|
|
|
|
*
|
|
|
|
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
|
|
|
|
*
|
|
|
|
* Date: September, 22, 2003
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2003-11-11 04:59:32 +08:00
|
|
|
void read_info(const char *filename,
|
2003-10-29 01:40:05 +08:00
|
|
|
pack_opt_t *options)
|
2003-10-23 05:43:34 +08:00
|
|
|
{
|
2003-12-30 04:26:21 +08:00
|
|
|
|
2003-10-23 05:43:34 +08:00
|
|
|
char stype[10];
|
|
|
|
char comp_info[1024];
|
|
|
|
FILE *fp;
|
|
|
|
char c;
|
|
|
|
int i, rc=1;
|
|
|
|
|
|
|
|
|
|
|
|
if ((fp = fopen(filename, "r")) == (FILE *)NULL) {
|
|
|
|
printf( "Cannot open options file %s", filename);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Cycle until end of file reached */
|
|
|
|
while( 1 )
|
|
|
|
{
|
|
|
|
rc=fscanf(fp, "%s", stype);
|
|
|
|
if (rc==-1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* comp
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
if (strcmp(stype,"-t") == 0) {
|
|
|
|
|
|
|
|
/* find begining of info */
|
|
|
|
i=0; c='0';
|
|
|
|
while( c!='"' )
|
|
|
|
{
|
|
|
|
fscanf(fp, "%c", &c);
|
|
|
|
}
|
|
|
|
c='0';
|
|
|
|
/* go until end */
|
|
|
|
while( c!='"' )
|
|
|
|
{
|
|
|
|
fscanf(fp, "%c", &c);
|
|
|
|
comp_info[i]=c;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
comp_info[i-1]='\0'; /*cut the last " */
|
|
|
|
|
2003-12-30 04:26:21 +08:00
|
|
|
if (h5repack_addfilter(comp_info,options)==-1){
|
2003-10-23 05:43:34 +08:00
|
|
|
printf( "Could not add compression option. Exiting\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* chunk
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
else if (strcmp(stype,"-c") == 0) {
|
|
|
|
|
|
|
|
/* find begining of info */
|
|
|
|
i=0; c='0';
|
|
|
|
while( c!='"' )
|
|
|
|
{
|
|
|
|
fscanf(fp, "%c", &c);
|
|
|
|
}
|
|
|
|
c='0';
|
|
|
|
/* go until end */
|
|
|
|
while( c!='"' )
|
|
|
|
{
|
|
|
|
fscanf(fp, "%c", &c);
|
|
|
|
comp_info[i]=c;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
comp_info[i-1]='\0'; /*cut the last " */
|
|
|
|
|
2003-12-31 06:59:33 +08:00
|
|
|
if (h5repack_addlayout(comp_info,options)==-1){
|
2003-10-23 05:43:34 +08:00
|
|
|
printf( "Could not add chunck option. Exiting\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* not valid
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
else {
|
|
|
|
printf( "Bad file format for %s", filename);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|