aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/bstr_io.zc
blob: 8b1f2af5bee4e881b40b7294ad4117d7b2acc53d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
namespace;
include rt;

fn main() {
	let path = b"/tmp/zc-bstr.txt";
	let msg = b"byte-io";
	let fd = rt.bopen(path, 1);
	let n = rt.bwrite(fd, msg, rt.len_s(msg));
	rt.syscall(rt.SYS_CLOSE, fd, 0, 0);
	fd = rt.bopen(path, 0);
	let buf = rt.new_s(7);
	let g = rt.bread(fd, buf, 7);
	rt.syscall(rt.SYS_CLOSE, fd, 0, 0);
	let name = b"ZC_BSTR";
	let envb = rt.new_s(16);
	let k = rt.bgetenv(name, envb, 16);
	rt.put_s(buf); rt.put_c(32);
	rt.put_n(n); rt.put_c(32);
	rt.put_n(g); rt.put_c(32);
	rt.put_n(buf == msg); rt.put_c(32);
	rt.put_n(k); rt.put_c(32);
	rt.put_n(rt.at_s(envb, 0)); rt.put_c(32);
	rt.put_n(rt.at_s(envb, 5)); rt.put_c(10);
	return 0;
}