code wiki / (root) / email_addr.nx

email_addr.nx

buildroot/runtime/email_addr.nx

7782 B240 linesdepth 3pulls 3 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

syscalls.nx email_addr.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 email_addr_validate ea_is_local_char ea_is_alnum

structs

50struct EmailAddr {

consts

33const EA_MAX_TOTAL: i64 = 320
34const EA_MAX_LOCAL: i64 = 64
35const EA_MAX_DOMAIN: i64 = 255
36const EA_MAX_LABEL: i64 = 63
38const EA_ERR_TOTAL_LEN: i64 = -1
39const EA_ERR_NO_AT: i64 = -2
40const EA_ERR_LOCAL_EMPTY: i64 = -3
41const EA_ERR_LOCAL_LEN: i64 = -4
42const EA_ERR_LOCAL_CHAR: i64 = -5
43const EA_ERR_LOCAL_DOT: i64 = -6
44const EA_ERR_DOMAIN_EMPTY: i64 = -7
45const EA_ERR_DOMAIN_LEN: i64 = -8
46const EA_ERR_LABEL_LEN: i64 = -9
47const EA_ERR_LABEL_CHAR: i64 = -10
48const EA_ERR_LABEL_DASH: i64 = -11

functions

56func ea_is_local_char(b: i64) -> i64 {
called by 1: email_addr_validate
92func ea_is_alnum(b: i64) -> i64 {
called by 1: email_addr_validate
106func if_eq_or(a: i64, b: i64, v1: i64, v2: i64) -> i64;
110func email_addr_validate(buf: *u8, n: i64, e: *EmailAddr) -> i64 {
called by 1: main calls 2: ea_is_local_charea_is_alnum
197func if_eq_or(a: i64, b: i64, v1: i64, v2: i64) -> i64 {
203func main() -> i64 {