diff options
Diffstat (limited to 'tools/h5repack/h5repack_parse.c')
-rw-r--r-- | tools/h5repack/h5repack_parse.c | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c index 2475068..f7188bf 100644 --- a/tools/h5repack/h5repack_parse.c +++ b/tools/h5repack/h5repack_parse.c @@ -67,12 +67,12 @@ obj_list_t* parse_filter(const char *str, char smask[3]; obj_list_t* obj_list=NULL; unsigned pixels_per_block; - - + + /* initialize compression info */ memset(filt,0,sizeof(filter_info_t)); *is_glb = 0; - + /* check for the end of object list and number of objects */ for ( i = 0, n = 0; i < len; i++) { @@ -86,14 +86,14 @@ obj_list_t* parse_filter(const char *str, n++; } } - + if (end_obj==-1) /* missing : */ - { + { /* apply to all objects */ options->all_filter=1; *is_glb = 1; } - + n++; obj_list = malloc(n*sizeof(obj_list_t)); if (obj_list==NULL) @@ -102,7 +102,7 @@ obj_list_t* parse_filter(const char *str, return NULL; } *n_objs=n; - + /* get object list */ for ( j = 0, k = 0, n = 0; j < end_obj; j++, k++) { @@ -124,8 +124,8 @@ obj_list_t* parse_filter(const char *str, error_msg(progname, "input Error: Invalid compression type in <%s>\n",str); exit(1); } - - + + /* get filter additional parameters */ m=0; for ( i=end_obj+1, k=0, j=0; i<len; i++,k++) @@ -135,9 +135,9 @@ obj_list_t* parse_filter(const char *str, if ( c=='=' || i==len-1) { if ( c=='=') /*one more parameter */ - { + { scomp[k]='\0'; /*cut space */ - + /*------------------------------------------------------------------------- * H5Z_FILTER_SZIP * szip has the format SZIP=<pixels per block,coding> @@ -182,14 +182,14 @@ obj_list_t* parse_filter(const char *str, error_msg(progname, "szip mask must be 'NN' or 'EC' \n"); exit(1); } - - + + } } - + } /* u */ } /*if */ - + /*------------------------------------------------------------------------- * H5Z_FILTER_SCALEOFFSET * scaleoffset has the format SOFF=<scale_factor,scale_type> @@ -204,7 +204,7 @@ obj_list_t* parse_filter(const char *str, * SOFF=3,DF *------------------------------------------------------------------------- */ - + else if (strcmp(scomp,"SOFF")==0) { l=-1; /* mask index check */ @@ -242,19 +242,19 @@ obj_list_t* parse_filter(const char *str, error_msg(progname, "scale type must be 'IN' or 'DS' \n"); exit(1); } - + } } - + } /* u */ } /*if */ - - + + /*------------------------------------------------------------------------- * all other filters *------------------------------------------------------------------------- */ - + else { /* here we could have 1 or 2 digits */ @@ -268,16 +268,16 @@ obj_list_t* parse_filter(const char *str, } stype[m]=c; } /* u */ - + stype[m]='\0'; } /*if */ - - - + + + filt->cd_values[j++]=atoi(stype); i+=m; /* jump */ } - else if (i==len-1) + else if (i==len-1) { /*no more parameters */ scomp[k+1]='\0'; no_param=1; @@ -287,7 +287,7 @@ obj_list_t* parse_filter(const char *str, * translate from string to filter symbol *------------------------------------------------------------------------- */ - + /*------------------------------------------------------------------------- * H5Z_FILTER_NONE *------------------------------------------------------------------------- @@ -297,7 +297,7 @@ obj_list_t* parse_filter(const char *str, filt->filtn=H5Z_FILTER_NONE; filt->cd_nelmts = 0; } - + /*------------------------------------------------------------------------- * H5Z_FILTER_DEFLATE *------------------------------------------------------------------------- @@ -306,14 +306,14 @@ obj_list_t* parse_filter(const char *str, { filt->filtn=H5Z_FILTER_DEFLATE; filt->cd_nelmts = 1; - if (no_param) + if (no_param) { /*no more parameters, GZIP must have parameter */ if (obj_list) free(obj_list); error_msg(progname, "missing compression parameter in <%s>\n",str); exit(1); } } - + /*------------------------------------------------------------------------- * H5Z_FILTER_SZIP *------------------------------------------------------------------------- @@ -322,14 +322,14 @@ obj_list_t* parse_filter(const char *str, { filt->filtn=H5Z_FILTER_SZIP; filt->cd_nelmts = 2; - if (no_param) + if (no_param) { /*no more parameters, SZIP must have parameter */ if (obj_list) free(obj_list); error_msg(progname, "missing compression parameter in <%s>\n",str); exit(1); } } - + /*------------------------------------------------------------------------- * H5Z_FILTER_SHUFFLE *------------------------------------------------------------------------- @@ -383,7 +383,7 @@ obj_list_t* parse_filter(const char *str, { filt->filtn=H5Z_FILTER_SCALEOFFSET; filt->cd_nelmts = 2; - if (no_param) + if (no_param) { /*no more parameters, SOFF must have parameter */ if (obj_list) free(obj_list); error_msg(progname, "missing compression parameter in <%s>\n",str); @@ -397,12 +397,12 @@ obj_list_t* parse_filter(const char *str, } } } /*i*/ - + /*------------------------------------------------------------------------- * check valid parameters *------------------------------------------------------------------------- */ - + switch (filt->filtn) { @@ -410,7 +410,7 @@ obj_list_t* parse_filter(const char *str, * H5Z_FILTER_DEFLATE *------------------------------------------------------------------------- */ - + case H5Z_FILTER_DEFLATE: if (filt->cd_values[0]<0 || filt->cd_values[0]>9 ) { @@ -419,27 +419,27 @@ obj_list_t* parse_filter(const char *str, exit(1); } break; - + /*------------------------------------------------------------------------- * H5Z_FILTER_SZIP *------------------------------------------------------------------------- */ - + case H5Z_FILTER_SZIP: pixels_per_block=filt->cd_values[0]; - if ((pixels_per_block%2)==1) + if ((pixels_per_block%2)==1) { if (obj_list) free(obj_list); error_msg(progname, "pixels_per_block is not even in <%s>\n",str); exit(1); } - if (pixels_per_block>H5_SZIP_MAX_PIXELS_PER_BLOCK) + if (pixels_per_block>H5_SZIP_MAX_PIXELS_PER_BLOCK) { if (obj_list) free(obj_list); error_msg(progname, "pixels_per_block is too large in <%s>\n",str); exit(1); } - if ( (strcmp(smask,"NN")!=0) && (strcmp(smask,"EC")!=0) ) + if ( (strcmp(smask,"NN")!=0) && (strcmp(smask,"EC")!=0) ) { if (obj_list) free(obj_list); error_msg(progname, "szip mask must be 'NN' or 'EC' \n"); @@ -461,7 +461,7 @@ obj_list_t* parse_filter(const char *str, } break; }; - + return obj_list; } @@ -501,12 +501,12 @@ obj_list_t* parse_layout(const char *str, char sobj[MAX_NC_NAME]; char sdim[10]; char slayout[10]; - - + + memset(sdim, '\0', sizeof(sdim)); memset(sobj, '\0', sizeof(sobj)); memset(slayout, '\0', sizeof(slayout)); - + /* check for the end of object list and number of objects */ for ( i=0, n=0; i<len; i++) { @@ -520,11 +520,11 @@ obj_list_t* parse_layout(const char *str, n++; } } - + if (end_obj==-1) { /* missing : chunk all */ options->all_layout=1; } - + n++; obj_list=malloc(n*sizeof(obj_list_t)); if (obj_list==NULL) @@ -533,7 +533,7 @@ obj_list_t* parse_layout(const char *str, return NULL; } *n_objs=n; - + /* get object list */ for ( j=0, k=0, n=0; j<end_obj; j++,k++) { @@ -548,7 +548,7 @@ obj_list_t* parse_layout(const char *str, k=-1; } } - + /* nothing after : */ if (end_obj+1==(int)len) { @@ -556,7 +556,7 @@ obj_list_t* parse_layout(const char *str, error_msg(progname, "in parse layout, no characters after : in <%s>\n",str); exit(1); } - + /* get layout info */ for ( j=end_obj+1, n=0; n<=5; j++,n++) { @@ -580,30 +580,30 @@ obj_list_t* parse_layout(const char *str, slayout[n]=c; } } /* j */ - - + + if ( pack->layout==H5D_CHUNKED ) { - + /*------------------------------------------------------------------------- * get chunk info *------------------------------------------------------------------------- */ k=0; - + if (j>(int)len) { if (obj_list) free(obj_list); error_msg(progname, "in parse layout, <%s> Chunk dimensions missing\n",str); exit(1); } - + for ( i=j, c_index=0; i<len; i++) { c = str[i]; sdim[k]=c; k++; /*increment sdim index */ - + if (!isdigit(c) && c!='x' && c!='N' && c!='O' && c!='N' && c!='E' ){ @@ -612,7 +612,7 @@ obj_list_t* parse_layout(const char *str, sdim,str); exit(1); } - + if ( c=='x' || i==len-1) { if ( c=='x') { @@ -648,11 +648,11 @@ obj_list_t* parse_layout(const char *str, } /*if */ } /*if c=='x' || i==len-1 */ } /*i*/ - - + + } /*H5D_CHUNKED*/ - - + + return obj_list; } |