code wiki / (root) / accept_lang.nx

accept_lang.nx

buildroot/runtime/accept_lang.nx

6683 B217 linesdepth 3pulls 3 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

syscalls.nx accept_lang.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

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

main accept_lang_parse al_ltrim al_is_ws al_rtrim al_is_ws ↻ al_parse_q al_is_ws ↻ accept_lang_sort

structs

32struct AcceptLang {

consts

30const AL_ERR_OVERFLOW: i64 = -1

functions

38func al_is_ws(b: i64) -> i64 {
44func al_ltrim(buf: *u8, off: i64, end: i64) -> i64 {
called by 1: accept_lang_parse calls 1: al_is_ws
53func al_rtrim(buf: *u8, start: i64, end: i64) -> i64 {
called by 1: accept_lang_parse calls 1: al_is_ws
64func al_parse_q(buf: *u8, pos: *i64, end: i64) -> i64 {
called by 1: accept_lang_parse calls 1: al_is_ws
111func accept_lang_parse(buf: *u8, n: i64,
called by 1: main calls 3: al_ltrimal_rtrimal_parse_q
159func accept_lang_sort(entries: *AcceptLang, count: i64) -> i64 {
called by 1: main
186func main() -> i64 {