code wiki / (root) / nx_email_mime.nx

nx_email_mime.nx

buildroot/runtime/nx_email_mime.nx

13163 B322 linesdepth 1pulls 1 transitivereach 9 importersview sourcekind librarytopic email
docsdependenciesstructsconstsfunctions

about

nx_email_mime.nx -- EMAIL RUNG R2: RFC 5322 message + MIME codec. module: nishi-core.email.mime depends: nishi-core.codec.base64 capability: CORE_EMAIL (Distinct from runtime/nx_mime.nx, which maps file extensions to content-type strings for the web server. THIS is the email message FORMAT codec.) The message FORMAT layer: what actually travels inside the SMTP DATA phase (R1) and what a retrieval client (R4) hands back. Pure codec, no syscalls -- fully gateable offline. Four parts: 1. RFC 5322 STRUCTURE -- split header block from body at the blank line (CRLFCRLF); case-insensitive header-field lookup that UNFOLDS folded continuation lines (§2.2.3); header append. 2. QUOTED-PRINTABLE (RFC 2045 §6.7) -- binary-safe encode/decode with "=XX" hex escapes and "=CRLF" soft line breaks at 76 cols. 3. BASE64 for MIME -- composes the canonical nx_base64 b64_encode/ b64_decode (NOT reimplemented) + the 76-column CRLF wrap RFC 2045 requires, and a whitespace-tolerant decode. 4. MULTIPART (RFC 2046) -- assemble parts under a boundary + extract the Nth part's content. license_tier: INDEPENDENT_REDERIVE genealogy_id: international-research-sources/ietf/rfc_5322 + rfc_2045 + rfc_2046 lineage_id: nishi_email_mime_r2 nx_safety_envelope: intended_use: "RFC 5322 header/body + MIME transfer-encodings + multipart. Email message format substrate." sil_target: SIL2 (header injection / boundary confusion) evidence: [RFC_5322_2045_2046_basis, header_unfold, qp_roundtrip, base64_composes_canonical, prefix-exact_header_match, multipart_extract] hazard_register: [bug-tape-header-injection-CRLF, bug-tape-mime-boundary-collision] residual_risk: "Encoded-word (RFC 2047) non-ASCII header values + nested multipart are later sub-rungs."

dependencies 1 imports · 3 importers

nx_base64.nx nx_email_mime.nx nx_email_mime_gate.nx nx_email_send.nx nx_email_webmail.nx

imports: nx_base64.nx

imported by: nx_email_mime_gate.nxnx_email_send.nxnx_email_webmail.nx

structs

none

consts

45const NX_MIME_BUF_FULL: i64 = 2
46const NX_MIME_BAD_QP: i64 = 3
47const NX_MIME_NOT_FOUND: i64 = 4

functions

50func mm_lower(c: i64) -> i64 { if c >= 65 && c <= 90 { return c + 32 } return c }
called by 1: mm_ci_eq
51func mm_ci_eq(a: *u8, b: *u8, len: i64) -> i64
called by 1: nx_mime_header_find calls 1: mm_lower
56func mm_match(a: *u8, b: *u8, len: i64) -> i64
61func mm_cat(out: *u8, oi: i64, s: *u8) -> i64
66func mm_catn(out: *u8, oi: i64, s: *u8, len: i64) -> i64
71func mm_hexu(v: i64) -> i64 { let w: i64 = v & 0xf; if w < 10 { return 48 + w } return 65 + (w - 10) }
called by 1: nx_mime_qp_encode
72func mm_hexval(c: i64) -> i64
called by 1: nx_mime_qp_decode
83func nx_mime_split_body(msg: *u8, n: i64, out_body_off: *i64) -> i64
100func nx_mime_header_find(hdr: *u8, hlen: i64, name: *u8, namelen: i64, out: *u8, out_cap: i64) -> i64
147func nx_mime_header_append(out: *u8, oi: i64, name: *u8, value: *u8) -> i64
called by 1: main calls 1: mm_cat
157func nx_mime_qp_encode(src: *u8, n: i64, out: *u8, cap: i64) -> i64
called by 1: main calls 1: mm_hexu
191func nx_mime_qp_decode(src: *u8, n: i64, out: *u8, cap: i64) -> i64
called by 1: main calls 1: mm_hexval
225func nx_mime_b64_encode_wrap(src: *u8, n: i64, out: *u8, cap: i64) -> i64
called by 1: main calls 1: b64_encode
242func nx_mime_b64_decode_ws(src: *u8, n: i64, scratch: *u8, out: *u8) -> i64
called by 1: main calls 1: b64_decode
255func nx_mime_multipart_assemble(
called by 1: main calls 2: mm_catnmm_cat
284func nx_mime_multipart_part(body: *u8, n: i64, boundary: *u8, blen: i64, idx: i64, out: *u8, out_cap: i64) -> i64
called by 1: main calls 1: mm_match