37 return (
byte == (uint8_t)
' ') || (
byte == (uint8_t)
'\t') || (
byte == (uint8_t)
'\n') ||
38 (
byte == (uint8_t)
'\r');
59 const size_t initial = *position;
63 return *position != initial;
82 static const char punctuation[] =
"-'()+,./:=?;!*#@$_%";
83 return (
byte == (uint8_t)
' ') || (
byte == (uint8_t)
'\r') || (
byte == (uint8_t)
'\n') ||
84 ((
byte >= (uint8_t)
'A') && (
byte <= (uint8_t)
'Z')) ||
85 ((
byte >= (uint8_t)
'a') && (
byte <= (uint8_t)
'z')) ||
86 ((
byte >= (uint8_t)
'0') && (
byte <= (uint8_t)
'9')) ||
87 ((
byte != 0U) && (
strchr(punctuation, (
int)
byte) !=
nullptr));
110 if ((*position >= end) ||
111 ((source[*position] != (uint8_t)
'\'') && (source[*position] != (uint8_t)
'"'))) {
114 const uint8_t quote = source[*position];
116 const size_t start = *position;
117 while ((*position < end) && (source[*position] != quote)) {
123 if (*position >= end) {
151 const size_t length =
strlen(keyword);
153 if (((*position + length) > end) || !
priv_xml_bytes_equal(source, *position, keyword, length)) {
198 static const char prefix[] =
"<!DOCTYPE";
202 ((position +
sizeof(prefix) - 1U) > end) ||
206 position +=
sizeof(prefix) - 1U;
210 size_t name_end = 0U;
216 if ((position < end) && (reader->
source[position] != (uint8_t)
'>')) {
222 if ((position >= end) || (reader->
source[position] != (uint8_t)
'>')) {
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
@ k_ra8_err_validation_failed
Validation rule failed (caller-supplied invariant not satisfied).
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
size_t strlen(const char *s)
Calculate string length.
char * strchr(const char *s, int c)
Locate first occurrence of character in string.
Pull-reader state; initialise before each pass.
uint8_t root_count
Completed/started roots.
const uint8_t * source
Immutable source bytes.
uint8_t doctype_seen
One after a supported DOCTYPE.
size_t source_len
Source byte count.
size_t position
Next scan position.
ra8_err_t priv_xml_qname(const uint8_t *source, size_t end, size_t start, size_t *out_end)
Scan the supported QName subset over a bounded byte range.
bool priv_xml_bytes_equal(const uint8_t *source, size_t offset, const char *literal, size_t length)
Compare bounded source bytes against a literal of known length.
ra8_err_t priv_xml_raw(const uint8_t *source, size_t start, size_t end)
Validate canonical UTF-8 XML 1.0 characters over a byte range.
static ra8_err_t internal_literal(const uint8_t *source, size_t end, size_t *position, bool public_id)
Parse one quoted system or public identifier literal.
static bool internal_space(uint8_t byte)
Test whether one byte is XML spacing inside a DOCTYPE.
static ra8_err_t internal_keyword(const uint8_t *source, size_t end, size_t *position, const char *keyword)
Consume an exact ASCII keyword followed by required spacing.
ra8_err_t priv_xml_doctype(xml_reader_t *reader)
Validate and skip one supported pre-root external DOCTYPE.
static bool internal_skip_space(const uint8_t *source, size_t end, size_t *position)
Skip XML spacing and report whether at least one byte was consumed.
static bool internal_pubid_byte(uint8_t byte)
Test the XML PubidChar subset accepted in public identifiers.
static ra8_err_t internal_external_id(const uint8_t *source, size_t end, size_t *position)
Parse a SYSTEM or PUBLIC external identifier.
Private lexical seams shared by the bounded XML reader.