nx_motion_lib.nx
buildroot/runtime/nx_motion_lib.nx
about
nx_motion_lib.nx -- THE /motion SURFACE'S ONE SET OF RULERS (2026-09-06): content typing by MAGIC, the multipart
upload parser, query and form decoding, the job status rows, the row-file readers, the page renderers and the
fork runner -- shared by the daemon (nx_motion_serve), the job (nx_motion_rig) and the gate (nx_motion_serve_gate)
so a parse fixed in one cannot stay broken in another. Every function is pure over buffers except the named reads.
WHY A LIB AND NOT THREE COPIES: the estate has measured, more than once, what happens when two organs must agree by
discipline -- they do not. The upload door types a file by its first bytes; the job names the same kinds; the gate
plants the same magics. One ruler, three callers.
license_tier: ORIGINAL
dependencies 1 imports · 4 importers
imports: nx_syscalls.nx
imported by: nx_motion_gate.nxnx_motion_rig.nxnx_motion_serve.nxnx_motion_serve_gate.nx
structs
| none |
consts
| 13 | const MO_KIND_UNKNOWN: i64 = 0 |
| 14 | const MO_KIND_GLB: i64 = 1 |
| 15 | const MO_KIND_FBX: i64 = 2 |
| 16 | const MO_KIND_NXA: i64 = 3 |
| 17 | const MO_KIND_OBJ: i64 = 4 // recognised so it can be REFUSED BY NAME: no sovereign OBJ door is composed yet (MO2) |
| 22 | const MO_UPLOAD_CAP: i64 = 8388608 |
| 23 | const MO_HDR_RESERVE: i64 = 65536 |
| 24 | const MO_REQ_CAP: i64 = 8453120 // MO_UPLOAD_CAP + MO_HDR_RESERVE, derived, so the request buffer cannot be a second guess |
| 25 | const MO_PATH_CAP: i64 = 1024 |
| 26 | const MO_VAL_CAP: i64 = 512 |
| 27 | const MO_ROWS_CAP: i64 = 262144 |
| 28 | const MO_PAGE_CAP: i64 = 1048576 |
| 29 | const MO_ARGV_CAP: i64 = 16 |
| 30 | const MO_JOBS_DIR: *u8 = "knowledge/motion/jobs/" |
| 31 | const MO_DEMOS_DIR: *u8 = "knowledge/motion/demos/" |
| 32 | const MO_CLIPS_ROWS: *u8 = "knowledge/motion_clips.rows" |
| 33 | const MO_DEMOS_ROWS: *u8 = "knowledge/motion_demos.rows" |
| 34 | const MO_TMPL: *u8 = "knowledge/motion_page.tmpl" |
| 35 | const MO_VERDICTS: *u8 = "knowledge/motion/verdicts.jrnl" |
| 36 | const MO_A_NL: i64 = 10 |
| 37 | const MO_A_CR: i64 = 13 |
| 38 | const MO_A_SP: i64 = 32 |
| 39 | const MO_A_QUOTE: i64 = 34 |
| 40 | const MO_A_AMP: i64 = 38 |
| 41 | const MO_A_PLUS: i64 = 43 |
| 42 | const MO_A_DASH: i64 = 45 |
| 43 | const MO_A_DOT: i64 = 46 |
| 44 | const MO_A_SLASH: i64 = 47 |
| 45 | const MO_A_D0: i64 = 48 |
| 46 | const MO_A_D9: i64 = 57 |
| 47 | const MO_A_SEMI: i64 = 59 |
| 48 | const MO_A_LT: i64 = 60 |
| 49 | const MO_A_EQ: i64 = 61 |
| 50 | const MO_A_GT: i64 = 62 |
| 51 | const MO_A_QMARK: i64 = 63 |
| 52 | const MO_A_AT: i64 = 64 |
| 53 | const MO_A_PCT: i64 = 37 |
| 54 | const MO_A_PIPE: i64 = 124 |
| 55 | const MO_A_UNDER: i64 = 95 |
| 56 | const MO_O_APPEND_CREATE_WR: i64 = 1089 // O_WRONLY 1 + O_CREAT 64 + O_APPEND 1024, the estate's append-only journal open |
| 57 | const MO_AT_FDCWD: i64 = 0 - 100 |
| 58 | const MO_SYS_OPENAT: i64 = 257 |
functions
| 61 | func mo_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 62 | func mo_cat(b: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; var p: i64 = o; while s[i] != (0 as u8) { b[p] = s[i]; p = p + 1; i = i + 1 } return p } |
| 63 | func mo_catb(b: *u8, o: i64, src: *u8, n: i64) -> i64 { var i: i64 = 0; while i < n { b[o + i] = src[i]; i = i + 1 } return o + n } |
| 64 | func mo_num(b: *u8, o: i64, v: i64) -> i64 |
| 76 | func mo_atoi(s: *u8, n: i64) -> i64 |
| 90 | func mo_streq(a: *u8, b: *u8) -> i64 |
| 97 | func mo_findfrom(buf: *u8, n: i64, from: i64, needle: *u8, nl: i64) -> i64 |
| 109 | func mo_find(buf: *u8, n: i64, needle: *u8) -> i64 { return mo_findfrom(buf, n, 0, needle, mo_slen(needle)) } |
| 110 | func mo_starts(buf: *u8, n: i64, pre: *u8) -> i64 |
| 116 | func mo_digits_only(s: *u8) -> i64 |
| 129 | func mo_safe_name(s: *u8) -> i64 |
| 149 | func mo_esc(b: *u8, o: i64, s: *u8, n: i64) -> i64 |
| 169 | func mo_kind_of(b: *u8, n: i64) -> i64 |
| 192 | func mo_kind_name(k: i64) -> *u8 called by 1: ms_upload |
| 199 | func mo_kind_from_name(s: *u8) -> i64 |
| 209 | func mo_boundary(req: *u8, hend: i64, out: *u8, cap: i64) -> i64 |
| 230 | func mo_part_find(body: *u8, n: i64, bnd: *u8, blen: i64, name: *u8, out_off: *i64, out_len: *i64) -> i64 |
| 273 | func mo_hexval(c: i64) -> i64 called by 1: mo_urldecode |
| 280 | func mo_urldecode(src: *u8, n: i64, out: *u8, cap: i64) -> i64 |
| 304 | func mo_kv(s: *u8, n: i64, key: *u8, out: *u8, cap: i64) -> i64 |
| 324 | func mo_qparam(path: *u8, plen: i64, key: *u8, out: *u8, cap: i64) -> i64 |
| 334 | func mo_path_has(path: *u8, plen: i64, seg: *u8) -> i64 |
| 342 | func mo_last_seg(path: *u8, plen: i64, out: *u8, cap: i64) -> i64 |
| 355 | func mo_prev_seg(path: *u8, plen: i64, out: *u8, cap: i64) -> i64 |
| 373 | func mo_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 } |
| 374 | func mo_size(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 - 1 } let n: i64 = sys_lseek(fd, 0, 2); sys_close(fd); return n } |
| 376 | func mo_write_all(path: *u8, b: *u8, n: i64) -> i64 |
| 389 | func mo_append(path: *u8, b: *u8, n: i64) -> i64 |
| 397 | func mo_read(path: *u8, lp: *i64) -> *u8 { lp[0] = 0; let b: *u8 = sys_read_file(path, lp); if (b as i64) == 0 { lp[0] = 0 } return b } |
| 399 | func mo_join(dir: *u8, name: *u8) -> *u8 |
| 410 | func mo_status_field(buf: *u8, n: i64, key: *u8) -> i64 |
| 427 | func mo_status_str(buf: *u8, n: i64, key: *u8, out: *u8, cap: i64) -> i64 |
| 451 | func mo_log_field(buf: *u8, n: i64, key: *u8) -> i64 |
| 465 | func mo_row_find(buf: *u8, n: i64, key: *u8) -> i64 |
| 482 | func mo_row_field(buf: *u8, n: i64, rs: i64, idx: i64, out: *u8, cap: i64) -> i64 |
| 503 | func mo_row_next(buf: *u8, n: i64, pos: i64) -> i64 |
| 517 | func mo_run(elf: *u8, words: *i64, nw: i64, logpath: *u8) -> i64 called by 5: mg_run_rigmr_rendermr_rigmr_animmg_run_rig calls 8: sys_mmapsys_forksys_openat_wrsys_dup3sys_execvesys_exit+2 |
| 540 | func mo_run_detached(elf: *u8, words: *i64, nw: i64, logpath: *u8) -> i64 called by 3: ms_uploadms_animms_verdict calls 7: sys_mmapsys_forksys_exitsys_openat_wrsys_dup3sys_execve+1 |
| 567 | func mo_splice(out: *u8, cap: i64, tmpl: *u8, tn: i64, head: *u8, hn: i64, body: *u8, bn: i64) -> i64 |
| 583 | func mo_clip_options(b: *u8, o: i64, rows: *u8, rn: i64) -> i64 |
| 609 | func mo_clip_list(b: *u8, o: i64, rows: *u8, rn: i64) -> i64 |
| 643 | func mo_demo_cards(b: *u8, o: i64, rows: *u8, rn: i64) -> i64 |
| 677 | func mo_body_index(b: *u8, clips: *u8, cn: i64, demos: *u8, dn: i64) -> i64 |
| 697 | func mo_body_job(b: *u8, id: *u8, st: *u8, sn: i64, done: i64, clips: *u8, cn: i64, applied: *u8, an: i64, verdicts: *u8, vn: i64) -> i64 |