]> Devoid-pointer.net GitWeb - libHPCS.git/commitdiff
- Fix a few stupid typos causing ChemStation version to be misidentified - Move read_...
authorUser <User>
Tue, 1 Dec 2015 15:19:35 +0000 (16:19 +0100)
committerMichal Malý <madcatxster@devoid-pointer.net>
Tue, 1 Dec 2015 17:00:56 +0000 (18:00 +0100)
Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net>
libhpcs.c
libhpcs_p.h

index 896e1146969daab7bee0827048a9ed2d19d7339a..f17eda59a5a5155c8de24c4bce88c19e71638f45 100644 (file)
--- a/libhpcs.c
+++ b/libhpcs.c
@@ -303,13 +303,22 @@ static enum HPCS_DataCheckCode check_for_marker(const char* segment, size_t* con
 
 static enum HPCS_ChemStationVer detect_chemstation_version(const char*const version_string)
 {
-       if (!strcmp(version_string, CHEMSTAT_B0625_STR))
+       PR_DEBUGF("ChemStation ersion string: %s\n", version_string);
+
+       if (!strcmp(version_string, CHEMSTAT_B0625_STR)) {
+               PR_DEBUG("ChemStation B.06.25\n");
                return CHEMSTAT_B0625;
-       else if (!strcmp(version_string, CHEMSTAT_B0625_STR))
+       }
+       else if (!strcmp(version_string, CHEMSTAT_B0626_STR)) {
+               PR_DEBUG("ChemStation B.06.26\n");
                return CHEMSTAT_B0626;
-       else if (strlen(version_string) == 0)
+       }
+       else if (strlen(version_string) == 0) {
+               PR_DEBUG("ChemStation Untagged\n");
                return CHEMSTAT_UNTAGGED;
+       }
 
+       PR_DEBUG("Unknown ChemStation version\n");
        return CHEMSTAT_UNKNOWN;
 }
 
@@ -332,52 +341,6 @@ static bool gentype_is_readable(const enum HPCS_GenType gentype)
        }
 }
 
-static enum HPCS_ParseCode read_generic_type(FILE* datafile, enum HPCS_GenType* gentype)
-{
-       enum HPCS_ParseCode ret;
-       uint8_t len;
-       char* gentype_str;
-
-       fseek(datafile, DATA_OFFSET_GENTYPE, SEEK_SET);
-       if (feof(datafile))
-               return PARSE_E_OUT_OF_RANGE;
-       if (ferror(datafile))
-               return PARSE_E_CANT_READ;
-
-       if (fread(&len, SMALL_SEGMENT_SIZE, 1, datafile) < SMALL_SEGMENT_SIZE)
-               return PARSE_E_CANT_READ;
-
-       gentype_str = malloc((sizeof(char) * len) + 1);
-       if (gentype_str == NULL)
-               return PARSE_E_NO_MEM;
-
-       if (fread(gentype_str, SMALL_SEGMENT_SIZE, len, datafile) < SMALL_SEGMENT_SIZE * len) {
-               ret = PARSE_E_CANT_READ;
-               goto out;
-       }
-
-       if (feof(datafile)) {
-               ret = PARSE_E_OUT_OF_RANGE;
-               goto out;
-       }
-       if (ferror(datafile)) {
-               ret = PARSE_E_CANT_READ;
-               goto out;
-       }
-
-       gentype_str[len] = '\0';
-
-       PR_DEBUGF("Generic type: %s\n", gentype_str);
-
-       *gentype = strtol(gentype_str, NULL, 10);
-       ret = PARSE_OK;
-
-out:
-       free(gentype_str);
-
-       return ret;
-}
-
 static HPCS_step guess_current_step(const enum HPCS_ChemStationVer version)
 {
        if (version != CHEMSTAT_B0625)
@@ -750,7 +713,7 @@ static enum HPCS_ParseCode read_file_header(FILE* datafile, enum HPCS_ChemStatio
            return pret;
        }
 
-       *cs_ver =  detect_chemstation_version(mdata->cs_rev);
+       *cs_ver =  detect_chemstation_version(mdata->cs_ver);
        if (pret != PARSE_OK) {
                PR_DEBUG("Cannot detect ChemStation version\n");
                return pret;
@@ -826,6 +789,52 @@ static enum HPCS_ParseCode read_method_info_file(HPCS_UFH fh, struct HPCS_Method
        return PARSE_OK;
 }
 
+static enum HPCS_ParseCode read_generic_type(FILE* datafile, enum HPCS_GenType* gentype)
+{
+       enum HPCS_ParseCode ret;
+       uint8_t len;
+       char* gentype_str;
+
+       fseek(datafile, DATA_OFFSET_GENTYPE, SEEK_SET);
+       if (feof(datafile))
+               return PARSE_E_OUT_OF_RANGE;
+       if (ferror(datafile))
+               return PARSE_E_CANT_READ;
+
+       if (fread(&len, SMALL_SEGMENT_SIZE, 1, datafile) < SMALL_SEGMENT_SIZE)
+               return PARSE_E_CANT_READ;
+
+       gentype_str = malloc((sizeof(char) * len) + 1);
+       if (gentype_str == NULL)
+               return PARSE_E_NO_MEM;
+
+       if (fread(gentype_str, SMALL_SEGMENT_SIZE, len, datafile) < SMALL_SEGMENT_SIZE * len) {
+               ret = PARSE_E_CANT_READ;
+               goto out;
+       }
+
+       if (feof(datafile)) {
+               ret = PARSE_E_OUT_OF_RANGE;
+               goto out;
+       }
+       if (ferror(datafile)) {
+               ret = PARSE_E_CANT_READ;
+               goto out;
+       }
+
+       gentype_str[len] = '\0';
+
+       PR_DEBUGF("Generic type: %s\n", gentype_str);
+
+       *gentype = strtol(gentype_str, NULL, 10);
+       ret = PARSE_OK;
+
+out:
+       free(gentype_str);
+
+       return ret;
+}
+
 static enum HPCS_ParseCode read_signal(FILE* datafile, struct HPCS_TVPair** pairs, size_t* pairs_count,
                                       const HPCS_step step, const double sampling_rate)
 {
index 3adb670d2c0d1a556d6a9b9c0522b5b9dac2cf0c..b52965798b2456c984b7cdf3b2c93698e35c80f6 100644 (file)
@@ -130,7 +130,7 @@ enum HPCS_ChemStationVer {
 
 /* Known ChemStation format versions */
 const char CHEMSTAT_B0625_STR[] = "B.06.25 [0003]";
-const char CHEMSTAT_B0626_STR[] = "B.06.25 [0010]";
+const char CHEMSTAT_B0626_STR[] = "B.06.26 [0010]";
 
 /* Values of markers found in .ch files */
 const char BIN_MARKER_A = 0x10;