From: Michal MalĂ˝ Date: Thu, 10 Jul 2014 08:45:10 +0000 (+0200) Subject: Fix debug build defines and add debugging output X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=b37a9b49018946270163c64c730fff9c5ed8195e;p=libHPCS.git Fix debug build defines and add debugging output --- diff --git a/libhpcs.c b/libhpcs.c index 68efb8c..072c0a5 100644 --- 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 diff --git a/libhpcs_p.h b/libhpcs_p.h index 2e9fb64..05529ae 100644 --- a/libhpcs_p.h +++ b/libhpcs_p.h @@ -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