summaryrefslogtreecommitdiffstats
path: root/tools/test/h5jam/getub.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /tools/test/h5jam/getub.c
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'tools/test/h5jam/getub.c')
-rw-r--r--tools/test/h5jam/getub.c73
1 files changed, 35 insertions, 38 deletions
diff --git a/tools/test/h5jam/getub.c b/tools/test/h5jam/getub.c
index f496a7a..9e9cd4d 100644
--- a/tools/test/h5jam/getub.c
+++ b/tools/test/h5jam/getub.c
@@ -21,11 +21,9 @@ void parse_command_line(int argc, const char *argv[]);
#define PROGRAM_NAME "getub"
char *nbytes = NULL;
-static const char *s_opts = "c:"; /* add more later ? */
-static struct long_options l_opts[] = {
- {"c", require_arg, 'c'}, /* input file */
- {NULL, 0, '\0'}
-};
+static const char * s_opts = "c:"; /* add more later ? */
+static struct long_options l_opts[] = {{"c", require_arg, 'c'}, /* input file */
+ {NULL, 0, '\0'}};
/*-------------------------------------------------------------------------
* Function: usage
@@ -36,7 +34,7 @@ static struct long_options l_opts[] = {
*-------------------------------------------------------------------------
*/
static void
-usage (const char *prog)
+usage(const char *prog)
{
HDfflush(stdout);
HDfprintf(stdout, "usage: %s -c nb file] \n", prog);
@@ -59,33 +57,33 @@ parse_command_line(int argc, const char *argv[])
int opt;
/* parse command line options */
- while((opt = get_option (argc, argv, s_opts, l_opts)) != EOF) {
- switch((char) opt) {
- case 'c':
- nbytes = HDstrdup(opt_arg);
- break;
- case '?':
- default:
- usage(h5tools_getprogname());
- HDexit(EXIT_FAILURE);
+ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ switch ((char)opt) {
+ case 'c':
+ nbytes = HDstrdup(opt_arg);
+ break;
+ case '?':
+ default:
+ usage(h5tools_getprogname());
+ HDexit(EXIT_FAILURE);
} /* end switch */
- } /* end while */
+ } /* end while */
- if(argc <= opt_ind) {
- error_msg("missing file name\n");
- usage(h5tools_getprogname());
- HDexit(EXIT_FAILURE);
+ if (argc <= opt_ind) {
+ error_msg("missing file name\n");
+ usage(h5tools_getprogname());
+ HDexit(EXIT_FAILURE);
} /* end if */
} /* end parse_command_line() */
int
main(int argc, const char *argv[])
{
- int fd = H5I_INVALID_HID;
+ int fd = H5I_INVALID_HID;
unsigned size;
- char *filename = NULL;
- long res;
- char *buf = NULL;
+ char * filename = NULL;
+ long res;
+ char * buf = NULL;
h5tools_setprogname(PROGRAM_NAME);
h5tools_setstatus(EXIT_SUCCESS);
@@ -95,14 +93,14 @@ main(int argc, const char *argv[])
parse_command_line(argc, argv);
- if(NULL == nbytes) {
+ if (NULL == nbytes) {
/* missing arg */
error_msg("missing size\n");
usage(h5tools_getprogname());
goto error;
} /* end if */
- if(argc <= (opt_ind)) {
+ if (argc <= (opt_ind)) {
error_msg("missing file name\n");
usage(h5tools_getprogname());
goto error;
@@ -111,30 +109,30 @@ main(int argc, const char *argv[])
filename = HDstrdup(argv[opt_ind]);
size = 0;
- if(EOF == (res = sscanf(nbytes, "%u", &size))) {
- /* fail */
- error_msg("missing file name\n");
- usage(h5tools_getprogname());
- goto error;
+ if (EOF == (res = sscanf(nbytes, "%u", &size))) {
+ /* fail */
+ error_msg("missing file name\n");
+ usage(h5tools_getprogname());
+ goto error;
} /* end if */
- if((fd = HDopen(filename, O_RDONLY, 0)) < 0) {
+ if ((fd = HDopen(filename, O_RDONLY, 0)) < 0) {
error_msg("can't open file %s\n", filename);
goto error;
} /* end if */
- if(NULL == (buf = (char *)HDmalloc((unsigned)(size + 1)))) {
+ if (NULL == (buf = (char *)HDmalloc((unsigned)(size + 1)))) {
error_msg("can't allocate buffer \n");
goto error;
} /* end if */
res = HDread(fd, buf, (unsigned)size);
- if(res < (long)size) {
+ if (res < (long)size) {
error_msg("Bad read \n");
goto error;
} /* end if */
- if(HDwrite(1, buf, (unsigned)size) < 0) {
+ if (HDwrite(1, buf, (unsigned)size) < 0) {
error_msg("Bad write \n");
goto error;
} /* end if */
@@ -146,10 +144,9 @@ main(int argc, const char *argv[])
return EXIT_SUCCESS;
error:
- if(buf)
+ if (buf)
HDfree(buf);
- if(fd >= 0)
+ if (fd >= 0)
HDclose(fd);
return EXIT_FAILURE;
} /* end main() */
-