code wiki / (root) / nx_fetch_to_file.nx

nx_fetch_to_file.nx

buildroot/runtime/nx_fetch_to_file.nx

2965 B39 linesdepth 21pulls 146 transitivereach 0 importersview sourcekind tooltopic fetch
docsdependenciesstructsconstsfunctions

about

nx_fetch_to_file.nx -- fetch an arbitrary (unknown-size) URL body into RAM via sovereign TLS (redirect-following) and write it to a file. For images/small assets where nx_hf_file_fetch (needs a known expected size) doesn't fit. Reads URL from data/mp_img_url.txt, writes to data/mp_img_dest.txt's path. expect_exit: 0

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_x509_trust_store.nx nx_trust_store_load_from_certdata. nx_https_fetch_follow.nx nx_fetch_to_file.nx

imports: nx_syscalls.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_https_fetch_follow.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 rdcfg sys_openat_rd sys_read sys_close w sys_write sys_exit nx_trust_store_load_from_c sys_mmap ↻ sys_read_file sys_openat_rd ↻ sys_lseek sys_mmap ↻ sys_read ↻ sys_close ↻ nx_nss_certdata_parse sys_mmap ↻ _pat_class_cert _pat_value_octal _pat_end _find_newline _starts_with _parse_octal_line sys_mmap ↻ _is_space _decode_octal_escape _is_octal trust_store_alloc sys_mmap ↻ nx_x509_trust_store_load sys_mmap ↻ x509_parse sys_mmap ↻ asn1_cursor_init asn1_expect_tag sys_mmap ↻ asn1_read_tlv_header asn1_read_tag

structs

none

consts

8const K_MAGIC_4096: i64 = 4096
9const K_MAGIC_4194304: i64 = 4194304
10const K_MAGIC_16777216: i64 = 16777216

functions

12func w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 2: wnmain calls 1: sys_write
13func wn(v: i64) -> i64 { var m: i64=v; if m<0{w("-" as *u8);m=0-m} let t:*u8=sys_mmap(24); var k:i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i:i64=0; let o:*u8=sys_mmap(24); while i<k{o[i]=t[k-1-i];i=i+1} sys_write(1,o,k); return 0 }
called by 1: main calls 3: wsys_mmapsys_write
14func shx(v: i64) -> i64 { let b: *u8=sys_mmap(4); var i: i64=0; while i<2 { let n: i64=(v>>((1-i)*4))&0xF; if n<10{b[i]=(48+n) as u8} else {b[i]=(87+n) as u8} i=i+1 } sys_write(1,b,2); return 0 }
called by 1: main calls 2: sys_mmapsys_write
15func rdcfg(path: *u8, buf: *u8, cap: i64) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0{return 0-1} var n: i64=sys_read(fd,buf,cap-1); sys_close(fd); if n<0{return 0-1} var go: i64=1; while go==1{go=0; if n>0{ let c: i64=buf[n-1] as i64; if c==10{n=n-1;go=1} if c==13{n=n-1;go=1} if c==32{n=n-1;go=1} }} buf[n]=0 as u8; return n }
called by 1: main calls 3: sys_openat_rdsys_readsys_close
17func main() -> i64