]> Devoid-pointer.net GitWeb - libHPCS.git/commitdiff
Fix debug build defines and add debugging output
authorMichal Malý <madcatxster@devoid-pointer.net>
Thu, 10 Jul 2014 08:45:10 +0000 (10:45 +0200)
committerMichal Malý <madcatxster@devoid-pointer.net>
Thu, 10 Jul 2014 08:45:10 +0000 (10:45 +0200)
libhpcs.c
libhpcs_p.h

index 68efb8cc999c4506cd7edc25af09f9cf329e9577..072c0a51c94c0a0a20acfdb1909486e96e5bc966 100644 (file)
--- a/libhpcs.c
+++ b/libhpcs.c
@@ -71,51 +71,61 @@ enum HPCS_RetCode hpcs_read_file(const char* filename, struct HPCS_MeasuredData*
 
        pret = read_string_at_offset(datafile, DATA_OFFSET_FILE_DESC, &mdata->file_description);
        if (pret != PARSE_OK) {
+               PR_DEBUG("Cannot read file description");
                ret = HPCS_E_PARSE_ERROR;
                goto out;
        }
        pret = read_string_at_offset(datafile, DATA_OFFSET_SAMPLE_INFO, &mdata->sample_info);
        if (pret != PARSE_OK) {
+               PR_DEBUG("Cannot read sample info");
                ret = HPCS_E_PARSE_ERROR;
                goto out;
        }
        pret = read_string_at_offset(datafile, DATA_OFFSET_OPERATOR_NAME, &mdata->operator_name);
        if (pret != PARSE_OK) {
+               PR_DEBUG("Cannot read operator name");
                ret = HPCS_E_PARSE_ERROR;
                goto out;
        }
        pret = read_string_at_offset(datafile, DATA_OFFSET_METHOD_NAME, &mdata->method_name);
        if (pret != PARSE_OK) {
+               PR_DEBUG("Cannot read method name");
                ret = HPCS_E_PARSE_ERROR;
                goto out;
        }
        pret = read_date(datafile, &mdata->date);
        if (pret != PARSE_OK) {
+               PR_DEBUG("Cannot read date of measurement");
                ret = HPCS_E_PARSE_ERROR;
                goto out;
        }
        pret = read_string_at_offset(datafile, DATA_OFFSET_CS_VER, &mdata->cs_ver);
        if (pret != PARSE_OK) {
+               PR_DEBUG("Cannot read ChemStation software version");
                ret = HPCS_E_PARSE_ERROR;
                goto out;
        }
        pret = read_string_at_offset(datafile, DATA_OFFSET_Y_UNITS, &mdata->y_units);
        if (pret != PARSE_OK) {
+               PR_DEBUG("Cannot read values of Y axis");
                ret = HPCS_E_PARSE_ERROR;
                goto out;
        }
        pret = read_string_at_offset(datafile, DATA_OFFSET_CS_REV, &mdata->cs_rev);
        if (pret != PARSE_OK) {
+               PR_DEBUG("Cannot read ChemStation software revision");
                ret = HPCS_E_PARSE_ERROR;
                goto out;
        }
        pret = read_sampling_rate(datafile, &mdata->sampling_rate);
        if (pret != PARSE_OK) {
+               PR_DEBUG("Cannot read sampling rate of the file");
                ret = HPCS_E_PARSE_ERROR;
                goto out;
        }
        pret = autodetect_file_type(datafile, &mdata->file_type);
        if (pret != PARSE_OK) {
+               PR_DEBUG("Cannot determine the type of file");
                ret = HPCS_E_PARSE_ERROR;
                goto out;
        }
@@ -123,11 +133,13 @@ enum HPCS_RetCode hpcs_read_file(const char* filename, struct HPCS_MeasuredData*
        if (mdata->file_type == HPCS_TYPE_CE_DAD) {
                pret = read_dad_wavelength(datafile, WAVELENGTH_MEASURED, &mdata->dad_wavelength_msr);
                if (pret != PARSE_OK && pret != PARSE_W_NO_DATA) {
+                       PR_DEBUG("Cannot read measured wavelength");
                        ret = HPCS_E_PARSE_ERROR;
                        goto out;
                }
                pret = read_dad_wavelength(datafile, WAVELENGTH_REFERENCE, &mdata->dad_wavelength_ref);
                if (pret != PARSE_OK && pret != PARSE_W_NO_DATA) {
+                       PR_DEBUG("Cannot read reference wavelength");
                        ret = HPCS_E_PARSE_ERROR;
                        goto out;
                }
@@ -153,6 +165,7 @@ enum HPCS_RetCode hpcs_read_file(const char* filename, struct HPCS_MeasuredData*
        }
 
        if (pret != PARSE_OK) {
+               PR_DEBUG("Cannot parse data in the file");
                ret = HPCS_E_PARSE_ERROR;
        }
        else
index 2e9fb6495e503bc403d9b878b05b7b1d76352acf..05529aeaab2fd54c6445179010d1169f1cdefc24 100644 (file)
@@ -120,12 +120,8 @@ void reverse_endianness(char* bytes, size_t sz) {
 #error "Endiannes has not been determined."
 #endif
 
-void print_debug(const char* msg)
-{
-#ifdef NDEBUG
-       fprintf(stderr, "%s\n"m msg);
+#ifndef NDEBUG
+#define PR_DEBUG(msg) fprintf(stderr, "%s\n", msg);
 #else
-       (void)msg;
-#endif //NDEBUG
-}
-
+#define PR_DEBUG(msg)
+#endif