nx_atlas_cite.nx source
↩ module page · 29 lines · 1215 B
1// nx_atlas_cite.nx -- atlas-hygiene CITATION FORMAT PRECHECK (blueprint Callout 1 / F265, first rung).
2// Syntactic pre-verify of an external reference id BEFORE the network authority check: a DOI must start
3// \"10.\" -> PASS-FORMAT (exit 0, eligible for Crossref/S2 verify); else -> QUARANTINE (exit 5, malformed).
4// Full external verify = the fetch compose (honest: this is the format rung only). license_tier: ORIGINAL expect_exit: 0
5import "nx_syscalls.nx"
6func ci_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
7func main(argc: i64, argv: *i64) -> i64 {
8 if argc < 2 {
9 sys_write(1, "ATLASCITE ERR need doi\n" as *u8, 23)
10 sys_exit(2)
11 return 2
12 }
13 let id: *u8 = argv[1] as *u8
14 let n: i64 = ci_slen(id)
15 if n >= 3 {
16 if id[0] == (49 as u8) {
17 if id[1] == (48 as u8) {
18 if id[2] == (46 as u8) {
19 sys_write(1, "ATLASCITE PASS-FORMAT doi-eligible-for-verify\n" as *u8, 46)
20 sys_exit(0)
21 return 0
22 }
23 }
24 }
25 }
26 sys_write(1, "ATLASCITE QUARANTINE malformed-doi\n" as *u8, 35)
27 sys_exit(5)
28 return 5
29}