Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_fixcpp/sys/include/oventi.h – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#pragma	lib	"liboventi.a"
2
#pragma	src	"/sys/src/liboventi"
3
 
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;
12
 
13
#pragma incomplete VtSession
14
#pragma incomplete VtSha1
15
#pragma incomplete Packet
16
#pragma incomplete VtLock
17
#pragma incomplete VtRendez
18
 
19
enum {
20
	VtScoreSize	= 20, /* Venti */
21
	VtMaxLumpSize	= 56*1024,
22
	VtPointerDepth	= 7,	
23
	VtEntrySize	= 40,
24
	VtRootSize 	= 300,
25
	VtMaxStringSize	= 1000,
26
	VtAuthSize 	= 1024,  /* size of auth group - in bits - must be multiple of 8 */
27
	MaxFragSize 	= 9*1024,
28
	VtMaxFileSize	= (1ULL<<48) - 1,
29
	VtRootVersion	= 2,
30
};
31
 
32
/* crypto strengths */
33
enum {
34
	VtCryptoStrengthNone,
35
	VtCryptoStrengthAuth,
36
	VtCryptoStrengthWeak,
37
	VtCryptoStrengthStrong,
38
};
39
 
40
/* crypto suites */
41
enum {
42
	VtCryptoNone,
43
	VtCryptoSSL3,
44
	VtCryptoTLS1,
45
 
46
	VtCryptoMax
47
};
48
 
49
/* codecs */
50
enum {
51
	VtCodecNone,
52
 
53
	VtCodecDeflate,
54
	VtCodecThwack,
55
 
56
	VtCodecMax
57
};
58
 
59
/* Lump Types */
60
enum {
61
	VtErrType,		/* illegal */
62
 
63
	VtRootType,
64
	VtDirType,
65
	VtPointerType0,
66
	VtPointerType1,
67
	VtPointerType2,
68
	VtPointerType3,
69
	VtPointerType4,
70
	VtPointerType5,
71
	VtPointerType6,
72
	VtPointerType7,		/* not used */
73
	VtPointerType8,		/* not used */
74
	VtPointerType9,		/* not used */
75
	VtDataType,
76
 
77
	VtMaxType
78
};
79
 
80
/* Dir Entry flags */
81
enum {
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 */
88
};
89
 
90
struct VtRoot {
91
	ushort version;
92
	char name[128];
93
	char type[128];
94
	uchar score[VtScoreSize];	/* to a Dir block */
95
	ushort blockSize;		/* maximum block size */
96
	uchar prev[VtScoreSize];	/* last root block */
97
};
98
 
99
struct VtEntry {
100
	ulong gen;			/* generation number */
101
	ushort psize;			/* pointer block size */
102
	ushort dsize;			/* data block size */
103
	uchar depth;			/* unpacked from flags */
104
	uchar flags;
105
	uvlong size;
106
	uchar score[VtScoreSize];
107
};
108
 
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*);
114
};
115
 
116
/* versions */
117
enum {
118
	/* experimental versions */
119
	VtVersion01 = 1,
120
	VtVersion02,
121
};
122
 
123
/* score of zero length block */
124
extern uchar vtZeroScore[VtScoreSize];	
125
 
126
/* both sides */
127
void vtAttach(void);
128
void vtDetach(void);
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);
149
 
150
/* internal */
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*);
159
 
160
/* client side */
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);
172
 
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]);
176
 
177
void vtRootPack(VtRoot*, uchar*);
178
int vtRootUnpack(VtRoot*, uchar*);
179
void vtEntryPack(VtEntry*, uchar*, int index);
180
int vtEntryUnpack(VtEntry*, uchar*, int index);
181
 
182
/* server side */
183
VtSession *vtServerAlloc(VtServerVtbl*);
184
int vtSetSid(VtSession *s, char *sid);
185
int vtExport(VtSession *s);
186
 
187
/* sha1 */
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);
196
 
197
/* Packet */
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);
219
 
220
/* portability stuff - should be a seperate library */
221
 
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);
232
 
233
/* locking/threads */
234
int vtThread(void (*f)(void*), void *rock);
235
void vtThreadSetName(char*);
236
 
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*);
246
 
247
VtRendez *vtRendezAlloc(VtLock*);
248
void vtRendezFree(VtRendez*);
249
int vtSleep(VtRendez*);
250
int vtWakeup(VtRendez*);
251
int vtWakeupAll(VtRendez*);
252
 
253
/* fd functions - really network (socket) functions */
254
void vtFdClose(int);
255
int vtFdRead(int, uchar*, int);
256
int vtFdReadFully(int, uchar*, int);
257
int vtFdWrite(int, uchar*, int);
258
 
259
/*
260
 * formatting
261
 * other than noted, these formats all ignore
262
 * the width and precision arguments, and all flags
263
 *
264
 * V	a venti score
265
 * R	venti error
266
 */
267
#pragma	varargck	type	"V"		uchar*
268
#pragma	varargck	type	"R"		void
269
 
270
#pragma	varargck	argpos	vtSetError	1
271