code wiki / (root) / nx_email_addr.nx

nx_email_addr.nx

buildroot/runtime/nx_email_addr.nx

7796 B246 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic email
docsdependenciesstructsconstsfunctions

about

email_addr.nx -- RFC 5322 addr-spec validator (practical subset). The full RFC 5322 grammar accepts obscure forms like quoted local parts (\"foo bar\"@example.com), comments ((comment)), and folded whitespace -- practically never seen in real email addresses. We implement the subset that matches what users actually type: local@domain local = 1+ chars from [A-Za-z0-9!#$%&'*+-/=?^_`{|}~.] with '.' not first, not last, not consecutive domain = at least one DNS label separated by '.' label = [A-Za-z0-9] with optional [A-Za-z0-9-] interior, trailing alnum, total length 1..63 Returns (local_off, local_len, domain_off, domain_len) on success so caller can upper-case compare, hash, etc. Zero- alloc. Use cases: signup form validation, mailing-list import sanity check, abuse detection, SPF lookup prep. Invariants: EA1 Total length cap 320 bytes (RFC 5321 ยง4.5.3.1.3). EA2 Local part cap 64 bytes. EA3 Domain cap 255 bytes; per-label cap 63. EA4 Returns EA_ERR_* negative on violation; offsets populated even on failure up to the point of failure (useful for error messaging).

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_email_addr.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 email_addr_validate ea_is_local_char ea_is_alnum

structs

56struct EmailAddr

consts

39const EA_MAX_TOTAL: i64 = 320
40const EA_MAX_LOCAL: i64 = 64
41const EA_MAX_DOMAIN: i64 = 255
42const EA_MAX_LABEL: i64 = 63
44const EA_ERR_TOTAL_LEN: i64 = -1
45const EA_ERR_NO_AT: i64 = -2
46const EA_ERR_LOCAL_EMPTY: i64 = -3
47const EA_ERR_LOCAL_LEN: i64 = -4
48const EA_ERR_LOCAL_CHAR: i64 = -5
49const EA_ERR_LOCAL_DOT: i64 = -6
50const EA_ERR_DOMAIN_EMPTY: i64 = -7
51const EA_ERR_DOMAIN_LEN: i64 = -8
52const EA_ERR_LABEL_LEN: i64 = -9
53const EA_ERR_LABEL_CHAR: i64 = -10
54const EA_ERR_LABEL_DASH: i64 = -11

functions

62func ea_is_local_char(b: i64) -> i64
called by 1: email_addr_validate
98func ea_is_alnum(b: i64) -> i64
called by 1: email_addr_validate
112func if_eq_or(a: i64, b: i64, v1: i64, v2: i64) -> i64;
116func email_addr_validate(buf: *u8, n: i64, e: *EmailAddr) -> i64
called by 1: main calls 2: ea_is_local_charea_is_alnum
203func if_eq_or(a: i64, b: i64, v1: i64, v2: i64) -> i64
209func main() -> i64