util.h

The util.h module contains additional functionality generally used throughout a makinori project.

API

enum mn_error

A representation of some error encountered during normal operations.

unsigned int MN_ERROR_NONE = 0

No error.

unsigned int MN_ERROR_CONFIG = 1

An error was encountered when either loading or executing a Lua config.

unsigned int MN_ERROR_INVALID_ARG = 2

An invalid argument was supplied to an API function.

unsigned int MN_ERROR_IMMUTABLE = 3

An attempt was made to update an immutable object.

unsigned int MN_ERROR_DUPLICATE = 4

An attempt was made to create another instance of some object.

unsigned int MN_ERROR_SYSTEM = 900

A generic error, internal to makinori, occurred. Please file an issue.

unsigned int MN_ERROR_NOMEM = 901

Memory was requested that could not be allocated.

struct mn_status

A general status indicator. Many API functions provided by makinori prefer to type over e.g. integer status codes for clarity or additional context.

enum mn_error error

The error code associated with the status. Considered successful if and only if error is MN_ERROR_NONE.

struct mn_str file

The file this status instance was generated from.

struct mn_str line

The line number of the file this status instance was generated from.

MN_SUCCESS

Utility for generating a mn_status instance with error MN_ERROR_NONE.

MN_FAILURE(err)

Utility for generating a mn_status instance with error set to err.

MN_FAILURE_EMIT(err, lvl, msg, ...)

Utility for logging a msg at log level lvl and then returning a mn_status instance with error set to err.

MN_WARN_EMIT(err, msg, ...)

Utility for logging a msg at log level MN_LOG_LEVEL_WARN and then returning a mn_status instance with error set to err.

MN_ERROR_EMIT(err, msg, ...)

Utility for logging a msg at log level MN_LOG_LEVEL_ERROR and then returning a mn_status instance with error set to err.

mn_assert(condition)

Asserts the provided condition at runtime. Calls abort() if false. Generally prefer this to assert since it outputs error messages in the same format as other logs.

Does nothing if NDEBUG is defined.