Status

Status codes and return values used for error handling.

Success and various specific errors are reported by an integer status code, which can be converted to a string to produce friendly error messages. Reading and writing functions return a “result”, which has a status code along with a count of bytes read or written.

enum ExessStatus

Status code to describe errors or other relevant situations.

enumerator EXESS_SUCCESS

Success.

enumerator EXESS_LOSS

Lossy operation.

enumerator EXESS_EXPECTED_BOOLEAN

Expected “false”, “true”, “0” or “1”.

enumerator EXESS_EXPECTED_INTEGER

Expected an integer value.

enumerator EXESS_EXPECTED_DURATION

Expected a duration starting with ‘P’.

enumerator EXESS_EXPECTED_SIGN

Expected ‘-’ or ‘+’.

enumerator EXESS_EXPECTED_DIGIT

Expected a digit.

enumerator EXESS_EXPECTED_ZERO

Expected ‘0’.

enumerator EXESS_EXPECTED_COLON

Expected ‘:’.

enumerator EXESS_EXPECTED_DASH

Expected ‘-‘.

enumerator EXESS_EXPECTED_TIME_SEP

Expected ‘T’.

enumerator EXESS_EXPECTED_TIME_TAG

Expected ‘H’, ‘M’, or ‘S’.

enumerator EXESS_EXPECTED_DATE_TAG

Expected ‘Y’, ‘M’, or ‘D’.

enumerator EXESS_EXPECTED_SECOND_TAG

Expected ‘S’.

enumerator EXESS_EXPECTED_HEX

Expected a hexadecimal character.

enumerator EXESS_EXPECTED_BASE64

Expected a base64 character.

enumerator EXESS_BAD_ORDER

Invalid field order.

enumerator EXESS_BAD_VALUE

Invalid value.

enumerator EXESS_OUT_OF_RANGE

Value out of range.

enumerator EXESS_NO_SPACE

Insufficient space.

enumerator EXESS_UNSUPPORTED

Unsupported value.

struct ExessResult

Result returned from a read or write function.

This combines a status code with a byte offset, so it can be used to determine how many characters were read or written, or what error occurred at what character offset.

ExessStatus status

Status code.

size_t count

Number of bytes read or written, excluding null.

struct ExessVariableResult

Result returned from a function that reads and writes.

This is like ExessResult but includes separate read and write counts. This allows the caller to know both how many bytes were read from the input and how many bytes were written to the output.

ExessStatus status

Status code.

size_t read_count

Number of bytes read.

size_t write_count

Number of bytes written, excluding null.

const char *exess_strerror(ExessStatus status)

Return a string describing a status code in plain language.

The returned string is always one sentence, with an uppercase first character, and no trailing period.