goto out;
}
+ pret = read_file_type_description(datafile, &mdata->file_description);
+ if (pret != PARSE_OK)
+ goto out;
+
+ if (!file_type_description_is_readable(mdata->file_description)) {
+ PR_DEBUGF("Incompatible file description: %s\n", mdata->file_description);
+ ret = HPCS_E_INCOMPATIBLE_FILE;
+ goto out;
+ }
+
pret = read_file_header(datafile, mdata);
if (pret != PARSE_OK) {
PR_DEBUG("Cannot read the header\n");
goto out;
}
+ pret = read_file_type_description(datafile, &mdata->file_description);
+ if (pret != PARSE_OK)
+ goto out;
+
+ if (!file_type_description_is_readable(mdata->file_description)) {
+ PR_DEBUGF("Incompatible file description: %s\n", mdata->file_description);
+ ret = HPCS_E_INCOMPATIBLE_FILE;
+ goto out;
+ }
+
pret = read_file_header(datafile, mdata);
if (pret != PARSE_OK)
ret = HPCS_E_PARSE_ERROR;
return DCHECK_NO_MARKER;
}
+static bool file_type_description_is_readable(const char*const description)
+{
+ if (!strcmp(FILE_DESC_LC_DATA_FILE, description))
+ return true;
+ else
+ return false;
+}
+
static bool gentype_is_readable(const enum HPCS_GenType gentype)
{
switch (gentype) {
{
enum HPCS_ParseCode pret;
- pret = read_string_at_offset(datafile, DATA_OFFSET_FILE_DESC, &mdata->file_description);
- if (pret != PARSE_OK) {
- PR_DEBUG("Cannot read file description\n");
- return pret;
- }
pret = read_string_at_offset(datafile, DATA_OFFSET_SAMPLE_INFO, &mdata->sample_info);
if (pret != PARSE_OK) {
PR_DEBUG("Cannot read sample info\n");
return PARSE_OK;
}
+static enum HPCS_ParseCode read_file_type_description(FILE* datafile, char** const description)
+{
+ enum HPCS_ParseCode pret;
+
+ pret = read_string_at_offset(datafile, DATA_OFFSET_FILE_DESC, description);
+ if (pret != PARSE_OK)
+ PR_DEBUG("Cannot read file description\n");
+
+ return pret;
+}
+
static enum HPCS_ParseCode read_method_info_file(HPCS_UFH fh, struct HPCS_MethodInfo* minfo)
{
HPCS_NChar line[64];
GENTYPE_ADC_UV2 = 131
};
+/* Known file descriptions */
+const char FILE_DESC_LC_DATA_FILE[] = "LC DATA FILE";
+
/* Known ChemStation format versions */
const char CHEMSTAT_VER_B0625[] = "B.06.25 [0003]";
static HPCS_step guess_elec_sigstep(const struct HPCS_MeasuredData *mdata);
static bool guess_p_meaning(const struct HPCS_MeasuredData* mdata);
static void guess_sampling_rate(struct HPCS_MeasuredData* mdata);
+static bool file_type_description_is_readable(const char*const description);
static enum HPCS_ParseCode next_native_line(HPCS_UFH fh, HPCS_NChar* line, int32_t length);
static HPCS_UFH open_data_file(const char* filename);
static enum HPCS_ParseCode parse_native_method_info_line(char** name, char** value, HPCS_NChar* line);
static uint8_t month_to_number(const char* month);
static enum HPCS_ParseCode read_date(FILE* datafile, struct HPCS_Date* date);
static enum HPCS_ParseCode read_file_header(FILE* datafile, struct HPCS_MeasuredData* mdata);
+static enum HPCS_ParseCode read_file_type_description(FILE* datafile, char** const description);
static enum HPCS_ParseCode read_generic_type(FILE* datafile, enum HPCS_GenType* gentype);
static enum HPCS_ParseCode read_method_info_file(HPCS_UFH fh, struct HPCS_MethodInfo* minfo);
static enum HPCS_ParseCode read_signal(FILE* datafile, struct HPCS_TVPair** pairs, size_t* pairs_count,