API reference

Return codes

group return_codes

Defines

ZONE_SUCCESS (0)

Success.

ZONE_SYNTAX_ERROR (-256)

A syntax error occurred.

ZONE_SEMANTIC_ERROR (-512)

A semantic error occurred.

ZONE_OUT_OF_MEMORY (-768)

Operation failed due to lack of memory.

ZONE_BAD_PARAMETER (-1024)

Bad parameter value.

ZONE_READ_ERROR (-1280)

Error reading zone file.

ZONE_NOT_IMPLEMENTED (-1536)

Control directive or support for record type is not implemented.

ZONE_NOT_A_FILE (-1792)

Specified file does not exist.

ZONE_NOT_PERMITTED (-2048)

Access to specified file is not allowed.

Parse functions

int32_t zone_parse(zone_parser_t *parser, const zone_options_t *options, zone_buffers_t *buffers, const char *path, void *user_data)

Parse zone file.

Parse file containing resource records.

Parameters:
  • parser[in] Zone parser

  • options[in] Settings used for parsing.

  • buffers[in] Scratch buffers used for parsing.

  • path[in] Path of master file to parse.

  • user_data[in] Pointer passed verbatim to callbacks.

Returns:

ZONE_SUCCESS on success or a negative number on error.

int32_t zone_parse_string(zone_parser_t *parser, const zone_options_t *options, zone_buffers_t *buffers, const char *string, size_t length, void *user_data)

Parse zone from string.

Parse string containing resource records in presentation format.

Warning

The input string must be null terminated and padded with at least ZONE_BLOCK_SIZE bytes.

Parameters:
  • parser[in] Zone parser

  • options[in] Settings used for parsing.

  • buffers[in] Scratch buffers used by parsing.

  • string[in] Input string.

  • length[in] Length of string (excluding null byte and padding).

  • user_data[in] Pointer passed verbatim to callbacks.

Returns:

ZONE_SUCCESS on success or a negative number on error.

Log priorities

group log_priorities

Note

No direct relation between log categories and error codes exists. Log categories communicate the importance of the log message, error codes communicate what went wrong to the caller.

Defines

ZONE_ERROR

Error condition.

ZONE_WARNING

Warning condition.

ZONE_INFO

Informational message.

Log functions

void zone_log(zone_parser_t *parser, uint32_t priority, const char *format, ...)

Write message to active log handler.

The zone parser operates on a per-record base and therefore cannot detect errors that span records. e.g. SOA records being specified more than once. The user may print a message using the active log handler, keeping the error message format consistent.

Parameters:
  • parser[in] Zone parser

  • priority[in] Log priority

  • format[in] Format string compatible with printf

  • ...[in] Variadic arguments corresponding to #format

For convenience simdzone defines a number of macros.

zone_error(parser, ...)

Write error message to active log handler.

Shorthand to write out error message via zone_log if error messages are not to be discarded.

Parameters:
  • parser[in] Zone parser

  • format[in] Format string

  • ...[in] Variadic arguments corresponding to #format

zone_warning(parser, ...)

Write warning message to active log handler.

Shorthand to write out warning message via zone_log if warning messages are not to be discarded.

Parameters:
  • parser[in] Zone parser

  • format[in] Format string compatible with printf.

  • ...[in] Variadic arguments corresponding to @format.

zone_info(parser, ...)

Write informational message to active log handler.

Shorthand to write out informational message via zone_log if informational messages are not be discarded.

Parameters:
  • parser[in] Zone parser.

  • format[in] Format string compatible with printf.

  • ...[in] Variadic arguments corresponding to @format.