summaryrefslogtreecommitdiffstats
path: root/tools/h5repack/h5repack_main.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-09-16 15:52:51 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-09-16 15:52:51 (GMT)
commitbdd7d59902483885dd8b883f3b2393e77383e5e8 (patch)
treeaaf20ab132d057b95b3c016d50fc22b77719084b /tools/h5repack/h5repack_main.c
parent8bc0d5ed9019a681e1ea20c24264415d01c1cf2a (diff)
downloadhdf5-bdd7d59902483885dd8b883f3b2393e77383e5e8.zip
hdf5-bdd7d59902483885dd8b883f3b2393e77383e5e8.tar.gz
hdf5-bdd7d59902483885dd8b883f3b2393e77383e5e8.tar.bz2
[svn-r15628] Description:
Remove trailing whitespace from C/C++ source files, with the following script: foreach f (*.[ch] *.cpp) sed 's/[[:blank:]]*$//' $f > sed.out && mv sed.out $f end Tested on: Mac OS X/32 10.5.5 (amazon) No need for h5committest, just whitespace changes...
Diffstat (limited to 'tools/h5repack/h5repack_main.c')
-rw-r--r--tools/h5repack/h5repack_main.c204
1 files changed, 102 insertions, 102 deletions
diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c
index f457f23..a2f4b14 100644
--- a/tools/h5repack/h5repack_main.c
+++ b/tools/h5repack/h5repack_main.c
@@ -74,9 +74,9 @@ static struct long_options l_opts[] = {
*
* Comments:
*
- * Modifications:
+ * Modifications:
* July 2004: Introduced the extra EC or NN option for SZIP
- * October 2006: Added a new switch -n, that allows to write the dataset
+ * October 2006: Added a new switch -n, that allows to write the dataset
* using a native type. The default to write is the file type.
*
* Modification:
@@ -87,11 +87,11 @@ static struct long_options l_opts[] = {
* PVN, November 28, 2007
* added support for multiple global filters
* PVN, May 16, 2008
- * added backward compatibility for -i infile -o outfile
+ * added backward compatibility for -i infile -o outfile
* PVN, August 20, 2008
* add a user block to repacked file (switches -u -b)
* PVN, August 28, 2008
- * add options to set alignment (H5Pset_alignment) (switches -t -a)
+ * add options to set alignment (H5Pset_alignment) (switches -t -a)
*-------------------------------------------------------------------------
*/
int main(int argc, char **argv)
@@ -101,15 +101,15 @@ int main(int argc, char **argv)
pack_opt_t options; /*the global options */
int ret=-1;
int i;
-
+
/* initialize options */
h5repack_init (&options,0);
/* detect -i or -o for file names */
for ( i = 1; i < argc; i++)
{
-
- if (strcmp(argv[i], "-i") == 0)
+
+ if (strcmp(argv[i], "-i") == 0)
{
has_i_o = 1;
}
@@ -121,104 +121,104 @@ int main(int argc, char **argv)
if (has_i_o)
{
-
+
for ( i = 1; i < argc; i++)
{
- if (strcmp(argv[i], "-h") == 0)
+ if (strcmp(argv[i], "-h") == 0)
{
usage(progname);
exit(0);
}
- if (strcmp(argv[i], "-i") == 0)
+ if (strcmp(argv[i], "-i") == 0)
{
infile = argv[++i];
}
- else if (strcmp(argv[i], "-o") == 0)
+ else if (strcmp(argv[i], "-o") == 0)
{
outfile = argv[++i];
}
- else if (strcmp(argv[i], "-v") == 0)
+ else if (strcmp(argv[i], "-v") == 0)
{
options.verbose = 1;
}
- else if (strcmp(argv[i], "-f") == 0)
+ else if (strcmp(argv[i], "-f") == 0)
{
-
+
/* add the -f filter option */
if (h5repack_addfilter(argv[i+1],&options)<0)
{
error_msg(progname, "in parsing filter\n");
exit(1);
}
-
+
/* jump to next */
++i;
}
- else if (strcmp(argv[i], "-l") == 0)
+ else if (strcmp(argv[i], "-l") == 0)
{
-
+
/* parse the -l layout option */
if (h5repack_addlayout(argv[i+1],&options)<0)
{
error_msg(progname, "in parsing layout\n");
exit(1);
}
-
+
/* jump to next */
++i;
}
-
- else if (strcmp(argv[i], "-m") == 0)
+
+ else if (strcmp(argv[i], "-m") == 0)
{
options.min_comp = parse_number(argv[i+1]);
- if ((int)options.min_comp<=0)
+ if ((int)options.min_comp<=0)
{
error_msg(progname, "invalid minimum compress size <%s>\n",argv[i+1]);
exit(1);
}
++i;
}
-
- else if (strcmp(argv[i], "-e") == 0)
+
+ else if (strcmp(argv[i], "-e") == 0)
{
read_info(argv[++i],&options);
}
- else if (strcmp(argv[i], "-n") == 0)
+ else if (strcmp(argv[i], "-n") == 0)
{
options.use_native = 1;
}
- else if (strcmp(argv[i], "-L") == 0)
+ else if (strcmp(argv[i], "-L") == 0)
{
options.latest = 1;
}
- else if (strcmp(argv[i], "-c") == 0)
+ else if (strcmp(argv[i], "-c") == 0)
{
options.grp_compact = atoi( argv[++i] );
if (options.grp_compact>0)
- options.latest = 1; /* must use latest format */
+ options.latest = 1; /* must use latest format */
}
- else if (strcmp(argv[i], "-d") == 0)
+ else if (strcmp(argv[i], "-d") == 0)
{
options.grp_indexed = atoi( argv[++i] );
if (options.grp_indexed>0)
- options.latest = 1; /* must use latest format */
+ options.latest = 1; /* must use latest format */
}
- else if (strcmp(argv[i], "-s") == 0)
+ else if (strcmp(argv[i], "-s") == 0)
{
-
+
char *s = argv[++i];
int idx = 0;
int ssize = 0;
char *msgPtr = strchr( s, ':');
options.latest = 1; /* must use latest format */
- if (msgPtr == NULL)
+ if (msgPtr == NULL)
{
ssize = atoi( s );
for (idx=0; idx<5; idx++)
- options.msg_size[idx] = ssize;
+ options.msg_size[idx] = ssize;
}
- else
+ else
{
char msgType[10];
strcpy(msgType, msgPtr+1);
@@ -239,66 +239,66 @@ int main(int argc, char **argv)
else if (strncmp(msgType, "attr",4) == 0) {
options.msg_size[4] = ssize;
}
- }
-
+ }
+
}
-
-
+
+
else if (argv[i][0] == '-') {
error_msg(progname, " - is not a valid argument\n");
usage(progname);
exit(1);
}
}
-
+
if (infile == NULL || outfile == NULL)
{
error_msg(progname, "file names missing\n");
usage(progname);
exit(1);
}
-
+
}
-
+
else
-
+
{
-
+
parse_command_line(argc, argv, &options);
-
-
-
- if ( argv[ opt_ind ] != NULL && argv[ opt_ind + 1 ] != NULL )
+
+
+
+ if ( argv[ opt_ind ] != NULL && argv[ opt_ind + 1 ] != NULL )
{
infile = argv[ opt_ind ];
outfile = argv[ opt_ind + 1 ];
-
+
if ( strcmp( infile, outfile ) == 0 )
{
error_msg(progname, "file names cannot be the same\n");
usage(progname);
exit(EXIT_FAILURE);
-
+
}
}
-
+
else
{
error_msg(progname, "file names missing\n");
usage(progname);
exit(EXIT_FAILURE);
}
-
+
}
-
+
/* pack it */
ret=h5repack(infile,outfile,&options);
-
+
/* free tables */
h5repack_end(&options);
-
+
if (ret==-1)
return 1;
else
@@ -338,7 +338,7 @@ static void usage(const char *prog)
printf(" -a A, --alignment=A Alignment value for H5Pset_alignment\n");
printf(" -f FILT, --filter=FILT Filter type\n");
printf(" -l LAYT, --layout=LAYT Layout type\n");
-
+
printf("\n");
printf(" M - is an integer greater than 1, size of dataset in bytes \n");
@@ -432,13 +432,13 @@ static void usage(const char *prog)
static void parse_command_line(int argc, const char* argv[], pack_opt_t* options)
{
-
+
int opt;
-
+
/* parse command line options */
- while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF)
+ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF)
{
- switch ((char)opt)
+ switch ((char)opt)
{
case 'h':
usage(progname);
@@ -450,7 +450,7 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options
options->verbose = 1;
break;
case 'f':
-
+
/* parse the -f filter option */
if (h5repack_addfilter( opt_arg, options)<0)
{
@@ -459,7 +459,7 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options
}
break;
case 'l':
-
+
/* parse the -l layout option */
if (h5repack_addlayout( opt_arg, options)<0)
{
@@ -467,18 +467,18 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options
exit(EXIT_FAILURE);
}
break;
-
+
case 'm':
options->min_comp = parse_number( opt_arg );
- if ((int)options->min_comp<=0)
+ if ((int)options->min_comp<=0)
{
error_msg(progname, "invalid minimum compress size <%s>\n", opt_arg );
exit(EXIT_FAILURE);
}
break;
-
+
case 'e':
read_info( opt_arg, options);
break;
@@ -486,19 +486,19 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options
case 'n':
options->use_native = 1;
break;
-
+
case 'L':
- options->latest = 1;
+ options->latest = 1;
break;
-
+
case 'c':
options->grp_compact = atoi( opt_arg );
if (options->grp_compact>0)
options->latest = 1; /* must use latest format */
break;
-
-
+
+
case 'd':
options->grp_indexed = atoi( opt_arg );
@@ -509,18 +509,18 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options
case 's':
{
-
+
int idx = 0;
int ssize = 0;
char *msgPtr = strchr( opt_arg, ':');
options->latest = 1; /* must use latest format */
- if (msgPtr == NULL)
+ if (msgPtr == NULL)
{
ssize = atoi( opt_arg );
for (idx=0; idx<5; idx++)
- options->msg_size[idx] = ssize;
+ options->msg_size[idx] = ssize;
}
- else
+ else
{
char msgType[10];
strcpy(msgType, msgPtr+1);
@@ -541,26 +541,26 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options
else if (strncmp(msgType, "attr", 4) == 0) {
options->msg_size[4] = ssize;
}
- }
+ }
}
-
+
break;
-
+
case 'u':
-
+
options->ublock_filename = opt_arg;
break;
-
+
case 'b':
-
+
options->ublock_size = atoi( opt_arg );
break;
case 't':
-
+
options->threshold = atoi( opt_arg );
- if ( options->threshold < 0 )
+ if ( options->threshold < 0 )
{
error_msg(progname, "invalid threshold size\n", opt_arg );
exit(EXIT_FAILURE);
@@ -568,9 +568,9 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options
break;
case 'a':
-
+
options->alignment = atoi( opt_arg );
- if ( options->alignment < 1 )
+ if ( options->alignment < 1 )
{
error_msg(progname, "invalid alignment size\n", opt_arg );
exit(EXIT_FAILURE);
@@ -578,21 +578,21 @@ static void parse_command_line(int argc, const char* argv[], pack_opt_t* options
break;
} /* switch */
-
-
+
+
} /* while */
-
+
/* check for file names to be processed */
- if (argc <= opt_ind || argv[ opt_ind + 1 ] == NULL)
+ if (argc <= opt_ind || argv[ opt_ind + 1 ] == NULL)
{
error_msg(progname, "missing file names\n");
usage(progname);
exit(EXIT_FAILURE);
}
-
-
-
+
+
+
}
/*-------------------------------------------------------------------------
@@ -616,7 +616,7 @@ int parse_number(char *str)
int n;
char c;
size_t len=strlen(str);
-
+
for ( i=0; i<len; i++)
{
c = str[i];
@@ -648,7 +648,7 @@ static
void read_info(const char *filename,
pack_opt_t *options)
{
-
+
char stype[10];
char comp_info[1024];
FILE *fp;
@@ -656,33 +656,33 @@ void read_info(const char *filename,
int i, rc=1;
char *srcdir = getenv("srcdir"); /* the source directory */
char data_file[512]=""; /* buffer to hold name of existing file */
-
+
/* compose the name of the file to open, using the srcdir, if appropriate */
if (srcdir){
strcpy(data_file,srcdir);
strcat(data_file,"/");
}
strcat(data_file,filename);
-
-
+
+
if ((fp = fopen(data_file, "r")) == (FILE *)NULL) {
error_msg(progname, "cannot open options file %s\n", filename);
exit(1);
}
-
+
/* cycle until end of file reached */
while( 1 )
{
rc=fscanf(fp, "%s", stype);
if (rc==-1)
break;
-
+
/*-------------------------------------------------------------------------
* filter
*-------------------------------------------------------------------------
*/
if (strcmp(stype,"-f") == 0) {
-
+
/* find begining of info */
i=0; c='0';
while( c!=' ' )
@@ -701,7 +701,7 @@ void read_info(const char *filename,
if (c==10 /*eol*/) break;
}
comp_info[i-1]='\0'; /*cut the last " */
-
+
if (h5repack_addfilter(comp_info,options)==-1){
error_msg(progname, "could not add compression option\n");
exit(1);
@@ -712,7 +712,7 @@ void read_info(const char *filename,
*-------------------------------------------------------------------------
*/
else if (strcmp(stype,"-l") == 0) {
-
+
/* find begining of info */
i=0; c='0';
while( c!=' ' )
@@ -731,7 +731,7 @@ void read_info(const char *filename,
if (c==10 /*eol*/) break;
}
comp_info[i-1]='\0'; /*cut the last " */
-
+
if (h5repack_addlayout(comp_info,options)==-1){
error_msg(progname, "could not add chunck option\n");
exit(1);
@@ -746,7 +746,7 @@ void read_info(const char *filename,
exit(1);
}
}
-
+
fclose(fp);
return;
}