Status codes

#include <lfp/lfp.h>

enum lfp_status

Status codes for return values.

Unless very explicitly documented otherwise, public functions in lfp return an integer corresponding to one of these error codes.

Values:

enumerator LFP_OK
enumerator LFP_OKINCOMPLETE

Returned in successful-but-incomplete scenarios, for example by lfp_readinto() when the underlying IO is blocked from providing more bytes.

For end-of-file, see LFP_EOF.

enumerator LFP_NOTIMPLEMENTED

Returned when functionality is not implemented by a specific handle.

enumerator LFP_LEAF_PROTOCOL

The functionality is implemented and supported in general, but not supported for leaf protocols.

enumerator LFP_NOTSUPPORTED

The functionality is implemented and supported in general, but not supported for a specific configuration for this handle.

An example is lfp_seek() or lfp_tell() in an unseekable lfp_cfile stream (pipe).

enumerator LFP_UNHANDLED_EXCEPTION

An implementation threw a C++ exception that was not properly caught, and would be next to bubble up to call site, which expects C and is not prepared for it (which would in the best case call std::terminate).

enumerator LFP_IOERROR

A problem with a phyiscal device - depending on the device, this might be recoverable, but it means a read or write operation could not be performed correctly.

enumerator LFP_RUNTIME_ERROR

Some error in the runtime, for example being unable to allocate or resize a buffer.

This does not mean an error at runtime, it means an error from the runtime.

enumerator LFP_INVALID_ARGS

Returned whenever an invalid argument is passed to the function, such as trying to seek beyond end-of-file.

enumerator LFP_PROTOCOL_FATAL_ERROR

A fatal, unrecoverable protocol error.

This is returned when actual reads or writes were successful, but the bytes are inconsistent with what the protocol expects.

enumerator LFP_PROTOCOL_TRYRECOVERY

There was a protocol violation, but simple recovery seems to work.

An example is formats that point backwards, and the backwards pointer is wrong.

In some cases you might want to consider this fatal as well.

enumerator LFP_PROTOCOL_FAILEDRECOVERY

When more protocol recovery was happening, but more errors occured.

enumerator LFP_EOF

Returned in successful-but-incomplete scenarios, for example by lfp_readinto() when the end of file is reached before reading all requested bytes.

enumerator LFP_UNEXPECTED_EOF

Returned when the underlying handle reports end-of-file while an outer protocol expected there to be more data.