code wiki / (root) / nx_accept_lang.nx

nx_accept_lang.nx

buildroot/runtime/nx_accept_lang.nx

6720 B223 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

accept_lang.nx -- parse HTTP Accept-Language header. RFC 7231 ยง5.3.5. Clients send a comma-separated list of language tags with optional quality values: Accept-Language: en-US,en;q=0.9,fr;q=0.8,*;q=0.1 We parse this into a sorted array of (tag, quality_thousandths) and expose a lookup helper that picks the best match from a server-supported-languages list. Quality values: - Default q = 1.0 if omitted - Range 0.0..1.0; anything else clamped - Stored as integer thousandths (0..1000) to avoid FP math Sorting: higher quality first; ties preserve input order (stable). Caller walks sorted list first-match against their supported set. Invariants: AL1 Zero-alloc: offsets into caller's buffer. AL2 \"*\" wildcard accepted as a language tag; it matches any language that hasn't been explicitly excluded. AL3 Language tag byte ranges preserved as-is (case-sensitive in the buffer); caller does ASCII-lowercase compare if they need RFC-correct case-insensitive matching.

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_accept_lang.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap accept_lang_parse sys_mmap ↻ al_ltrim al_is_ws al_rtrim al_is_ws ↻ al_parse_q al_is_ws ↻ accept_lang_sort

structs

38struct AcceptLang

consts

36const AL_ERR_OVERFLOW: i64 = -1

functions

44func al_is_ws(b: i64) -> i64
50func al_ltrim(buf: *u8, off: i64, end: i64) -> i64
called by 1: accept_lang_parse calls 1: al_is_ws
59func al_rtrim(buf: *u8, start: i64, end: i64) -> i64
called by 1: accept_lang_parse calls 1: al_is_ws
70func al_parse_q(buf: *u8, pos: *i64, end: i64) -> i64
called by 1: accept_lang_parse calls 1: al_is_ws
117func accept_lang_parse(buf: *u8, n: i64,
165func accept_lang_sort(entries: *AcceptLang, count: i64) -> i64
called by 1: main
192func main() -> i64