home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume39 / ldb / patch01 next >
Text File  |  1993-08-23  |  25KB  |  810 lines

  1. Newsgroups: comp.sources.misc
  2. From: ross@teserv.den.mmc.com (Perry R. Ross)
  3. Subject: v39i047:  ldb - Play backgammon by e-mail, version 1.3, Patch01
  4. Message-ID: <1993Aug23.040954.27618@sparky.sterling.com>
  5. X-Md4-Signature: e23418b04681aa242f5c2bfc82828903
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Mon, 23 Aug 1993 04:09:54 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: ross@teserv.den.mmc.com (Perry R. Ross)
  12. Posting-number: Volume 39, Issue 47
  13. Archive-name: ldb/patch01
  14. Environment: UNIX, C, VMS, VAXC, CURSES, 32BIT
  15. Patch-To: ldb: Volume 36, Issue 98-109
  16.  
  17.         Long Distance Backgammon
  18.  
  19. This is a program that lets two people easily play backgammon
  20. by e-mail.  It currently runs only on character-oriented terminals
  21. (or emulators thereof) under the curses package.  It runs on most
  22. flavors of UNIX, as well as VMS version 5.0 and above.
  23.  
  24. This is patch 1 to version 1.3 of ldb.  Most changes are minor bug
  25. fixes.  Some non-portable usage of signed char has been eliminated, 
  26. allowing ldb to compile on AT&T machines.  My e-mail address for 
  27. ldb-related questions has also changed; you should use the one listed 
  28. by ldb -help, not the one from this posting.  
  29.  
  30. Thanks once again to Earle Ake for finding & fixing loads-o-bugs.
  31.  
  32. *** 130src/Makefile    Mon Aug  2 13:04:59 1993
  33. --- Makefile    Tue Aug  3 12:18:56 1993
  34. ***************
  35. *** 76,82 ****
  36.   CFLAGS=-O $(OLDCURSES) $(NEED_READDIR)
  37.   LIBS=-lcurses -ltermcap
  38.   
  39. ! # use these 2 lines for SCO XENIX (also SCO UNIX?)
  40.   #CFLAGS= -O -Mle -LARGE -Zi -DM_TERMCAP $(OLDCURSES)
  41.   #LIBS=-lx -ltcap -ltermlib
  42.   LINTFLAGS=
  43. --- 76,82 ----
  44.   CFLAGS=-O $(OLDCURSES) $(NEED_READDIR)
  45.   LIBS=-lcurses -ltermcap
  46.   
  47. ! # use these 2 lines for SCO XENIX (not SCO UNIX!)
  48.   #CFLAGS= -O -Mle -LARGE -Zi -DM_TERMCAP $(OLDCURSES)
  49.   #LIBS=-lx -ltcap -ltermlib
  50.   LINTFLAGS=
  51. ***************
  52. *** 109,114 ****
  53. --- 109,117 ----
  54.   $(LDB): $(OFILES)
  55.       $(CC) $(CFLAGS) -s -o $(LDB) $(OFILES) $(LIBS)
  56.   
  57. + ldb.h: patchlevel.h
  58. +     touch ldb.h
  59.   all: $(LDB) ldb.doc
  60.   
  61.   ldb.doc: ldb.man
  62. ***************
  63. *** 146,148 ****
  64. --- 149,186 ----
  65.       mv .tags tags
  66.   
  67.   .XXX:
  68. + depend:
  69. +     rm -f make.tmp
  70. +     sed '/^# DO NOT DELETE/,$$d' < Makefile > make.tmp
  71. +     echo '# DO NOT DELETE THIS LINE -- make depend uses it' >>make.tmp
  72. +     egrep '^#.*include.*\"' $(HFILES) $(CFILES) \
  73. +     | sed -e 's/.c:/.o:/' -e 's/:/: /' -e 's/"//g' \
  74. +     | awk '{print $$1 " " $$3;}' >>make.tmp
  75. +     mv Makefile Makefile.old
  76. +     mv make.tmp Makefile
  77. + # DO NOT DELETE THIS LINE -- make depend uses it
  78. + ldb.h: patchlevel.h
  79. + board.o: ldb.h
  80. + game.o: ldb.h
  81. + main.o: ldb.h
  82. + misc.o: ldb.h
  83. + move.o: ldb.h
  84. + process.o: ldb.h
  85. + rcvop.o: ldb.h
  86. + control.o: ldb.h
  87. + check.o: ldb.h
  88. + readmail.o: ldb.h
  89. + save.o: ldb.h
  90. + vars.o: ldb.h
  91. + fe_curses.o: ldb.h
  92. + t_email.o: ldb.h
  93. + r_xrand.o: ldb.h
  94. + dohelp.o: ldb.h
  95. + dostats.o: ldb.h
  96. + rename.o: ldb.h
  97. + flist_unix.o: ldb.h
  98. + flist_vms.o: ldb.h
  99. + flist_none.o: ldb.h
  100. + lock.o: ldb.h
  101. *** 130src/TODO    Mon Aug  2 13:05:02 1993
  102. --- TODO    Fri Jul 23 10:37:42 1993
  103. ***************
  104. *** 1,3 ****
  105. --- 1,23 ----
  106. + flist_unix does not work on SCO UNIX.
  107. + From Dick King (king@ukulele.reasoning.com):
  108. + 1. Proposition support.  Need more info.
  109. + 2. Dice server to support secure games.  For games that need
  110. + to be secure, moves would either go from player 1 to dice server
  111. + to player 2 (if player 2 can't double or says he doesn't want to),
  112. + or from player 1 to player 2 to dice server back to player 2.
  113. + Each time you request a roll from the server, you send your opponent's
  114. + last roll for verification.
  115. + Patch to FeFinishSession for Linux: add nl() after refresh().
  116. + Maybe add nocbreak() and echo() too just to be safe?
  117. + Found by Stephan G. Dasia (stephand@solist.htsa.aha.nl)
  118. + Include earle's modified makefile, etc.
  119. + way of showing all opponent pieces that you could hit.
  120. + way of showing all points you could make.
  121.   delete redundant fields from game structure (opaddr, myaddr, etc)
  122.   
  123.   delmail option should work on system mail file.
  124. *** 130src/control.c    Mon Aug  2 13:05:16 1993
  125. --- control.c    Tue Aug  3 13:51:34 1993
  126. ***************
  127. *** 180,187 ****
  128.   char *file;
  129.   {
  130.   FILE *fp;
  131. ! char c;
  132. ! int i, j;
  133.   struct mv m;
  134.   struct game *g;
  135.   struct people *p;
  136. --- 180,187 ----
  137.   char *file;
  138.   {
  139.   FILE *fp;
  140. ! int c;
  141. ! int i, j, line;
  142.   struct mv m;
  143.   struct game *g;
  144.   struct people *p;
  145. ***************
  146. *** 193,201 ****
  147.       ldbexit(STAT_ABORT);
  148.       }
  149.   g = addgame();            /* get a game structure */
  150.   while ( (c = getc(fp)) != EOF) {
  151.       ungetc(c,fp);            /* put char back */
  152. !     nvscan(fp,nv_gfile,g);
  153.       if (strcmp(g->opaddr,rc.myaddr))    /* this game wasn't with me */
  154.           continue;
  155.       if ( (g->state == ST_OPSTART) || (g->state == ST_GAMEOVER) )
  156. --- 193,206 ----
  157.       ldbexit(STAT_ABORT);
  158.       }
  159.   g = addgame();            /* get a game structure */
  160. + line = 0;
  161.   while ( (c = getc(fp)) != EOF) {
  162.       ungetc(c,fp);            /* put char back */
  163. !     if (nvscan(fp,nv_gfile,g,&line) < 0) {
  164. !         fprintf(stderr,"ERROR: bad line %d in %s -- aborting.\n",
  165. !             line, file);
  166. !         ldbexit(STAT_ABORT);
  167. !         }
  168.       if (strcmp(g->opaddr,rc.myaddr))    /* this game wasn't with me */
  169.           continue;
  170.       if ( (g->state == ST_OPSTART) || (g->state == ST_GAMEOVER) )
  171. *** 130src/ldb.h    Mon Aug  2 13:05:47 1993
  172. --- ldb.h    Tue Aug  3 13:56:56 1993
  173. ***************
  174. *** 171,177 ****
  175.   #define F_CRDONE    1024    /* The crawford rule game has been played */
  176.   
  177.           /* field types for reading name/value files */
  178. ! #define FT_CHAR        1    /* store a single character */
  179.   #define FT_INT        2    /* store a single integer */
  180.   #define FT_STRING    3    /* store a char * (use save()) */
  181.   #define FT_MOVE        4    /* a struct mv */
  182. --- 171,177 ----
  183.   #define F_CRDONE    1024    /* The crawford rule game has been played */
  184.   
  185.           /* field types for reading name/value files */
  186. ! #define FT_CHAR        1    /* store a single char (may not be signed!) */
  187.   #define FT_INT        2    /* store a single integer */
  188.   #define FT_STRING    3    /* store a char * (use save()) */
  189.   #define FT_MOVE        4    /* a struct mv */
  190. ***************
  191. *** 316,323 ****
  192.       };
  193.   
  194.   struct mv {
  195. !     char    roll;            /* # on 1 die, 0 = DOUBLE, -1=empty */
  196. !     char    pt;            /* point move is from, -1=UNUSED */
  197.       };
  198.   
  199.   struct point {
  200. --- 316,323 ----
  201.       };
  202.   
  203.   struct mv {
  204. !     int    roll;            /* # on 1 die, 0 = DOUBLE, -1=empty */
  205. !     int    pt;            /* point move is from, -1=UNUSED */
  206.       };
  207.   
  208.   struct point {
  209. ***************
  210. *** 334,341 ****
  211.       char    *myaddr;        /* my address for this user */
  212.       char    mycolor;        /* char to represent my pieces */
  213.       char    opcolor;        /* opponent's pieces */
  214. !     char    mydir;            /* 1/-1 direction I am moving */
  215. !     char    opdir;            /* 1/-1 direction opponent is moving */
  216.       int    gameval;        /* current value of game */
  217.       int    adcnt;            /* current number of autodoubles */
  218.       int    admax;            /* max autodoubles allowed */
  219. --- 334,341 ----
  220.       char    *myaddr;        /* my address for this user */
  221.       char    mycolor;        /* char to represent my pieces */
  222.       char    opcolor;        /* opponent's pieces */
  223. !     int    mydir;            /* 1/-1 direction I am moving */
  224. !     int    opdir;            /* 1/-1 direction opponent is moving */
  225.       int    gameval;        /* current value of game */
  226.       int    adcnt;            /* current number of autodoubles */
  227.       int    admax;            /* max autodoubles allowed */
  228. ***************
  229. *** 429,439 ****
  230.   extern char *rejlcl[];            /* error messages for local player */
  231.   extern char *rejmsg[];            /* error messages for received moves */
  232.   extern char *opcodes[];
  233.   extern char blk76[];            /* 76 blanks */
  234.   extern struct packet P;            /* last packet read */
  235.   extern char cr_mycolor;            /* my color when game is created */
  236.   extern char cr_opcolor;            /* opponent's color for new games */
  237. ! extern char cr_mydir;            /* my direction for new games */
  238.   extern char *notify;            /* address to notify when game ends */
  239.   extern char *states[];            /* description of the states */
  240.   
  241. --- 429,440 ----
  242.   extern char *rejlcl[];            /* error messages for local player */
  243.   extern char *rejmsg[];            /* error messages for received moves */
  244.   extern char *opcodes[];
  245. + extern char nvbuf[128];            /* buffer for nvscan/nvwrite */
  246.   extern char blk76[];            /* 76 blanks */
  247.   extern struct packet P;            /* last packet read */
  248.   extern char cr_mycolor;            /* my color when game is created */
  249.   extern char cr_opcolor;            /* opponent's color for new games */
  250. ! extern int cr_mydir;            /* my direction for new games */
  251.   extern char *notify;            /* address to notify when game ends */
  252.   extern char *states[];            /* description of the states */
  253.   
  254. ***************
  255. *** 449,455 ****
  256.   
  257.   char *tgetstr();
  258.   char *save(), *makeid(), *calloc();
  259. ! char *nvscan(), *strchr(), *boardstr();
  260.   char *strchr(), *strrchr();
  261.   struct game *startgame(), *addgame(), *findgame();
  262.   
  263. --- 450,456 ----
  264.   
  265.   char *tgetstr();
  266.   char *save(), *makeid(), *calloc();
  267. ! char *strchr(), *boardstr();
  268.   char *strchr(), *strrchr();
  269.   struct game *startgame(), *addgame(), *findgame();
  270.   
  271. *** 130src/main.c    Mon Aug  2 13:06:06 1993
  272. --- main.c    Wed Aug  4 09:41:44 1993
  273. ***************
  274. *** 385,396 ****
  275.    *    one -remotestart may be used per run of ldb.  Suggested by Earle Ake.
  276.    * 19.    findppl now detects infinite loops in equiv records.  Should never
  277.    *    happen, but ...
  278. !  *** Version 01   Rev 2   Patch 0
  279.    * 1.    A warning is printed if the crawford rule is used with a pre-1.3
  280.    *    version of ldb.  The Crawford rule was fixed during 1.2, but many
  281.    *    beta versions were distributed before this fix was included.
  282.    * 2.    The -newaddr option was added.  I was going to wait on this, but
  283.    *    my employment situation is such that I may need to use it soon. :-(
  284.    *============================================================================
  285.    */
  286.   
  287. --- 385,402 ----
  288.    *    one -remotestart may be used per run of ldb.  Suggested by Earle Ake.
  289.    * 19.    findppl now detects infinite loops in equiv records.  Should never
  290.    *    happen, but ...
  291. !  *** Version 01   Rev 3   Patch 0
  292.    * 1.    A warning is printed if the crawford rule is used with a pre-1.3
  293.    *    version of ldb.  The Crawford rule was fixed during 1.2, but many
  294.    *    beta versions were distributed before this fix was included.
  295.    * 2.    The -newaddr option was added.  I was going to wait on this, but
  296.    *    my employment situation is such that I may need to use it soon. :-(
  297. +  *** Version 01   Rev 3   Patch 1
  298. +  * 1.    The game file was not checkpointed when our double is accepted.
  299. +  * 2.    Some non-portable uses of chars as signed chars were changed to int's.
  300. +  * 3.    The Makefile was changed to do a full recompile if ldb.h is changed.
  301. +  *    This was done by adding a homebrew "make depend", which should be run
  302. +  *    before each release is packed so the users don't have to.
  303.    *============================================================================
  304.    */
  305.   
  306. ***************
  307. *** 681,687 ****
  308.               i++;            /* keep count */
  309.               }
  310.           }
  311. !     message("newaddr: %d opponents to notify.\n",i);
  312.       }
  313.   
  314.   i = 0;
  315. --- 687,693 ----
  316.               i++;            /* keep count */
  317.               }
  318.           }
  319. !     message("newaddr: %d opponent%s to notify.\n",i,(i==1) ? "" : "s");
  320.       }
  321.   
  322.   i = 0;
  323. ***************
  324. *** 752,758 ****
  325.           VERSION,REVISION);
  326.   #else
  327.       printf(
  328. !     "\nLdb version %d.%d (patch %d) by Perry R. Ross.  Mail\ncomments",
  329.       VERSION,REVISION,PATCHLEVEL);
  330.   #endif
  331.       printf("or suggestions to \"%s\".\n",AUTHOR_EMAIL);
  332. --- 758,764 ----
  333.           VERSION,REVISION);
  334.   #else
  335.       printf(
  336. !     "\nLdb version %d.%d (patch %d) by Perry R. Ross.  Mail\ncomments ",
  337.       VERSION,REVISION,PATCHLEVEL);
  338.   #endif
  339.       printf("or suggestions to \"%s\".\n",AUTHOR_EMAIL);
  340. *** 130src/makefile.vms    Mon Aug  2 13:05:09 1993
  341. --- makefile.vms    Thu Jun 10 10:56:14 1993
  342. ***************
  343. *** 79,85 ****
  344.   
  345.   *.obj :    *.c
  346.       write sys$output "Compiling $*"
  347. !     cc $(CFLAGS) $*
  348.       purge/nolog $*.obj
  349.       rename $*.obj *.*;1
  350.   
  351. --- 79,85 ----
  352.   
  353.   *.obj :    *.c
  354.       write sys$output "Compiling $*"
  355. !     cc $(CFLAGS) $*.c
  356.       purge/nolog $*.obj
  357.       rename $*.obj *.*;1
  358.   
  359. ***************
  360. *** 96,102 ****
  361.   #    Include all the sources necessary to build under VMS or unix
  362.   #
  363.   
  364. ! SHARFILES=readme.,todo.,ldb.doc,ldb.man,ldb.ps,makefile.*,ldb.opt,makeldb.com,*.c,*.h,ldbstarter.csh,ldb-man.tex,ldb-man.ps1,ldb-man.ps2,ldb-man.ps3
  365.   
  366.   $(LDB) : $(ldb_objs)
  367.       write sys$output "Linking $(LDB)"
  368. --- 96,102 ----
  369.   #    Include all the sources necessary to build under VMS or unix
  370.   #
  371.   
  372. ! SHARFILES=readme.,todo.,ldb.doc,ldb.man,ldb.ps,makefile.*,ldb.opt,makeldb.com,*.c,*.h,ldbstarter.csh,ldb.tex
  373.   
  374.   $(LDB) : $(ldb_objs)
  375.       write sys$output "Linking $(LDB)"
  376. *** 130src/makeldb.com    Mon Aug  2 13:05:10 1993
  377. --- makeldb.com    Thu Jun 10 10:56:14 1993
  378. ***************
  379. *** 1,28 ****
  380.   $ set verify
  381.   $ assign "sys$library" vaxc$include
  382. ! $ cc/nolist board
  383. ! $ cc/nolist check
  384. ! $ cc/nolist control
  385. ! $ cc/nolist dohelp
  386. ! $ cc/nolist dostats
  387. ! $ cc/nolist fe_curses
  388. ! $ cc/nolist flist_vms
  389. ! $ cc/nolist game
  390. ! $ cc/nolist lock
  391. ! $ cc/nolist main
  392. ! $ cc/nolist misc
  393. ! $ cc/nolist move
  394. ! $ cc/nolist process
  395. ! $ cc/nolist r_xrand
  396. ! $ cc/nolist rcvop
  397. ! $ cc/nolist readmail
  398. ! $ cc/nolist save
  399. ! $ cc/nolist t_email
  400. ! $ cc/nolist vars
  401. ! $ link/exe=ldb sys$input/opt
  402. ! board,check,control,dohelp,dostats,fe_curses,flist_vms,game,lock,main
  403. ! misc,move,process,r_xrand,rcvop,readmail,save,t_email,vars
  404. ! sys$share:vaxccurse.olb/library
  405. ! ldb.opt/options
  406.   $ set noverify
  407.   $ exit
  408. --- 1,30 ----
  409. + $ ccopts := "/nodebug"
  410.   $ set verify
  411.   $ assign "sys$library" vaxc$include
  412. ! $ cc/nolist'ccopts' board.c
  413. ! $ cc/nolist'ccopts' check.c
  414. ! $ cc/nolist'ccopts' control.c
  415. ! $ cc/nolist'ccopts' dohelp.c
  416. ! $ cc/nolist'ccopts' dostats.c
  417. ! $ cc/nolist'ccopts' fe_curses.c
  418. ! $ cc/nolist'ccopts' flist_vms.c
  419. ! $ cc/nolist'ccopts' game.c
  420. ! $ cc/nolist'ccopts' lock.c
  421. ! $ cc/nolist'ccopts' main.c
  422. ! $ cc/nolist'ccopts' misc.c
  423. ! $ cc/nolist'ccopts' move.c
  424. ! $ cc/nolist'ccopts' process.c
  425. ! $ cc/nolist'ccopts' r_xrand.c
  426. ! $ cc/nolist'ccopts' rcvop.c
  427. ! $ cc/nolist'ccopts' readmail.c
  428. ! $ cc/nolist'ccopts' save.c
  429. ! $ cc/nolist'ccopts' t_email.c
  430. ! $ cc/nolist'ccopts' vars.c
  431. ! $ link/exe=ldb/nodebug/notrace -
  432. ! board.obj,check.obj,control.obj,dohelp.obj,dostats.obj,fe_curses.obj,-
  433. ! flist_vms.obj,game.obj,lock.obj,main.obj,misc.obj,move.obj,process.obj,-
  434. ! r_xrand.obj,rcvop.obj,readmail.obj,save.obj,t_email.obj,vars.obj,-
  435. ! sys$share:vaxccurse.olb/library,-
  436. ! sys$disk:[]ldb.opt/option
  437.   $ set noverify
  438.   $ exit
  439. *** 130src/patchlevel.h    Mon Aug  2 13:05:11 1993
  440. --- patchlevel.h    Fri Aug 20 18:34:33 1993
  441. ***************
  442. *** 36,40 ****
  443.   
  444.   #define VERSION        1
  445.   #define REVISION    3        /* no more than 9 */
  446. ! #define PATCHLEVEL    0        /* no more than 9 */
  447. ! #define AUTHOR_EMAIL    "ross@emf780.den.mmc.com"
  448. --- 36,40 ----
  449.   
  450.   #define VERSION        1
  451.   #define REVISION    3        /* no more than 9 */
  452. ! #define PATCHLEVEL    1        /* no more than 9 */
  453. ! #define AUTHOR_EMAIL    "perry@aap.com"
  454. *** 130src/rcvop.c    Mon Aug  2 13:05:35 1993
  455. --- rcvop.c    Thu Jun 10 10:13:53 1993
  456. ***************
  457. *** 407,412 ****
  458. --- 407,416 ----
  459.   clearmvs(g->mvs);        /* erase our previous move */
  460.   rolldice(g);            /* go ahead and roll, I can't double */
  461.   g->dispmsg = save("Opponent has accepted your double.");/* notify user */
  462. + if (*rc.chkpt == 'y') {        /* checkpoint games */
  463. +     writegames(rc.gfile,rc.gbackup,rc.pfile);
  464. +     rc.gbackup = NULL;    /* only backup old file once */
  465. +     }
  466.   }
  467.   
  468.   
  469. *** 130src/readmail.c    Mon Aug  2 13:05:38 1993
  470. --- readmail.c    Tue Aug  3 13:40:37 1993
  471. ***************
  472. *** 232,238 ****
  473.       clearmvs(P.mvs);
  474.       P.gameptr = NULL;
  475.       P.notify = NULL;
  476. !     nvscan(fp,nv_packet,&P);    /* scan the packet into P */
  477.       if (P.gameid == NULL) {        /* didn't get a gameid */
  478.           message("ERROR: missing gameid in packet -- ignored\n");
  479.           continue;
  480. --- 232,241 ----
  481.       clearmvs(P.mvs);
  482.       P.gameptr = NULL;
  483.       P.notify = NULL;
  484. !     if (nvscan(fp,nv_packet,&P,NULL) < 0) { /* scan the packet into P */
  485. !         message("ERROR: bad line in packet -- ignored.\n");
  486. !         continue;
  487. !         }
  488.       if (P.gameid == NULL) {        /* didn't get a gameid */
  489.           message("ERROR: missing gameid in packet -- ignored\n");
  490.           continue;
  491. *** 130src/save.c    Mon Aug  2 13:05:59 1993
  492. --- save.c    Tue Aug  3 13:56:35 1993
  493. ***************
  494. *** 58,64 ****
  495.   readldbrc()
  496.   {
  497.   FILE *fp;
  498. ! char *s, *n, *getenv();
  499.   char buf[80];
  500.   
  501.   if ( (s = getenv("HOME")) != NULL)    /* if we have a home */
  502. --- 58,65 ----
  503.   readldbrc()
  504.   {
  505.   FILE *fp;
  506. ! int line;
  507. ! char *s, *getenv();
  508.   char buf[80];
  509.   
  510.   if ( (s = getenv("HOME")) != NULL)    /* if we have a home */
  511. ***************
  512. *** 168,175 ****
  513.   rc.acctime = 7;            /* access timeout in 7 days by default */
  514.   rc.keepold = 7;            /* keep dead games 7 days by default */
  515.   rc.debug = 0;            /* default to no debug */
  516. ! if ( (n = nvscan(fp,nv_rcfile,&rc)) != NULL) {
  517. !     fprintf(stderr,"Invalid line in .ldbrc: %s\n",n);
  518.       ldbexit(STAT_ABORT);
  519.       }
  520.   fclose(fp);
  521. --- 169,177 ----
  522.   rc.acctime = 7;            /* access timeout in 7 days by default */
  523.   rc.keepold = 7;            /* keep dead games 7 days by default */
  524.   rc.debug = 0;            /* default to no debug */
  525. ! line = 0;
  526. ! if (nvscan(fp,nv_rcfile,&rc,&line) < 0) {
  527. !     fprintf(stderr,"ERROR: invalid line %d in %s: %s\n",line,s,nvbuf);
  528.       ldbexit(STAT_ABORT);
  529.       }
  530.   fclose(fp);
  531. ***************
  532. *** 222,228 ****
  533.   readgames()
  534.   {
  535.   FILE *fp;
  536. ! char c, *s;
  537.   struct game *g;
  538.   long old;
  539.   
  540. --- 224,231 ----
  541.   readgames()
  542.   {
  543.   FILE *fp;
  544. ! int c, line;
  545. ! char *s;
  546.   struct game *g;
  547.   long old;
  548.   
  549. ***************
  550. *** 232,237 ****
  551. --- 235,241 ----
  552.   old = time( (long *) 0);
  553.   if (rc.keepold > 0)        /* if keeping old games is enabled */
  554.       old -= (rc.keepold * 86400);    /* how old is too old? */
  555. + line = 0;
  556.   while ( (c = getc(fp)) != EOF) {
  557.       ungetc(c,fp);    /* put char back */
  558.       g = addgame();        /* insert a new game */
  559. ***************
  560. *** 249,258 ****
  561.       g->starttime = 0L;
  562.       clearmvs(g->opmvs);
  563.       clearmvs(g->mvs);
  564. !     if ( (s = nvscan(fp,nv_gfile,g)) != NULL) {    /* read game */
  565.           FeFinishSession();    /* close down front-end */
  566.           TFinishSession();    /* close down transport */
  567. !         fprintf(stderr,"ERROR: invalid line in %s: %s\n", rc.gfile, s);
  568.           ldbexit(STAT_ABORT);
  569.           }
  570.       if (g->gameid == NULL) {        /* empty game (prob. EOF) */
  571. --- 253,263 ----
  572.       g->starttime = 0L;
  573.       clearmvs(g->opmvs);
  574.       clearmvs(g->mvs);
  575. !     if (nvscan(fp,nv_gfile,g,&line) < 0) {    /* read game */
  576.           FeFinishSession();    /* close down front-end */
  577.           TFinishSession();    /* close down transport */
  578. !         fprintf(stderr,"ERROR: invalid line %d in %s: %s\n",
  579. !             line, rc.gfile, nvbuf);
  580.           ldbexit(STAT_ABORT);
  581.           }
  582.       if (g->gameid == NULL) {        /* empty game (prob. EOF) */
  583. ***************
  584. *** 351,361 ****
  585.   readpeople()
  586.   {
  587.   FILE *fp;
  588. ! char c, *s;
  589.   struct people *p;
  590.   
  591.   if ( (fp = fopen(rc.pfile,"r")) == NULL)
  592.       return;                /* no people file */
  593.   while ( (c = getc(fp)) != EOF) {
  594.       ungetc(c,fp);    /* put char back */
  595.       p = addppl();        /* insert a new record */
  596. --- 356,368 ----
  597.   readpeople()
  598.   {
  599.   FILE *fp;
  600. ! int c, line;
  601. ! char *s;
  602.   struct people *p;
  603.   
  604.   if ( (fp = fopen(rc.pfile,"r")) == NULL)
  605.       return;                /* no people file */
  606. + line = 0;
  607.   while ( (c = getc(fp)) != EOF) {
  608.       ungetc(c,fp);    /* put char back */
  609.       p = addppl();        /* insert a new record */
  610. ***************
  611. *** 365,374 ****
  612.       p->myaddr = NULL;
  613.       p->equiv = NULL;
  614.       p->fence = 0L;
  615. !     if ( (s = nvscan(fp,nv_pfile,p)) != NULL) {    /* read record */
  616.           FeFinishSession();    /* close down front-end */
  617.           TFinishSession();    /* close down transport */
  618. !         fprintf(stderr,"ERROR: invalid line in %s: %s\n", rc.pfile, s);
  619.           ldbexit(STAT_ABORT);
  620.           }
  621.       if (p->equiv != NULL)        /* an equiv record */
  622. --- 372,382 ----
  623.       p->myaddr = NULL;
  624.       p->equiv = NULL;
  625.       p->fence = 0L;
  626. !     if (nvscan(fp,nv_pfile,p,&line) < 0) {    /* read record */
  627.           FeFinishSession();    /* close down front-end */
  628.           TFinishSession();    /* close down transport */
  629. !         fprintf(stderr,"ERROR: invalid line %d in %s: %s\n",
  630. !             c, rc.pfile, nvbuf);
  631.           ldbexit(STAT_ABORT);
  632.           }
  633.       if (p->equiv != NULL)        /* an equiv record */
  634. ***************
  635. *** 477,506 ****
  636.    * expected to be in the form "name=value\n", with no spaces before
  637.    * or after name, and with any spaces after the = or before the
  638.    * newline being part of the value string.  Comments are indicated by
  639. !  * a # in column 1, which comments to the end of the line.
  640.    *----------------------------------------------------------------------
  641.    */
  642.   
  643. ! char *nvscan(fp,t,st)
  644.   FILE *fp;        /* file to scan */
  645.   struct namevalue *t;    /* table of name/value pairs */
  646.   char *st;        /* really a pointer to a structure */
  647.   {
  648. - static char buf[128];
  649.   char *s, **p;
  650.   int i, j;
  651.   union nvtypes u;
  652.   long atol();
  653.   
  654. ! while (fgets(buf,sizeof(buf),fp) != NULL) {
  655. !     if (*buf == '#')            /* comment character */
  656.           continue;
  657. !     buf[strlen(buf)-1] = '\0';        /* clobber the newline */
  658. !     if ( (s = strchr(buf,'=')) == NULL)
  659. !         return(buf);            /* bad line, return it */
  660.       *s++ = '\0';
  661.       for (i = 0; t[i].name != NULL; i++)
  662. !         if (strcmp(t[i].name,buf) == 0)
  663.               break;
  664.       if (t[i].name == NULL)        /* got a name we don't recognize */
  665.           continue;        /* ignore it */
  666. --- 485,518 ----
  667.    * expected to be in the form "name=value\n", with no spaces before
  668.    * or after name, and with any spaces after the = or before the
  669.    * newline being part of the value string.  Comments are indicated by
  670. !  * a # in column 1, which comments to the end of the line.  If lp is
  671. !  * not NULL, it is incremented for each line read.  0 is returned for
  672. !  * success, -1 for failure.
  673.    *----------------------------------------------------------------------
  674.    */
  675.   
  676. ! nvscan(fp,t,st,lp)
  677.   FILE *fp;        /* file to scan */
  678.   struct namevalue *t;    /* table of name/value pairs */
  679.   char *st;        /* really a pointer to a structure */
  680. + int *lp;
  681.   {
  682.   char *s, **p;
  683.   int i, j;
  684.   union nvtypes u;
  685.   long atol();
  686.   
  687. ! while (fgets(nvbuf,sizeof(nvbuf),fp) != NULL) {
  688. !     if (lp != NULL)
  689. !         (*lp)++;
  690. !     if (*nvbuf == '#')            /* comment character */
  691.           continue;
  692. !     nvbuf[strlen(nvbuf)-1] = '\0';        /* clobber the newline */
  693. !     if ( (s = strchr(nvbuf,'=')) == NULL)
  694. !         return(-1);            /* bad line, return failure */
  695.       *s++ = '\0';
  696.       for (i = 0; t[i].name != NULL; i++)
  697. !         if (strcmp(t[i].name,nvbuf) == 0)
  698.               break;
  699.       if (t[i].name == NULL)        /* got a name we don't recognize */
  700.           continue;        /* ignore it */
  701. ***************
  702. *** 552,564 ****
  703.               }
  704.           break;
  705.       case FT_END:            /* we hit the end marker */
  706. !         return(NULL);        /* return success */
  707.       default:            /* we have a bad nv table */
  708.           *--s = '=';        /* restore the buffer */
  709. !         return(buf);        /* return bad line */
  710.           }
  711.       }
  712. ! return(NULL);
  713.   }
  714.   
  715.   
  716. --- 564,576 ----
  717.               }
  718.           break;
  719.       case FT_END:            /* we hit the end marker */
  720. !         return(0);        /* return success */
  721.       default:            /* we have a bad nv table */
  722.           *--s = '=';        /* restore the buffer */
  723. !         return(-1);        /* return failure */
  724.           }
  725.       }
  726. ! return(0);
  727.   }
  728.   
  729.   
  730. ***************
  731. *** 582,588 ****
  732.   char *st;            /* really a pointer to a structure */
  733.   {
  734.   struct namevalue *n;
  735. - static char buf[128];
  736.   int nstr;
  737.   union nvtypes u;
  738.   char c, **stbl;
  739. --- 594,599 ----
  740. ***************
  741. *** 603,610 ****
  742.           break;
  743.       case FT_MOVE:            /* store a struct mv */
  744.           if (u.nvmove->roll > 0) {
  745. !             mv2str(u.nvmove,buf);
  746. !             fprintf(fp,"%s=%s\n",n->name,buf);
  747.               }
  748.           break;
  749.       case FT_BOARD:            /* store an entire board */
  750. --- 614,621 ----
  751.           break;
  752.       case FT_MOVE:            /* store a struct mv */
  753.           if (u.nvmove->roll > 0) {
  754. !             mv2str(u.nvmove,nvbuf);
  755. !             fprintf(fp,"%s=%s\n",n->name,nvbuf);
  756.               }
  757.           break;
  758.       case FT_BOARD:            /* store an entire board */
  759. *** 130src/vars.c    Mon Aug  2 13:05:27 1993
  760. --- vars.c    Tue Aug  3 13:42:05 1993
  761. ***************
  762. *** 31,38 ****
  763.   struct packet P;        /* last packet read */
  764.   char cr_mycolor;        /* my color when game is created */
  765.   char cr_opcolor;        /* opponent's color for new games */
  766. ! char cr_mydir;            /* my direction for new games */
  767.   char *notify;            /* address to notify when game ends */
  768.   char blk76[] =            /* 76 blanks */
  769.   "                                                                            ";
  770.   
  771. --- 31,39 ----
  772.   struct packet P;        /* last packet read */
  773.   char cr_mycolor;        /* my color when game is created */
  774.   char cr_opcolor;        /* opponent's color for new games */
  775. ! int cr_mydir;            /* my direction for new games */
  776.   char *notify;            /* address to notify when game ends */
  777. + char nvbuf[128];        /* buffer for nvscan/nvwrite */
  778.   char blk76[] =            /* 76 blanks */
  779.   "                                                                            ";
  780.   
  781. ***************
  782. *** 137,144 ****
  783.       "myaddr",    FT_STRING,    Offset(struct game *,myaddr),    NULL,
  784.       "mycolor",    FT_CHAR,    Offset(struct game *,mycolor),    0,
  785.       "opcolor",    FT_CHAR,    Offset(struct game *,opcolor),    0,
  786. !     "mydir",    FT_CHAR,    Offset(struct game *,mydir),    0,
  787. !     "opdir",    FT_CHAR,    Offset(struct game *,opdir),    0,
  788.       "gameval",    FT_INT,        Offset(struct game *,gameval),    0,
  789.       "flags",    FT_INT,        Offset(struct game *,flags),    0,
  790.       "opversion",    FT_INT,        Offset(struct game *,opver),    0,
  791. --- 138,145 ----
  792.       "myaddr",    FT_STRING,    Offset(struct game *,myaddr),    NULL,
  793.       "mycolor",    FT_CHAR,    Offset(struct game *,mycolor),    0,
  794.       "opcolor",    FT_CHAR,    Offset(struct game *,opcolor),    0,
  795. !     "mydir",    FT_INT,        Offset(struct game *,mydir),    0,
  796. !     "opdir",    FT_INT,        Offset(struct game *,opdir),    0,
  797.       "gameval",    FT_INT,        Offset(struct game *,gameval),    0,
  798.       "flags",    FT_INT,        Offset(struct game *,flags),    0,
  799.       "opversion",    FT_INT,        Offset(struct game *,opver),    0,
  800.  
  801. exit 0 # Just in case...
  802.