diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2011-07-11 15:39:02 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2011-07-11 15:39:02 (GMT) |
commit | 3397a114ced762dd088c674ff9bca5a950428927 (patch) | |
tree | 45d0dddec486eda498d503b97eb267c730d951dc | |
parent | eddfc8bbc348e7a5064136ff9fc715698d0aabbe (diff) | |
download | hdf5-3397a114ced762dd088c674ff9bca5a950428927.zip hdf5-3397a114ced762dd088c674ff9bca5a950428927.tar.gz hdf5-3397a114ced762dd088c674ff9bca5a950428927.tar.bz2 |
[svn-r21091] Replace #ifdef WIN32 around 64 bit integers with H5_SIZEOF_LONG_LONG. This is set if 64-bit integers are supported.
Tested: local linux
-rwxr-xr-x | tools/h5import/h5import.c | 185 | ||||
-rwxr-xr-x | tools/h5import/h5importtest.c | 94 |
2 files changed, 126 insertions, 153 deletions
diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c index bbd8746..cfed58b 100755 --- a/tools/h5import/h5import.c +++ b/tools/h5import/h5import.c @@ -25,6 +25,12 @@ /* Name of tool */ #define PROGRAMNAME "h5import" +#ifdef WIN32 +#define READ_OPEN_FLAGS "rb" +#else +#define READ_OPEN_FLAGS "r" +#endif + int main(int argc, char *argv[]) { struct Options opt; @@ -50,8 +56,8 @@ int main(int argc, char *argv[]) (void) HDsetvbuf(stderr, (char *) NULL, _IOLBF, 0); (void) HDsetvbuf(stdout, (char *) NULL, _IOLBF, 0); - if (argv[1] && (strcmp("-V", argv[1]) == 0)) { - print_version("h5import"); + if (argv[1] && (HDstrcmp("-V", argv[1]) == 0)) { + print_version(PROGRAMNAME); exit(EXIT_SUCCESS); } @@ -185,15 +191,15 @@ int main(int argc, char *argv[]) for (i = 0; i < opt.fcount; i++) { in = &(opt.infiles[i].in); if (in->sizeOfDimension) - free(in->sizeOfDimension); + HDfree(in->sizeOfDimension); if (in->sizeOfChunk) - free(in->sizeOfChunk); + HDfree(in->sizeOfChunk); if (in->maxsizeOfDimension) - free(in->maxsizeOfDimension); + HDfree(in->maxsizeOfDimension); if (in->externFilename) - free(in->externFilename); + HDfree(in->externFilename); if (in->data) - free(in->data); + HDfree(in->data); } return (EXIT_SUCCESS); @@ -202,15 +208,15 @@ err: for (i = 0; i < opt.fcount; i++) { in = &(opt.infiles[i].in); if (in->sizeOfDimension) - free(in->sizeOfDimension); + HDfree(in->sizeOfDimension); if (in->sizeOfChunk) - free(in->sizeOfChunk); + HDfree(in->sizeOfChunk); if (in->maxsizeOfDimension) - free(in->maxsizeOfDimension); + HDfree(in->maxsizeOfDimension); if (in->externFilename) - free(in->externFilename); + HDfree(in->externFilename); if (in->data) - free(in->data); + HDfree(in->data); } return (EXIT_FAILURE); } @@ -311,28 +317,17 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id) */ if (in->inputClass == 4 /* "IN" */|| in->inputClass == 3 /* "FP" */|| in->inputClass == 7 /* "UIN" */) { -#ifdef WIN32 - - if ((strm = fopen(infile, "rb")) == NULL) { - (void) fprintf(stderr, err1, infile); - return(-1); - } -#else - - if ((strm = fopen(infile, "r")) == NULL) { + if ((strm = HDfopen(infile, READ_OPEN_FLAGS)) == NULL) { (void) fprintf(stderr, err1, infile); return (-1); } - -#endif - } /*------------------------------------------------------------------------- * if the input class is not binary, just use "r" *------------------------------------------------------------------------- */ else { - if ((strm = fopen(infile, "r")) == NULL) { + if ((strm = HDfopen(infile, "r")) == NULL) { (void) fprintf(stderr, err1, infile); return (-1); } @@ -343,13 +338,13 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id) case 4: /* IN */ if (allocateIntegerStorage(in) == -1) { (void) fprintf(stderr, err2, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (readIntegerData(strm, in) == -1) { (void) fprintf(stderr, err4, infile); - fclose(strm); + HDfclose(strm); return (-1); } break; @@ -359,14 +354,14 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id) case 3: /* FP */ if (allocateFloatStorage(in) == -1) { (void) fprintf(stderr, err3, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (readFloatData(strm, in) == -1) { (void) fprintf(stderr, err5, infile); - fclose(strm); + HDfclose(strm); return (-1); } break; @@ -375,7 +370,7 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id) if (processStrData(strm, in, file_id) == -1) { (void) fprintf(stderr, err11, infile); - fclose(strm); + HDfclose(strm); return (-1); } @@ -385,22 +380,22 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id) case 7: /* UIN */ if (allocateUIntegerStorage(in) == -1) { (void) fprintf(stderr, err6, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (readUIntegerData(strm, in) == -1) { (void) fprintf(stderr, err7, infile); - fclose(strm); + HDfclose(strm); return (-1); } break; default: (void) fprintf(stderr, "%s", err10); - fclose(strm); + HDfclose(strm); return (-1); } - fclose(strm); + HDfclose(strm); return (0); } @@ -410,7 +405,7 @@ static int readIntegerData(FILE *strm, struct Input *in) H5DT_INT16 *in16; H5DT_INT16 temp; H5DT_INT32 *in32; -#ifndef WIN32 +#ifdef H5_SIZEOF_LONG_LONG H5DT_INT64 *in64; char buffer[256]; #endif @@ -442,7 +437,7 @@ static int readIntegerData(FILE *strm, struct Input *in) case 4: /* IN */ in08 = (H5DT_INT8 *) in->data; for (i = 0; i < len; i++, in08++) { - if (fread((char *) in08, sizeof(H5DT_INT8), 1, strm) != 1) { + if (HDfread((char *) in08, sizeof(H5DT_INT8), 1, strm) != 1) { (void) fprintf(stderr, "%s", err1); return (-1); } @@ -470,7 +465,7 @@ static int readIntegerData(FILE *strm, struct Input *in) case 4: /* IN */ for (i = 0; i < len; i++, in16++) { - if (fread((char *) in16, sizeof(H5DT_INT16), 1, strm) != 1) { + if (HDfread((char *) in16, sizeof(H5DT_INT16), 1, strm) != 1) { (void) fprintf(stderr, "%s", err1); return (-1); } @@ -497,7 +492,7 @@ static int readIntegerData(FILE *strm, struct Input *in) case 4: /* IN */ for (i = 0; i < len; i++, in32++) { - if (fread((char *) in32, sizeof(H5DT_INT32), 1, strm) != 1) { + if (HDfread((char *) in32, sizeof(H5DT_INT32), 1, strm) != 1) { (void) fprintf(stderr, "%s", err1); return (-1); } @@ -510,7 +505,7 @@ static int readIntegerData(FILE *strm, struct Input *in) } break; -#ifndef _WIN32 +#ifdef H5_SIZEOF_LONG_LONG case 64: in64 = (H5DT_INT64 *) in->data; switch (in->inputClass) { @@ -526,7 +521,7 @@ static int readIntegerData(FILE *strm, struct Input *in) case 4: /* IN */ for (i = 0; i < len; i++, in64++) { - if (fread((char *) in64, sizeof(H5DT_INT64), 1, strm) != 1) { + if (HDfread((char *) in64, sizeof(H5DT_INT64), 1, strm) != 1) { (void) fprintf(stderr, "%s", err1); return (-1); } @@ -538,7 +533,7 @@ static int readIntegerData(FILE *strm, struct Input *in) return (-1); } break; -#endif /* ifndef _WIN32 */ +#endif /* ifdef H5_SIZEOF_LONG_LONG */ default: (void) fprintf(stderr, "%s", err3); @@ -553,7 +548,7 @@ static int readUIntegerData(FILE *strm, struct Input *in) H5DT_UINT16 *in16; H5DT_UINT16 temp; H5DT_UINT32 *in32; -#ifndef _WIN32 +#ifdef H5_SIZEOF_LONG_LONG H5DT_UINT64 *in64; char buffer[256]; #endif @@ -584,7 +579,7 @@ static int readUIntegerData(FILE *strm, struct Input *in) case 7: /* UIN */ in08 = (H5DT_UINT8 *) in->data; for (i = 0; i < len; i++, in08++) { - if (fread((char *) in08, sizeof(H5DT_UINT8), 1, strm) != 1) { + if (HDfread((char *) in08, sizeof(H5DT_UINT8), 1, strm) != 1) { (void) fprintf(stderr, "%s", err1); return (-1); } @@ -611,7 +606,7 @@ static int readUIntegerData(FILE *strm, struct Input *in) case 7: /* UIN */ for (i = 0; i < len; i++, in16++) { - if (fread((char *) in16, sizeof(H5DT_UINT16), 1, strm) != 1) { + if (HDfread((char *) in16, sizeof(H5DT_UINT16), 1, strm) != 1) { (void) fprintf(stderr, "%s", err1); return (-1); } @@ -638,7 +633,7 @@ static int readUIntegerData(FILE *strm, struct Input *in) case 7: /* UIN */ for (i = 0; i < len; i++, in32++) { - if (fread((char *) in32, sizeof(H5DT_UINT32), 1, strm) != 1) { + if (HDfread((char *) in32, sizeof(H5DT_UINT32), 1, strm) != 1) { (void) fprintf(stderr, "%s", err1); return (-1); } @@ -651,7 +646,7 @@ static int readUIntegerData(FILE *strm, struct Input *in) } break; -#ifndef _WIN32 +#ifdef H5_SIZEOF_LONG_LONG case 64: in64 = (H5DT_UINT64 *) in->data; switch (in->inputClass) { @@ -667,7 +662,7 @@ static int readUIntegerData(FILE *strm, struct Input *in) case 7: /* UIN */ for (i = 0; i < len; i++, in64++) { - if (fread((char *) in64, sizeof(H5DT_UINT64), 1, strm) != 1) { + if (HDfread((char *) in64, sizeof(H5DT_UINT64), 1, strm) != 1) { (void) fprintf(stderr, "%s", err1); return (-1); } @@ -679,7 +674,7 @@ static int readUIntegerData(FILE *strm, struct Input *in) return (-1); } break; -#endif /* ifndef _WIN32 */ +#endif /* ifdef H5_SIZEOF_LONG_LONG */ default: (void) fprintf(stderr, "%s", err3); @@ -733,7 +728,7 @@ static int readFloatData(FILE *strm, struct Input *in) case 3: /* FP */ for (i = 0; i < len; i++, fp32++) { - if (fread((char *) fp32, sizeof(H5DT_FLOAT32), 1, strm) != 1) { + if (HDfread((char *) fp32, sizeof(H5DT_FLOAT32), 1, strm) != 1) { (void) fprintf(stderr, "%s", err1); return (-1); } @@ -775,7 +770,7 @@ static int readFloatData(FILE *strm, struct Input *in) case 3: /* FP */ for (i = 0; i < len; i++, fp64++) { - if (fread((char *) fp64, sizeof(H5DT_FLOAT64), 1, strm) != 1) { + if (HDfread((char *) fp64, sizeof(H5DT_FLOAT64), 1, strm) != 1) { (void) fprintf(stderr, "%s", err1); return (-1); } @@ -830,8 +825,8 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id) *------------------------------------------------------------------------- */ - while (!feof(strm)) { - c = fgetc(strm); + while (!HDfeof(strm)) { + c = HDfgetc(strm); if (c == 10) { /* eol */ nlines++; @@ -845,7 +840,7 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id) dims[0] = nlines; /* rewind */ - fseek(strm, 0L, 0); + HDfseek(strm, 0L, 0); /*------------------------------------------------------------------------- * read file again and generate an HDF5 dataset @@ -897,8 +892,8 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id) line = 0; - while (!feof(strm)) { - c = fgetc(strm); + while (!HDfeof(strm)) { + c = HDfgetc(strm); str[i] = c; @@ -1120,7 +1115,7 @@ static int processConfigurationFile(char *infile, struct Input *in) process the output file according to the options */ - if ((strm = fopen(infile, "r")) == NULL) { + if ((strm = HDfopen(infile, "r")) == NULL) { (void) fprintf(stderr, err1, infile); return (-1); } @@ -1128,24 +1123,24 @@ static int processConfigurationFile(char *infile, struct Input *in) while (fscanf(strm, "%s", key) == 1) { if ((kindex = mapKeywordToIndex(key)) == -1) { (void) fprintf(stderr, err2, infile); - fclose(strm); + HDfclose(strm); return (-1); } switch (kindex) { case 0: /* PATH */ if (in->configOptionVector[PATH] == 1) { (void) fprintf(stderr, err3a, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (fscanf(strm, "%s", temp) != 1) { (void) fprintf(stderr, "%s", err18); - fclose(strm); + HDfclose(strm); return (-1); } if (parsePathInfo(&in->path, temp) == -1) { (void) fprintf(stderr, err3b, infile); - fclose(strm); + HDfclose(strm); return (-1); } in->configOptionVector[PATH] = 1; @@ -1154,18 +1149,18 @@ static int processConfigurationFile(char *infile, struct Input *in) case 1: /* INPUT-CLASS */ if (in->configOptionVector[INPUT_CLASS] == 1) { (void) fprintf(stderr, err4a, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (fscanf(strm, "%s", temp) != 1) { (void) fprintf(stderr, "%s", err18); - fclose(strm); + HDfclose(strm); return (-1); } if (getInputClass(in, temp) == -1) { (void) fprintf(stderr, err4b, infile); - fclose(strm); + HDfclose(strm); return (-1); } @@ -1186,17 +1181,17 @@ static int processConfigurationFile(char *infile, struct Input *in) case 2: /* INPUT-SIZE */ if (in->configOptionVector[INPUT_SIZE] == 1) { (void) fprintf(stderr, err5a, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (fscanf(strm, "%d", (&ival)) != 1) { (void) fprintf(stderr, "%s", err19); - fclose(strm); + HDfclose(strm); return (-1); } if (getInputSize(in, ival) == -1) { (void) fprintf(stderr, err5b, infile); - fclose(strm); + HDfclose(strm); return (-1); } in->configOptionVector[INPUT_SIZE] = 1; @@ -1209,13 +1204,13 @@ static int processConfigurationFile(char *infile, struct Input *in) case 3: /* RANK */ if (in->configOptionVector[RANK] == 1) { (void) fprintf(stderr, err6a, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (getRank(in, strm) == -1) { (void) fprintf(stderr, err6b, infile); - fclose(strm); + HDfclose(strm); return (-1); } in->configOptionVector[RANK] = 1; @@ -1224,18 +1219,18 @@ static int processConfigurationFile(char *infile, struct Input *in) case 4: /* DIMENSION-SIZES */ if (in->configOptionVector[DIM] == 1) { (void) fprintf(stderr, err7a, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (in->configOptionVector[RANK] == 0) { (void) fprintf(stderr, err7b, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (getDimensionSizes(in, strm) == -1) { (void) fprintf(stderr, err7c, infile); - fclose(strm); + HDfclose(strm); return (-1); } in->configOptionVector[DIM] = 1; @@ -1244,13 +1239,13 @@ static int processConfigurationFile(char *infile, struct Input *in) case 5: /* OUTPUT-CLASS */ if (in->configOptionVector[OUTPUT_CLASS] == 1) { (void) fprintf(stderr, err8a, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (getOutputClass(in, strm) == -1) { (void) fprintf(stderr, err8b, infile); - fclose(strm); + HDfclose(strm); return (-1); } in->configOptionVector[OUTPUT_CLASS] = 1; @@ -1259,13 +1254,13 @@ static int processConfigurationFile(char *infile, struct Input *in) case 6: /* OUTPUT-SIZE */ if (in->configOptionVector[OUTPUT_SIZE] == 1) { (void) fprintf(stderr, err9a, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (getOutputSize(in, strm) == -1) { (void) fprintf(stderr, err9b, infile); - fclose(strm); + HDfclose(strm); return (-1); } in->configOptionVector[OUTPUT_SIZE] = 1; @@ -1274,13 +1269,13 @@ static int processConfigurationFile(char *infile, struct Input *in) case 7: /* OUTPUT-ARCHITECTURE */ if (in->configOptionVector[OUTPUT_ARCH] == 1) { (void) fprintf(stderr, err10a, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (getOutputArchitecture(in, strm) == -1) { (void) fprintf(stderr, err10b, infile); - fclose(strm); + HDfclose(strm); return (-1); } in->configOptionVector[OUTPUT_ARCH] = 1; @@ -1289,13 +1284,13 @@ static int processConfigurationFile(char *infile, struct Input *in) case 8: /* OUTPUT-BYTE-ORDER */ if (in->configOptionVector[OUTPUT_B_ORDER] == 1) { (void) fprintf(stderr, err11a, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (getOutputByteOrder(in, strm) == -1) { (void) fprintf(stderr, err11b, infile); - fclose(strm); + HDfclose(strm); return (-1); } in->configOptionVector[OUTPUT_B_ORDER] = 1; @@ -1304,19 +1299,19 @@ static int processConfigurationFile(char *infile, struct Input *in) case 9: /* CHUNKED-DIMENSION-SIZES */ if (in->configOptionVector[CHUNK] == 1) { (void) fprintf(stderr, err12a, infile); - fclose(strm); + HDfclose(strm); return (-1); } /* cant appear before dimension sizes have been provided */ if (in->configOptionVector[DIM] == 0) { (void) fprintf(stderr, err12b, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (getChunkedDimensionSizes(in, strm) == -1) { (void) fprintf(stderr, err12c, infile); - fclose(strm); + HDfclose(strm); return (-1); } in->configOptionVector[CHUNK] = 1; @@ -1325,13 +1320,13 @@ static int processConfigurationFile(char *infile, struct Input *in) case 10: /* COMPRESSION-TYPE */ if (in->configOptionVector[COMPRESS] == 1) { (void) fprintf(stderr, err13a, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (getCompressionType(in, strm) == -1) { (void) fprintf(stderr, err13b, infile); - fclose(strm); + HDfclose(strm); return (-1); } in->configOptionVector[COMPRESS] = 1; @@ -1345,13 +1340,13 @@ static int processConfigurationFile(char *infile, struct Input *in) case 11: /* COMPRESSION-PARAM */ if (in->configOptionVector[COMPRESS_PARAM] == 1) { (void) fprintf(stderr, err14a, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (getCompressionParameter(in, strm) == -1) { (void) fprintf(stderr, err14b, infile); - fclose(strm); + HDfclose(strm); return (-1); } @@ -1365,13 +1360,13 @@ static int processConfigurationFile(char *infile, struct Input *in) case 12: /* EXTERNAL-STORAGE */ if (in->configOptionVector[EXTERNAL] == 1) { (void) fprintf(stderr, err15a, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (getExternalFilename(in, strm) == -1) { (void) fprintf(stderr, err15b, infile); - fclose(strm); + HDfclose(strm); return (-1); } in->configOptionVector[EXTERNAL] = 1; @@ -1380,18 +1375,18 @@ static int processConfigurationFile(char *infile, struct Input *in) case 13: /* MAXIMUM-DIMENSIONS */ if (in->configOptionVector[EXTEND] == 1) { (void) fprintf(stderr, err16a, infile); - fclose(strm); + HDfclose(strm); return (-1); } /* cant appear before dimension sizes have been provided */ if (in->configOptionVector[DIM] == 0) { (void) fprintf(stderr, err16b, infile); - fclose(strm); + HDfclose(strm); return (-1); } if (getMaximumDimensionSizes(in, strm) == -1) { (void) fprintf(stderr, err16c, infile); - fclose(strm); + HDfclose(strm); return (-1); } in->configOptionVector[EXTEND] = 1; @@ -1408,11 +1403,11 @@ static int processConfigurationFile(char *infile, struct Input *in) if (validateConfigurationParameters(in) == -1) { (void) fprintf(stderr, err17, infile); - fclose(strm); + HDfclose(strm); return (-1); } - fclose(strm); + HDfclose(strm); return (0); } @@ -1424,7 +1419,7 @@ static int validateConfigurationParameters(struct Input *in) const char *err4a = "OUTPUT-ARCHITECTURE cannot be STD if OUTPUT-CLASS is floating point (FP).\n"; const char *err4b = "OUTPUT-ARCHITECTURE cannot be IEEE if OUTPUT-CLASS is integer (IN).\n"; const char *err5 = "For OUTPUT-CLASS FP, valid values for OUTPUT-SIZE are (32, 64) .\n"; -#ifdef _WIN32 +#ifndef H5_SIZEOF_LONG_LONG const char *err6 = "No support for reading 64-bit integer (INPUT-CLASS: IN, TEXTIN, UIN, TEXTUIN files\n"; #endif @@ -1471,7 +1466,7 @@ static int validateConfigurationParameters(struct Input *in) return (-1); } -#ifdef _WIN32 +#ifndef H5_SIZEOF_LONG_LONG if (in->inputSize == 64 && (in->inputClass == 0 || in->inputClass == 4 || in->inputClass == 6 || in->inputClass == 7) ) { (void) fprintf(stderr, "%s", err6); return -1; diff --git a/tools/h5import/h5importtest.c b/tools/h5import/h5importtest.c index 9c839a3..2869236 100755 --- a/tools/h5import/h5importtest.c +++ b/tools/h5import/h5importtest.c @@ -16,6 +16,12 @@ #include <stdio.h> #include "H5private.h" +#ifdef WIN32 +#define OPEN_FLAGS "wb" +#else +#define OPEN_FLAGS "w" +#endif + /* * Name: * h5importtest @@ -42,7 +48,7 @@ main(void) int rowo4i = (int)11 , colo4i = (int)21 , plno4i = (int)51 ; int rowi4i = (int)1 , coli4i = (int)2 , plni4i = (int)5 ; -#ifndef WIN32 +#ifdef H5_SIZEOF_LONG_LONG long long row4i64[3], col4i64[4], pln4i64[5]; long long rowo4i64 = (long long)11 , colo4i64 = (long long)21 , plno4i64 = (long long)51 ; long long rowi4i64 = (long long)1 , coli4i64 = (long long)2 , plni4i64 = (long long)5 ; @@ -91,7 +97,7 @@ main(void) col4i[0] = colo4i; pln4i[0] = plno4i; -#ifndef WIN32 +#ifdef H5_SIZEOF_LONG_LONG row4i64[0] = rowo4i64; col4i64[0] = colo4i64; pln4i64[0] = plno4i64; @@ -110,7 +116,7 @@ main(void) row4[i] = row4[i - 1] + rowi4; row8[i] = row8[i - 1] + rowi8; row4i[i] = row4i[i - 1] + rowi4i; -#ifndef WIN32 +#ifdef H5_SIZEOF_LONG_LONG row4i64[i] = row4i64[i - 1] + rowi4i64; #endif row4i16[i] = row4i16[i - 1] + rowi4i16; @@ -122,7 +128,7 @@ main(void) col4[j] = col4[j - 1] + coli4; col8[j] = col8[j - 1] + coli8; col4i[j] = col4i[j - 1] + coli4i; -#ifndef WIN32 +#ifdef H5_SIZEOF_LONG_LONG col4i64[j] = col4i64[j - 1] + coli4i64; #endif col4i16[j] = col4i16[j - 1] + coli4i16; @@ -133,7 +139,7 @@ main(void) pln4[k] = pln4[k - 1] + plni4; pln8[k] = pln8[k - 1] + plni8; pln4i[k] = pln4i[k - 1] + plni4i; -#ifndef WIN32 +#ifdef H5_SIZEOF_LONG_LONG pln4i64[k] = pln4i64[k - 1] + plni4i64; #endif pln4i16[k] = pln4i16[k - 1] + plni4i16; @@ -165,7 +171,7 @@ main(void) */ - sp = fopen("txtin16.txt", "w"); + sp = HDfopen("txtin16.txt", "w"); for (k = 0; k < npln; k++) { for (i = 0; i < nrow; i++) @@ -175,14 +181,14 @@ main(void) (void) fprintf(sp, "\n"); } } - (void) fclose(sp); + (void) HDfclose(sp); /*------------------------------------------------------------------------- * TOOLTEST txtin32.txt -c $srcdir/testfiles/textin32.conf -o textin32.h5 *------------------------------------------------------------------------- */ - sp = fopen("txtin32.txt", "w"); + sp = HDfopen("txtin32.txt", "w"); for (k = 0; k < npln; k++) { for (i = 0; i < nrow; i++) @@ -192,51 +198,43 @@ main(void) (void) fprintf(sp, "\n"); } } - (void) fclose(sp); + (void) HDfclose(sp); /*------------------------------------------------------------------------- * TOOLTEST binin32.bin -c $srcdir/testfiles/binin32.conf -o binin32.h5 *------------------------------------------------------------------------- */ -#ifdef WIN32 - sp = fopen("binin32.bin", "wb"); -#else - sp = fopen("binin32.bin", "w"); -#endif + sp = HDfopen("binin32.bin", OPEN_FLAGS); for (k = 0; k < npln; k++) { for (i = 0; i < nrow; i++) { for (j = 0; j < ncol; j++) { - (void) fwrite((char *) &b32i3[k][i][j], sizeof(int), 1, sp); + (void) HDfwrite((char *) &b32i3[k][i][j], sizeof(int), 1, sp); } } } - (void) fclose(sp); + (void) HDfclose(sp); /*------------------------------------------------------------------------- * TOOLTEST binuin32.bin -c $srcdir/testfiles/binuin32.conf -o binuin32.h5 *------------------------------------------------------------------------- */ -#ifdef WIN32 - sp = fopen("binuin32.bin", "wb"); -#else - sp = fopen("binuin32.bin", "w"); -#endif + sp = HDfopen("binuin32.bin", OPEN_FLAGS); for (k = 0; k < npln; k++) { for (i = 0; i < nrow; i++) { for (j = 0; j < ncol; j++) { - (void) fwrite((char *) &b32i3[k][i][j], sizeof(unsigned int), 1, sp); + (void) HDfwrite((char *) &b32i3[k][i][j], sizeof(unsigned int), 1, sp); } } } - (void) fclose(sp); + (void) HDfclose(sp); @@ -246,43 +244,35 @@ main(void) *------------------------------------------------------------------------- */ -#ifdef WIN32 - sp = fopen("binin16.bin", "wb"); -#else - sp = fopen("binin16.bin", "w"); -#endif + sp = HDfopen("binin16.bin", OPEN_FLAGS); for (k = 0; k < npln; k++) { for (i = 0; i < nrow; i++) { for (j = 0; j < ncol; j++) { - (void) fwrite((char *) &b16i3[k][i][j], sizeof(short), 1, sp); + (void) HDfwrite((char *) &b16i3[k][i][j], sizeof(short), 1, sp); } } } - (void) fclose(sp); + (void) HDfclose(sp); /*------------------------------------------------------------------------- * TOOLTEST binuin16.bin -c $srcdir/testfiles/binuin16.conf -o binuin16.h5 *------------------------------------------------------------------------- */ -#ifdef WIN32 - sp = fopen("binuin16.bin", "wb"); -#else - sp = fopen("binuin16.bin", "w"); -#endif + sp = HDfopen("binuin16.bin", OPEN_FLAGS); for (k = 0; k < npln; k++) { for (i = 0; i < nrow; i++) { for (j = 0; j < ncol; j++) { - (void) fwrite((char *) &b16i3[k][i][j], sizeof(unsigned short), 1, sp); + (void) HDfwrite((char *) &b16i3[k][i][j], sizeof(unsigned short), 1, sp); } } } - (void) fclose(sp); + (void) HDfclose(sp); @@ -291,22 +281,18 @@ main(void) *------------------------------------------------------------------------- */ -#ifdef WIN32 - sp = fopen("binin8.bin", "wb"); -#else - sp = fopen("binin8.bin", "w"); -#endif + sp = HDfopen("binin8.bin", OPEN_FLAGS); for (k = 0; k < npln; k++) { for (i = 0; i < nrow; i++) { for (j = 0; j < ncol; j++) { - (void) fwrite((char *) &b8i3[k][i][j], sizeof(char), 1, sp); + (void) HDfwrite((char *) &b8i3[k][i][j], sizeof(char), 1, sp); } } } - (void) fclose(sp); + (void) HDfclose(sp); #endif /* UNICOS */ @@ -322,22 +308,18 @@ main(void) * binary 64-bit file - rank 2 & 3 */ -#ifdef WIN32 - sp = fopen("binfp64.bin", "wb"); -#else - sp = fopen("binfp64.bin", "w"); -#endif + sp = HDfopen("binfp64.bin", OPEN_FLAGS); for (k = 0; k < npln; k++) { for (i = 0; i < nrow; i++) { for (j = 0; j < ncol; j++) { - (void) fwrite((char *) &b64r3[k][i][j], sizeof(double), 1, sp); + (void) HDfwrite((char *) &b64r3[k][i][j], sizeof(double), 1, sp); } } } - (void) fclose(sp); + (void) HDfclose(sp); @@ -350,18 +332,14 @@ main(void) /* test CR+LF (13,10) and EOF (26) in windows */ char bin8w[4] = {13,10,26,0}; -#ifdef WIN32 - sp = fopen("binin8w.bin", "wb"); -#else - sp = fopen("binin8w.bin", "w"); -#endif + sp = HDfopen("binin8w.bin", OPEN_FLAGS); for (i = 0; i < 4; i++) { char c = bin8w[i]; - if ( fwrite( &c, sizeof(char), 1, sp) != 1 ) + if ( HDfwrite( &c, sizeof(char), 1, sp) != 1 ) printf("error writing file\n"); } - fclose(sp); + HDfclose(sp); } |