|
|
1.1 root 1: #include "stdio.h"
2: #include "cbt.h"
3:
4: extern int errno;
5: mbuf key, value;
6: char kbuf[NDSZ], vbuf[32767];
7: bfile *bfd;
8: FILE *pfd;
9: extern FILE *popen();
10: char iflag, rflag;
11:
12: main(argc, argv)
13: char **argv;
14: {
15: if(argc != 2) {
16: fprintf(stderr, "usage; %s file-name\n", argv[0]);
17: exit(1);
18: }
19: bfd = bopen(argv[1], 0);
20: if(bfd == NULL)
21: fail(argv[1]);
22: strcpy(vbuf, "cbt creat ");
23: if(bfd->path[0]->htype & INDEX) {
24: iflag = 1;
25: strcat(vbuf, "-i ");
26: }
27: if(bfd->path[0]->htype & READONLY) {
28: rflag = 1;
29: strcat(vbuf, "-r");
30: }
31: sprintf(kbuf, "%s TS%d", vbuf, getpid());
32: if(system(kbuf) != 0) {
33: fprintf(stderr, "%s failed\n", kbuf);
34: exit(1);
35: }
36: sprintf(kbuf, "cbt build -r TS%d", getpid());
37: pfd = popen(kbuf, "w");
38: if(pfd == NULL)
39: fail(kbuf);
40: key.mdata = kbuf;
41: value.mdata = vbuf;
42: errno = 0;
43: while(bread(bfd, &key, &value) != EOF) {
44: (void) fwrite((char *)&key.mlen, 1, sizeof(key.mlen), pfd);
45: (void) fwrite(key.mdata, 1, key.mlen, pfd);
46: (void) fwrite((char *)&value.mlen, 1, sizeof(value.mlen), pfd);
47: (void) fwrite(value.mdata, 1, value.mlen, pfd);
48: if(ferror(pfd))
49: fail("write to build");
50: }
51: if(errno)
52: fail("extracting");
53: if(pclose(pfd) != 0)
54: fail("pipe close");
55: sprintf(kbuf, "%s.T", argv[1]);
56: sprintf(vbuf, "TS%d.T", getpid());
57: unlink(kbuf);
58: link(vbuf, kbuf);
59: if(iflag)
60: exit(0);
61: sprintf(kbuf, "%s.F", argv[1]);
62: sprintf(vbuf, "TS%d.F", getpid());
63: unlink(kbuf);
64: link(vbuf, kbuf);
65: if(errno)
66: perror("linking");
67: exit(0);
68: }
69:
70: fail(s)
71: char *s;
72: {
73: perror(s);
74: exit(2);
75: }
76: static struct D { struct D *a; char *b;} VER = {&VER,"\n81/4/26:btsquash.c\n"};
77: /*0100011001101001*/
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.