nx_fetch_to_file.nx
buildroot/runtime/nx_fetch_to_file.nx
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
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
structs
| none |
consts
| 8 | const K_MAGIC_4096: i64 = 4096 |
| 9 | const K_MAGIC_4194304: i64 = 4194304 |
| 10 | const K_MAGIC_16777216: i64 = 16777216 |
functions
| 12 | func w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 13 | func 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 } |
| 14 | func 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 } |
| 15 | func 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 } |
| 17 | func main() -> i64 |