enum HPCS_ChemStationVer cs_ver;
double signal_step;
double signal_shift;
+ size_t scans_start;
if (mdata == NULL)
return HPCS_E_NULLPTR;
goto out;
}
- pret = read_signal(datafile, &mdata->data, &mdata->data_count, signal_step, signal_shift, gentype);
+ pret = read_scans_start(datafile, &scans_start);
+ if (pret != PARSE_OK) {
+ PR_DEBUG("Cannot read scans start offset\n");
+ ret = HPCS_E_PARSE_ERROR;
+ goto out;
+ }
+
+ pret = read_signal(datafile, &mdata->data, &mdata->data_count, scans_start, signal_step, signal_shift);
if (pret != PARSE_OK) {
PR_DEBUG("Cannot parse data in the file\n");
ret = HPCS_E_PARSE_ERROR;
return ret;
}
+static enum HPCS_ParseCode read_scans_start(FILE* datafile, size_t *scans_start)
+{
+ size_t r;
+ int32_t _start;
+
+ fseek(datafile, DATA_SCANS_START, SEEK_SET);
+ if (feof(datafile))
+ return PARSE_E_OUT_OF_RANGE;
+ if (ferror(datafile))
+ return PARSE_E_CANT_READ;
+
+ r = fread(&_start, LARGE_SEGMENT_SIZE, 1, datafile);
+ if (r != 1)
+ return PARSE_E_CANT_READ;
+
+ be_to_cpu_val(_start);
+
+ *scans_start = (_start - 1) * 512;
+
+ return PARSE_OK;
+}
+
static enum HPCS_ParseCode read_signal(FILE* datafile, struct HPCS_TVPair** pairs, size_t* pairs_count,
- const double signal_step, const double signal_shift, const enum HPCS_GenType gentype)
+ const size_t scans_start, const double signal_step, const double signal_shift)
{
size_t alloc_size = (size_t)((60 * 25));
bool read_file = true;
size_t segments_read = 0;
size_t data_segments_read = 0;
size_t next_marker_idx = 0;
- const HPCS_offset data_start_offset = OLD_FORMAT(gentype) ? DATA_OFFSET_DATA_START_OLD : DATA_OFFSET_DATA_START;
char raw[2];
size_t r;
enum HPCS_DataCheckCode dret;
- fseek(datafile, data_start_offset, SEEK_SET);
+ fseek(datafile, scans_start, SEEK_SET);
if (feof(datafile))
return PARSE_E_OUT_OF_RANGE;
if (ferror(datafile))
/* Offsets containing data of interest in .ch files */
const HPCS_offset DATA_OFFSET_GENTYPE = 0x000;
+const HPCS_offset DATA_SCANS_START = 0x108;
const HPCS_offset DATA_OFFSET_XMIN = 0x11A;
const HPCS_offset DATA_OFFSEt_XMAX = 0x11E;
const HPCS_offset DATA_OFFSET_FILE_DESC = 0x15B;
static enum HPCS_ParseCode read_file_type_description(FILE* datafile, char** const description, const enum HPCS_GenType gentype);
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_scans_start(FILE* datafile, size_t *scans_start);
static enum HPCS_ParseCode read_signal(FILE* datafile, struct HPCS_TVPair** pairs, size_t* pairs_count,
- const double sigal_step, const double signal_shift, const enum HPCS_GenType gentype);
+ const size_t scans_start, const double sigal_step, const double signal_shift);
static enum HPCS_ParseCode read_string_at_offset(FILE* datafile, const HPCS_offset, char** const result, const bool read_as_wchar);
static enum HPCS_ParseCode read_timing(FILE* datafile, struct HPCS_TVPair*const pairs, double *sampling_rate, const size_t data_count);
static void remove_trailing_newline(HPCS_NChar* s);