#ifndef SIGSUM_ASCII_INTERNAL_H_INCLUDED
#define SIGSUM_ASCII_INTERNAL_H_INCLUDED

#include <stddef.h>
#include <stdbool.h>

struct sigsum_buffer
{
  size_t size;
  const char *data;
};

/* Case-insensitive hex decoding. */
/* Decodes SIZE bytes, input must be 2*SIZE hex digits. */
bool
_sigsum_decode_hex (size_t size, uint8_t *dst, const char *src);

/* Parse next line from BUFFER, store it (by reference, and without
   the terminating newline character) in VALUE. Requires terminating
   newline. */
bool
_sigsum_buffer_line_strict (struct sigsum_buffer *buffer, struct sigsum_buffer *value);

/* Parse next line from BUFFER, store it (by reference, and without
   any terminating newline character) in VALUE. Never fails: End of
   data is treated as a line terminator followed by all empty
   lines. */
void
_sigsum_buffer_line (struct sigsum_buffer *buffer, struct sigsum_buffer *value);

/* Parses next whitespace-separated field from BUFFER, store it (by
   reference) in VALUE. Ignores leading whitespace, and advances
   BUFFER past the token and the whitespace character (if any)
   separating it from the rest of the data. Whitespace characters are
   only SPC and TAB. Returns an empty token if and only if the input
   buffer was all whitespace. */
void
_sigsum_buffer_token (struct sigsum_buffer *buffer, struct sigsum_buffer *token);

#endif /* SIGSUM_ASCII_INTERNAL_H_INCLUDED */
