1 #pragma lib "liboventi.a"
2 #pragma src "/sys/src/liboventi"
4 typedef struct VtSession VtSession;
5 typedef struct VtSha1 VtSha1;
6 typedef struct Packet Packet;
7 typedef struct VtLock VtLock;
8 typedef struct VtRendez VtRendez;
9 typedef struct VtRoot VtRoot;
10 typedef struct VtEntry VtEntry;
11 typedef struct VtServerVtbl VtServerVtbl;
13 #pragma incomplete VtSession
14 #pragma incomplete VtSha1
15 #pragma incomplete Packet
16 #pragma incomplete VtLock
17 #pragma incomplete VtRendez
20 VtScoreSize = 20, /* Venti */
21 VtMaxLumpSize = 56*1024,
25 VtMaxStringSize = 1000,
26 VtAuthSize = 1024, /* size of auth group - in bits - must be multiple of 8 */
28 VtMaxFileSize = (1ULL<<48) - 1,
32 /* crypto strengths */
37 VtCryptoStrengthStrong,
61 VtErrType, /* illegal */
72 VtPointerType7, /* not used */
73 VtPointerType8, /* not used */
74 VtPointerType9, /* not used */
82 VtEntryActive = (1<<0), /* entry is in use */
83 VtEntryDir = (1<<1), /* a directory */
84 VtEntryDepthShift = 2, /* shift for pointer depth */
85 VtEntryDepthMask = (0x7<<2), /* mask for pointer depth */
86 VtEntryLocal = (1<<5), /* used for local storage: should not be set for Venti blocks */
87 VtEntryNoArchive = (1<<6), /* used for local storage: should not be set for Venti blocks */
94 uchar score[VtScoreSize]; /* to a Dir block */
95 ushort blockSize; /* maximum block size */
96 uchar prev[VtScoreSize]; /* last root block */
100 ulong gen; /* generation number */
101 ushort psize; /* pointer block size */
102 ushort dsize; /* data block size */
103 uchar depth; /* unpacked from flags */
106 uchar score[VtScoreSize];
109 struct VtServerVtbl {
110 Packet *(*read)(VtSession*, uchar score[VtScoreSize], int type, int n);
111 int (*write)(VtSession*, uchar score[VtScoreSize], int type, Packet *p);
112 void (*closing)(VtSession*, int clean);
113 void (*sync)(VtSession*);
118 /* experimental versions */
123 /* score of zero length block */
124 extern uchar vtZeroScore[VtScoreSize];
129 void vtClose(VtSession *s);
130 void vtFree(VtSession *s);
131 char *vtGetUid(VtSession *s);
132 char *vtGetSid(VtSession *s);
133 int vtSetDebug(VtSession *s, int);
134 int vtGetDebug(VtSession *s);
135 int vtSetFd(VtSession *s, int fd);
136 int vtGetFd(VtSession *s);
137 int vtConnect(VtSession *s, char *password);
138 int vtSetCryptoStrength(VtSession *s, int);
139 int vtGetCryptoStrength(VtSession *s);
140 int vtSetCompression(VtSession *s, int);
141 int vtGetCompression(VtSession *s);
142 int vtGetCrypto(VtSession *s);
143 int vtGetCodec(VtSession *s);
144 char *vtGetVersion(VtSession *s);
145 char *vtGetError(void);
146 int vtErrFmt(Fmt *fmt);
147 void vtDebug(VtSession*, char *, ...);
148 void vtDebugMesg(VtSession *z, Packet *p, char *s);
151 VtSession *vtAlloc(void);
152 void vtReset(VtSession*);
153 int vtAddString(Packet*, char*);
154 int vtGetString(Packet*, char**);
155 int vtSendPacket(VtSession*, Packet*);
156 Packet *vtRecvPacket(VtSession*);
157 void vtDisconnect(VtSession*, int);
158 int vtHello(VtSession*);
161 VtSession *vtClientAlloc(void);
162 VtSession *vtDial(char *server, int canfail);
163 int vtRedial(VtSession*, char *server);
164 VtSession *vtStdioServer(char *server);
165 int vtPing(VtSession *s);
166 int vtSetUid(VtSession*, char *uid);
167 int vtRead(VtSession*, uchar score[VtScoreSize], int type, uchar *buf, int n);
168 int vtWrite(VtSession*, uchar score[VtScoreSize], int type, uchar *buf, int n);
169 Packet *vtReadPacket(VtSession*, uchar score[VtScoreSize], int type, int n);
170 int vtWritePacket(VtSession*, uchar score[VtScoreSize], int type, Packet *p);
171 int vtSync(VtSession *s);
173 int vtZeroExtend(int type, uchar *buf, int n, int nn);
174 int vtZeroTruncate(int type, uchar *buf, int n);
175 int vtParseScore(char*, uint, uchar[VtScoreSize]);
177 void vtRootPack(VtRoot*, uchar*);
178 int vtRootUnpack(VtRoot*, uchar*);
179 void vtEntryPack(VtEntry*, uchar*, int index);
180 int vtEntryUnpack(VtEntry*, uchar*, int index);
183 VtSession *vtServerAlloc(VtServerVtbl*);
184 int vtSetSid(VtSession *s, char *sid);
185 int vtExport(VtSession *s);
188 VtSha1* vtSha1Alloc(void);
189 void vtSha1Free(VtSha1*);
190 void vtSha1Init(VtSha1*);
191 void vtSha1Update(VtSha1*, uchar *, int n);
192 void vtSha1Final(VtSha1*, uchar sha1[VtScoreSize]);
193 void vtSha1(uchar score[VtScoreSize], uchar *, int);
194 int vtSha1Check(uchar score[VtScoreSize], uchar *, int);
195 int vtScoreFmt(Fmt *fmt);
198 Packet *packetAlloc(void);
199 void packetFree(Packet*);
200 Packet *packetForeign(uchar *buf, int n, void (*free)(void *a), void *a);
201 Packet *packetDup(Packet*, int offset, int n);
202 Packet *packetSplit(Packet*, int n);
203 int packetConsume(Packet*, uchar *buf, int n);
204 int packetTrim(Packet*, int offset, int n);
205 uchar *packetHeader(Packet*, int n);
206 uchar *packetTrailer(Packet*, int n);
207 int packetPrefix(Packet*, uchar *buf, int n);
208 int packetAppend(Packet*, uchar *buf, int n);
209 int packetConcat(Packet*, Packet*);
210 uchar *packetPeek(Packet*, uchar *buf, int offset, int n);
211 int packetCopy(Packet*, uchar *buf, int offset, int n);
212 int packetFragments(Packet*, IOchunk*, int nio, int offset);
213 int packetSize(Packet*);
214 int packetAllocatedSize(Packet*);
215 void packetSha1(Packet*, uchar sha1[VtScoreSize]);
216 int packetCompact(Packet*);
217 int packetCmp(Packet*, Packet*);
218 void packetStats(void);
220 /* portability stuff - should be a seperate library */
222 void vtMemFree(void *);
223 void *vtMemAlloc(int);
224 void *vtMemAllocZ(int);
225 void *vtMemRealloc(void *p, int);
226 void *vtMemBrk(int n);
227 char *vtStrDup(char *);
228 void vtFatal(char *, ...);
229 char *vtGetError(void);
230 char *vtSetError(char *, ...);
231 char *vtOSError(void);
233 /* locking/threads */
234 int vtThread(void (*f)(void*), void *rock);
235 void vtThreadSetName(char*);
237 VtLock *vtLockAlloc(void);
238 /* void vtLockInit(VtLock**); */
239 void vtLock(VtLock*);
240 int vtCanLock(VtLock*);
241 void vtRLock(VtLock*);
242 int vtCanRLock(VtLock*);
243 void vtUnlock(VtLock*);
244 void vtRUnlock(VtLock*);
245 void vtLockFree(VtLock*);
247 VtRendez *vtRendezAlloc(VtLock*);
248 void vtRendezFree(VtRendez*);
249 int vtSleep(VtRendez*);
250 int vtWakeup(VtRendez*);
251 int vtWakeupAll(VtRendez*);
253 /* fd functions - really network (socket) functions */
255 int vtFdRead(int, uchar*, int);
256 int vtFdReadFully(int, uchar*, int);
257 int vtFdWrite(int, uchar*, int);
261 * other than noted, these formats all ignore
262 * the width and precision arguments, and all flags
267 #pragma varargck type "V" uchar*
268 #pragma varargck type "R" void
270 #pragma varargck argpos vtSetError 1