|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T U
Length: 24680 (0x6068) Types: TextFile Notes: Uncompressed file
└─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit └─⟦874a464dd⟧ »EurOpenD3/news/cnews/16-Apr-1990.Z« └─⟦this⟧
Newsgroups: news.software.b,comp.sources.bugs Subject: C News patch of 16-Apr-1990 This is the third of three (!) patches mostly constituting the new dbz. start of patch 16-Apr-1990 (suggested archive name: `pch16Apr90.Z') this should be run with patch -p0 <thisfile The following is a complete list of patches to date. Prereq: 23-Jun-1989 Prereq: 7-Jul-1989 Prereq: 23-Jul-1989 Prereq: 22-Aug-1989 Prereq: 24-Aug-1989 Prereq: 14-Sep-1989 Prereq: 13-Nov-1989 Prereq: 10-Jan-1990 Prereq: 16-Jan-1990 Prereq: 17-Jan-1990 Prereq: 18-Jan-1990 Prereq: 12-Mar-1990 Prereq: 14-Apr-1990 Prereq: 15-Apr-1990 *** PATCHDATES.old Sat Apr 14 20:24:28 1990 --- PATCHDATES Sat Apr 14 20:24:28 1990 *************** *** 1,14 **** --- 1,15 ---- 23-Jun-1989 7-Jul-1989 23-Jul-1989 22-Aug-1989 24-Aug-1989 14-Sep-1989 13-Nov-1989 10-Jan-1990 16-Jan-1990 17-Jan-1990 18-Jan-1990 12-Mar-1990 14-Apr-1990 15-Apr-1990 + 16-Apr-1990 new dbz/dbz.h (patch can't create, so diff against null): Index: dbz/dbz.h *** cnpatch/old/dbz/dbz.h Sat Apr 14 20:29:10 1990 --- dbz/dbz.h Wed Apr 11 17:14:10 1990 *************** *** 0 **** --- 1,31 ---- + /* for dbm and dbz */ + typedef struct { + char *dptr; + int dsize; + } datum; + + /* standard dbm functions */ + extern int dbminit(); + extern datum fetch(); + extern int store(); + extern int delete(); /* not in dbz */ + extern datum firstkey(); /* not in dbz */ + extern datum nextkey(); /* not in dbz */ + extern int dbmclose(); /* in dbz, but not in old dbm */ + + /* new stuff for dbz */ + extern int dbzfresh(); + extern int dbzagain(); + extern datum dbzfetch(); + extern int dbzstore(); + extern int dbzsync(); + extern long dbzsize(); + extern int dbzincore(); + extern int dbzdebug(); + + /* + * In principle we could handle unlimited-length keys by operating a chunk + * at a time, but it's not worth it in practice. Setting a nice large + * bound on them simplifies the code and doesn't hurt anything. + */ + #define DBZMAXKEY 255 new dbz/dbzmain.c (patch can't create, so diff against null): Index: dbz/dbzmain.c *** cnpatch/old/dbz/dbzmain.c Sat Apr 14 20:29:10 1990 --- dbz/dbzmain.c Thu Apr 12 16:52:59 1990 *************** *** 0 **** --- 1,500 ---- + /* + * dbz - use and test dbz in various ways + * + * $Log$ + */ + + #include <stdio.h> + #include <sys/types.h> + #include <sys/stat.h> + #include <string.h> + #include <dbz.h> + + #ifdef FUNNYSEEKS + #include <unistd.h> + #else + #define SEEK_SET 0 + #endif + + #define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0) + + #ifndef lint + static char RCSid[] = "$Header$"; + #endif + + char *progname; + + char *inname = "(no file)"; /* filename for messages etc. */ + long lineno; /* line number for messages etc. */ + + char *basename; + char *pagname; + char *dirname; + char *str2dup(); + FILE *base; + + int op = 'b'; /* what to do, default build a new table */ + int baseinput = 1; /* is the base file also the input? */ + + char *from = NULL; /* old table to use for dbzagain() */ + int omitzero = 0; /* omit lines tagged with 0 */ + long every = 0; /* report every n lines */ + int syncs = 0; /* dbzsync() on each report */ + int quick = 0; /* quick checking, not too thorough */ + int sweep = 0; /* sweep file checking all offsets */ + int useincore = 1; /* should we use incore facility? */ + long xxx = 0; /* debugging variable */ + int printx = 0; /* print xxx after all is done */ + int unique = 1; /* before store(), check with fetch() */ + int usefresh = 0; /* use dbzfresh? */ + long siz = 0; /* -p size */ + char map = 'C'; /* -p map */ + long tag = 0; /* -p tag mask */ + int exact = 0; /* do not run dbzsize(siz) */ + int dbzint = 1; /* use new interface? */ + char fs = '\t'; /* field separator, default tab */ + int unopen = 0; /* make base unopenable during dbminit? */ + char *change = NULL; /* chdir here before dbmclose */ + + #define DEFBUF 1024 /* default line-buffer size */ + int buflen = DEFBUF; /* line length limit */ + char lbuf[DEFBUF]; + char *line = lbuf; + char cbuf[DEFBUF]; + char *cmp = cbuf; + + void fail(); + void dofile(); + void runs(); + void dosweep(); + void mkfiles(); + void crfile(); + void doline(); + + #ifdef HAVERFCIZE + extern char *rfc822ize(); + #else + #define rfc822ize(n) (n) + #endif + + /* + - main - parse arguments and handle options + */ + main(argc, argv) + int argc; + char *argv[]; + { + int c; + int errflg = 0; + extern int optind; + extern char *optarg; + void process(); + int doruns = 0; + extern long atol(); + extern char *malloc(); + + progname = argv[0]; + + while ((c = getopt(argc, argv, "axct:l:R0E:SqOiX:Yuf:p:eMUC:d")) != EOF) + switch (c) { + case 'a': /* append to existing table */ + if (op != 'b') + fail("only one of -a -x -c can be given", ""); + op = 'a'; + baseinput = 0; + break; + case 'x': /* extract from existing table */ + if (op != 'b') + fail("only one of -a -x -c can be given", ""); + op = 'x'; + baseinput = 0; + break; + case 'c': /* check existing table */ + if (op != 'b') + fail("only one of -a -x -c can be given", ""); + op = 'c'; + break; + case 't': /* set field separator */ + if (strlen(optarg) > 1) + fail("only one field separator allowed", ""); + fs = *optarg; + break; + case 'l': /* override line-length limit */ + buflen = atoi(optarg) + 1; + if (buflen <= 2) + fail("bad -l value `%s'", optarg); + line = malloc(buflen); + cmp = malloc(buflen); + if (line == NULL || cmp == NULL) + fail("cannot allocate %s-byte buffers", optarg); + break; + case 'R': /* print run statistics */ + doruns = 1; + break; + case '0': /* omit lines tagged (by fake -t) with 0 */ + omitzero = 1; + break; + case 'E': /* report every n items */ + every = atol(optarg); + break; + case 'S': /* dbzsync() on each -E report */ + syncs = 1; + break; + case 'q': /* quick check, not too thorough */ + quick = 1; + break; + case 'O': /* sweep file checking all offsets */ + sweep = 1; + break; + case 'i': /* don't use incore */ + useincore = 0; + break; + case 'X': /* set xxx */ + xxx = atoi(optarg); + break; + case 'Y': /* print xxx afterward */ + printx = 1; + break; + case 'u': /* don't check uniqueness */ + unique = 0; + break; + case 'f': /* init from existing table's parameters */ + from = optarg; + break; + case 'p': /* parameters for dbzfresh */ + if (sscanf(optarg, "%ld %1s %lx", &siz, &map, &tag) != 3) { + map = '?'; + tag = 0; + if (sscanf(optarg, "%ld", &siz) != 1) + fail("bad -n value `%s'", optarg); + } + usefresh = 1; + break; + case 'e': /* -p size is exact, don't dbzsize() it */ + exact = 1; + break; + case 'M': /* use old dbm interface + rfc822ize */ + dbzint = 0; + break; + case 'U': /* make base unopenable during init */ + unopen = 1; + break; + case 'C': /* change directories before dbmclose */ + change = optarg; + break; + case 'd': /* Debugging. */ + if (dbzdebug(1) < 0) + fail("dbz debugging not available", ""); + break; + case '?': + default: + errflg++; + break; + } + if (errflg || optind >= argc || (optind+1 < argc && baseinput)) { + fprintf(stderr, "usage: %s ", progname); + fprintf(stderr, "[-a] [-x] [-c] database [file] ...\n"); + exit(2); + } + + (void) dbzincore(useincore); + basename = argv[optind]; + pagname = str2dup(basename, ".pag"); + dirname = str2dup(basename, ".dir"); + mkfiles(); + optind++; + + if (baseinput) /* implies no further arguments */ + process(base, basename); + else if (optind >= argc) + process(stdin, "stdin"); + else + for (; optind < argc; optind++) + dofile(argv[optind]); + + if (change != NULL) + (void) chdir(change); + if (dbmclose() < 0) + fail("dbmclose failed", ""); + if (doruns) + runs(pagname); + if (sweep) + dosweep(basename, pagname); + if (printx) + printf("%ld\n", xxx); + exit(0); + } + + /* + - dofile - open a file and invoke process() + */ + void + dofile(name) + char *name; + { + register FILE *in; + + if (STREQ(name, "-")) + process(stdin, "-"); + else { + in = fopen(name, "r"); + if (in == NULL) + fail("cannot open `%s'", name); + process(in, name); + (void) fclose(in); + } + } + + /* + - mkfiles - create empty files and open them up + */ + void + mkfiles() + { + if (op == 'b' && !dbzint) { + crfile(dirname); + crfile(pagname); + } + + base = fopen(basename, (op == 'a') ? "a" : "r"); + if (base == NULL) + fail("cannot open `%s'", basename); + if (unopen) + (void) chmod(basename, 0); + if (from != NULL) { + if (dbzagain(basename, from) < 0) + fail("dbzagain(`%s'...) failed", basename); + } else if (op == 'b' && dbzint) { + if (!exact) + siz = dbzsize(siz); + if (dbzfresh(basename, siz, (int)fs, map, tag) < 0) + fail("dbzfresh(`%s'...) failed", basename); + } else if (dbminit(basename) < 0) + fail("dbminit(`%s') failed", basename); + if (unopen) + (void) chmod(basename, 0600); /* hard to restore original */ + } + + /* + - crfile - create a file + */ + void + crfile(name) + char *name; + { + register int f; + + f = creat(name, 0666); + if (f < 0) + fail("cannot create `%s'", name); + (void) close(f); + } + + /* + - process - process input file + */ + void + process(in, name) + FILE *in; + char *name; + { + register off_t place; + + inname = name; + lineno = 0; + + for (;;) { + place = ftell(in); + if (fgets(line, buflen, in) == NULL) + return; + lineno++; + if (every > 0 && lineno%every == 0) { + fprintf(stderr, "%ld\n", lineno); + if (dbzsync() < 0) + fail("dbzsync failed", ""); + } + doline(line, place); + } + /* NOTREACHED */ + } + + /* + - doline - process input line + */ + void + doline(lp, inoffset) + char *lp; + off_t inoffset; + { + register char *p; + register char pc; + datum key, value; + off_t place = inoffset; + register int shouldfind; + register int llen; + char keytext[DBZMAXKEY+1]; + + p = NULL; + if (fs != '\0') + p = strchr(lp, fs); + if (p == NULL) + p = lp + strlen(lp); + if (p > lp && *(p-1) == '\n') + p--; + if (p - lp > DBZMAXKEY) + fail("key of `%.40s...' too long", lp); + pc = *p; + *p = '\0'; + (void) strcpy(keytext, lp); + *p = pc; + key.dptr = (dbzint) ? keytext : rfc822ize(keytext); + key.dsize = strlen(keytext)+1; + + switch (op) { + case 'a': + place = ftell(base); + llen = strlen(lp); + if (fwrite(lp, 1, llen, base) != llen) + fail("write error in `%s'", basename); + /* FALLTHROUGH */ + case 'b': + if (omitzero && p != NULL && *(p+1) == '0') + return; + if (unique) { + value = (dbzint) ? dbzfetch(key) : fetch(key); + if (value.dptr != NULL) + fail("`%.40s...' already present", lp); + } + value.dptr = (char *)&place; + value.dsize = (int)sizeof(off_t); + if (((dbzint) ? dbzstore(key, value) : store(key, value)) < 0) + fail("store failed on `%.40s...'", lp); + break; + case 'c': + value = (dbzint) ? dbzfetch(key) : fetch(key); + shouldfind = (omitzero && p != NULL && *(p+1) == '0') ? 0 : 1; + if (!shouldfind && (value.dptr != NULL || value.dsize != 0)) + fail("`%.40s...' found, shouldn't be", lp); + if (shouldfind && (value.dptr == NULL || + value.dsize != sizeof(off_t))) + fail("can't find `%.40s...'", lp); + if (shouldfind && !quick) { + (void) memcpy((char *)&place, value.dptr, sizeof(off_t)); + if (place != inoffset) + fail("offset mismatch on `%.40s...'", lp); + if (fseek(base, place, SEEK_SET) == -1) + fail("fseek failed on `%.40s...'", lp); + if (fgets(cmp, buflen, base) == NULL) + fail("can't read line for `%.40s...'", lp); + if (!STREQ(lp, cmp)) + fail("compare failed on `%.40s...'", lp); + } + break; + case 'x': + value = (dbzint) ? dbzfetch(key) : fetch(key); + if (value.dptr != NULL) { + (void) memcpy((char *)&place, value.dptr, sizeof(off_t)); + if (fseek(base, place, SEEK_SET) == -1) + fail("fseek failed on `%.40s...'", lp); + if (fgets(cmp, buflen, base) == NULL) + fail("can't read line for `%.40s...'", lp); + fputs(cmp, stdout); + } + break; + default: + fail("unknown operator -- can't happen", ""); + break; + } + } + + /* + - runs - print run statistics + */ + void + runs(file) + char *file; + { + register FILE *fd; + off_t it; + register long run; + + fd = fopen(file, "r"); + if (fd == NULL) + fail("cannot reopen `%s'", file); + run = 0; + while (fread((char *)&it, sizeof(off_t), 1, fd) == 1) { + if (it != 0) + run++; + else if (run > 0) { + printf("%ld\n", run); + run = 0; + } + } + (void) fclose(fd); + } + + /* + - dosweep - sweep pag file checking for valid offsets + */ + void + dosweep(fn, pn) + char *fn; + char *pn; + { + register FILE *pf; + off_t it; + char nl; + register FILE *hf; + + hf = fopen(fn, "r"); + if (hf == NULL) + fail("cannot reopen `%s'", fn); + pf = fopen(pn, "r"); + if (pf == NULL) + fail("cannot reopen `%s'", pn); + while (fread((char *)&it, sizeof(off_t), 1, pf) == 1) { + it = (it & (0x80<<24)) ? (it&~(0xff<<24)) : it; + if (it != 0 && it != 1) { /* 0 empty, 1 known okay */ + it--; /* get rid of bias */ + (void) fseek(hf, it-1, SEEK_SET); + nl = getc(hf); + if (nl != '\n') + fprintf(stderr, "offset 0%lo does not point to line\n", + (long)it); + } + } + (void) fclose(hf); + (void) fclose(pf); + } + + /* + - fail - complain and die + */ + void + fail(s1, s2) + char *s1; + char *s2; + { + fprintf(stderr, "%s: (file `%s', line %ld) ", progname, inname, lineno); + fprintf(stderr, s1, s2); + fprintf(stderr, "\n"); + exit(1); + } + + /* + - str2dup - concatenate strings and malloc result + */ + char * + str2dup(s1, s2) + char *s1; + char *s2; + { + register char *p; + + p = malloc((size_t)strlen(s1) + strlen(s2) + 1); + if (p == NULL) + fail("can't allocate space for strings", ""); + (void) strcpy(p, s1); + (void) strcat(p, s2); + return(p); + } new dbz/fake.c (patch can't create, so diff against null): Index: dbz/fake.c *** cnpatch/old/dbz/fake.c Sat Apr 14 20:29:12 1990 --- dbz/fake.c Sat Mar 31 19:24:20 1990 *************** *** 0 **** --- 1,142 ---- + /* + * fake - make up random lines resembling history-file entries, reproducibly + * + * $Log$ + */ + + #include <stdio.h> + #include <sys/types.h> + #include <sys/stat.h> + #include <string.h> + + #define MAXSTR 500 /* For sizing strings -- DON'T use BUFSIZ! */ + #define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0) + + #ifndef lint + static char RCSid[] = "$Header$"; + #endif + + int midonly = 0; /* just message ids, rest not realistic */ + int tag = 0; /* tag lines with random digit for later use */ + int expired = -1; /* percentage of lines to be expired */ + + int debug = 0; + char *progname; + + char *inname; /* filename for messages etc. */ + long lineno; /* line number for messages etc. */ + + void fail(); + void doline(); + void addchars(); + void seed(); + + /* + - main - parse arguments and handle options + */ + main(argc, argv) + int argc; + char *argv[]; + { + int c; + int errflg = 0; + FILE *in; + struct stat statbuf; + extern int optind; + extern char *optarg; + extern FILE *efopen(); + void process(); + register long no; + extern long atol(); + char line[MAXSTR]; + + progname = argv[0]; + + while ((c = getopt(argc, argv, "ms:te:d")) != EOF) + switch (c) { + case 'm': /* message-ids only */ + midonly = 1; + break; + case 's': /* seed */ + seed(atol(optarg)); + break; + case 't': /* tag lines with a random digit */ + tag = 1; + break; + case 'e': /* percentage to be expired */ + expired = atoi(optarg); + break; + case 'd': /* Debugging. */ + debug++; + break; + case '?': + default: + errflg++; + break; + } + if (errflg || optind != argc - 1) { + fprintf(stderr, "usage: %s ", progname); + fprintf(stderr, "[-m] [-s seed] length\n"); + exit(2); + } + + for (no = atol(argv[optind]); no > 0; no--) { + doline(line); + puts(line); + } + exit(0); + } + + /* + - doline - generate random history pseudo-line + */ + void + doline(buf) + char *buf; + { + char tagch[2]; + + (void) strcpy(buf, "<"); + addchars(buf, range(4, 20)); + (void) strcat(buf, "@"); + addchars(buf, range(8, 20)); + if (midonly) + (void) strcat(buf, ">\tx"); + else { + if (tag) { + tagch[0] = "1234567890"[range(0,9)]; + tagch[1] = '\0'; + (void) strcat(buf, ">\t"); + (void) strcat(buf, tagch); + (void) strcat(buf, "00000000~-"); + } else + (void) strcat(buf, ">\t1234567890~-"); + } + if (range(1, 100) > expired) { + if (midonly) + (void) strcat(buf, "\tx"); + else { + (void) strcat(buf, "\t"); + addchars(buf, range(10, 30)); + } + } + } + + /* + - addchars - generate n random characters suitable for history file + */ + void + addchars(buf, len) + char *buf; + int len; + { + register int i; + register char *p = buf + strlen(buf); + static char vocab[] = "1234567890.abcde.fghij.klmno.pqrst.uvwxyz.\ + 1234567890.ABCDE.FGHIJ.KLMNO.PQRST.UVWXYZ.1234567890.\ + 1234567890.abcde.fghij.klmno.pqrst.uvwxyz.1234567890"; + + for (i = len; i > 0; i--) + *p++ = vocab[range(0, sizeof(vocab)-2)]; + *p++ = '\0'; + } new dbz/firstlast25 (patch can't create, so diff against null): Index: dbz/firstlast25 *** cnpatch/old/dbz/firstlast25 Sat Apr 14 20:29:12 1990 --- dbz/firstlast25 Sat Mar 31 19:24:20 1990 *************** *** 0 **** --- 1,50 ---- + <m....VO1.9q.@s95e1zKsIj7LrIwa1> 600000000~- 90fz0706yo.1Env21x8b + <H5.i.R6ZQ2@Vg6.5mqj8..z> 200000000~- + <1Hy.ufmjqe371x5.o@HEEl0tAp4> 700000000~- + <T6.c9.xM4i@943..7z.c..3h> 600000000~- + <Exus7LsME4fPL9v8@2.ouu97O25z9cdft> 700000000~- + <6kUzkf.v74@iC1iGj882RQ0zli> 400000000~- + <J.7YT7dV.Kkul8Bh0fc@Rar.EnMx2lm0.6Yeob> 600000000~- + <.wVJi1DX42@5.4i6.jaZ6qw9Ln1.> 500000000~- + <uUd9e18vxzevae7uY@33a480208l0.4p2q> 300000000~- + <43hQ.5shbE7@912400.ajES6x0sXl.M> 400000000~- + <g25r..2r.0WOZ6k3@tb3.U9xrR.uw61a2y0> 600000000~- + <923s5e67d5Oq085Y.1@6Pik68584> 900000000~- + <.5.n5cx5aD62i9q8@Ai60Sc.4x> 200000000~- + <9N9n@3.1ql87.yj2xFs.zLqI> 700000000~- Q2.kni8kZps7kF5uiEv32B38y4z.p + <.X.fw.6LtoT.0@pp6bp.5s6yh74.> 400000000~- + <54c1w@7..u1.99m9T4j.BNGBiK> 600000000~- .F3hb.OFh06V..p + <j12Mtn6q9@m2.m1X1s> 500000000~- + <o1WJV9G4H.zf0BX44w@W7.76xn33> 000000000~- + <0C605s6plaAgfM.ap40@e6d66n.uv01W.j.8ph.> 100000000~- m.x7TY8.8DQ5 + <.2.14xdn.@D0g.W.uZ.75gyyg.q1G> 100000000~- + <.A..03.@5v..64.5v3.3tbjUo.> 500000000~- + <72..c19ms65.WCf0G3.@83seEG9nnhM.O.j22> 900000000~- + <D..xX.kti9@u739li.xvy2> 000000000~- NPLL42XVfM + <6HO.nFal1ufl3.8b@3.n0k7a.IDgNy> 700000000~- Wv4j3Itccnh0Zp3 + <x5RjUnIpd03xBBnuN@z0puc82Q26Ou.0T6> 400000000~- k67.hvXwv6X745R4rh2ybuFN3n. + <62dIeg.fW92.ov375@x76mf5c6.37.v> 000000000~- + <chdpqs.0mgZOp.@Dxl9v..94e7ar2> 900000000~- + <.9Xr.7V91..oe5CG.hX@p5x3jos3s27R6O3yj1> 400000000~- + <Mm6dr.231dH35ua@SE1u0za3V1M43lRn9> 100000000~- + <JIhw2@.Qdf.8v28Tnf1M> 200000000~- + <z4FCa.q4MF..EE0.2@W9U63e33h9w3lcFFl> 400000000~- + <87.W3r6is4.@svVqQCBiNqz400A.qwj> 200000000~- + <0liI7Lu0Mx435m7M99@87Xw.8j63.9.> 500000000~- + <tRtht5M.6d0@06gj.qm3.s9> 200000000~- e27S.BKVD70P.o + <Jpga8@m68yvw.b4b> 200000000~- + <.2.69hy3JT1@Aq3.r83o.9> 700000000~- + <.W7EurYppo4fhzs.I@8651m2W7v> 700000000~- + <3m02.@22074.a5ct2j3> 900000000~- + <.fy9Epa@.1.kNGCNokFwB8ezo1WM> 800000000~- + <c758d64.FS4yY7L5@43sw.kI6> 900000000~- + <vLd0.t@.kq70oHl96ixdnXd.GVv> 100000000~- 9A6Ejq5t55I4VJ6.q1 + <d3.4@n17p4N.77N7W..7.8> 300000000~- + <f2lv064.8@4jokk3e07> 400000000~- + <rr7hoxA.U7.JXxnpvd@1rbMO437vHnakx> 000000000~- + <.0p3G7novlrYz9kjI@Sx.2w.yqzerZl12781.k> 700000000~- + <51ny.pQ7ay4@nfU2l1f0ixG09584.m> 000000000~- 38K5bhK7cr6.bg.5MlC2Fxq06Ziuw. + <2.cau.9s@.n4Pk0Jd9g> 300000000~- + <bEH1Bwa.662i@zm.3g.gx4.lp3> 300000000~- c8.t4Q0.8t0.m50 + <.t13789u5AqM4m3.z0T@P17e.ypf> 200000000~- q17z.fZ3.FyD533WthqZs8q7 + <M4r1I@Ovaev.dp> 100000000~- new dbz/getmap (patch can't create, so diff against null): Index: dbz/getmap *** cnpatch/old/dbz/getmap Sat Apr 14 20:29:13 1990 --- dbz/getmap Thu Apr 12 16:29:25 1990 *************** *** 0 **** --- 1,5 ---- + awk 'NR == 1 { + for (i = 9; i <= NF; i++) + printf "%s ", $i + printf "\n" + }' $* new dbz/random.c (patch can't create, so diff against null): Index: dbz/random.c *** cnpatch/old/dbz/random.c Sat Apr 14 20:29:13 1990 --- dbz/random.c Sat Mar 31 19:24:21 1990 *************** *** 0 **** --- 1,31 ---- + /* + * random-number generator for testing + */ + static unsigned long next = 1; + + /* + - range - generate a random number within an inclusive range + * + * Algorithm from ANSI C standard. Limitation: max-min <= 32767. + */ + int + range(min, max) + int min; + int max; + { + register int temp; + + next = next * 1103515245 + 12345; + temp = (int)((next/65536)%32768); + return(temp%(max - min + 1) + min); + } + + /* + - seed - seed random number generator + */ + void + seed(n) + long n; + { + next = (unsigned long)n; + } new dbz/revbytes (patch can't create, so diff against null): Index: dbz/revbytes *** cnpatch/old/dbz/revbytes Sat Apr 14 20:29:13 1990 --- dbz/revbytes Thu Apr 12 16:34:45 1990 *************** *** 0 **** --- 1,7 ---- + NR == 1 { + printf "%s %s %s %s %s %s %s %s %s", $1, $2, $3, $4, $5, $6, $7, $8, $9 + for (i = NF; i > 9; i--) + printf " %s", $i + printf "\n" + } + NR > 1 { print } new h/dbz.h (patch can't create, so diff against null): Index: h/dbz.h *** cnpatch/old/h/dbz.h Sat Apr 14 20:29:14 1990 --- h/dbz.h Thu Apr 12 16:18:34 1990 *************** *** 0 **** --- 1,31 ---- + /* for dbm and dbz */ + typedef struct { + char *dptr; + int dsize; + } datum; + + /* standard dbm functions */ + extern int dbminit(); + extern datum fetch(); + extern int store(); + extern int delete(); /* not in dbz */ + extern datum firstkey(); /* not in dbz */ + extern datum nextkey(); /* not in dbz */ + extern int dbmclose(); /* in dbz, but not in old dbm */ + + /* new stuff for dbz */ + extern int dbzfresh(); + extern int dbzagain(); + extern datum dbzfetch(); + extern int dbzstore(); + extern int dbzsync(); + extern long dbzsize(); + extern int dbzincore(); + extern int dbzdebug(); + + /* + * In principle we could handle unlimited-length keys by operating a chunk + * at a time, but it's not worth it in practice. Setting a nice large + * bound on them simplifies the code and doesn't hurt anything. + */ + #define DBZMAXKEY 255 new libfake/dbz.c (patch can't create, so diff against null): Index: libfake/dbz.c *** cnpatch/old/libfake/dbz.c Sat Apr 14 20:29:15 1990 --- libfake/dbz.c Thu Apr 12 17:43:54 1990 *************** *** 0 **** --- 1,82 ---- + /* + * fakes for using dbm (or old dbz) as if it were dbz + */ + #include <stdio.h> + #include <sys/types.h> + #include <dbz.h> + + /* the simple stuff */ + dbzfresh(a,b,c,d,e) char *a; long b; { return(dbzagain(a,a)); } + long dbzsize(a) long a; { return(a); } + dbzincore(n) int n; { return(0); } + dbzdebug(n) int n; { return(0); } + long dbztrim(a) long a; { return(a); } + int dbzsync() { return(0); } + + /* + - dbzagain - like dbminit but creates files + */ + int + dbzagain(a, b) + char *a; + char *b; + { + char dirname[200]; + char pagname[200]; + FILE *p; + FILE *d; + + sprintf(dirname, "%s.dir", a); + sprintf(pagname, "%s.pag", a); + p = fopen(dirname, "w"); + d = fopen(pagname, "w"); + if (p != NULL) + (void) fclose(p); + if (d != NULL) + (void) fclose(d); + if (p == NULL || d == NULL) + return(-1); + + return(dbminit(a)); + } + + /* + - dbzfetch - fetch() with case mapping built in + * + * Uses C News rfc822ize(). Assumes keys are strings. + */ + datum + dbzfetch(key) + datum key; + { + char buffer[DBZMAXKEY + 1]; + datum mappedkey; + + (void) strcpy(buffer, key.dptr); + (void) rfc822ize(buffer); + mappedkey.dptr = buffer; + mappedkey.dsize = key.dsize; + + return(fetch(mappedkey)); + } + + /* + - dbzstore - store() with case mapping built in + * + * Uses C News rfc822ize(). Assumes keys are strings. + */ + int + dbzstore(key, data) + datum key; + datum data; + { + char buffer[DBZMAXKEY + 1]; + datum mappedkey; + + (void) strcpy(buffer, key.dptr); + (void) rfc822ize(buffer); + mappedkey.dptr = buffer; + mappedkey.dsize = key.dsize; + + return(store(mappedkey, data)); + } end of patch 16-Apr-1990