1 2SELF: con "$self"; # Language support for loading my instance 3 4Sys: module 5{ 6 PATH: con "$Sys"; 7 8 Maxint: con 2147483647; 9 10 # Unique file identifier for file objects 11 Qid: adt 12 { 13 path: big; 14 vers: int; 15 qtype: int; 16 }; 17 18 QTDIR: con 16r80; 19 QTAPPEND: con 16r40; 20 QTEXCL: con 16r20; 21 QTAUTH: con 16r08; 22 QTTMP: con 16r04; 23 QTFILE: con 0; 24 25 # Return from stat and directory read 26 Dir: adt 27 { 28 name: string; 29 uid: string; 30 gid: string; 31 muid: string; 32 qid: Qid; 33 mode: int; 34 atime: int; 35 mtime: int; 36 length: big; 37 dtype: int; 38 dev: int; 39 }; 40 nulldir: con Dir(nil, nil, nil, nil, (~big 0, ~0, ~0), ~0, ~0, ~0, ~big 0, ~0, ~0); 41 zerodir: con Dir(nil, nil, nil, nil, (big 0, 0, 0), 0, 0, 0, big 0, 0, 0); 42 43 # File descriptor 44 # 45 FD: adt 46 { 47 fd: int; 48 }; 49 50 # Network connection returned by dial 51 # 52 Connection: adt 53 { 54 dfd: ref FD; 55 cfd: ref FD; 56 dir: string; 57 }; 58 59 # File IO structures returned from file2chan 60 # read: (offset, bytes, fid, chan) 61 # write: (offset, data, fid, chan) 62 # 63 Rread: type chan of (array of byte, string); 64 Rwrite: type chan of (int, string); 65 FileIO: adt 66 { 67 read: chan of (int, int, int, Rread); 68 write: chan of (int, array of byte, int, Rwrite); 69 }; 70 71 # Maximum read which will be completed atomically; 72 # also the optimum block size 73 # 74 ATOMICIO: con 8192; 75 76 SEEKSTART: con 0; 77 SEEKRELA: con 1; 78 SEEKEND: con 2; 79 80 NAMEMAX: con 256; 81 ERRMAX: con 128; 82 WAITLEN: con ERRMAX+64; 83 84 OREAD: con 0; 85 OWRITE: con 1; 86 ORDWR: con 2; 87 OTRUNC: con 16; 88 ORCLOSE: con 64; 89 OEXCL: con 16r1000; 90 91 DMDIR: con int 1<<31; 92 DMAPPEND: con int 1<<30; 93 DMEXCL: con int 1<<29; 94 DMAUTH: con int 1<<27; 95 DMTMP: con int 1<<26; 96 97 MREPL: con 0; 98 MBEFORE: con 1; 99 MAFTER: con 2; 100 MCREATE: con 4; 101 MCACHE: con 16; 102 103 NEWFD: con (1<<0); 104 FORKFD: con (1<<1); 105 NEWNS: con (1<<2); 106 FORKNS: con (1<<3); 107 NEWPGRP: con (1<<4); 108 NODEVS: con (1<<5); 109 NEWENV: con (1<<6); 110 FORKENV: con (1<<7); 111 112 EXPWAIT: con 0; 113 EXPASYNC: con 1; 114 115 UTFmax: con 4; # maximum bytes per rune in UTF-8 116 UTFerror: con 16rFFFD; # decoding error in UTF 117 Runemax: con 16r10FFFF; # 21-bit rune 118 Runemask: con 16r1FFFFF; # bits used by runes 119 120 announce: fn(addr: string): (int, Connection); 121 aprint: fn(s: string, *): array of byte; 122 bind: fn(s, on: string, flags: int): int; 123 byte2char: fn(buf: array of byte, n: int): (int, int, int); 124 char2byte: fn(c: int, buf: array of byte, n: int): int; 125 chdir: fn(path: string): int; 126 create: fn(s: string, mode, perm: int): ref FD; 127 dial: fn(addr, local: string): (int, Connection); 128 dirread: fn(fd: ref FD): (int, array of Dir); 129 dup: fn(old, new: int): int; 130 export: fn(c: ref FD, dir: string, flag: int): int; 131 fauth: fn(fd: ref FD, aname: string): ref FD; 132 fd2path: fn(fd: ref FD): string; 133 fildes: fn(fd: int): ref FD; 134 file2chan: fn(dir, file: string): ref FileIO; 135 fprint: fn(fd: ref FD, s: string, *): int; 136 fstat: fn(fd: ref FD): (int, Dir); 137 fversion: fn(fd: ref FD, msize: int, version: string): (int, string); 138 fwstat: fn(fd: ref FD, d: Dir): int; 139 iounit: fn(fd: ref FD): int; 140 listen: fn(c: Connection): (int, Connection); 141 millisec: fn(): int; 142 mount: fn(fd: ref FD, afd: ref FD, on: string, flags: int, spec: string): int; 143 open: fn(s: string, mode: int): ref FD; 144 pctl: fn(flags: int, movefd: list of int): int; 145 pipe: fn(fds: array of ref FD): int; 146 print: fn(s: string, *): int; 147 pread: fn(fd: ref FD, buf: array of byte, n: int, off: big): int; 148 pwrite: fn(fd: ref FD, buf: array of byte, n: int, off: big): int; 149 read: fn(fd: ref FD, buf: array of byte, n: int): int; 150 readn: fn(fd: ref FD, buf: array of byte, n: int): int; 151 remove: fn(s: string): int; 152 seek: fn(fd: ref FD, off: big, start: int): big; 153 sleep: fn(period: int): int; 154 sprint: fn(s: string, *): string; 155 stat: fn(s: string): (int, Dir); 156 stream: fn(src, dst: ref FD, bufsiz: int): int; 157 tokenize: fn(s, delim: string): (int, list of string); 158 unmount: fn(s1: string, s2: string): int; 159 utfbytes: fn(buf: array of byte, n: int): int; 160 werrstr: fn(s: string): int; 161 write: fn(fd: ref FD, buf: array of byte, n: int): int; 162 wstat: fn(s: string, d: Dir): int; 163}; 164