code wiki / _hdl_build / _eval_flag_authored.nx

_eval_flag_authored.nx source

↩ module page · 24 lines · 985 B

1// AUTHORED BY THE NISHI BUILDER (nx_module_author_data eval-flag template) -- the O lane. 2import "nx_syscalls.nx" 3func _eg_w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } 4func main(argc: i64, argv: *i64) -> i64 { 5 if argc < 3 { _eg_w(1, "usage: eval_flag <img-id> <score-permil> [lanes-log]\n" as *u8); sys_exit(1); return 1 } 6 var lanes: *u8 = "knowledge/status/eval_lanes.log" as *u8 7 if argc>=4 { lanes = argv[3] as *u8 } 8 let logfd: i64 = sys_openat_append(lanes, 0x1a4) 9 if logfd < 0 { _eg_w(1, "FLAG FAIL log-unwritable\n" as *u8); sys_exit(1); return 1 } 10 var fdi: i64=1 11 while fdi>=0 { 12 var ofd: i64=1 13 if fdi==0 { ofd=logfd } 14 _eg_w(ofd, "EVAL img=" as *u8) 15 _eg_w(ofd, argv[1] as *u8) 16 _eg_w(ofd, " lane=O score=" as *u8) 17 _eg_w(ofd, argv[2] as *u8) 18 _eg_w(ofd, "\n" as *u8) 19 fdi=fdi-1 20 } 21 sys_close(logfd) 22 sys_exit(0) 23 return 0 24}