summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/h5repack/h5repack.c16
-rw-r--r--tools/h5repack/h5repack.h8
-rw-r--r--tools/h5repack/h5repack_list.c9
-rw-r--r--tools/h5repack/h5repack_list.h8
-rw-r--r--tools/h5repack/h5repack_opttable.c2
-rw-r--r--tools/h5repack/h5repack_opttable.h2
-rw-r--r--tools/h5repack/h5repack_parse.c23
-rw-r--r--tools/h5repack/h5repack_parse.h11
-rw-r--r--tools/h5repack/test_h5repack_add.c6
-rw-r--r--tools/h5repack/test_h5repack_main.c6
10 files changed, 58 insertions, 33 deletions
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c
index fa66ae4..91f21dd 100644
--- a/tools/h5repack/h5repack.c
+++ b/tools/h5repack/h5repack.c
@@ -42,8 +42,8 @@ static void print_options(pack_opt_t *options);
*
*-------------------------------------------------------------------------
*/
-int h5repack(char* infile,
- char* outfile,
+int h5repack(const char* infile,
+ const char* outfile,
pack_opt_t *options)
{
options->trip=0;
@@ -113,7 +113,7 @@ int h5repack_end (pack_opt_t *options)
*-------------------------------------------------------------------------
*/
-int h5repack_addcomp(char* str,
+int h5repack_addcomp(const char* str,
pack_opt_t *options)
{
obj_list_t *obj_list=NULL; /*one object list for the -t and -c option entry */
@@ -128,6 +128,8 @@ int h5repack_addcomp(char* str,
/* parse the -t option */
obj_list=parse_comp(str,&n_objs,&comp);
+ if (obj_list==NULL)
+ return -1;
/* searh for the "*" all objects character */
for (i = 0; i < n_objs; i++)
@@ -150,6 +152,8 @@ int h5repack_addcomp(char* str,
if (options->all_comp==0)
options_add_comp(obj_list,n_objs,comp,options->op_tbl);
+
+ free(obj_list);
return 0;
}
@@ -166,7 +170,7 @@ int h5repack_addcomp(char* str,
*/
-int h5repack_addchunk(char* str,
+int h5repack_addchunk(const char* str,
pack_opt_t *options)
{
@@ -183,6 +187,8 @@ int h5repack_addchunk(char* str,
/* parse the -c option */
obj_list=parse_chunk(str,&n_objs,chunk_lengths,&chunk_rank);
+ if (obj_list==NULL)
+ return -1;
/* searh for the "*" all objects character */
for (i = 0; i < n_objs; i++)
@@ -339,7 +345,7 @@ void print_options(pack_opt_t *options)
*-------------------------------------------------------------------------
*/
-void read_info(char *filename,
+void read_info(const char *filename,
pack_opt_t *options)
{
char stype[10];
diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h
index 01eef14..a1085da 100644
--- a/tools/h5repack/h5repack.h
+++ b/tools/h5repack/h5repack.h
@@ -101,9 +101,9 @@ typedef struct {
extern "C" {
#endif
-int h5repack (char* infile, char* outfile, pack_opt_t *options);
-int h5repack_addcomp (char* str, pack_opt_t *options);
-int h5repack_addchunk(char* str, pack_opt_t *options);
+int h5repack (const char* infile, const char* outfile, pack_opt_t *options);
+int h5repack_addcomp (const char* str, pack_opt_t *options);
+int h5repack_addchunk(const char* str, pack_opt_t *options);
int h5repack_init (pack_opt_t *options, int verbose);
int h5repack_end (pack_opt_t *options);
@@ -117,7 +117,7 @@ int h5repack_end (pack_opt_t *options);
*/
-void read_info(char *filename,pack_opt_t *options);
+void read_info(const char *filename,pack_opt_t *options);
diff --git a/tools/h5repack/h5repack_list.c b/tools/h5repack/h5repack_list.c
index 81b56ce..f1142f2 100644
--- a/tools/h5repack/h5repack_list.c
+++ b/tools/h5repack/h5repack_list.c
@@ -37,7 +37,8 @@
*/
-int get_objlist(char* fname, pack_opt_t *options)
+int get_objlist(const char* fname,
+ pack_opt_t *options)
{
hid_t fid;
int nobjects, i;
@@ -139,8 +140,8 @@ int get_objlist(char* fname, pack_opt_t *options)
*-------------------------------------------------------------------------
*/
-int copy_file(char* fnamein,
- char* fnameout,
+int copy_file(const char* fnamein,
+ const char* fnameout,
pack_opt_t *options)
{
hid_t fidin;
@@ -231,7 +232,7 @@ int copy_file(char* fnamein,
*
*-------------------------------------------------------------------------
*/
-void print_objlist(char *filename,
+void print_objlist(const char *filename,
int nobjects,
trav_info_t *info )
{
diff --git a/tools/h5repack/h5repack_list.h b/tools/h5repack/h5repack_list.h
index fd10c6b..29f16e6 100644
--- a/tools/h5repack/h5repack_list.h
+++ b/tools/h5repack/h5repack_list.h
@@ -27,14 +27,14 @@
*/
-int get_objlist(char* infname,
+int get_objlist(const char* infname,
pack_opt_t *options);
-int copy_file(char* fnamein,
- char* fnameout,
+int copy_file(const char* fnamein,
+ const char* fnameout,
pack_opt_t *options);
-void print_objlist(char *filename,
+void print_objlist(const char *filename,
int nobjects,
trav_info_t *info );
diff --git a/tools/h5repack/h5repack_opttable.c b/tools/h5repack/h5repack_opttable.c
index b7019eb..f9d42b7 100644
--- a/tools/h5repack/h5repack_opttable.c
+++ b/tools/h5repack/h5repack_opttable.c
@@ -272,7 +272,7 @@ int options_add_comp( obj_list_t *obj_list,
*-------------------------------------------------------------------------
*/
-pack_info_t* options_get_object( char *path,
+pack_info_t* options_get_object( const char *path,
pack_opttbl_t *table )
{
int i;
diff --git a/tools/h5repack/h5repack_opttable.h b/tools/h5repack/h5repack_opttable.h
index 0bb1292..e9d0c9a 100644
--- a/tools/h5repack/h5repack_opttable.h
+++ b/tools/h5repack/h5repack_opttable.h
@@ -36,7 +36,7 @@ int options_add_comp ( obj_list_t *obj_list,
int n_objs,
comp_info_t comp,
pack_opttbl_t *table );
-pack_info_t* options_get_object( char *path,
+pack_info_t* options_get_object( const char *path,
pack_opttbl_t *table);
diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c
index 36f6884..beaa9a6 100644
--- a/tools/h5repack/h5repack_parse.c
+++ b/tools/h5repack/h5repack_parse.c
@@ -25,10 +25,11 @@
* Purpose: read compression info
*
* Return: a list of names, the number of names and its compression type
+ * NULL, on error
*
* Examples:
* "AA,B,CDE:RLE"
- * "*:GZIP 6"
+ * "GZIP 6"
* "A,B:NONE"
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
@@ -39,7 +40,9 @@
*/
-obj_list_t* parse_comp(char *str, int *n_objs, comp_info_t *comp)
+obj_list_t* parse_comp(const char *str,
+ int *n_objs,
+ comp_info_t *comp)
{
unsigned i, u;
char c;
@@ -74,6 +77,11 @@ obj_list_t* parse_comp(char *str, int *n_objs, comp_info_t *comp)
n++;
obj_list=malloc(n*sizeof(obj_list_t));
+ if (obj_list==NULL)
+ {
+ printf("Could not alloc object list\n");
+ return NULL;
+ }
*n_objs=n;
/* get object list */
@@ -114,6 +122,7 @@ obj_list_t* parse_comp(char *str, int *n_objs, comp_info_t *comp)
for ( m=0,u=i+1; u<len; u++,m++) {
c = str[u];
if (!isdigit(c)){
+ if (obj_list) free(obj_list);
printf("Input Error: Compression parameter not digit in <%s>\n",str);
exit(1);
}
@@ -221,10 +230,11 @@ char* get_scomp(int code)
* Purpose: read chunkink info
*
* Return: a list of names, the number of names and its chunking info
+ * NULL, on error
*
* Examples:
* "AA,B,CDE:10X10
- * "*:10X10"
+ * "10X10"
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
@@ -234,7 +244,7 @@ char* get_scomp(int code)
*/
-obj_list_t* parse_chunk(char *str,
+obj_list_t* parse_chunk(const char *str,
int *n_objs,
hsize_t *chunk_lengths,
int *chunk_rank)
@@ -268,6 +278,11 @@ obj_list_t* parse_chunk(char *str,
n++;
obj_list=malloc(n*sizeof(obj_list_t));
+ if (obj_list==NULL)
+ {
+ printf("Could not alloc object list\n");
+ return NULL;
+ }
*n_objs=n;
/* get object list */
diff --git a/tools/h5repack/h5repack_parse.h b/tools/h5repack/h5repack_parse.h
index a3c5715..4a8616b 100644
--- a/tools/h5repack/h5repack_parse.h
+++ b/tools/h5repack/h5repack_parse.h
@@ -25,10 +25,15 @@
*-------------------------------------------------------------------------
*/
+obj_list_t* parse_comp (const char *str,
+ int *n_objs,
+ comp_info_t *comp);
+obj_list_t* parse_chunk (const char *str,
+ int *n_objs,
+ hsize_t *chunk_lengths,
+ int *chunk_rank);
+char* get_scomp (int code);
int parse_number(char *str);
-obj_list_t* parse_comp(char *str, int *n_objs, comp_info_t *comp);
-char* get_scomp(int code);
-obj_list_t* parse_chunk(char *str, int *n_objs, hsize_t *chunk_lengths, int *chunk_rank);
#endif /* H5REPACK_PARSE_H__ */
diff --git a/tools/h5repack/test_h5repack_add.c b/tools/h5repack/test_h5repack_add.c
index faaa9c3..dc3250f 100644
--- a/tools/h5repack/test_h5repack_add.c
+++ b/tools/h5repack/test_h5repack_add.c
@@ -41,7 +41,7 @@ make_deflate(hid_t fid)
int rank=2;
hsize_t dims[2]={4,2};
hsize_t chunk_dims[2]={2,1};
- int buf[4][2]={1,2,3,4,5,6,7,8};
+ int buf[4][2]={{1,2},{3,4},{5,6},{7,8}};
/* create a space */
if((sid = H5Screate_simple(rank, dims, NULL))<0)
@@ -103,7 +103,7 @@ make_szip(hid_t fid)
int rank=2;
hsize_t dims[2]={4,2};
hsize_t chunk_dims[2]={2,1};
- int buf[4][2]={1,2,3,4,5,6,7,8};
+ int buf[4][2]={{1,2},{3,4},{5,6},{7,8}};
unsigned szip_options_mask=H5_SZIP_ALLOW_K13_OPTION_MASK|H5_SZIP_NN_OPTION_MASK;
unsigned szip_pixels_per_block;
@@ -177,9 +177,7 @@ int make_dsets()
TEST_ERROR;
nerrors += make_deflate(fid);
-#if 1
nerrors += make_szip(fid);
-#endif
/* close */
if(H5Fclose(fid)<0)
diff --git a/tools/h5repack/test_h5repack_main.c b/tools/h5repack/test_h5repack_main.c
index b647427..406c94f 100644
--- a/tools/h5repack/test_h5repack_main.c
+++ b/tools/h5repack/test_h5repack_main.c
@@ -18,9 +18,6 @@
#include "h5diff.h"
#include "test_h5repack_add.h"
-
-
-
/*-------------------------------------------------------------------------
* Function: test
*
@@ -48,6 +45,9 @@ test()
diff_opt_t diff_options;
memset(&diff_options, 0, sizeof (diff_opt_t));
+ /* compare attributes in h5diff */
+ diff_options.attr=1;
+
TESTING(" deflate filter");
if (h5repack_init (&pack_options, 0)<0)