xref: /inferno-os/module/styxlib.m (revision 46439007cf417cbd9ac8049bb4122c890097a0fa)
1*46439007SCharles.Forsyth#
2*46439007SCharles.Forsyth# deprecated: use styxservers(2) instead
3*46439007SCharles.Forsyth#
4*46439007SCharles.Forsyth
5*46439007SCharles.ForsythStyxlib: module
6*46439007SCharles.Forsyth{
7*46439007SCharles.Forsyth	PATH: con "/dis/lib/styxlib.dis";
8*46439007SCharles.Forsyth	Chan: adt {
9*46439007SCharles.Forsyth		fid: int;
10*46439007SCharles.Forsyth		qid: Sys->Qid;
11*46439007SCharles.Forsyth		open: int;
12*46439007SCharles.Forsyth		mode: int;
13*46439007SCharles.Forsyth		uname: string;
14*46439007SCharles.Forsyth		path: string;
15*46439007SCharles.Forsyth		data: array of byte;
16*46439007SCharles.Forsyth
17*46439007SCharles.Forsyth		isdir: fn(c: self ref Chan): int;
18*46439007SCharles.Forsyth	};
19*46439007SCharles.Forsyth
20*46439007SCharles.Forsyth	Dirtab: adt {
21*46439007SCharles.Forsyth		name: string;
22*46439007SCharles.Forsyth		qid: Sys->Qid;
23*46439007SCharles.Forsyth		length: big;
24*46439007SCharles.Forsyth		perm: int;
25*46439007SCharles.Forsyth	};
26*46439007SCharles.Forsyth
27*46439007SCharles.Forsyth	Styxserver: adt {
28*46439007SCharles.Forsyth		fd: ref Sys->FD;
29*46439007SCharles.Forsyth		chans: array of list of ref Chan;
30*46439007SCharles.Forsyth		uname: string;
31*46439007SCharles.Forsyth		msize: int;
32*46439007SCharles.Forsyth
33*46439007SCharles.Forsyth		new: fn(fd: ref Sys->FD): (chan of ref Styx->Tmsg, ref Styxserver);
34*46439007SCharles.Forsyth		reply: fn(srv: self ref Styxserver, m: ref Styx->Rmsg): int;
35*46439007SCharles.Forsyth
36*46439007SCharles.Forsyth		fidtochan: fn(srv: self ref Styxserver, fid: int): ref Chan;
37*46439007SCharles.Forsyth		newchan: fn(srv: self ref Styxserver, fid: int): ref Chan;
38*46439007SCharles.Forsyth		chanfree: fn(srv: self ref Styxserver, c: ref Chan);
39*46439007SCharles.Forsyth		chanlist: fn(srv: self ref Styxserver): list of ref Chan;
40*46439007SCharles.Forsyth		clone: fn(srv: self ref Styxserver, c: ref Chan, fid: int): ref Chan;
41*46439007SCharles.Forsyth
42*46439007SCharles.Forsyth		devversion: fn(srv: self ref Styxserver, m: ref Styx->Tmsg.Version): int;
43*46439007SCharles.Forsyth		devauth: fn(srv: self ref Styxserver, m: ref Styx->Tmsg.Auth);
44*46439007SCharles.Forsyth		devattach: fn(srv: self ref Styxserver, m: ref Styx->Tmsg.Attach): ref Chan;
45*46439007SCharles.Forsyth		devflush: fn(srv: self ref Styxserver, m: ref Styx->Tmsg.Flush);
46*46439007SCharles.Forsyth		devwalk: fn(srv: self ref Styxserver, m: ref Styx->Tmsg.Walk,
47*46439007SCharles.Forsyth							gen: Dirgenmod, tab: array of Dirtab): ref Chan;
48*46439007SCharles.Forsyth		devclunk: fn(srv: self ref Styxserver, m: ref Styx->Tmsg.Clunk): ref Chan;
49*46439007SCharles.Forsyth		devstat: fn(srv: self ref Styxserver, m: ref Styx->Tmsg.Stat,
50*46439007SCharles.Forsyth							gen: Dirgenmod, tab: array of Dirtab);
51*46439007SCharles.Forsyth		devdirread: fn(srv: self ref Styxserver, m: ref Styx->Tmsg.Read,
52*46439007SCharles.Forsyth							gen: Dirgenmod, tab: array of Dirtab);
53*46439007SCharles.Forsyth		devopen: fn(srv: self ref Styxserver, m: ref Styx->Tmsg.Open,
54*46439007SCharles.Forsyth							gen: Dirgenmod, tab: array of Dirtab): ref Chan;
55*46439007SCharles.Forsyth		devremove: fn(srv: self ref Styxserver, m: ref Styx->Tmsg.Remove): ref Chan;
56*46439007SCharles.Forsyth	};
57*46439007SCharles.Forsyth
58*46439007SCharles.Forsyth	init:	fn(s: Styx): string;
59*46439007SCharles.Forsyth
60*46439007SCharles.Forsyth	readbytes: fn(m: ref Styx->Tmsg.Read, d: array of byte): ref Styx->Rmsg.Read;
61*46439007SCharles.Forsyth	readnum: fn(m: ref Styx->Tmsg.Read, val, size: int): ref Styx->Rmsg.Read;
62*46439007SCharles.Forsyth	readstr: fn(m: ref Styx->Tmsg.Read, d: string): ref Styx->Rmsg.Read;
63*46439007SCharles.Forsyth
64*46439007SCharles.Forsyth	openok: fn(omode, perm: int, uname, funame, fgname: string): int;
65*46439007SCharles.Forsyth	openmode: fn(o: int): int;
66*46439007SCharles.Forsyth
67*46439007SCharles.Forsyth	devdir: fn(c: ref Chan, qid: Sys->Qid, n: string, length: big,
68*46439007SCharles.Forsyth				user: string, perm: int): Sys->Dir;
69*46439007SCharles.Forsyth
70*46439007SCharles.Forsyth	dirgenmodule: fn(): Dirgenmod;
71*46439007SCharles.Forsyth	dirgen: fn(srv: ref Styxserver, c: ref Chan, tab: array of Dirtab, i: int): (int, Sys->Dir);
72*46439007SCharles.Forsyth
73*46439007SCharles.Forsyth	Einuse		: con "fid already in use";
74*46439007SCharles.Forsyth	Ebadfid		: con "bad fid";
75*46439007SCharles.Forsyth	Eopen		: con "fid already opened";
76*46439007SCharles.Forsyth	Enotfound	: con "file does not exist";
77*46439007SCharles.Forsyth	Enotdir		: con "not a directory";
78*46439007SCharles.Forsyth	Eperm		: con "permission denied";
79*46439007SCharles.Forsyth	Ebadarg		: con "bad argument";
80*46439007SCharles.Forsyth	Eexists		: con "file already exists";
81*46439007SCharles.Forsyth};
82*46439007SCharles.Forsyth
83*46439007SCharles.Forsyth
84*46439007SCharles.ForsythDirgenmod: module {
85*46439007SCharles.Forsyth	dirgen: fn(srv: ref Styxlib->Styxserver, c: ref Styxlib->Chan,
86*46439007SCharles.Forsyth			tab: array of Styxlib->Dirtab, i: int): (int, Sys->Dir);
87*46439007SCharles.Forsyth};
88