|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Private lexical seams shared by the bounded XML reader. More...
Go to the source code of this file.
Functions | |
| bool | priv_xml_span_valid (size_t source_len, xml_span_t span) |
| Check that a source-relative span is in range. | |
| bool | priv_xml_bytes_equal (const uint8_t *source, size_t offset, const char *literal, size_t length) |
| Compare bounded source bytes with an ASCII character sequence. | |
| 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. | |
| 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. | |
| ra8_err_t | priv_xml_doctype (xml_reader_t *reader) |
| Validate and skip one supported pre-root external DOCTYPE. | |
Private lexical seams shared by the bounded XML reader.
Exposes the scalar geometry plus the span, QName, raw UTF-8, and external-only DOCTYPE validators shared across the reader's implementation translation units.
[Ring 3 / LIB] {World: NS}
Definition in file xml_internal.h.
| enum priv_xml_encoding_t : uint32_t |
XML 1.0 scalar bounds and canonical UTF-8 bit geometry.
Definition at line 24 of file xml_internal.h.
| bool priv_xml_bytes_equal | ( | const uint8_t * | source, |
| size_t | offset, | ||
| const char * | literal, | ||
| size_t | length ) |
Compare bounded source bytes with an ASCII character sequence.
Compares byte by byte so plain-character literals are never passed to memcmp() alongside essentially-unsigned source bytes.
| [in] | source | Immutable source bytes. |
| [in] | offset | First source byte to compare. |
| [in] | literal | Character sequence whose first length bytes are compared. |
| [in] | length | Number of bytes to compare. |
| true | The complete byte sequence matched. |
| false | At least one byte differed. |
source spans at least offset + length readable bytes. literal spans at least length readable characters. Compare bounded source bytes with an ASCII character sequence.
Walks both operands one byte at a time so the comparison never hands an essentially-character operand to memcmp(), whose ordering is implementation-defined for plain char (MISRA-C:2012 Rules 21.14, 21.16). Only equality is ever asked of this function, so the loop is the whole contract.
| [in] | source | Immutable source bytes. |
| [in] | offset | First source byte to compare. |
| [in] | literal | Literal whose first length bytes are compared. |
| [in] | length | Byte count to compare. |
| true | Every compared byte matched. |
| false | At least one byte differed. |
source spans at least offset + length readable bytes. literal spans at least length readable bytes. Definition at line 260 of file xml_decode.c.
Referenced by internal_encoding(), internal_entity(), internal_external_id(), internal_keyword(), internal_pi(), internal_special(), internal_terminator(), priv_xml_doctype(), and xml_span_equal().
| ra8_err_t priv_xml_doctype | ( | xml_reader_t * | reader | ) |
Validate and skip one supported pre-root external DOCTYPE.
Accepts bare, SYSTEM, or PUBLIC external-only forms and fetches nothing.
| [in,out] | reader | Active reader positioned at <!DOCTYPE. |
| k_ra8_ok | Supported declaration consumed. |
| k_ra8_err_validation_failed | Placement, subset, or grammar was invalid. |
Definition at line 196 of file xml_doctype.c.
References xml_reader_t::doctype_seen, internal_external_id(), internal_skip_space(), k_ra8_err_validation_failed, k_ra8_ok, xml_reader_t::position, priv_xml_bytes_equal(), priv_xml_qname(), xml_reader_t::root_count, xml_reader_t::source, and xml_reader_t::source_len.
Referenced by internal_special().
| 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.
Accepts one or two ASCII NCName components separated by one colon.
| [in] | source | Immutable XML source. |
| [in] | end | One-past-last readable lexical byte. |
| [in] | start | Candidate QName start offset. |
| [out] | out_end | One-past-last accepted QName byte. |
| k_ra8_ok | At least one valid QName component was consumed. |
| k_ra8_err_validation_failed | Start or namespace spelling was invalid. |
source spans at least end readable bytes. out_end is writable and does not overlap source. Definition at line 47 of file xml.c.
References internal_name_continue(), internal_name_start(), k_ra8_err_validation_failed, and k_ra8_ok.
Referenced by internal_attr_parse(), internal_end(), internal_pi(), internal_start(), and priv_xml_doctype().
| 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.
Rejects overlong encoding, invalid continuations, controls, and surrogates.
| [in] | source | Immutable XML source. |
| [in] | start | First byte to validate. |
| [in] | end | One-past-last byte to validate. |
| k_ra8_ok | Every byte belongs to a permitted canonical scalar. |
| k_ra8_err_validation_failed | Encoding or XML character was invalid. |
source spans at least end readable bytes. Definition at line 610 of file xml_decode.c.
References internal_utf8_next(), and k_ra8_ok.
Referenced by internal_cdata(), internal_comment(), internal_literal(), and internal_pi().
| bool priv_xml_span_valid | ( | size_t | source_len, |
| xml_span_t | span ) |
Check that a source-relative span is in range.
Uses subtraction after checking the offset to avoid overflow.
| [in] | source_len | Exact source byte extent. |
| [in] | span | Candidate source-relative span. |
| true | Offset and length are bounded. |
| false | The span is forged, stale, or out of range. |
source_len is the true readable extent. span uses the same source-relative coordinate system. Definition at line 161 of file xml_decode.c.
References xml_span_t::length, and xml_span_t::offset.
Referenced by xml_attr_next(), xml_decode(), xml_decode_prefix(), xml_decoded_size(), xml_span_equal(), and xml_span_local_equal().