char channel_name[MAX_CHANNEL_NAME_SIZE];
};
-/*
- * Header items used to process the input file.
- *
- * Parameter WFID is optional, the rest are required.
- */
+/* Header items used to process the input file. */
enum header_items_enum {
+ /* Mandatory items */
YOFF = 0,
YZERO = 1,
YMULT = 2,
BYTNR = 4,
BYTE_ORDER = 5,
BN_FMT = 6,
- WFID = 7,
- WFMTYPE = 8,
- ENCODING = 9,
+ ENCODING = 7,
+
+ /* Optional items */
+ WFID = 8,
+ WFMTYPE = 9,
};
/* Strings searched for in the file header representing the header items. */
[BYTNR] = "BYT_NR ",
[BYTE_ORDER] = "BYT_OR ",
[BN_FMT] = "BN_FMT ",
+ [ENCODING] = "ENCDG ",
[WFID] = "WFID ",
[WFMTYPE] = "WFMTYPE ",
- [ENCODING] = "ENCDG ",
};
/* Find the header item string in the header. */
for (i = 0; i < HEADER_ITEMS_PARAMETERS; ++i) {
pattern = find_item(buf->str, data_section_offset, header_items[i]);
if (pattern == NULL) {
- /* WFID is not required. */
- if (i == WFID)
- continue;
- return SR_ERR_DATA;
+ /* Return an error if a mandatory item is not found. */
+ if (i <= ENCODING)
+ return SR_ERR_DATA;
+ continue;
}
/*
return SR_OK;
}
+ /* Set optional items to default values and parse the header. */
+ inc->wfmtype = ANALOG;
ret = parse_isf_header(in->buf, inc);
if (ret != SR_OK)
return ret;