home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume19 / cnews2 / pch14apr90 < prev    next >
Internet Message Format  |  1990-06-07  |  48KB

  1. From @uunet.uu.net:henry@zoo.toronto.edu Wed Apr 18 16:57:09 1990
  2. Received: from BBN.COM by pineapple.bbn.com id <AA15136@pineapple.bbn.com>; Wed, 18 Apr 90 16:56:41 -0400
  3. Received: from uunet.UU.NET by BBN.COM id aa17658; 18 Apr 90 16:45 EDT
  4. Received: from zoo.utoronto.ca by uunet.uu.net (5.61/1.14) with SMTP 
  5.     id AA11936; Wed, 18 Apr 90 16:39:22 -0400
  6. Message-Id: <9004182039.AA11936@uunet.uu.net>
  7. From: henry@zoo.toronto.edu
  8. Date: Wed, 18 Apr 90 14:14:49 EDT
  9. To: uunet!source-patches@uunet.uu.net
  10. Newsgroups: news.software.b,comp.sources.bugs
  11. Subject: C News patch of 14-Apr-1990
  12. Status: R
  13.  
  14. This is the first of three (!) patches mostly constituting the new dbz.
  15. In addition to that, there have been a few small things.  Our old slow
  16. dbm emulation has been deleted.  The nntpdiffs directory is gone too:
  17. it corresponds to a version of NNTP which is now obsolete, and current
  18. ones include reasonable C News support anyway.  The sample-cron-entries
  19. file now uses your news uid, rather than "news".  Various Makefiles and
  20. the like have been amended for dbz.  Expire and mkdbm have been altered
  21. to fully exploit the new dbz.  Relaynews no longer tries to run dbmclose()
  22. when preparing to execute a control message, because that causes trouble
  23. on old systems which don't have dbmclose() and refuse to do dbminit()
  24. more than once.  And there are the usual bits of minor cleanup.
  25.  
  26. The new dbz is now the default database for C News; there is a fake module
  27. which imitates it using dbm, for those of you who prefer big files and
  28. slow execution. :-)  For those unfamiliar with it, dbz -- originally
  29. invented by Jon Zeeff -- implements just the subset of dbm that news
  30. actually wants, and by doing this cleverly, is rather faster than dbm
  31. and has files that are about a twentieth the size of dbm's.  This one
  32. is considerably improved over Jon's original, in various ways:
  33.  
  34.     - It's faster (!).
  35.     - It handles table overflow gracefully and efficiently.
  36.     - It is byte-order independent, for use over networks.
  37.     - In-core tables can be selected at run time, not just by special
  38.         compilation.
  39.     - There are new functions that let the user completely ignore the
  40.         ugly case-mapping algorithms, with dbz doing all the work.
  41.     - Case mapping is self-contained, so dbz can be used independently
  42.         of C News with C-News-compatible mapping.
  43.     - There are new functions giving control of dbz's parameters (table
  44.         size, case mapping, etc.) when creating a new database.
  45.     - It remembers a history of table sizes, so that when expire
  46.         rebuilds the database, it can use a size that is likely
  47.         to prevent future overflow.
  48.     - It uses stdio for i/o, and has generally been overhauled for
  49.         portability; it should work on non-Unix systems.
  50.     - A shell-level interface (program) is provided.
  51.     - The Makefile uses the program to run a thorough regression test.
  52.     - It's compatible with old dbz databases, I think.
  53.     - It's documented (!).
  54.  
  55. start of patch 14-Apr-1990
  56. (suggested archive name: `pch14Apr90.Z')
  57. this should be run with   patch -p0 <thisfile
  58.  
  59. Please do the following (there is no easy way we can convince
  60. patch to do this automatically):
  61. rm libfake/dbm.c
  62. rm nntpdiffs/README
  63. rm nntpdiffs/cdiff.1.5.0
  64. rm nntpdiffs/cdiff.1.5.5
  65. rm nntpdiffs/diff/ihave.c
  66. rm nntpdiffs/diff/misc.c
  67. rm nntpdiffs/diff/newnews.c
  68. rm nntpdiffs/diff/serve.c
  69. rm nntpdiffs/src.allnew/batch.c
  70. rm nntpdiffs/src/Makefile
  71. rm nntpdiffs/src/ihave.c
  72. rm nntpdiffs/src/misc.c
  73. rm nntpdiffs/src/newnews.c
  74. rm nntpdiffs/src/serve.c
  75.  
  76. The following is a complete list of patches to date.
  77.  
  78. Prereq: 23-Jun-1989
  79. Prereq: 7-Jul-1989
  80. Prereq: 23-Jul-1989
  81. Prereq: 22-Aug-1989
  82. Prereq: 24-Aug-1989
  83. Prereq: 14-Sep-1989
  84. Prereq: 13-Nov-1989
  85. Prereq: 10-Jan-1990
  86. Prereq: 16-Jan-1990
  87. Prereq: 17-Jan-1990
  88. Prereq: 18-Jan-1990
  89. Prereq: 12-Mar-1990
  90. *** PATCHDATES.old    Sat Apr 14 20:24:28 1990
  91. --- PATCHDATES    Sat Apr 14 20:24:28 1990
  92. ***************
  93. *** 1,12 ****
  94. --- 1,13 ----
  95.   23-Jun-1989
  96.   7-Jul-1989
  97.   23-Jul-1989
  98.   22-Aug-1989
  99.   24-Aug-1989
  100.   14-Sep-1989
  101.   13-Nov-1989
  102.   10-Jan-1990
  103.   16-Jan-1990
  104.   17-Jan-1990
  105.   18-Jan-1990
  106.   12-Mar-1990
  107. + 14-Apr-1990
  108.  
  109. Changed files, if any:
  110.  
  111. *** cnpatch/old/README    Tue Mar 13 13:41:16 1990
  112. --- README    Sat Mar 31 18:32:20 1990
  113. ***************
  114. *** 171,176 ****
  115.   UUCP connections.  However, it does talk to utzoo.  Utzoo connects to half
  116.   the known universe (well, not quite, but try via allegra, att, attcan,
  117. ! attunix, decvax, dptcdc, floyd, hoptoad, kitty, linus, mnetor, pyramid,
  118. ! suncan, utai, utgpu, watmath, or yunexus).
  119.   
  120.                       Geoff Collyer
  121. --- 171,176 ----
  122.   UUCP connections.  However, it does talk to utzoo.  Utzoo connects to half
  123.   the known universe (well, not quite, but try via allegra, att, attcan,
  124. ! decvax, floyd, hoptoad, kitty, linus, mnetor, pyramid, suncan, utai, utgpu,
  125. ! watmath, or yunexus).
  126.   
  127.                       Geoff Collyer
  128.  
  129. *** cnpatch/old/conf/Makefile    Tue Jan 16 17:58:28 1990
  130. --- conf/Makefile    Sat Mar 31 21:11:47 1990
  131. ***************
  132. *** 13,20 ****
  133.   LIBS = ../libcnews.a
  134.   LIBDIRS = libbig libbsd42 libc libcnews libfake \
  135. !     libsmall libstdio libusg libv7 libv8
  136.   DIRS = batch conf expire h hfake input $(LIBDIRS) misc relay rna
  137.   CMPDIRS = batch conf expire input man misc relay rna
  138. ! RDIRS = batch expire input relay
  139.   SHS = doit.root doit.bin doit.news again.root
  140.   
  141. --- 13,20 ----
  142.   LIBS = ../libcnews.a
  143.   LIBDIRS = libbig libbsd42 libc libcnews libfake \
  144. !     libsmall libstdio libusg libv7 libv8 dbz
  145.   DIRS = batch conf expire h hfake input $(LIBDIRS) misc relay rna
  146.   CMPDIRS = batch conf expire input man misc relay rna
  147. ! RDIRS = batch dbz expire input relay
  148.   SHS = doit.root doit.bin doit.news again.root
  149.   
  150. ***************
  151. *** 43,46 ****
  152. --- 43,47 ----
  153.       : too late for h and hfake, include has already been built
  154.       -egrep '^(h|hfake)/' subst.hs subst.gc >junk
  155. +     : so test to make sure they do not need it
  156.       test ! -s junk ;
  157.       rm -f junk
  158. ***************
  159. *** 97,101 ****
  160.       rm -f spacefor.sgi spacefor.xenix queuelen.pre
  161.       rm -f config mailname organization server whoami hostname errlog
  162. !     rm -f substitutions history history.pag history.dir active localgroups
  163.       rm -f log mailpaths sys cron rc setnewsids setnewsids.o spacefor.bsd
  164.       rm -rf replyusepath spacefor queuelen junk save
  165. --- 98,102 ----
  166.       rm -f spacefor.sgi spacefor.xenix queuelen.pre
  167.       rm -f config mailname organization server whoami hostname errlog
  168. !     rm -f history history.pag history.dir active localgroups
  169.       rm -f log mailpaths sys cron rc setnewsids setnewsids.o spacefor.bsd
  170.       rm -rf replyusepath spacefor queuelen junk save
  171. ***************
  172. *** 110,114 ****
  173.   spotless:    gclean
  174.       rm -f $(SHS)
  175. !     rm -f substs
  176.   
  177.   lclean:
  178. --- 111,115 ----
  179.   spotless:    gclean
  180.       rm -f $(SHS)
  181. !     rm -f substs substitutions
  182.   
  183.   lclean:
  184.  
  185. *** cnpatch/old/conf/build    Tue Mar 13 13:41:17 1990
  186. --- conf/build    Sun Apr  1 01:52:36 1990
  187. ***************
  188. *** 135,141 ****
  189.           needucb=`yesno 'on your system.  Is that right' yes`
  190.       else
  191. !         echo 'It appears that /usr/ucb does not exist or is not'
  192. !         echo 'needed for normal operation on your system.  Is that'
  193. !         tmp=`yesno 'right' yes`
  194.           case "$tmp" in
  195.           yes)    needucb=no    ;;
  196. --- 135,141 ----
  197.           needucb=`yesno 'on your system.  Is that right' yes`
  198.       else
  199. !         echo 'It appears that /usr/ucb does not exist or that no'
  200. !         echo 'standard programs live there (and only there) on your'
  201. !         tmp=`yesno 'system.  Is that right' yes`
  202.           case "$tmp" in
  203.           yes)    needucb=no    ;;
  204. ***************
  205. *** 303,323 ****
  206.       esac
  207.   done
  208. ! has=`notinlist "$fake" dbm.o`
  209. ! tmp=`yesno 'Does your system have the "dbm" library' $has`
  210.   case "$tmp" in
  211. ! yes)    dbmopt=`ask 'What is the compile option needed to get it' ${dbmopt--ldbm}`
  212.       has=`notinlist "$fake" dbmclose.o`
  213. !     tmp=`yesno 'Does your dbm have a dbmclose() function' $has`
  214.       case "$tmp" in
  215.       no)    newfake="$newfake dbmclose.o"    ;;
  216.       esac
  217.       ;;
  218. - no)    newfake="$newfake dbm.o dbmclose.o"
  219. -     dbmopt=
  220. -     echo "Okay, we'll fake it for you.  You might want to look at"
  221. -     echo "contrib/dbz, which is a probably-superior fake that we have"
  222. -     echo "not examined closely."
  223. -     ;;
  224.   esac
  225.   fake="$newfake"
  226.   
  227. --- 303,335 ----
  228.       esac
  229.   done
  230. ! echo
  231. ! has=`notinlist "$fake" dbz.o`
  232. ! echo 'The news system uses a database package, typically the old "dbm"'
  233. ! echo 'library from Version 7 or a lookalike, as an indexing system.  We'
  234. ! echo 'supply a version of the "dbz" library which is faster than "dbm"'
  235. ! echo 'and uses much less disk space.  This is usually the best thing to'
  236. ! echo 'use, unless you have major backward-compatibility problems.  Do you'
  237. ! tmp=`yesno 'want to use our "dbz" library' $has`
  238.   case "$tmp" in
  239. ! yes)    dbzlib=dbz
  240. !     dbmopt=
  241. !     storeval=yes
  242. !     ;;
  243. ! no)    echo 'Presumably you want to use the dbm library or some local'
  244. !     echo 'equivalent, then.  What is the compile option, or filename,'
  245. !     dbmopt=`ask 'needed to get it' ${dbmopt--ldbm}`
  246. !     newfake="$newfake dbz.o"    # make dbm look like dbz
  247. !     dbzlib=
  248.       has=`notinlist "$fake" dbmclose.o`
  249. !     tmp=`yesno 'Does your dbm/dbz have a dbmclose() function' $has`
  250.       case "$tmp" in
  251.       no)    newfake="$newfake dbmclose.o"    ;;
  252.       esac
  253. +     echo 'Does the store() function in your dbm/dbz return a'
  254. +     storeval=`yesno 'value (some old dbms did not)' ${storeval-yes}`
  255.       ;;
  256.   esac
  257.   fake="$newfake"
  258.   
  259. ***************
  260. *** 339,350 ****
  261.   esac
  262.   
  263. - case "$dbmopt" in
  264. - '')    storeval=yes        ;;
  265. - *)    echo
  266. -     echo 'Does the store() function in your dbm library return a'
  267. -     storeval=`yesno 'value (some old ones did not)' ${storeval-yes}`
  268. -     ;;
  269. - esac
  270.   has=`notinlist "$fake" strchr.o`
  271.   case "$has" in
  272. --- 351,354 ----
  273. ***************
  274. *** 754,758 ****
  275.       *)    ccc="$ccc POST='$postlibs'"    ;;
  276.       esac
  277. !     echo "for dir in lib$unixkind lib$addrsize libc libcnews $libstdio"
  278.       echo "do"
  279.       echo "    cd ../\$dir"
  280. --- 758,762 ----
  281.       *)    ccc="$ccc POST='$postlibs'"    ;;
  282.       esac
  283. !     echo "for dir in lib$unixkind lib$addrsize libc libcnews $libstdio $dbzlib"
  284.       echo "do"
  285.       echo "    cd ../\$dir"
  286. ***************
  287. *** 790,797 ****
  288.           ;;
  289.       esac
  290. !     case "$dbmopt" in
  291. !     '')    dbm=            ;;
  292. !     *)    dbm="DBM=$dbmopt"    ;;
  293. !     esac
  294.       echo "for dir in $pgmdirs"
  295.       echo "do"
  296. --- 794,798 ----
  297.           ;;
  298.       esac
  299. !     dbm="DBM=$dbmopt"
  300.       echo "for dir in $pgmdirs"
  301.       echo "do"
  302. ***************
  303. *** 844,857 ****
  304.       echo "cat >cron <<'!'"
  305.       cat <<!
  306. ! 15 *    1-31 *    0-6    su news -c '$newsbin/input/newsrun'
  307. ! 30 8    1-31 *    1-5    su news -c '$newsbin/input/newsrunning off'
  308. ! 00 17    1-31 *    1-5    su news -c '$newsbin/input/newsrunning on'
  309. ! 40 *    1-31 *    0-6    su news -c '$newsbin/batch/sendbatches'
  310. ! 59 0    1-31 *    0-6    su news -c '$newsbin/expire/doexpire $a'
  311. ! 10 8    1-31 *    0-6    su news -c '$newsbin/maint/newsdaily'
  312. ! 00 5,13,21    1-31 *    0-6    su news -c '$newsbin/maint/newswatch'
  313.   !
  314.       echo "!"
  315. !     echo "echo 'su news -c $newsbin/maint/newsboot' >rc"
  316.       echo ": done"
  317.       echo 'case "$1" in'
  318. --- 845,858 ----
  319.       echo "cat >cron <<'!'"
  320.       cat <<!
  321. ! 15 *    1-31 *    0-6    su $newsuid -c '$newsbin/input/newsrun'
  322. ! 30 8    1-31 *    1-5    su $newsuid -c '$newsbin/input/newsrunning off'
  323. ! 00 17    1-31 *    1-5    su $newsuid -c '$newsbin/input/newsrunning on'
  324. ! 40 *    1-31 *    0-6    su $newsuid -c '$newsbin/batch/sendbatches'
  325. ! 59 0    1-31 *    0-6    su $newsuid -c '$newsbin/expire/doexpire $a'
  326. ! 10 8    1-31 *    0-6    su $newsuid -c '$newsbin/maint/newsdaily'
  327. ! 00 5,13,21    1-31 *    0-6    su $newsuid -c '$newsbin/maint/newswatch'
  328.   !
  329.       echo "!"
  330. !     echo "echo 'su $newsuid -c $newsbin/maint/newsboot' >rc"
  331.       echo ": done"
  332.       echo 'case "$1" in'
  333.  
  334. *** cnpatch/old/expire/Makefile    Tue Jan 16 17:58:29 1990
  335. --- expire/Makefile    Thu Apr  5 14:17:41 1990
  336. ***************
  337. *** 4,8 ****
  338.   LINTFLAGS = -I../include
  339.   JUNKLINT = 'possible pointer align'
  340. ! DBM = -ldbm
  341.   LIBS= ../libcnews.a
  342.   THEM = expire histdups histinfo histslash mkdbm mkhistory \
  343. --- 4,8 ----
  344.   LINTFLAGS = -I../include
  345.   JUNKLINT = 'possible pointer align'
  346. ! DBM =
  347.   LIBS= ../libcnews.a
  348.   THEM = expire histdups histinfo histslash mkdbm mkhistory \
  349. ***************
  350. *** 38,42 ****
  351.   
  352.   expire: expire.o $(LIBS)
  353. !     $(CC) $(CFLAGS) $(LDFLAGS) expire.o $(PRE) $(LIBS) $(DBM) $(POST) -o $@
  354.   
  355.   histinfo: histinfo.o $(LIBS)
  356. --- 38,42 ----
  357.   
  358.   expire: expire.o $(LIBS)
  359. !     $(CC) $(CFLAGS) $(LDFLAGS) expire.o $(PRE) $(DBM) $(LIBS) $(POST) -o $@
  360.   
  361.   histinfo: histinfo.o $(LIBS)
  362.  
  363. *** cnpatch/old/expire/expire.c    Tue Mar 13 13:41:18 1990
  364. --- expire/expire.c    Fri Apr  6 01:17:42 1990
  365. ***************
  366. *** 21,24 ****
  367. --- 21,25 ----
  368.   #include "fgetmfs.h"
  369.   #include "case.h"
  370. + #include "dbz.h"
  371.   
  372.   #ifndef EPOCH
  373. ***************
  374. *** 26,36 ****
  375.   #endif
  376.   
  377. - /* structure for dbm */
  378. - typedef struct {
  379. -     char *dptr;
  380. -     int dsize;
  381. - } datum;
  382.   #define    DAY    ((double)24*60*60)
  383.   
  384. --- 27,30 ----
  385. ***************
  386. *** 77,81 ****
  387.   int verbose = 0;        /* report statistics */
  388.   int rebuild = 1;        /* rebuild history files */
  389. - int violate = 0;        /* non-rfc822 case-sensitive messageIDs */
  390.   int getdgrump = 0;        /* report un-getdate()able expiry dates */
  391.   
  392. --- 71,74 ----
  393. ***************
  394. *** 201,207 ****
  395.               rebuild = 0;
  396.               break;
  397. -         case 'V':    /* non-rfc822 dualcase messageIDs */
  398. -             violate = 1;
  399. -             break;
  400.           case 'g':    /* report getdate() failures on expiry dates */
  401.               getdgrump = 1;
  402. --- 194,197 ----
  403. ***************
  404. *** 453,458 ****
  405.           (void) fclose(eufopen("history.n.dir", "w"));
  406.           (void) fclose(eufopen("history.n.pag", "w"));
  407. !         if (dbminit("history.n") < 0)
  408. !             fail("dbminit(history.n) failed", "");
  409.       }
  410.   
  411. --- 443,449 ----
  412.           (void) fclose(eufopen("history.n.dir", "w"));
  413.           (void) fclose(eufopen("history.n.pag", "w"));
  414. !         (void) dbzincore(1);
  415. !         if (dbzagain("history.n", "history") < 0)
  416. !             fail("dbzagain(history.n) failed", "");
  417.       }
  418.   
  419. ***************
  420. *** 470,478 ****
  421.               /* make the DBM entry */
  422.               *nameend = '\0';
  423. !             if (!violate)
  424. !                 lhs.dptr = rfc822ize(strsave(line));
  425. !             else
  426. !                 lhs.dptr = strsave(line);
  427. !             *nameend = '\t';
  428.               lhs.dsize = strlen(lhs.dptr)+1;
  429.               here = ftell(new);
  430. --- 461,465 ----
  431.               /* make the DBM entry */
  432.               *nameend = '\0';
  433. !             lhs.dptr = line;
  434.               lhs.dsize = strlen(lhs.dptr)+1;
  435.               here = ftell(new);
  436. ***************
  437. *** 480,487 ****
  438.               rhs.dsize = sizeof(here);
  439.               errno = 0;
  440. !             ret = store(lhs, rhs);
  441.               if (ret < 0)
  442.                   fail("dbm failure on `%s'", line);
  443. !             free(lhs.dptr);
  444.   
  445.               /* and the history entry */
  446. --- 467,474 ----
  447.               rhs.dsize = sizeof(here);
  448.               errno = 0;
  449. !             ret = dbzstore(lhs, rhs);
  450.               if (ret < 0)
  451.                   fail("dbm failure on `%s'", line);
  452. !             *nameend = '\t';
  453.   
  454.               /* and the history entry */
  455. ***************
  456. *** 497,501 ****
  457.       if (rebuild) {
  458.           eufclose(new, "history.n");
  459. !         dbmclose();
  460.       }
  461.   
  462. --- 484,489 ----
  463.       if (rebuild) {
  464.           eufclose(new, "history.n");
  465. !         if (dbmclose() < 0)
  466. !             fail("dbmclose() failed", "");
  467.       }
  468.   
  469.  
  470. *** cnpatch/old/expire/mkdbm.c    Wed Jan 10 19:10:25 1990
  471. --- expire/mkdbm.c    Fri Apr  6 01:31:06 1990
  472. ***************
  473. *** 6,14 ****
  474.   #include "alloc.h"
  475.   #include "fgetmfs.h"
  476. ! #include "case.h"
  477.   
  478.   
  479.   char *progname = "mkdbm";
  480. - typedef struct { char *dptr; int dsize; } datum;
  481.   
  482.   main(argc, argv)
  483. --- 6,13 ----
  484.   #include "alloc.h"
  485.   #include "fgetmfs.h"
  486. ! #include "dbz.h"
  487.   
  488.   
  489.   char *progname = "mkdbm";
  490.   
  491.   main(argc, argv)
  492. ***************
  493. *** 31,34 ****
  494. --- 30,34 ----
  495.       (void) close(creat(str3save(argv[1], ".", "dir"), 0666));
  496.       (void) close(creat(str3save(argv[1], ".", "pag"), 0666));
  497. +     (void) dbzincore(1);
  498.       if (dbminit(argv[1]) < 0)
  499.           error("unable to do dbminit(`%s')", argv[1]);
  500. ***************
  501. *** 47,51 ****
  502.           *scan = '\0';
  503.   
  504. -         rfc822ize(line);
  505.           lhs.dptr = line;
  506.           lhs.dsize = strlen(line) + 1;
  507. --- 47,50 ----
  508. ***************
  509. *** 52,56 ****
  510.           rhs.dptr = (char *)&place;
  511.           rhs.dsize = sizeof place;
  512. !         if (store(lhs, rhs) < 0)
  513.               fprintf(stderr, "dbm failure `%.50s' @ %ld\n", line, place);
  514.           free(line);
  515. --- 51,55 ----
  516.           rhs.dptr = (char *)&place;
  517.           rhs.dsize = sizeof place;
  518. !         if (dbzstore(lhs, rhs) < 0)
  519.               fprintf(stderr, "dbm failure `%.50s' @ %ld\n", line, place);
  520.           free(line);
  521.  
  522. *** cnpatch/old/h/Makefile    Thu Aug 24 16:39:51 1989
  523. --- h/Makefile    Sat Mar 31 21:13:50 1990
  524. ***************
  525. *** 1,4 ****
  526.   I = ../include
  527. ! INCLS = $(I)/alloc.h $(I)/config.h $(I)/fgetmfs.h $(I)/libc.h $(I)/news.h $(I)/case.h
  528.   
  529.   all:    $(INCLS)
  530. --- 1,5 ----
  531.   I = ../include
  532. ! INCLS = $(I)/alloc.h $(I)/config.h $(I)/fgetmfs.h $(I)/libc.h $(I)/news.h \
  533. ! $(I)/case.h $(I)/dbz.h
  534.   
  535.   all:    $(INCLS)
  536. ***************
  537. *** 14,17 ****
  538. --- 15,20 ----
  539.   $(I)/case.h:    case.h
  540.       cp case.h $@
  541. + $(I)/dbz.h:    dbz.h
  542. +     cp dbz.h $@
  543.   $(I)/news.h:    news.h newshsed
  544.       sed -f newshsed news.h >$@
  545.  
  546. *** cnpatch/old/input/newsspool.c    Thu Sep 14 16:03:36 1989
  547. --- input/newsspool.c    Mon Mar 26 17:37:50 1990
  548. ***************
  549. *** 290,294 ****
  550.       setgid(getgid());
  551.       setuid(getuid());
  552. !     fprintf(stderr, "%s: renouncing setuid due to nonstandard `%s'\n",
  553.                               progname, reason);
  554.   }
  555. --- 290,294 ----
  556.       setgid(getgid());
  557.       setuid(getuid());
  558. !     fprintf(stderr, "%s: renouncing setuid due to nonstandard `%s' in environment\n",
  559.                               progname, reason);
  560.   }
  561.  
  562. *** cnpatch/old/libfake/Makefile    Tue Mar 13 13:41:21 1990
  563. --- libfake/Makefile    Sat Apr 14 20:12:25 1990
  564. ***************
  565. *** 5,11 ****
  566.   SHELL = /bin/sh
  567.   
  568. ! ALL = dbm.o fsync.o getopt.o memchr.o memcmp.o memcpy.o \
  569.   memset.o mkdir.o putenv.o strchr.o strcspn.o strpbrk.o strrchr.o \
  570. ! strspn.o strtok.o symlink.o dbmclose.o
  571.   
  572.   # beware -- build knows about NEEDED
  573. --- 5,11 ----
  574.   SHELL = /bin/sh
  575.   
  576. ! ALL = fsync.o getopt.o memchr.o memcmp.o memcpy.o \
  577.   memset.o mkdir.o putenv.o strchr.o strcspn.o strpbrk.o strrchr.o \
  578. ! strspn.o strtok.o symlink.o dbmclose.o dbz.o
  579.   
  580.   # beware -- build knows about NEEDED
  581.  
  582. *** cnpatch/old/man/newsbatch.8    Tue Mar 13 13:41:24 1990
  583. --- man/newsbatch.8    Sat Apr 14 20:22:12 1990
  584. ***************
  585. *** 7,11 ****
  586.   .\" =()<.ds m @<NEWSMASTER>@>()=
  587.   .ds m usenet
  588. ! .TH NEWSBATCH 8 "13 Jan 1990"
  589.   .BY "C News"
  590.   .SH NAME
  591. --- 7,11 ----
  592.   .\" =()<.ds m @<NEWSMASTER>@>()=
  593.   .ds m usenet
  594. ! .TH NEWSBATCH 8 "14 April 1990"
  595.   .BY "C News"
  596.   .SH NAME
  597. ***************
  598. *** 301,302 ****
  599. --- 301,309 ----
  600.   (see \fInewsaux\fR(8)) does not know about multicast groups.
  601.   Also, \fIviauuxl\fR has not been tested well.
  602. + .PP
  603. + .I Viarsh
  604. + does not incorporate a spooling subsystem,
  605. + so a slow site stalls the entire batching system
  606. + and a non-responding site loses news.
  607. + It is not recommended for bulk transmission or where high reliability
  608. + is essential.
  609.  
  610. *** cnpatch/old/misc/Makefile    Tue Mar 13 13:41:25 1990
  611. --- misc/Makefile    Thu Apr  5 16:59:03 1990
  612. ***************
  613. *** 3,7 ****
  614.   CFLAGS = $(DEFS) $(COPTS) -I../include
  615.   LIBS = ../libcnews.a
  616. ! DBM = -ldbm
  617.   LINTFLAGS = $(DEFS) -ha
  618.   RN = ../relay
  619. --- 3,7 ----
  620.   CFLAGS = $(DEFS) $(COPTS) -I../include
  621.   LIBS = ../libcnews.a
  622. ! DBM =
  623.   LINTFLAGS = $(DEFS) -ha
  624.   RN = ../relay
  625.  
  626. *** cnpatch/old/misc/addfeed    Tue Jan 16 17:58:25 1990
  627. --- misc/addfeed    Mon Apr  2 13:04:01 1990
  628. ***************
  629. *** 1,4 ****
  630.   #! /bin/sh
  631. ! # addgroup - add a newsgroup, locally only
  632.   
  633.   # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  634. --- 1,4 ----
  635.   #! /bin/sh
  636. ! # addfeed - add an outbound feed
  637.   
  638.   # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  639.  
  640. *** cnpatch/old/relay/README.relay    Tue Jun 20 19:01:44 1989
  641. --- relay/README.relay    Fri Mar 16 11:29:54 1990
  642. ***************
  643. *** 19,24 ****
  644.   directories and I encourage this.
  645.   
  646. ! If you plan to run rn, you'll need the rn patches to allow Xref: to
  647. ! work without Relay-Version:, which has been banished.
  648.   
  649.   You will need to put your site name in /usr/lib/news/mailname (../conf/build
  650. --- 19,25 ----
  651.   directories and I encourage this.
  652.   
  653. ! If you plan to run rn, you'll need a recent rn which honours Xref:  in
  654. ! the absence of Relay-Version:, which has been banished.  patchlevel 40
  655. ! or greater should be fine; patchlevel 40 works here.
  656.   
  657.   You will need to put your site name in /usr/lib/news/mailname (../conf/build
  658.  
  659. *** cnpatch/old/relay/caches.c    Tue Mar 13 13:41:27 1990
  660. --- relay/caches.c    Fri Mar 30 17:03:01 1990
  661. ***************
  662. *** 8,17 ****
  663.   #include "active.h"
  664.   #include "caches.h"
  665. - #include "history.h"
  666.   #include "transmit.h"
  667.   
  668.   statust
  669. ! synccaches()                /* force in-core caches to disk */
  670.   {
  671. !     return actsync() | trclose() | closehist();
  672.   }
  673. --- 8,16 ----
  674.   #include "active.h"
  675.   #include "caches.h"
  676.   #include "transmit.h"
  677.   
  678.   statust
  679. ! synccaches()            /* force dirty in-core caches to disk */
  680.   {
  681. !     return actsync() | trclose();
  682.   }
  683.  
  684. *** cnpatch/old/relay/hdrdefs.c    Tue Mar 13 13:41:28 1990
  685. --- relay/hdrdefs.c    Mon Mar 19 12:41:03 1990
  686. ***************
  687. *** 15,19 ****
  688.   #include "hdrint.h"        /* may define "const" or REALSTDC */
  689.   #ifdef REALSTDC
  690. ! #include <stdlib.h>        /* may define offsetof */
  691.   #endif                /* REALSTDC */
  692.   
  693. --- 15,19 ----
  694.   #include "hdrint.h"        /* may define "const" or REALSTDC */
  695.   #ifdef REALSTDC
  696. ! #include <stddef.h>        /* defines offsetof */
  697.   #endif                /* REALSTDC */
  698.   
  699.  
  700. *** cnpatch/old/relay/procart.c    Tue Jan 16 17:58:41 1990
  701. --- relay/procart.c    Wed Apr  4 15:10:24 1990
  702. ***************
  703. *** 305,309 ****
  704.       } else if (msgid[0] != '<' || msgid[strlen(msgid)-1] != '>') {
  705.           prefuse(art);
  706. !         (void) printf("<> brackets missing in Message-ID\n");
  707.       } else if (alreadyseen(msgid)) {
  708.           prefuse(art);
  709. --- 305,309 ----
  710.       } else if (msgid[0] != '<' || msgid[strlen(msgid)-1] != '>') {
  711.           prefuse(art);
  712. !         (void) printf("Message-ID not bracketed by <>\n");
  713.       } else if (alreadyseen(msgid)) {
  714.           prefuse(art);
  715.  
  716. *** cnpatch/old/relay/regress/out/stderr    Thu Sep 14 16:03:50 1989
  717. --- relay/regress/out/stderr    Sat Mar 31 21:34:24 1990
  718. ***************
  719. *** 1 ****
  720. ! ./relaynews: warning: renouncing setuid due to nonstandard `NEWSARTS'
  721. --- 1 ----
  722. ! ./relaynews: warning: renouncing setuid due to nonstandard `NEWSARTS' in environment
  723.  
  724. *** cnpatch/old/relay/relaynews.c    Tue Jan 16 17:58:42 1990
  725. --- relay/relaynews.c    Fri Mar 30 17:03:06 1990
  726. ***************
  727. *** 122,125 ****
  728. --- 122,126 ----
  729.   
  730.       status |= synccaches();        /* being cautious: write & close caches */
  731. +     status |= closehist();
  732.       (void) fflush(stdout);        /* log file */
  733.       (void) fflush(stderr);        /* errlog file */
  734. ***************
  735. *** 263,267 ****
  736.       userealids = YES;
  737.       (void) fprintf(stderr,
  738. !         "%s: warning: renouncing setuid due to nonstandard `%s'\n",
  739.                               progname, reason);
  740.   }
  741. --- 264,268 ----
  742.       userealids = YES;
  743.       (void) fprintf(stderr,
  744. !     "%s: warning: renouncing setuid due to nonstandard `%s' in environment\n",
  745.                               progname, reason);
  746.   }
  747.  
  748. *** cnpatch/old/relay/sh/inews    Tue Jan 16 17:58:42 1990
  749. --- relay/sh/inews    Wed Apr  4 23:59:38 1990
  750. ***************
  751. *** 249,253 ****
  752.                           echo 'default    %s') |
  753.                       sed -n "1{s/^[^     ]*[     ][     ]*//
  754. !                         s/%s/` echo $ng | tr . - `/p;q;}" \
  755.                           >$modroute
  756.                   moderator="`cat $modroute `"
  757. --- 249,253 ----
  758.                           echo 'default    %s') |
  759.                       sed -n "1{s/^[^     ]*[     ][     ]*//
  760. !                       s/%s/` echo $ng | tr . - `/;p;q;}" \
  761.                           >$modroute
  762.                   moderator="`cat $modroute `"
  763.  
  764. Files that are new:
  765.  
  766. new dbz/Makefile (patch can't create, so diff against null):
  767. Index: dbz/Makefile
  768. *** cnpatch/old/dbz/Makefile    Sat Apr 14 20:29:03 1990
  769. --- dbz/Makefile    Thu Apr 12 17:13:39 1990
  770. ***************
  771. *** 0 ****
  772. --- 1,156 ----
  773. + COPTS = -O
  774. + FLAGS = -I../include
  775. + # -lc before libcnews.a so we get fread etc. from system
  776. + DBMLIBS = -lc ../libcnews.a
  777. + RFC = -DHAVERFCIZE
  778. + DEBUG = -DDBZDEBUG
  779. + CFLAGS = $(COPTS) $(FLAGS)
  780. + LINTFLAGS = -h $(FLAGS) $(DEBUG) $(RFC)
  781. + LDFLAGS =
  782. + # database sizes for performance tests, regression, and regression prime-find
  783. + TSIZE=12007
  784. + RSIZE=4019
  785. + RPSIZE=3012
  786. + # history files for regression and performance tests
  787. + RHIST=hist3.3
  788. + R2HIST=hist10
  789. + THIST=hist13
  790. + it:    dbz.o
  791. + all:    dbz.o dbz
  792. + u:    dbz.o
  793. +     ar ruv ../libcnews.a dbz.o
  794. +     cmp dbz.h ../h/dbz.h
  795. + t:    tdbz fake
  796. + lint:
  797. +     lint $(LINTFLAGS) dbzmain.c dbz.c
  798. + rdbz.o:    dbz.c
  799. +     cp dbz.c rdbz.c
  800. +     $(CC) $(CFLAGS) $(DEBUG) -DDEFSIZE=$(RSIZE) -c rdbz.c
  801. +     rm rdbz.c
  802. + rdbzmain.o:    dbzmain.c
  803. +     cp dbzmain.c rdbzmain.c
  804. +     $(CC) $(CFLAGS) $(RFC) -c rdbzmain.c
  805. +     rm rdbzmain.c
  806. + tdbz.o:    dbz.c
  807. +     cp dbz.c tdbz.c
  808. +     $(CC) $(CFLAGS) -DDEFSIZE=$(TSIZE) -c tdbz.c
  809. +     rm tdbz.c
  810. + dbz:    dbzmain.o dbz.o
  811. +     $(CC) $(CFLAGS) $(LDFLAGS) dbzmain.o dbz.o -o $@
  812. + tdbz:    dbzmain.o tdbz.o
  813. +     $(CC) $(CFLAGS) $(LDFLAGS) dbzmain.o tdbz.o -o $@
  814. + rdbz:    rdbzmain.o rdbz.o
  815. +     $(CC) $(CFLAGS) $(LDFLAGS) rdbzmain.o rdbz.o $(DBMLIBS) -o $@
  816. + fake:    fake.o random.o
  817. +     $(CC) $(CFLAGS) $(LDFLAGS) fake.o random.o -o $@
  818. + byteflip:    byteflip.o
  819. +     $(CC) $(CFLAGS) $(LDFLAGS) byteflip.o -o $@
  820. + hist10:    fake
  821. +     fake -t -e 75 10000 >$@
  822. + hist3.3:    fake
  823. +     fake -t -e 75 3300 >$@
  824. + hist13:    fake
  825. +     fake -t -e 75 13000 >$@
  826. + r:    rdbz $(RHIST) $(R2HIST) byteflip getmap revbytes altbytes
  827. +     : 'WARNING:  creates about 2MB of debris; do "make rclean" afterward'
  828. +     rm -f dbase dbase[23] dbase.* dbase[23].*
  829. +     test ! -d xx || rmdir xx
  830. +     : crude check of synthetic history file
  831. +     ( sed 25q $(RHIST) ; tail -25 $(RHIST) ) >histjunk
  832. +     cmp histjunk firstlast25
  833. +     rm histjunk
  834. +     : basic tests, exercising as many options as possible
  835. +     cp $(RHIST) dbase
  836. +     mkdir xx
  837. +     chmod -w xx
  838. +     rdbz -E 1000 -0 -M -i -S -u -U -C xx dbase
  839. +     rmdir xx
  840. +     sed '/>    0/d' $(RHIST) >dbase.used
  841. +     test "`cat dbase.used | wc -l`" -eq "`sed -n '2s/ .*//p' dbase.dir`" ;
  842. +     cp $(RHIST) dbase2
  843. +     rdbz -E 1000 -0 -p $(RPSIZE) -t '    ' dbase2
  844. +     cmp $(RHIST) dbase
  845. +     cmp dbase dbase2
  846. +     cmp dbase.dir dbase2.dir
  847. +     cmp dbase.pag dbase2.pag
  848. +     rdbz -E 1000 -0 -c dbase
  849. +     rdbz -E 1000 -0 -c -i -q -M -U dbase
  850. +     : build a database and then add to it
  851. +     sed 1000q $(RHIST) >dbase2
  852. +     sed 1,1000d $(RHIST) >dbase2.add
  853. +     rdbz -E 1000 -0 dbase2
  854. +     rdbz -E 1000 -0 -a dbase2 dbase2.add
  855. +     cmp dbase dbase2
  856. +     cmp dbase.dir dbase2.dir
  857. +     cmp dbase.pag dbase2.pag
  858. +     : build based on existing one, test extraction and readonly files
  859. +     rdbz -E 1000 -0 -f dbase dbase2
  860. +     test "`cat dbase.used | wc -l`" -eq "`awk 'NR==2{print $$1}' dbase2.dir`" ;
  861. +     test "`cat dbase.used | wc -l`" -eq "`awk 'NR==2{print $$2}' dbase2.dir`" ;
  862. +     chmod -w dbase2.dir dbase2.pag
  863. +     rdbz -E 1000 -x dbase2 dbase >dbase.temp
  864. +     cmp dbase.used dbase.temp
  865. +     : try some small case perversions
  866. +     sed 's/\(@[^     ]*\)A/\1a/' dbase >dbase.ick
  867. +     rdbz -E 1000 -x dbase2 dbase.ick >dbase.temp
  868. +     cmp dbase.used dbase.temp
  869. +     sed -n 's/A\([^     ]*@\)/a\1/p' dbase >dbase.ick
  870. +     rdbz -x dbase2 dbase.ick >dbase.temp
  871. +     test ! -s dbase.temp ;
  872. +     rm -f dbase2.dir dbase2.pag
  873. +     : try it without tags, case-insensitive, with case perversions
  874. +     rdbz -E 1000 -0 -p '0 b 1' dbase2
  875. +     tr '[A-M][n-z]' '[a-m][N-Z]' <dbase2 >dbase.ick
  876. +     rdbz -E 1000 -x dbase2 dbase.ick >dbase.temp
  877. +     cmp dbase.used dbase.temp
  878. +     rm -f dbase.temp dbase.ick
  879. +     : test various perversions of byte ordering
  880. +     awk -f revbytes dbase.dir >dbase2.dir
  881. +     chmod +x getmap
  882. +     byteflip `getmap dbase.dir` `getmap dbase2.dir` <dbase.pag >dbase2.pag
  883. +     cp dbase dbase2
  884. +     rdbz -E 1000 -0 -c dbase2
  885. +     awk -f altbytes dbase.dir >dbase2.dir
  886. +     dd conv=swab <dbase.pag >dbase2.pag
  887. +     rdbz -E 1000 -0 -c dbase2
  888. +     cp dbase2 dbase3
  889. +     rdbz -E 1000 -0 -f dbase2 dbase3
  890. +     rdbz -E 1000 -0 -c dbase3
  891. +     test " `getmap dbase2.dir`" = " `getmap dbase3.dir`" ;
  892. +     : test massive overflow, throw in case sensitivity and tag mask
  893. +     cp $(R2HIST) dbase
  894. +     rdbz -E 1000 -0 -p '0 0 7ff00000' dbase
  895. +     rdbz -E 1000 -0 -cq dbase
  896. +     sed 100q dbase | egrep '[aA].*    ' | tr aA Aa >dbase.ick
  897. +     rdbz -x dbase dbase.ick >dbase.temp
  898. +     test ! -s dbase.temp ;
  899. +     : success!
  900. + rclean:
  901. +     rm -f dbase dbase[23] dbase.* dbase[23].* fake fake.o random.o
  902. +     rm -f rdbz rdbz.o rdbzmain.o $(RHIST) $(R2HIST) byteflip byteflip.o
  903. +     rm -f histjunk core
  904. +     test ! -d xx || rmdir xx
  905. + clean:    rclean
  906. +     rm -f *.o dbz [a-z]dbz [a-z][a-z]dbz junk* PostScript.out
  907. +     rm -f hist* dbase* *.bak mon.out gmon.out core dbm.h
  908.  
  909. new dbz/README (patch can't create, so diff against null):
  910. Index: dbz/README
  911. *** cnpatch/old/dbz/README    Sat Apr 14 20:29:04 1990
  912. --- dbz/README    Thu Apr 12 17:14:33 1990
  913. ***************
  914. *** 0 ****
  915. --- 1,13 ----
  916. + This is the new, improved, lemon-freshened :-) dbz.
  917. + Just "make" will get you dbz.o and the dbz program.  "make r" runs an
  918. + extensive set of regression tests; most of the mysterious oddments lying
  919. + around here are to do with that.  "make rclean" cleans up after "make r".
  920. + You probably want to inspect the #ifdef list early in dbz.c before
  921. + compiling, although the defaults should work all right on most systems.
  922. + If you are not building this as part of C News, you will need to change
  923. + the -I option in FLAGS in the Makefile to "-I.", and delete the DBMLIBS
  924. + and RFC lines entirely.  That will break some of the regression tests;
  925. + at some point I'll fix this.
  926.  
  927. new dbz/altbytes (patch can't create, so diff against null):
  928. Index: dbz/altbytes
  929. *** cnpatch/old/dbz/altbytes    Sat Apr 14 20:29:04 1990
  930. --- dbz/altbytes    Thu Apr 12 16:34:59 1990
  931. ***************
  932. *** 0 ****
  933. --- 1,7 ----
  934. + NR == 1 {
  935. +     printf "%s %s %s %s %s %s %s %s %s", $1, $2, $3, $4, $5, $6, $7, $8, $9
  936. +     for (i = 10; i <= NF; i += 2)
  937. +         printf " %s %s", $(i+1), $i
  938. +     printf "\n"
  939. + }
  940. + NR > 1 { print }
  941.  
  942. new dbz/byteflip.c (patch can't create, so diff against null):
  943. Index: dbz/byteflip.c
  944. *** cnpatch/old/dbz/byteflip.c    Sat Apr 14 20:29:04 1990
  945. --- dbz/byteflip.c    Sat Mar 31 19:24:20 1990
  946. ***************
  947. *** 0 ****
  948. --- 1,33 ----
  949. + #include <stdio.h>
  950. + #define    MAXWORD    32
  951. + main(argc, argv)
  952. + int argc;
  953. + char *argv[];
  954. + {
  955. +     register int len;
  956. +     int inmap[MAXWORD];
  957. +     int outmap[MAXWORD];
  958. +     char in[MAXWORD];
  959. +     char out[MAXWORD];
  960. +     register int i;
  961. +     register int a;
  962. +     a = 1;
  963. +     len = atoi(argv[a++]);
  964. +     if (len > MAXWORD)
  965. +         abort();    /* kind of drastic... */
  966. +     for (i = 0; i < len; i++)
  967. +         inmap[i] = atoi(argv[a++]);
  968. +     if (atoi(argv[a++]) != len)
  969. +         abort();
  970. +     for (i = 0; i < len; i++)
  971. +         outmap[i] = atoi(argv[a++]);
  972. +     while (fread(in, 1, len, stdin) == len) {
  973. +         for (i = 0; i < len; i++)
  974. +             out[outmap[i]] = in[inmap[i]];
  975. +         fwrite(out, 1, len, stdout);
  976. +     }
  977. + }
  978.  
  979. new dbz/dbz.1 (patch can't create, so diff against null):
  980. Index: dbz/dbz.1
  981. *** cnpatch/old/dbz/dbz.1    Sat Apr 14 20:29:05 1990
  982. --- dbz/dbz.1    Thu Apr 12 18:14:50 1990
  983. ***************
  984. *** 0 ****
  985. --- 1,205 ----
  986. + .TH DBZ 1 "12 April 1990"
  987. + .BY "C News"
  988. + .SH NAME
  989. + dbz \- operate on dbz databases of text
  990. + .SH SYNOPSIS
  991. + .B dbz
  992. + [
  993. + .BR \- { axc }
  994. + ] [
  995. + .B \-t
  996. + c
  997. + ] [
  998. + .B \-l
  999. + length
  1000. + ] [
  1001. + .BR \- { qiue }
  1002. + ] [
  1003. + .B \-f
  1004. + old
  1005. + ] [
  1006. + .B \-p
  1007. + parms
  1008. + ] database file ...
  1009. + .SH DESCRIPTION
  1010. + .I Dbz
  1011. + is a shell-level interface to the
  1012. + .IR dbz (3z)
  1013. + database routines for indexed access to a text file.
  1014. + .PP
  1015. + The
  1016. + .I database
  1017. + file must be a text file,
  1018. + one line per database record,
  1019. + with the key the first field on the line.
  1020. + The
  1021. + .B \-t
  1022. + option sets the field-separator character; the default is tab.
  1023. + Setting the separator character to NUL (with
  1024. + .BR "\-t\ ''" )
  1025. + makes the whole line the key.
  1026. + Lines must not exceed 1023 bytes in length including the newline;
  1027. + this limit can be increased with the
  1028. + .B \-l
  1029. + option.
  1030. + The limitations and restrictions of
  1031. + .IR dbz (3z)
  1032. + must also be observed.
  1033. + .PP
  1034. + In the absence of options,
  1035. + .I dbz
  1036. + creates a
  1037. + .IR dbz (3z)
  1038. + index for the database;
  1039. + the index comprises files
  1040. + .IB database .pag
  1041. + and
  1042. + .IB database .dir
  1043. + in the same directory.
  1044. + Any previous index is silently overwritten.
  1045. + The
  1046. + .BR \-a ,
  1047. + .BR \-x ,
  1048. + and
  1049. + .B \-c
  1050. + options specify other operations.
  1051. + .PP
  1052. + With
  1053. + .BR \-a ,
  1054. + .I dbz
  1055. + appends lines from the
  1056. + .IR file (s)
  1057. + (standard input if none)
  1058. + to the database, updating both the
  1059. + text file and the indexes.
  1060. + .PP
  1061. + With
  1062. + .BR \-x ,
  1063. + .I dbz
  1064. + reads keys from the
  1065. + .IR file (s)
  1066. + (standard input if none)
  1067. + and prints (on standard output) the corresponding lines, if any,
  1068. + from the database.
  1069. + The input is in the form of database lines, although only the keys are
  1070. + significant.
  1071. + .PP
  1072. + With
  1073. + .BR \-c ,
  1074. + .I dbz
  1075. + checks the database for internal consistency.
  1076. + The
  1077. + .B \-q
  1078. + option causes this check to be done more quickly but less thoroughly
  1079. + (each key is looked up in the index, but no check is made to be sure
  1080. + that the index entry points to the right place).
  1081. + .PP
  1082. + The
  1083. + .B \-i
  1084. + option suppresses the use of
  1085. + .IR dbz (3z)'s
  1086. + .I incore
  1087. + facility.
  1088. + This makes accesses slower, but keeps the files current
  1089. + during updating
  1090. + and reduces
  1091. + startup/shutdown overhead.
  1092. + .PP
  1093. + Normally,
  1094. + .I dbz
  1095. + checks whether a key is already in the database before adding it.
  1096. + The
  1097. + .B \-u
  1098. + option suppresses this check, speeding things up at the expense of safety.
  1099. + .PP
  1100. + A new index is normally created with default size,
  1101. + case mapping, and tagging.
  1102. + The default size is right for 90-100,000 records.
  1103. + The default case mapping is right for RFC822 message-ids.
  1104. + See
  1105. + .IR dbz (3z)
  1106. + for what tagging is about.
  1107. + (Note, these defaults can be changed when
  1108. + .IR dbz (3z)
  1109. + is installed.)
  1110. + .PP
  1111. + If the
  1112. + .B \-f
  1113. + option is given,
  1114. + size, case mapping, and tagging
  1115. + are instead initialized based on the
  1116. + database
  1117. + .IR old .
  1118. + This is mostly useful when
  1119. + creating a new generation of an existing database.
  1120. + (See the description of
  1121. + .I dbzagain
  1122. + in
  1123. + .IR dbz (3z)
  1124. + for details.)
  1125. + .PP
  1126. + If the
  1127. + .B \-p
  1128. + option is given, the
  1129. + .I parms
  1130. + string specifies the size, case mapping, and tagging.
  1131. + If
  1132. + .I parms
  1133. + is a single decimal number,
  1134. + that is taken as the expected number of records
  1135. + in the index, with case mapping and tagging defaulted.
  1136. + Alternatively,
  1137. + .I parms
  1138. + can be three fields\(ema decimal number, a case-mapping code character, and a
  1139. + hexadecimal tag mask\(emseparated by white space.
  1140. + The decimal number is, again, the expected number of records;
  1141. + 0 means ``use the default''.
  1142. + See
  1143. + .IR dbz (3z)
  1144. + for possible choices of case-mapping code,
  1145. + but in particular,
  1146. + .B 0
  1147. + means ``no case mapping''.
  1148. + See
  1149. + .IR dbz (3z)
  1150. + for details on tag masks;
  1151. + 0 means ``use the default''.
  1152. + .PP
  1153. + If the
  1154. + .B \-e
  1155. + option is given, the decimal number in
  1156. + .B \-p
  1157. + is taken to be the exact table size, not the expected number of records,
  1158. + and invocation of
  1159. + .I dbzsize
  1160. + (see
  1161. + .IR dbz (3z))
  1162. + to predict a good size for that number of records is suppressed.
  1163. + .PP
  1164. + The
  1165. + .B \&.pag
  1166. + file is normally 5-6 bytes per record (based on the estimate given to
  1167. + .B \-p
  1168. + or the previous history of the
  1169. + .B \-f
  1170. + database).
  1171. + The
  1172. + .B \&.dir
  1173. + file is tiny.
  1174. + .SH SEE ALSO
  1175. + dbz(3z)
  1176. + .SH HISTORY
  1177. + Written at U of Toronto by Henry Spencer, for the C News project.
  1178. + See
  1179. + .IR dbz (3z)
  1180. + for the history of the underlying database routines.
  1181. + .SH BUGS
  1182. + There are a number of undocumented options with obscure effects,
  1183. + meant for debugging and regression testing of
  1184. + .IR dbz (3z).
  1185. + .PP
  1186. + Permissions for the index files probably ought to be taken from those
  1187. + of the base file.
  1188. + .PP
  1189. + The line-length limit is a blemish, alleviated only slightly by
  1190. + .BR \-l .
  1191.  
  1192. new dbz/dbz.3z (patch can't create, so diff against null):
  1193. Index: dbz/dbz.3z
  1194. *** cnpatch/old/dbz/dbz.3z    Sat Apr 14 20:29:05 1990
  1195. --- dbz/dbz.3z    Thu Apr 12 18:14:20 1990
  1196. ***************
  1197. *** 0 ****
  1198. --- 1,509 ----
  1199. + .TH DBZ 3Z "12 April 1990"
  1200. + .BY "C News"
  1201. + .SH NAME
  1202. + dbminit, fetch, store, dbmclose \- somewhat dbm-compatible database routines
  1203. + .br
  1204. + dbzfresh, dbzagain, dbzfetch, dbzstore \- database routines
  1205. + .br
  1206. + dbzsize, dbzincore, dbzdebug \- database routines
  1207. + .SH SYNOPSIS
  1208. + .nf
  1209. + .B #include <dbz.h>
  1210. + .PP
  1211. + .B dbminit(base)
  1212. + .B char *base;
  1213. + .PP
  1214. + .B datum
  1215. + .B fetch(key)
  1216. + .B datum key;
  1217. + .PP
  1218. + .B store(key, value)
  1219. + .B datum key;
  1220. + .B datum value;
  1221. + .PP
  1222. + .B dbmclose()
  1223. + .PP
  1224. + .B dbzfresh(base, size, fieldsep, cmap, tagmask)
  1225. + .B char *base;
  1226. + .B long size;
  1227. + .B int fieldsep;
  1228. + .B int cmap;
  1229. + .B long tagmask;
  1230. + .PP
  1231. + .B dbzagain(base, oldbase)
  1232. + .B char *base;
  1233. + .B char *oldbase;
  1234. + .PP
  1235. + .B datum
  1236. + .B dbzfetch(key)
  1237. + .B datum key;
  1238. + .PP
  1239. + .B dbzstore(key, value)
  1240. + .B datum key;
  1241. + .B datum value;
  1242. + .PP
  1243. + .B dbzsync()
  1244. + .PP
  1245. + .B long
  1246. + .B dbzsize(nentries)
  1247. + .B long nentries;
  1248. + .PP
  1249. + .B dbzincore(newvalue)
  1250. + .PP
  1251. + .B dbzdebug(newvalue)
  1252. + .SH DESCRIPTION
  1253. + These functions provide an indexing system for rapid random access to a
  1254. + text file (the
  1255. + .I base 
  1256. + .IR file ).
  1257. + Subject to certain constraints, they are compatible with
  1258. + .IR dbm (3),
  1259. + although they also provide some extensions.
  1260. + .PP
  1261. + In principle,
  1262. + .I dbz
  1263. + stores key-value pairs, where both key and value are arbitrary sequences
  1264. + of bytes, specified to the functions by
  1265. + values of type
  1266. + .IR datum ,
  1267. + typedefed in the header file to be a structure with members
  1268. + .I dptr
  1269. + (a value of type
  1270. + .I char *
  1271. + pointing to the bytes)
  1272. + and
  1273. + .I dsize
  1274. + (a value of type
  1275. + .I int
  1276. + indicating how long the byte sequence is).
  1277. + .PP
  1278. + In practice,
  1279. + .I dbz
  1280. + is more restricted than
  1281. + .IR dbm .
  1282. + A
  1283. + .I dbz
  1284. + database
  1285. + must be an index into a base file,
  1286. + with the database
  1287. + .IR value s
  1288. + being
  1289. + .IR fseek (3)
  1290. + offsets into the base file.
  1291. + Each such
  1292. + .I value
  1293. + must ``point to'' a place in the base file where the corresponding
  1294. + .I key
  1295. + sequence is found.
  1296. + A key can be no longer than
  1297. + .SM DBZMAXKEY
  1298. + (a constant defined in the header file) bytes.
  1299. + No key can be an initial subsequence of another,
  1300. + which in most applications requires that keys be
  1301. + either bracketed or terminated in some way (see the
  1302. + discussion of the
  1303. + .I fieldsep
  1304. + parameter of
  1305. + .IR dbzfresh ,
  1306. + below,
  1307. + for a fine point on terminators).
  1308. + .PP
  1309. + .I Dbminit
  1310. + opens a database,
  1311. + an index into the base file
  1312. + .IR base ,
  1313. + consisting of files
  1314. + .IB base .dir
  1315. + and
  1316. + .IB base .pag
  1317. + which must already exist.
  1318. + (If the database is new, they should be zero-length files.)
  1319. + Subsequent accesses go to that database until
  1320. + .I dbmclose
  1321. + is called to close the database.
  1322. + The base file need not exist at the time of the
  1323. + .IR dbminit ,
  1324. + but it must exist before accesses are attempted.
  1325. + .PP
  1326. + .I Fetch
  1327. + searches the database for the specified
  1328. + .IR key ,
  1329. + returning the corresponding
  1330. + .IR value
  1331. + if any.
  1332. + .I Store
  1333. + stores the
  1334. + .IR key - value
  1335. + pair in the database.
  1336. + .I Store
  1337. + will fail unless the database files are writeable.
  1338. + See below for a complication arising from case mapping.
  1339. + .PP
  1340. + .I Dbzfresh
  1341. + is a variant of
  1342. + .I dbminit
  1343. + for creating a new database with more control over details.
  1344. + Unlike for
  1345. + .IR dbminit ,
  1346. + the database files need not exist:
  1347. + they will be created if necessary,
  1348. + and truncated in any case.
  1349. + .PP
  1350. + .IR Dbzfresh 's
  1351. + .I size
  1352. + parameter specifies the size of the first hash table within the database,
  1353. + in key-value pairs.
  1354. + Performance will be best if
  1355. + .I size
  1356. + is a prime number and
  1357. + the number of key-value pairs stored in the database does not exceed
  1358. + about 75% of
  1359. + .IR size .
  1360. + (The
  1361. + .I dbzsize
  1362. + function, given the expected number of key-value pairs,
  1363. + will suggest a database size that meets these criteria.)
  1364. + Assuming that an
  1365. + .I fseek
  1366. + offset is 4 bytes,
  1367. + the
  1368. + .B .pag
  1369. + file will be
  1370. + .RI 4* size
  1371. + bytes
  1372. + (the
  1373. + .B .dir
  1374. + file is tiny and roughly constant in size)
  1375. + until
  1376. + the number of key-value pairs exceeds about 80% of
  1377. + .IR size .
  1378. + (Nothing awful will happen if the database grows beyond 100% of
  1379. + .IR size ,
  1380. + but accesses will slow down somewhat and the
  1381. + .B .pag
  1382. + file will grow somewhat.)
  1383. + .PP
  1384. + .IR Dbzfresh 's
  1385. + .I fieldsep
  1386. + parameter specifies the field separator in the base file.
  1387. + If this is not
  1388. + NUL (0), and the last character of a
  1389. + .I key
  1390. + argument is NUL, that NUL compares equal to either a NUL or a
  1391. + .I fieldsep
  1392. + in the base file.
  1393. + This permits use of NUL to terminate key strings without requiring that
  1394. + NULs appear in the base file.
  1395. + The
  1396. + .I fieldsep
  1397. + of a database created with
  1398. + .I dbminit
  1399. + is the horizontal-tab character.
  1400. + .PP
  1401. + For use in news systems, various forms of case mapping (e.g. uppercase to
  1402. + lowercase) in keys are available.
  1403. + The
  1404. + .I cmap
  1405. + parameter to
  1406. + .I dbzfresh
  1407. + is a single character specifying which of several mapping algorithms to use.
  1408. + Available algorithms are:
  1409. + .RS
  1410. + .TP
  1411. + .B 0
  1412. + case-sensitive:  no case mapping
  1413. + .TP
  1414. + .B B
  1415. + same as
  1416. + .B 0
  1417. + .TP
  1418. + .B NUL
  1419. + same as
  1420. + .B 0
  1421. + .TP
  1422. + .B =
  1423. + case-insensitive:  uppercase and lowercase equivalent
  1424. + .TP
  1425. + .B b
  1426. + same as
  1427. + .B =
  1428. + .TP
  1429. + .B C
  1430. + RFC822 message-ID rules, case-sensitive before `@' (with certain exceptions)
  1431. + and case-insensitive after
  1432. + .TP
  1433. + .B ?
  1434. + whatever the local default is, normally
  1435. + .B C
  1436. + .RE
  1437. + .PP
  1438. + Mapping algorithm
  1439. + .B 0
  1440. + (no mapping) is faster than the others and is overwhelmingly the correct
  1441. + choice for most applications.
  1442. + Unless compatibility constraints interfere, it is more efficient to pre-map
  1443. + the keys, storing mapped keys in the base file, than to have
  1444. + .I dbz
  1445. + do the mapping on every search.
  1446. + .PP
  1447. + For historical reasons,
  1448. + .I fetch
  1449. + and
  1450. + .I store
  1451. + expect their
  1452. + .I key
  1453. + arguments to be pre-mapped, but expect unmapped keys in the base file.
  1454. + .I Dbzfetch
  1455. + and
  1456. + .I dbzstore
  1457. + do the same jobs but handle all case mapping internally,
  1458. + so the customer need not worry about it.
  1459. + .PP
  1460. + .I Dbz
  1461. + stores only the database
  1462. + .IR value s
  1463. + in its files, relying on reference to the base file to confirm a hit on a key.
  1464. + References to the base file can be minimized, greatly speeding up searches,
  1465. + if a little bit of information about the keys can be stored in the
  1466. + .I dbz
  1467. + files.
  1468. + This is ``free'' if there are some unused bits in an
  1469. + .I fseek
  1470. + offset,
  1471. + so that the offset can be
  1472. + .I tagged
  1473. + with some information about the key.
  1474. + The
  1475. + .I tagmask
  1476. + parameter of
  1477. + .I dbzfresh
  1478. + allows specifying the location of unused bits.
  1479. + .I Tagmask
  1480. + should be a mask with
  1481. + one group of
  1482. + contiguous
  1483. + .B 1
  1484. + bits.
  1485. + The bits in the mask should
  1486. + be unused (0) in
  1487. + .I most
  1488. + offsets.
  1489. + The bit immediately above the mask (the
  1490. + .I flag
  1491. + bit) should be unused (0) in
  1492. + .I all
  1493. + offsets;
  1494. + .I (dbz)store
  1495. + will reject attempts to store a key-value pair in which the
  1496. + .I value
  1497. + has the flag bit on.
  1498. + Apart from this restriction, tagging is invisible to the user.
  1499. + As a special case, a
  1500. + .I tagmask
  1501. + of 1 means ``no tagging'', for use with enormous base files or
  1502. + on systems with unusual offset representations.
  1503. + .PP
  1504. + A
  1505. + .I size
  1506. + of 0
  1507. + given to
  1508. + .I dbzfresh
  1509. + is synonymous with the local default;
  1510. + the normal default is suitable for tables of 90-100,000
  1511. + key-value pairs.
  1512. + A
  1513. + .I cmap
  1514. + of 0 (NUL) is synonymous with the character
  1515. + .BR 0 ,
  1516. + signifying no case mapping
  1517. + (note that the character
  1518. + .B ?
  1519. + specifies the local default mapping,
  1520. + normally
  1521. + .BR C ).
  1522. + A
  1523. + .I tagmask
  1524. + of 0 is synonymous with the local default tag mask,
  1525. + normally 0x7f000000 (specifying the top bit in a 32-bit offset
  1526. + as the flag bit, and the next 7 bits as the mask,
  1527. + which is suitable for base files up to circa 24MB).
  1528. + Calling
  1529. + .I dbminit(name)
  1530. + with the database files empty is equivalent to calling
  1531. + .IR dbzfresh(name,0,'\et','?',0) .
  1532. + .PP
  1533. + When databases are regenerated periodically, as in news,
  1534. + it is simplest to pick the parameters for a new database based on the old one.
  1535. + This also permits some memory of past sizes of the old database, so that
  1536. + a new database size can be chosen to cover expected fluctuations.
  1537. + .I Dbzagain
  1538. + is a variant of
  1539. + .I dbminit
  1540. + for creating a new database as a new generation of an old database.
  1541. + The database files for
  1542. + .I oldbase
  1543. + must exist.
  1544. + .I Dbzagain
  1545. + is equivalent to calling
  1546. + .I dbzfresh
  1547. + with the same field separator, case mapping, and tag mask as the old database,
  1548. + and a
  1549. + .I size
  1550. + equal to the result of applying
  1551. + .I dbzsize
  1552. + to the largest number of entries in the
  1553. + .I oldbase
  1554. + database and its previous 10 generations.
  1555. + .PP
  1556. + When many accesses are being done by the same program,
  1557. + .I dbz
  1558. + is massively faster if its first hash table is in memory.
  1559. + If an internal flag is 1,
  1560. + an attempt is made to read the table in when
  1561. + the database is opened, and
  1562. + .I dbmclose
  1563. + writes it out to disk again (if it was read successfully and
  1564. + has been modified).
  1565. + .I Dbzincore
  1566. + sets the flag to
  1567. + .I newvalue
  1568. + (which should be 0 or 1)
  1569. + and returns the previous value;
  1570. + this does not affect the status of a database that has already been opened.
  1571. + The default is 0.
  1572. + The attempt to read the table in may fail due to memory shortage;
  1573. + in this case
  1574. + .I dbz
  1575. + quietly falls back on its default behavior.
  1576. + .IR Store s
  1577. + to an in-memory database are not (in general) written out to the file
  1578. + until
  1579. + .IR dbmclose
  1580. + or
  1581. + .IR dbzsync ,
  1582. + so if robustness in the presence of crashes
  1583. + or concurrent accesses
  1584. + is crucial, in-memory databases
  1585. + should probably be avoided.
  1586. + .PP
  1587. + .I Dbzsync
  1588. + causes all buffers etc. to be flushed out to the files.
  1589. + It is typically used as a precaution against crashes or concurrent accesses
  1590. + when a
  1591. + .IR dbz -using
  1592. + process will be running for a long time.
  1593. + It is a somewhat expensive operation,
  1594. + especially
  1595. + for an in-memory database.
  1596. + .PP
  1597. + If
  1598. + .I dbz
  1599. + has been compiled with debugging facilities available (which makes it
  1600. + bigger and a bit slower),
  1601. + .I dbzdebug
  1602. + alters the value (and returns the previous value) of an internal flag
  1603. + which (when 1; default is 0) causes
  1604. + verbose and cryptic debugging output on standard output.
  1605. + .PP
  1606. + Concurrent reading of databases is fairly safe,
  1607. + but there is no (inter)locking,
  1608. + so concurrent updating is not.
  1609. + .PP
  1610. + The database files include a record of the byte order of the processor
  1611. + creating the database, and accesses by processors with different byte
  1612. + order will work, although they will be slightly slower.
  1613. + Byte order is preserved by
  1614. + .IR dbzagain .
  1615. + However,
  1616. + agreement on the size and internal structure of an
  1617. + .I fseek
  1618. + offset is necessary, as is consensus on
  1619. + the character set.
  1620. + .PP
  1621. + An open database occupies three
  1622. + .I stdio
  1623. + streams and their corresponding file descriptors;
  1624. + a fourth is needed for an in-memory database.
  1625. + Memory consumption is negligible (except for
  1626. + .I stdio
  1627. + buffers) except for in-memory databases.
  1628. + .SH SEE ALSO
  1629. + dbz(1), dbm(3)
  1630. + .SH DIAGNOSTICS
  1631. + Functions returning
  1632. + .I int
  1633. + values return 0 for success, \-1 for failure.
  1634. + Functions returning
  1635. + .I datum
  1636. + values return a value with
  1637. + .I dptr
  1638. + set to NULL for failure.
  1639. + .SH HISTORY
  1640. + The original
  1641. + .I dbz
  1642. + was written by
  1643. + Jon Zeeff (zeeff@b-tech.ann-arbor.mi.us).
  1644. + Later contributions by David Butler and Mark Moraes.
  1645. + Extensive reworking,
  1646. + including this documentation,
  1647. + by Henry Spencer (henry@zoo.toronto.edu) as
  1648. + part of the C News project.
  1649. + Hashing function by Peter Honeyman.
  1650. + .SH BUGS
  1651. + The
  1652. + .I dptr
  1653. + members of returned
  1654. + .I datum
  1655. + values point to static storage which is overwritten by later calls.
  1656. + .PP
  1657. + Unlike
  1658. + .IR dbm ,
  1659. + .I dbz
  1660. + will misbehave if an existing key-value pair is `overwritten' by
  1661. + a new
  1662. + .I (dbz)store
  1663. + with the same key.
  1664. + The user is responsible for avoiding this by using
  1665. + .I (dbz)fetch
  1666. + first to check for duplicates;
  1667. + an internal optimization remembers the result of the
  1668. + first search so there is minimal overhead in this.
  1669. + .PP
  1670. + Waiting until after
  1671. + .I dbminit
  1672. + to bring the base file into existence
  1673. + will fail if
  1674. + .IR chdir (2)
  1675. + has been used meanwhile.
  1676. + .PP
  1677. + The RFC822 case mapper implements only a first approximation to the
  1678. + hideously-complex RFC822 case rules.
  1679. + .PP
  1680. + The prime finder in
  1681. + .I dbzsize
  1682. + is not particularly quick.
  1683. + .PP
  1684. + Should implement the
  1685. + .I dbm
  1686. + functions
  1687. + .IR delete ,
  1688. + .IR firstkey ,
  1689. + and
  1690. + .IR nextkey .
  1691. + .PP
  1692. + On C implementations which trap integer overflow,
  1693. + .I dbz
  1694. + will refuse to
  1695. + .I (dbz)store
  1696. + an
  1697. + .I fseek
  1698. + offset equal to the greatest
  1699. + representable
  1700. + positive number,
  1701. + as this would cause overflow in the biased representation used.
  1702. + .PP
  1703. + .I Dbzagain
  1704. + perhaps ought to notice when many offsets
  1705. + in the old database were
  1706. + too big for
  1707. + tagging, and shrink the tag mask to match.
  1708.  
  1709.  
  1710. end of patch 14-Apr-1990
  1711.  
  1712.