home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1994 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1994.iso
/
compsrcs
/
games
/
vmsnet
/
ldb
/
part14
< prev
next >
Wrap
Internet Message Format
|
1993-04-07
|
49KB
Path: uunet!zaphod.mps.ohio-state.edu!usc!news.service.uci.edu!unogate!mvb.saic.com!dayton.saic.com!dayvd.dayton.saic.com!ake
From: ake@dayvd.dayton.saic.com (Earle Ake)
Newsgroups: vmsnet.sources.games
Subject: ldb - Long Distance Backgammon [14/16]
Date: 8 Apr 93 11:05:50 EST
Organization: Science Applications Intl Corp - Dayton, OH
Lines: 1122
Message-ID: <1993Apr8.110550.1@dayvd.dayton.saic.com>
NNTP-Posting-Host: dayvd.dayton.saic.com
Xref: uunet vmsnet.sources.games:675
-+-+-+-+-+-+-+-+ START OF PART 14 -+-+-+-+-+-+-+-+
X
X/*----------------------------------------------------------------------
X`20*`09nvscan`20--`20read`20name/value`20pairs`20from`20a`20file
X`20*
X`20*`20This`20function`20provides`20a`20generalized`20method`20for`20reading
V`20name/value
X`20*`20pairs.`20`20The`20names`20and`20value`20types`20are`20specified`20in
V`20an`20array`20of
X`20*`20struct`20namevalue's,`20along`20with`20an`20offset`20which`20is`20used
V`20to`20store
X`20*`20the`20value.`20`20The`20offset`20is`20added`20to`20a`20base`20pointer,
V`20passed`20as`20the
X`20*`20"st"`20argument,`20to`20form`20a`20pointer,`20which`20is`20then`20conve
Vrted`20to`20the
X`20*`20type`20indicated`20by`20the`20"type"`20field`20of`20the`20namevalue`20t
Vable`20using
X`20*`20the`20"nvtypes"`20union,`20and`20used`20to`20store`20the`20value.`20
V`20The`20legal
X`20*`20value`20types`20are`20defined`20in`20ldb.h`20as`20FT_*.`20`20Name/value
V`20pairs`20are
X`20*`20expected`20to`20be`20in`20the`20form`20"name=value`5Cn",`20with`20no
V`20spaces`20before
X`20*`20or`20after`20name,`20and`20with`20any`20spaces`20after`20the`20=`20or
V`20before`20the
X`20*`20newline`20being`20part`20of`20the`20value`20string.`20`20Comments`20are
V`20indicated`20by
X`20*`20a`20#`20in`20column`201,`20which`20comments`20to`20the`20end`20of`20the
V`20line.
X`20*----------------------------------------------------------------------
X`20*/
X
Xchar`20*nvscan(fp,t,st)
XFILE`20*fp;`09`09/*`20file`20to`20scan`20*/
Xstruct`20namevalue`20*t;`09/*`20table`20of`20name/value`20pairs`20*/
Xchar`20*st;`09`09/*`20really`20a`20pointer`20to`20a`20structure`20*/
X`7B
Xstatic`20char`20buf`5B128`5D;
Xchar`20*s,`20**p;
Xint`20i,`20j;
Xunion`20nvtypes`20u;
Xlong`20atol();
X
Xwhile`20(fgets(buf,sizeof(buf),fp)`20!=`20NULL)`20`7B
X`09if`20(*buf`20==`20'#')`09`09`09/*`20comment`20character`20*/
X`09`09continue;
X`09buf`5Bstrlen(buf)-1`5D`20=`20'`5C0';`09`09/*`20clobber`20the`20newline`20*/
V
X`09if`20(`20(s`20=`20strchr(buf,'='))`20==`20NULL)
X`09`09return(buf);`09`09`09/*`20bad`20line,`20return`20it`20*/
X`09*s++`20=`20'`5C0';
X`09for`20(i`20=`200;`20t`5Bi`5D.name`20!=`20NULL;`20i++)
X`09`09if`20(strcmp(t`5Bi`5D.name,buf)`20==`200)
X`09`09`09break;
X`09if`20(t`5Bi`5D.name`20==`20NULL)`09`09/*`20got`20a`20name`20we`20don't`20re
Vcognize`20*/
X`09`09continue;`09`09/*`20ignore`20it`20*/
X`09u.nvchar`20=`20st`20+`20t`5Bi`5D.offset;`09/*`20put`20pointer`20into`20unio
Vn`20*/
X`09switch`20(t`5Bi`5D.type)`20`7B
X`09case`20FT_CHAR:`09`09`09/*`20just`20store`20a`20single`20char`20*/
X`09`09*u.nvchar`20=`20atoi(s);`09/*`20chars`20stored`20as`20ints`20in`20the
V`20file`20*/
X`09`09break;
X`09case`20FT_INT:`09`09`09/*`20store`20an`20int`20*/
X`09`09*u.nvint`20=`20atoi(s);
X`09`09break;
X`09case`20FT_STRING:`09`09`09/*`20store`20a`20copy`20of`20a`20string`20*/
X`09`09*u.nvstring`20=`20save(s);
X`09`09break;
X`09case`20FT_MOVE:`09`09`09/*`20store`20a`20struct`20mv`20*/
X`09`09str2mv(s,u.nvmove);
X`09`09break;
X`09case`20FT_BOARD:`09`09`09/*`20store`20an`20entire`20board`20*/
X`09`09for`20(j`20=`200;`20j`20<`20BOARDSIZE;`20j++)`20`7B
X`09`09`09u.nvboard`5Bj`5D.qty`20=`20*s++`20-`20'A';
X`09`09`09u.nvboard`5Bj`5D.color`20=`20*s++;
X`09`09`09`7D
X`09`09break;
X`09case`20FT_STRLKUP:`09`09/*`20look`20up`20string`20`26`20store`20index`20*/
X`09`09p`20=`20(char`20**)`20t`5Bi`5D.dflt;`09/*`20unions`20are`20such`20a`20pa
Vin`20*/
X`09`09if`20(p`20==`20NULL)`09`09/*`20choke...`20*/
X`09`09`09fatal("ERROR:`20NULL`20string`20table`20in`20nvscan.");
X`09`09for`20(j`20=`200;`20*p;`20j++,`20p++)
X`09`09`09if`20(strcmp(s,*p)`20==`200)
X`09`09`09`09break;
X`09`09if`20(*p`20==`20NULL)`20`7B
X`09`09`09FeFinishSession();`09/*`20close`20down`20front-end`20*/
X`09`09`09TFinishSession();`09/*`20close`20down`20transport`20*/
X`09`09`09fprintf(stderr,"ERROR:`20unknown`20string:`20%s`5Cn",s);
X`09`09`09ldbexit(STAT_ABORT);`09/*`20shouldn't`20do`20this...`20*/
X`09`09`09`7D
X`09`09*u.nvint`20=`20j;`09/*`20store`20integer`20opcode`20*/
X`09`09break;
X`09case`20FT_TIME:`09`09`09/*`20read`20in`20a`20timestamp`20*/
X`09`09*u.nvtime`20=`20atol(s);
X`09`09break;
X`09case`20FT_INTARRAY:`09`09/*`20array`20of`20integers`20*/
X`09`09for`20(j`20=`200;`20j`20<`20t`5Bi`5D.dflt;`20j++)`20`7B
X`09`09`09while`20(isspace(*s))
X`09`09`09`09s++;
X`09`09`09(u.nvint)`5Bj`5D`20=`20atoi(s);`09`09/*`20store`20an`20int`20*/
X`09`09`09while`20(isdigit(*s))`09/*`20skip`20to`20end`20of`20int`20*/
X`09`09`09`09s++;
X`09`09`09`7D
X`09`09break;
X`09case`20FT_END:`09`09`09/*`20we`20hit`20the`20end`20marker`20*/
X`09`09return(NULL);`09`09/*`20return`20success`20*/
X`09default:`09`09`09/*`20we`20have`20a`20bad`20nv`20table`20*/
X`09`09*--s`20=`20'=';`09`09/*`20restore`20the`20buffer`20*/
X`09`09return(buf);`09`09/*`20return`20bad`20line`20*/
X`09`09`7D
X`09`7D
Xreturn(NULL);
X`7D
X
X
X
X/*----------------------------------------------------------------------
X`20*`09nvwrite`20--`20write`20name/value`20pairs`20into`20a`20file
X`20*
X`20*`20This`20function`20writes`20name/value`20pairs`20to`20a`20file`20in`20th
Ve`20same`20format
X`20*`20used`20by`20nvscan.`20`20Nvwrite`20is`20merely`20the`20inverse`20of`20n
Vvscan,`20taking`20values
X`20*`20out`20of`20the`20structure`20in`20the`20same`20manner`20nvscan`20used
V`20to`20store`20them
X`20*`20there,`20and`20generating`20"name=value"`20lines.`20`20One`20line`20is
V`20generated`20for
X`20*`20each`20element`20in`20the`20namevalue`20table,`20except`20that`20elemen
Vts`20of`20type
X`20*`20FT_MOVE`20whose`20"roll"`20field`20is`20<=`200`20are`20skipped,`20as
V`20are`20elements`20of
X`20*`20type`20FT_STRING`20that`20are`20equal`20to`20NULL.
X`20*----------------------------------------------------------------------
X`20*/
X
Xnvwrite(fp,t,st)
XFILE`20*fp;`09`09`09/*`20file`20to`20write`20to`20*/
Xstruct`20namevalue`20*t;`09`09/*`20table`20of`20name/value`20pairs`20*/
Xchar`20*st;`09`09`09/*`20really`20a`20pointer`20to`20a`20structure`20*/
X`7B
Xstruct`20namevalue`20*n;
Xstatic`20char`20buf`5B128`5D;
Xint`20nstr;
Xunion`20nvtypes`20u;
Xchar`20c,`20**stbl;
Xint`20j;
X
Xfor`20(n`20=`20t;`20n->name`20!=`20NULL;`20n++)`20`7B
X`09u.nvchar`20=`20st`20+`20n->offset;
X`09switch`20(n->type)`20`7B
X`09case`20FT_CHAR:`09`09`09/*`20just`20store`20a`20single`20char`20*/
X`09`09fprintf(fp,"%s=%d`5Cn",n->name,*u.nvchar);
X`09`09break;
X`09case`20FT_INT:`09`09`09/*`20store`20an`20int`20*/
X`09`09fprintf(fp,"%s=%d`5Cn",n->name,*u.nvint);
X`09`09break;
X`09case`20FT_STRING:`09`09`09/*`20store`20a`20copy`20of`20a`20string`20*/
X`09`09if`20(*u.nvstring`20!=`20NULL)/*`20skip`20NULL`20strings`20*/
X`09`09`09fprintf(fp,"%s=%s`5Cn",n->name,*u.nvstring);
X`09`09break;
X`09case`20FT_MOVE:`09`09`09/*`20store`20a`20struct`20mv`20*/
X`09`09if`20(u.nvmove->roll`20>`200)`20`7B
X`09`09`09mv2str(u.nvmove,buf);
X`09`09`09fprintf(fp,"%s=%s`5Cn",n->name,buf);
X`09`09`09`7D
X`09`09break;
X`09case`20FT_BOARD:`09`09`09/*`20store`20an`20entire`20board`20*/
X`09`09fprintf(fp,"%s=%s`5Cn",n->name,boardstr(u.nvboard));
X`09`09break;
X`09case`20FT_STRLKUP:`09`09/*`20look`20up`20string`20`26`20store`20index`20*/
X`09`09stbl`20=`20(char`20**)`20n->dflt;`09/*`20hope`20char**`20fits`20in`20int
V`20*/
X`09`09if`20(stbl`20==`20NULL)
X`09`09`09fatal("ERROR:`20NULL`20string`20table`20in`20nvwrite.");
X`09`09for`20(nstr`20=`200;`20stbl`5Bnstr`5D;`20nstr++);`20/*`20#`20strings`20*
V/
X`09`09if`20(`20(*u.nvint`20<`200)`20`7C`7C`20(*u.nvint`20>=`20nstr)`20)`20`7B
X`09`09`09FeFinishSession();`09/*`20close`20down`20front-end`20*/
X`09`09`09TFinishSession();`09/*`20close`20down`20transport`20*/
X`09`09`09fprintf(stderr,"ERROR:`20invalid`20index:`20%s=%d`5Cn",
X`09`09`09`09n->name,*u.nvint);
X`09`09`09ldbexit(STAT_ABORT);`09/*`20shouldn't`20do`20this...`20*/
X`09`09`09`7D
X`09`09fprintf(fp,"%s=%s`5Cn",n->name,stbl`5B*u.nvint`5D);
X`09`09break;
X`09case`20FT_TIME:`09`09`09/*`20generate`20a`20timestamp`20*/
X`09`09fprintf(fp,"%s=%lu`5Cn",n->name,*u.nvtime);
X`09`09break;
X`09case`20FT_INTARRAY:`09`09/*`20generate`20an`20integer`20array`20*/
X`09`09fprintf(fp,"%s",n->name);
X`09`09c`20=`20'=';
X`09`09for`20(j`20=`200;`20j`20<`20n->dflt;`20j++)`20`7B
X`09`09`09fprintf(fp,"%c%d",c,(u.nvint)`5Bj`5D);
X`09`09`09c`20=`20'`20';
X`09`09`09`7D
X`09`09fprintf(fp,"`5Cn");
X`09`09break;
X`09case`20FT_END:`09`09`09/*`20we`20hit`20the`20end`20marker`20*/
X`09`09fprintf(fp,"%s=end`5Cn",n->name);
X`09`09break;
X`09default:`09`09`09/*`20we`20have`20a`20bad`20nv`20table`20*/
X`09`09FeFinishSession();`09/*`20close`20down`20front-end`20*/
X`09`09TFinishSession();`09/*`20close`20down`20transport`20*/
X`09`09fprintf(stderr,"ERROR:`20bad`20namevalue`20type:`20%s`20(%d)`5Cn",
X`09`09`09n->name,n->type);
X`09`09ldbexit(STAT_ABORT);`09`09/*`20should`20have`20saved`20games?`20*/
X`09`09`7D
X`09`7D
X`7D
X
X
X/*---------------------------------------------------------------------------
X`20*`09check_timeout`20--`20see`20if`20a`20game`20has`20been`20accessed`20rece
Vntly
X`20*
X`20*`20This`20function`20checks`20the`20access`20time`20of`20a`20game.`20`20If
V`20it`20is`20less`20than
X`20*`20rc.acctime`20(default`207`20days),`20and`20the`20game`20is`20waiting
V`20for`20the`20opponent,
X`20*`20an`20automatic`20timeout`20is`20performed.`20`20If`20rc.acctime`20is
V`20<=`200,
X`20*`20automatic`20timeouts`20are`20disabled.
X`20*--------------------------------------------------------------------------
V-
X`20*/
X
Xcheck_timeout(g)
Xstruct`20game`20*g;
X`7B
Xlong`20old;
X
Xif`20(rc.acctime`20<=`200)
X`09return;
Xold`20=`20time((long`20*)`200)`20-`20((long)`20(rc.acctime*86400));`20/*`20loo
Vk`20for`20idle`20games`20*/
Xif`20(`20(g->lastacc`20<`20old)`20`26`26`20(g->state`20<`20OPSTATES)`20)`20
V`7B
X`09message("Access`20timeout`20(%d`20days)`20with`20%s`20--`20resending...`5Cn
V",
X`09`09rc.acctime,g->opaddr);
X`09g->lastacc`20=`20time(`20(long`20*)`200);
X`09resendpkt(g);`09/*`20auto`20resend`20*/
X`09`7D
X`7D
$ call unpack SAVE.C;1 1246453896 ""
$!
$ create 'f'
X/*`09t_email.c`09`099/5/91
X`20*
X`20*`20Copyright`201991`20`20Perry`20R.`20Ross
X`20*
X`20*`20Permission`20to`20use,`20copy,`20modify,`20and`20distribute`20this`20so
Vftware`20and`20its
X`20*`20documentation`20without`20fee`20is`20hereby`20granted,`20subject`20to
V`20the`20restrictions
X`20*`20detailed`20in`20the`20README`20file,`20which`20is`20included`20here`20b
Vy`20reference.
X`20*`20Any`20other`20use`20requires`20written`20permission`20from`20the`20auth
Vor.`20`20This`20software
X`20*`20is`20distributed`20"as`20is"`20without`20any`20warranty,`20including
V`20any`20implied
X`20*`20warranties`20of`20merchantability`20or`20fitness`20for`20a`20particular
V`20purpose.
X`20*`20The`20author`20shall`20not`20be`20liable`20for`20any`20damages`20result
Ving`20from`20the
X`20*`20use`20of`20this`20software.`20`20By`20using`20this`20software,`20the
V`20user`20agrees
X`20*`20to`20these`20terms.
X`20*/
X
X#include`20"ldb.h"
X
X/*======================================================================
X`20*`20This`20file`20is`20the`20e-mail`20transport`20for`20the`20ldb`20program
V.`20`20It`20is
X`20*`20modularized`20to`20allow`20other`20transports`20to`20be`20substituted,
V`20most
X`20*`20notably`20a`20socket`20transport`20to`20allow`20interactive`20network
V`20backgammon.
X`20*`20For`20now,`20though,`20this`20is`20the`20only`20transport`20available.
X`20*
X`20*`20Packets`20are`20sent`20via`20TSendPacket,`20which`20takes`20an`20instan
Vce`20of
X`20*`20struct`20packet`20and`20an`20address,`20and`20sends`20the`20packet`20to
V`20that`20address.
X`20*`20TInitialize`20must`20be`20called`20before`20any`20calls`20to`20TSendPac
Vket,`20and
X`20*`20TFinishSession`20must`20be`20called`20before`20exiting.
X`20*
X`20*`20Individual`20files`20may`20be`20sent`20by`20calling`20TSendFile.`20`20T
Vhese`20files
X`20*`20need`20not`20be`20related`20to`20a`20game.
X`20*======================================================================
X`20*/
X
XPRIVATE`20PStringSub();
X
X
X/*----------------------------------------------------------------------
X`20*`09TInitialize`20--`20initialize`20the`20transport
X`20*
X`20*`20This`20function`20is`20called`20before`20the`20transport`20is`20used.
V`20`20As`20you`20can
X`20*`20see,`20email`20doesn't`20require`20a`20great`20deal`20of`20initializati
Von.
X`20*----------------------------------------------------------------------
X`20*/
X
XTInitialize()
X`7B
X`7D
X
X
X/*----------------------------------------------------------------------
X`20*`09FeDrawMenu`20--`20draw`20menu`20choices`20in`20menu`20box
X`20*
X`20*`20This`20function`20closes`20down`20the`20transport.
X`20*----------------------------------------------------------------------
X`20*/
X
XTFinishSession()
X`7B
X`7D
X
X
X
X/*----------------------------------------------------------------------
X`20*`09TSendPacket`20--`20send`20a`20packet`20to`20an`20email`20address
X`20*
X`20*`20This`20function`20sends`20a`20packet`20to`20an`20email`20address.`20
V`20It`20returns`201`20if
X`20*`20the`20packet`20was`20sent,`200`20if`20an`20error`20occurred.
X`20*----------------------------------------------------------------------
X`20*/
X
XTSendPacket(p,addr)
Xstruct`20packet`20*p;
Xchar`20*addr;
X`7B
Xchar`20subject`5B80`5D;
XFILE`20*fp;
Xint`20status;
X
X
Xif`20((fp`20=`20fopen(rc.tempfile,"w"))`20==`20NULL)`20`7B`09/*`20open`20temp
V`20file`20*/
X`09message("ERROR:`20can't`20create`20%s!`5Cn",rc.tempfile);
X`09return;
X`09`7D
Xfprintf(fp,"<<<===LDB===>>>`5Cn");`09/*`20send`20magic`20header`20text`20*/
Xnvwrite(fp,nv_packet,p);`09/*`20write`20the`20contents`20of`20the`20packet`20*
V/
Xfclose(fp);`09`09`09`09/*`20close`20temp`20file`20*/
Xsprintf(subject,"<=LDB=>`20from`20%s`20(Long`20Distance`20Backgammon)",`20rc.m
Vyname);
Xstatus`20=`20TSendFile(addr,rc.tempfile,subject);`09/*`20send`20the`20file`20*
V/
Xunlink(rc.tempfile);`09`09/*`20delete`20the`20temp`20file`20*/
Xreturn(status);
X`7D
X
X
X/*----------------------------------------------------------------------
X`20*`09TSendFile`20--`20send`20a`20file`20to`20an`20address
X`20*
X`20*`20This`20function`20takes`20an`20e-mail`20address,`20a`20file,`20and`20a
V`20subject`20line,
X`20*`20and`20sends`20the`20contents`20of`20the`20file`20to`20the`20specified
V`20address.`20`20The
X`20*`20subject`20is`20set`20to`20the`20contents`20of`20the`20subject`20argumen
Vt,`20which`20should
X`20*`20be`20one`20line.`20`20TSendFile`20returns`20a`201`20if`20the`20message
V`20was`20sent,
X`20*`20and`20a`200`20if`20an`20error`20occurred.
X`20*----------------------------------------------------------------------
X`20*/
X
XTSendFile(addr,file,subj)
Xchar`20*addr,`20*file,`20*subj;
X`7B
Xchar`20cmd`5B256`5D;
Xchar`20*subs`5B3`5D;
Xint`20s;
X
Xsubs`5B0`5D`20=`20addr;`09`09`09/*`20substitute`20$a`20with`20opponent`20addre
Vss`20*/
Xsubs`5B1`5D`20=`20file;`09`09`09/*`20substitue`20$f`20with`20file`20*/
Xsubs`5B2`5D`20=`20subj;`09`09`09/*`20substitute`20$s`20with`20subject`20*/
XPStringSub(rc.sendcmd,"afs",subs,cmd);
Xs`20=`20system(cmd);`09`09`09/*`20execute`20email`20command`20*/
Xreturn(s`20==`20SYS_GOOD);
X`7D
X
X
X
X/*----------------------------------------------------------------------
X`20*`09PStringSub`20--`20substitute`20variables`20in`20a`20string
X`20*
X`20*`20This`20function`20copies`20str`20to`20obuf,`20replacing`20occurrences
V`20of`20$x`20to
X`20*`20a`20corresponding`20string.`20`20The`20characters`20which`20can`20appea
Vr`20after
X`20*`20the`20$`20are`20passed`20in`20a`20single`20string`20in`20the`20"chars"
V`20argument,`20and
X`20*`20the`20strings`20to`20replace`20them`20with`20are`20passed,`20in`20the
V`20same`20order`20as
X`20*`20the`20characters`20appear`20in`20"chars",`20in`20the`20"strings"`20argu
Vment.
X`20*----------------------------------------------------------------------
X`20*/
X
XPRIVATE`20PStringSub(str,chars,strings,obuf)
Xchar`20*str,`20*chars,`20*strings`5B`5D,`20obuf`5B`5D;
X`7B
Xchar`20*s,`20*o,`20*t;
X
Xfor`20(s`20=`20str,`20o`20=`20obuf;`20*s;`20s++)`20`7B
X`09if`20(*s`20!=`20'$')`20`7B`09/*`20as`20long`20as`20we`20don't`20see`20a`20$
V`20*/
X`09`09*o++`20=`20*s;`09/*`20just`20keep`20copying`20*/
X`09`09continue;
X`09`09`7D
X`09s++;
X`09if`20(*s`20==`20'$')`20`7B`09/*`20$$`20is`20a`20single`20$`20*/
X`09`09*o++`20=`20'$';
X`09`09continue;
X`09`09`7D
X`09if`20(`20(t`20=`20strchr(chars,*s))`20==`20NULL)`09/*`20skip`20invalid`20$
V`20subs`20*/
X`09`09continue;
X`09t`20=`20strings`5Bt`20-`20chars`5D;`09`09/*`20get`20ptr`20to`20replacement
V`20string`20*/
X`09while`20(*t)`09`09`09/*`20copy`20it`20to`20obuf`20*/
X`09`09*o++`20=`20*t++;
X`09`7D
X*o`20=`20'`5C0';`09`09`09`09/*`20null`20terminate`20obuf`20*/
X`7D
$ call unpack T_EMAIL.C;1 2014881667 ""
$!
$ create 'f'
X/*`09vars.c`09`098/4/91
X`20*
X`20*`20Copyright`201991`20`20Perry`20R.`20Ross
X`20*
X`20*`20Permission`20to`20use,`20copy,`20modify,`20and`20distribute`20this`20so
Vftware`20and`20its
X`20*`20documentation`20without`20fee`20is`20hereby`20granted,`20subject`20to
V`20the`20restrictions
X`20*`20detailed`20in`20the`20README`20file,`20which`20is`20included`20here`20b
Vy`20reference.
X`20*`20Any`20other`20use`20requires`20written`20permission`20from`20the`20auth
Vor.`20`20This`20software
X`20*`20is`20distributed`20"as`20is"`20without`20any`20warranty,`20including
V`20any`20implied
X`20*`20warranties`20of`20merchantability`20or`20fitness`20for`20a`20particular
V`20purpose.
X`20*`20The`20author`20shall`20not`20be`20liable`20for`20any`20damages`20result
Ving`20from`20the
X`20*`20use`20of`20this`20software.`20`20By`20using`20this`20software,`20the
V`20user`20agrees
X`20*`20to`20these`20terms.
X`20*/
X
X#include`20"ldb.h"
X
X/*======================================================================
X`20*`20This`20file`20contains`20the`20definition`20for`20all`20global`20variab
Vles,`20as`20well
X`20*`20as`20the`20static`20initialization`20values`20for`20those`20that`20need
V`20it.
X`20*======================================================================
X`20*/
X
Xint`20Pflag;`09`09`09/*`20should`20I`20process`20local`20input?`20*/
Xint`20Rflag;`09`09`09/*`20should`20I`20look`20for`20mail?`20*/
Xstruct`20game`20*ghead;`09`09/*`20head`20of`20linked`20list`20of`20games`20*/
Xstruct`20game`20*gtail;`09`09/*`20tail`20of`20linked`20list`20of`20games`20*/
Xstruct`20legal`20*lhead;`09`09/*`20head`20of`20list`20of`20legal`20moves`20*/
Xstruct`20legal`20*ltail;`09`09/*`20tail`20of`20list`20of`20legal`20moves`20*/
Xstruct`20people`20*phead;`09`09/*`20head`20of`20people`20list`20*/
Xstruct`20packet`20P;`09`09/*`20last`20packet`20read`20*/
Xchar`20cr_mycolor;`09`09/*`20my`20color`20when`20game`20is`20created`20*/
Xchar`20cr_opcolor;`09`09/*`20opponent's`20color`20for`20new`20games`20*/
Xchar`20cr_mydir;`09`09`09/*`20my`20direction`20for`20new`20games`20*/
Xchar`20*notify;`09`09`09/*`20address`20to`20notify`20when`20game`20ends`20*/
Xchar`20blk76`5B`5D`20=`09`09`09/*`2076`20blanks`20*/
X"`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20
V`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20
V`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20
V`20";
X
Xchar`20FeIsActive`20=`200;`09`09/*`20has`20the`20front-end`20been`20initialize
Vd?`20*/
Xchar`20FeWaitInit`20=`200;`09`09/*`20non-0`20if`20message()`20has`20been`20cal
Vled`20*/
X
X#ifdef`20NEED_READDIR
Xstruct`20direct`20dirbuf;`09`09/*`20mem`20used`20by`20readdir`20emulation`20#d
Vefine`20*/
X#endif
X
Xint`20GameState`20=`200;`09`09/*`20Current`20game`20state`20for`20help`20*/
Xint`20boardnums`5B3`5D`20=`20`7BBD_AFTOP,`20BD_BEFOP,`20BD_CUR`7D;
Xchar`20*states`5B`5D`20=`20`7B`09`09/*`20description`20of`20the`20states`20*/
X`09"Waiting`20for`20opponent`20to`20start`20game",
X`09"Waiting`20for`20opponent`20to`20move",
X`09"Waiting`20for`20opponent`20to`20accept`20double",
X`09"Your`20turn`20(you`20haven't`20rolled`20yet)",
X`09"Your`20move`20(you`20have`20rolled)",
X`09"Waiting`20for`20you`20to`20accept`20double",
X`09"Game`20over"
X`09`7D;
X
Xstruct`20opt`20options`5B`5D`20=`20`7B
X`09"broadcast",`09OPT_BCAST,`09"`20`5Bfile`5D",
X`09"`5CtSend`20a`20mail`20message`20to`20all`20opponents",
X`09"colors",`09OPT_COLOR,`09"`20xx",
X`09"`5Ct`5CtSet`20colors`20for`20new`20game",
X`09"control",`09OPT_CONTROL,`09"",
X`09"`5Ct`5CtPerform`20control`20functions`20on`20games",
X`09"crawford",`09OPT_CRAWFORD,`09"",
X`09"`5Ct`5CtEnable`20crawford`20rule`20for`20new`20games",
X`09"direction",`09OPT_DIRECTION,`09"`20dir",
X`09"`5Ct`5CtSet`20direction`20for`20new`20game`20`5Bup`20or`20down`5D",
X`09"european",`09OPT_EUROPE,`09"",
X`09"`5Ct`5CtEnable`20european`20rule`20for`20new`20games",
X`09"help",`09`09OPT_HELP,`09"",
X`09"`5Ct`5Ct`5CtPrint`20this`20message",
X`09"jacoby",`09OPT_JACOBY,`09"",
X`09"`5Ct`5Ct`5CtEnable`20jacoby`20rule`20for`20new`20games",
X`09"match",`09OPT_MATCH,`09"`20number",
X`09"`5Ct`5CtSet`20number`20of`20points`20in`20match",
X`09"myaddr",`09OPT_MYADDR,`09"`20addr",
X`09"`5Ct`5CtSet`20local`20e-mail`20address",
X`09"notify",`09OPT_NOTIFY,`09"`20addr",
X`09"`5Ct`5CtSend`20mail`20to`20addr`20when`20game`20ends",
X`09"permanent",`09OPT_PERM,`09"",
X`09"`5Ct`5CtMake`20new`20games`20permanent",
X`09"play",`09`09OPT_PLAY,`09"",
X`09"`5Ct`5Ct`5CtPlay`20any`20waiting`20games`20but`20do`20not`20read`20mail",
X`09"read",`09`09OPT_READ,`09"",
X`09"`5Ct`5Ct`5CtRead`20incoming`20mail`20but`20do`20not`20play",
X`09"reconstruct",`09OPT_RECONS,`09"`20file",
X`09"`5CtReconstruct`20a`20game`20from`20opponent's`20data`20file",
X`09"remotestart",`09OPT_RSTART,`09"`20u1`20u2",
X`09"`5CtStart`20a`20game`20between`20u1`20and`20u2",
X`09"score",`09OPT_SCORE,`09"",
X`09"`5Ct`5Ct`5CtPrint`20cumulative`20score`20by`20opponent",
X`09"start",`09OPT_START,`09"`20user",
X`09"`5Ct`5CtStart`20a`20game`20with`20another`20user",
X`09NULL,`09`09-1,`09`09NULL,`09`09NULL
X`09`7D;
X
Xchar`20*opcodes`5B`5D`20=`20`7B
X`20`20`20`20`20`20`20`20"START",`20"USTART",`20"TIE",`20`20"MOVE",`20"OFFERDOU
VBLE",`20"ACCEPTDOUBLE",
X`09"DECLINEDOUBLE",`20"CONCEDE",`20"REMOTESTART",`20"RESTART",`20"MSTART",
X`09"RESEND",`20"NOTIFY",
X`09NULL
X`20`20`20`20`20`20`20`20`7D;
X
Xstruct`20namevalue`20nv_rcfile`5B`5D`20=`20`7B
X`09"myname",`09FT_STRING,`09Offset(struct`20ldbrc`20*,myname),`09NULL,
X`09"myaddr",`09FT_STRING,`09Offset(struct`20ldbrc`20*,myaddr),`09NULL,
X`09"peoplefile",`09FT_STRING,`09Offset(struct`20ldbrc`20*,pfile),`09NULL,
X`09"gamefile",`09FT_STRING,`09Offset(struct`20ldbrc`20*,gfile),`09NULL,
X`09"backupfile",`09FT_STRING,`09Offset(struct`20ldbrc`20*,gbackup),`09NULL,
X`09"mailfile",`09FT_STRING,`09Offset(struct`20ldbrc`20*,mfile),`09NULL,
X`09"delmail",`09FT_STRING,`09Offset(struct`20ldbrc`20*,delmail),`09NULL,
X`09"lockfile",`09FT_STRING,`09Offset(struct`20ldbrc`20*,lockfile),NULL,
X`09"sendcmd",`09FT_STRING,`09Offset(struct`20ldbrc`20*,sendcmd),`09NULL,
X`09"tempfile",`09FT_STRING,`09Offset(struct`20ldbrc`20*,tempfile),NULL,
X`09"colors",`09FT_STRING,`09Offset(struct`20ldbrc`20*,defclrs),`09NULL,
X`09"direction",`09FT_STRING,`09Offset(struct`20ldbrc`20*,defdir),`09NULL,
X`09"initialboard",`09FT_STRING,`09Offset(struct`20ldbrc`20*,initboard),NULL,
X`09"autoroll",`09FT_STRING,`09Offset(struct`20ldbrc`20*,autoroll),NULL,
X`09"automove",`09FT_STRING,`09Offset(struct`20ldbrc`20*,automove),NULL,
X`09"autodouble",`09FT_INT,`09`09Offset(struct`20ldbrc`20*,autodouble),0,
X`09"supercmd",`09FT_STRING,`09Offset(struct`20ldbrc`20*,supercmd),NULL,
X`09"superkey",`09FT_CHAR,`09Offset(struct`20ldbrc`20*,superkey),0,
X`09"checkpoint",`09FT_STRING,`09Offset(struct`20ldbrc`20*,chkpt),`09NULL,
X`09"timeout",`09FT_INT,`09`09Offset(struct`20ldbrc`20*,acctime),`090,
X`09"keepold",`09FT_INT,`09`09Offset(struct`20ldbrc`20*,keepold),`090,
X`09"debug",`09FT_INT,`09`09Offset(struct`20ldbrc`20*,debug),`090,
X`09NULL,`09`090,`09`09-1,`090
X`09`7D;
X
Xstruct`20namevalue`20nv_gfile`5B`5D`20=`20`7B`09`09/*`20extracts`20into`20glob
Val`20var`20G`20*/
X`09"gameid",`09FT_STRING,`09Offset(struct`20game`20*,gameid),`09NULL,
X`09"opaddr",`09FT_STRING,`09Offset(struct`20game`20*,opaddr),`09NULL,
X`09"opname",`09FT_STRING,`09Offset(struct`20game`20*,opname),`09NULL,
X`09"myaddr",`09FT_STRING,`09Offset(struct`20game`20*,myaddr),`09NULL,
X`09"mycolor",`09FT_CHAR,`09Offset(struct`20game`20*,mycolor),`090,
X`09"opcolor",`09FT_CHAR,`09Offset(struct`20game`20*,opcolor),`090,
X`09"mydir",`09FT_CHAR,`09Offset(struct`20game`20*,mydir),`090,
X`09"opdir",`09FT_CHAR,`09Offset(struct`20game`20*,opdir),`090,
X`09"gameval",`09FT_INT,`09`09Offset(struct`20game`20*,gameval),`090,
X`09"flags",`09FT_INT,`09`09Offset(struct`20game`20*,flags),`090,
X`09"opversion",`09FT_INT,`09`09Offset(struct`20game`20*,opver),`090,
X`09"state",`09FT_CHAR,`09Offset(struct`20game`20*,state),`090,
X`09"term",`09`09FT_CHAR,`09Offset(struct`20game`20*,term),`090,
X`09"seq",`09`09FT_INT,`09`09Offset(struct`20game`20*,seq),`090,
X`09"lastop",`09FT_STRLKUP,`09Offset(struct`20game`20*,lastop),
X`09`09(int)`20opcodes,
X`09"mycmt",`09FT_STRING,`09Offset(struct`20game`20*,mycmt),`09NULL,
X`09"mycmt2",`09FT_STRING,`09Offset(struct`20game`20*,mycmt2),`09NULL,
X`09"opcmt",`09FT_STRING,`09Offset(struct`20game`20*,opcmt),`09NULL,
X`09"opcmt2",`09FT_STRING,`09Offset(struct`20game`20*,opcmt2),`09NULL,
X`09"dispmsg",`09FT_STRING,`09Offset(struct`20game`20*,dispmsg),`09NULL,
X`09"opmvs0",`09FT_MOVE,`09Offset(struct`20game`20*,opmvs`5B0`5D),`090,
X`09"opmvs1",`09FT_MOVE,`09Offset(struct`20game`20*,opmvs`5B1`5D),`090,
X`09"opmvs2",`09FT_MOVE,`09Offset(struct`20game`20*,opmvs`5B2`5D),`090,
X`09"opmvs3",`09FT_MOVE,`09Offset(struct`20game`20*,opmvs`5B3`5D),`090,
X`09"blot0",`09FT_CHAR,`09Offset(struct`20game`20*,blot`5B0`5D),`090,
X`09"blot1",`09FT_CHAR,`09Offset(struct`20game`20*,blot`5B1`5D),`090,
X`09"blot2",`09FT_CHAR,`09Offset(struct`20game`20*,blot`5B2`5D),`090,
X`09"blot3",`09FT_CHAR,`09Offset(struct`20game`20*,blot`5B3`5D),`090,
X`09"mvs0",`09`09FT_MOVE,`09Offset(struct`20game`20*,mvs`5B0`5D),`090,
X`09"mvs1",`09`09FT_MOVE,`09Offset(struct`20game`20*,mvs`5B1`5D),`090,
X`09"mvs2",`09`09FT_MOVE,`09Offset(struct`20game`20*,mvs`5B2`5D),`090,
X`09"mvs3",`09`09FT_MOVE,`09Offset(struct`20game`20*,mvs`5B3`5D),`090,
X`09"maxused",`09FT_INT,`09`09Offset(struct`20game`20*,maxused),`090,
X`09"hiused",`09FT_INT,`09`09Offset(struct`20game`20*,hiused),`090,
X`09"adcnt",`09FT_INT,`09`09Offset(struct`20game`20*,adcnt),`090,
X`09"admax",`09FT_INT,`09`09Offset(struct`20game`20*,admax),`090,
X`09"opbd",`09`09FT_BOARD,`09Offset(struct`20game`20*,opbd`5B0`5D),`090,
X`09"mybd",`09`09FT_BOARD,`09Offset(struct`20game`20*,mybd`5B0`5D),`090,
X`09"board",`09FT_BOARD,`09Offset(struct`20game`20*,board`5B0`5D),`090,
X`09"curbd",`09FT_CHAR,`09Offset(struct`20game`20*,curbd),`09-1,
X`09"rolls",`09FT_INTARRAY,`09Offset(struct`20game`20*,rolls`5B0`5D),`096,
X`09"doubles",`09FT_INTARRAY,`09Offset(struct`20game`20*,doubles`5B0`5D),6,
X`09"oprolls",`09FT_INTARRAY,`20Offset(struct`20game`20*,oprolls`5B0`5D),`096,
X`09"opdoubles",`09FT_INTARRAY,`20Offset(struct`20game`20*,opdoubles`5B0`5D),6,
V
X`09"starttime",`09FT_TIME,`09Offset(struct`20game`20*,starttime),0,
X`09"lastacc",`09FT_TIME,`09Offset(struct`20game`20*,lastacc),`090,
X`09"mcurrent",`09FT_INTARRAY,`09Offset(struct`20game`20*,mcurrent`5B0`5D),2,
X`09"mtotal",`09FT_INT,`09`09Offset(struct`20game`20*,mtotal),`090,
X`09"notify",`09FT_STRING,`09Offset(struct`20game`20*,notify),`09NULL,
X`09"end",`09`09FT_END,`09`09-1,`090,
X`09NULL,`09`090,`09`09-1,`090
X`09`7D;
X
Xstruct`20namevalue`20nv_packet`5B`5D`20=`20`7B
X`09"version",`09FT_INT,`09`09Offset(struct`20packet`20*,version),0,
X`09"timestamp",`09FT_TIME,`09Offset(struct`20packet`20*,timestamp),0,
X`09"gameid",`09FT_STRING,`09Offset(struct`20packet`20*,gameid),`09NULL,
X`09"opcode",`09FT_STRLKUP,`09Offset(struct`20packet`20*,opcode),
X`09`09(int)`20opcodes,
X`09"move0",`09FT_MOVE,`09Offset(struct`20packet`20*,mvs`5B0`5D),`090,
X`09"move1",`09FT_MOVE,`09Offset(struct`20packet`20*,mvs`5B1`5D),`090,
X`09"move2",`09FT_MOVE,`09Offset(struct`20packet`20*,mvs`5B2`5D),`090,
X`09"move3",`09FT_MOVE,`09Offset(struct`20packet`20*,mvs`5B3`5D),`090,
X`09"name",`09`09FT_STRING,`09Offset(struct`20packet`20*,name),`09NULL,
X`09"addr",`09`09FT_STRING,`09Offset(struct`20packet`20*,addr),`09NULL,
X`09"comment",`09FT_STRING,`09Offset(struct`20packet`20*,comment),NULL,
X`09"comment2",`09FT_STRING,`09Offset(struct`20packet`20*,comment2),NULL,
X`09"seq",`09`09FT_INT,`09`09Offset(struct`20packet`20*,seq),`090,
X`09"colors",`09FT_STRING,`09Offset(struct`20packet`20*,colors),`09NULL,
X`09"direction",`09FT_STRING,`09Offset(struct`20packet`20*,dir),`09NULL,
X`09"autodouble",`09FT_STRING,`09Offset(struct`20packet`20*,autodbl),NULL,
X`09"jacoby",`09FT_STRING,`09Offset(struct`20packet`20*,jacoby),`20NULL,
X`09"crawford",`09FT_STRING,`09Offset(struct`20packet`20*,crawford),NULL,
X`09"european",`09FT_STRING,`09Offset(struct`20packet`20*,european),NULL,
X`09"permanent",`09FT_STRING,`09Offset(struct`20packet`20*,perm),`09NULL,
X`09"match",`09FT_STRING,`09Offset(struct`20packet`20*,match),`20`20NULL,
X`09"notify",`09FT_STRING,`09Offset(struct`20packet`20*,notify),`09NULL,
X`09"end",`09`09FT_END,`09`09-1,`090,
X`09NULL,`09`090,`09`09-1,`090
X`09`7D;
X
Xstruct`20namevalue`20nv_pfile`5B`5D`20=`20`7B
X`09"addr",`09`09FT_STRING,`09Offset(struct`20people`20*,addr),`09NULL,
X`09"name",`09`09FT_STRING,`09Offset(struct`20people`20*,name),`09NULL,
X`09"alias",`09FT_STRING,`09Offset(struct`20people`20*,alias),`09NULL,
X`09"myaddr",`09FT_STRING,`09Offset(struct`20people`20*,myaddr),`09NULL,
X`09"equiv",`09FT_STRING,`09Offset(struct`20people`20*,equiv),`09NULL,
X`09"fence",`09FT_TIME,`09Offset(struct`20people`20*,fence),`090,
X`09"score",`09FT_INTARRAY,`09Offset(struct`20people`20*,score`5B0`5D),`2010,
X`09"end",`09`09FT_END,`09`09-1,`090,
X`09NULL,`09`090,`09`09-1,`090
X`09`7D;
X
Xstruct`20namevalue`20nv_pequiv`5B`5D`20=`20`7B
X`09"addr",`09`09FT_STRING,`09Offset(struct`20people`20*,addr),`09NULL,
X`09"equiv",`09FT_STRING,`09Offset(struct`20people`20*,equiv),`09NULL,
X`09"end",`09`09FT_END,`09`09-1,`090,
X`09NULL,`09`090,`09`09-1,`090
X`09`7D;
X
Xint`20(*func`5BOPSTATES`5D`5BNOP`5D)()`20=`20`7B
X/*`09START`09USTART`09TIE`09MOVE`09OFRDBL`09ACPTDBL
X`09`09DECDBL`09CONCEDE`09RSTART`09RESTART`09MSTART`09RESEND`09NOTIFY`09*/
X`09start,`09istart,`09tie,`09opmove,`09smerr,`09smerr,
X`09`09smerr,`09opconc,`09smerr,`09restart,mstart,`09smerr,`09smerr,
X`09smerr,`09smerr,`09smerr,`09opmove,`09opofr,`09smerr,
X`09`09smerr,`09opconc,`09smerr,`09smerr,`09smerr,`09smerr,`09smerr,
X`09smerr,`09smerr,`09smerr,`09smerr,`09smerr,`09opacpt,
X`09`09opdec,`09opconc,`09smerr,`09smerr,`09smerr,`09smerr,`09smerr
X`09`7D;
X
Xchar`20*rejlcl`5B`5D`20=`20`7B`09`09`09/*`20reject`20messages`20for`20local
V`20player`20*/
X`09"",`09`09`09`09`09/*`20no`20error`20*/
X`09"Move`20does`20not`20contain`20a`20legal`20roll.",`09/*`20shouldn't`20happe
Vn`20*/
X`09"You`20must`20fill`20your`20inner`20table`20before`20bearing`20off.",
X`09"There`20is`20no`20piece`20on`20that`20point.",
X`09"The`20destination`20of`20that`20move`20is`20occupied.",
X`09"You`20cannot`20move`20while`20you`20are`20on`20the`20bar.",
X`09"You`20can't`20move`20your`20opponent's`20pieces.",
X`09"You`20must`20bear`20that`20piece`20off`20with`20an`20exact`20roll."
X`09`7D;
X
Xchar`20*rejmsg`5B`5D`20=`20`7B`09`09/*`20reject`20messages`20for`20received
V`20moves`20*/
X`09"Move`20Accepted.",`09`09`09`09/*`20no`20error`20*/
X`09"Move`20does`20not`20contain`20a`20legal`20roll.",`09`09/*`20bad`20roll`20*
V/
X`09"Cannot`20remove`20pieces`20before`20filling`20inner`20table.",
X`09"There`20is`20no`20piece`20at`20the`20specified`20location.",
X`09"The`20destination`20of`20this`20move`20is`20occupied.",
X`09"Attempt`20to`20move`20while`20pieces`20are`20on`20the`20bar.",
X`09"Attempt`20to`20move`20wrong`20color.",
X`09"That`20piece`20must`20be`20borne`20off`20by`20an`20exact`20roll."
X`09`7D;
$ call unpack VARS.C;1 374419947 ""
$!
$ create 'f'
X/*`09ldb.h`09`098/3/91
X`20*
X`20*`20Copyright`201991`20`20Perry`20R.`20Ross
X`20*
X`20*`20Permission`20to`20use,`20copy,`20modify,`20and`20distribute`20this`20so
Vftware`20and`20its
X`20*`20documentation`20without`20fee`20is`20hereby`20granted,`20subject`20to
V`20the`20restrictions
X`20*`20detailed`20in`20the`20README`20file,`20which`20is`20included`20here`20b
Vy`20reference.
X`20*`20Any`20other`20use`20requires`20written`20permission`20from`20the`20auth
Vor.`20`20This`20software
X`20*`20is`20distributed`20"as`20is"`20without`20any`20warranty,`20including
V`20any`20implied
X`20*`20warranties`20of`20merchantability`20or`20fitness`20for`20a`20particular
V`20purpose.
X`20*`20The`20author`20shall`20not`20be`20liable`20for`20any`20damages`20result
Ving`20from`20the
X`20*`20use`20of`20this`20software.`20`20By`20using`20this`20software,`20the
V`20user`20agrees
X`20*`20to`20these`20terms.
X`20*/
X
X#include`20"patchlevel.h"
X
X`09/*`20LDB_VER`20breaks`20if`20REVISION`20or`20PATCHLEVEL`20>`209,`20see`20pa
Vtchlevel.h`20*/
X#define`20LDB_VER`09((VERSION*100)+(REVISION*10)+PATCHLEVEL)`20`20/*`20used
V`20in`20sendpkt`20*/
X
X#include`20<stdio.h>
X#include`20<ctype.h>
X#include`20<curses.h>
X#include`20<signal.h>
X
X#ifdef`20VMS
X
X#include`20<types.h>
X#include`20<time.h>
X#include`20<unixio.h>
X#include`20<file.h>
X#include`20<descrip.h>
X#include`20<processes.h>
X#include`20<ssdef.h>
X#include`20<rms.h>
X#include`20<stat.h>
X#define`20STAT_NORM`20SS$_NORMAL
X#define`20STAT_ABORT`20SS$_ABORT
X#define`20SYS_GOOD`201`09`09/*`20success`20return`20from`20system()`20*/
X
X#else
X
X#include`20<sys/types.h>
X#include`20<sys/dir.h>
X#include`20<sys/stat.h>
X#include`20<time.h>
X#include`20<fcntl.h>
X#define`20STAT_NORM`200
X#define`20STAT_ABORT`201
X#define`20SYS_GOOD`200`09`09/*`20success`20return`20from`20system()`20*/
X
X#endif
X
X#ifdef`20NEED_READDIR`09`09/*`20defined`20by`20Makefile`20*/
Xextern`20struct`20direct`20dirbuf;`09/*`20simulate`20Berkeley`20directory`20ro
Vutines`20*/
X#define`20DIR`20FILE
X#define`20opendir(X)`20fopen((X),"r")
X#define`20readdir(X)`20(fread(`26dirbuf,sizeof(dirbuf),1,(X))?`26dirbuf:NULL)
X#define`20closedir(X)`20fclose(X)
X#endif
X
X#ifdef`20vaxc
X#define`20OLD_CURSES`201
X#define`20unlink(X)`20delete(X)
X#endif
X
X#ifdef`20sequent
X#define`20OLD_CURSES`201
X#endif
X
X#ifdef`20OLD_CURSES`09`09/*`20defined`20above`20or`20in`20Makefile`20*/
X#define`20cbreak()`20crmode()`09/*`20from`20ancient`20curses`20*/
X#define`20nocbreak()`20nocrmode()
X#endif
X
X#ifdef`20USE_INDEX`09`09/*`20defined`20in`20Makefile`20*/
X#define`20strchr`20index`09`09/*`20$%!@`5E`26#$`20pick`20a`20name`20and`20stic
Vk`20with`20it`20*/
X#define`20strrchr`20rindex
X#endif
X
X#define`20release_lock(X)`20unlink(X)`09/*`20delete`20lock`20file`20*/
X
X`09/*`20swiped`20from`20X`20toolkit`20*/
X#define`20Offset(T,F)`20((int)(((char`20*)(`26(((T)NULL)->F)))-((char`20*)NULL
V)))
X
X#define`20PRIVATE`20static`09`09/*`20for`20private`20functions`20*/
X
X#define`20INTGFILE`20"interrupt.ldbdata"`09/*`20file`20to`20save`20games`20to
V`20on`20`5EC`20*/
X#define`20INTPFILE`20"interrupt.ldbpeople"`09/*`20file`20to`20save`20people
V`20to`20on`20`5EC`20*/
X
X#define`20BLANKS(X)`20(`26blk76`5B76-(X)`5D)`09/*`20blank`20string`20of`20spec
Vified`20length`20*/
X
X`09`09/*`20locations`20in`20board`20typedef`20*/
X#define`20UPBAR`09`090`09`09/*`20BAR`20point`20for`20up-bound`20player`20*/
X#define`20DOWNBAR`09`0925`09`09/*`20BAR`20point`20for`20down-bound`20player
V`20*/
X#define`20UPOFF`09`0926`09`09/*`20off`20point`20for`20up-bound`20player`20*/
X#define`20DOWNOFF`09`0927`09`09/*`20off`20point`20for`20down-bound`20player
V`20*/
X#define`20BOARDSIZE`0928`09`09/*`20number`20of`20points`20in`20board`20*/
X
X`09/*`20BARPT`20takes`20a`20direction`20(-1`20or`201)`20and`20returns`20the
V`09*/
X`09/*`20point`20in`20the`20board`20typedef`20that`20represents`20that`09*/
X`09/*`20players`20bar.`20`20OFFPT`20does`20the`20same`20thing`20for`20the`09*/
V
X`09/*`20point`20that`20pieces`20go`20to`20when`20they`20are`20thrown`20off.
V`09*/
X`09/*`20REV(direction)`20returns`20the`20opposite`20direction.`09*/
X#define`20BARPT(D)`09(((D)>0)?UPBAR:DOWNBAR)
X#define`20OFFPT(D)`09(((D)>0)?UPOFF:DOWNOFF)
X#define`20REV(D)`09`09(-(D))
X
X`09`09/*`20states`20we`20can`20be`20in`20*/
X#define`20ST_OPSTART`090`09`09/*`20we`20have`20sent`20a`20START`20(or`20rcvd
V`20one)*/
X#define`20ST_OPTURN`091`09`09/*`20Its`20the`20opponent's`20turn`20*/
X#define`20ST_OPACCEPT`092`09`09/*`20I`20have`20offered`20to`20double`20*/
X
X#define`20OPSTATES`093`09`09/*`20<`20OPSTATES`20needs`20remote`20input`20*/
X
X#define`20ST_MYTURN`093`09`09/*`20My`20turn,`20I`20haven't`20rolled`20yet`20*/
V
X#define`20ST_MYMOVE`094`09`09/*`20I've`20rolled,`20but`20I`20haven't`20moved
V`20*/
X#define`20ST_MYACCEPT`095`09`09/*`20Opponent`20has`20offered`20to`20double`20*
V/
X#define`20ST_GAMEOVER`096`09`09/*`20game`20is`20dead,`20see`20T_*`20for`20reas
Von`20*/
X#define`20NSTATE`09`097`09`09/*`20number`20of`20possible`20states`20*/
X
X`09`09/*`20operations`20to`20send`20or`20receive`20*/
X#define`20START`09`090`09`09/*`20start`20a`20game`20*/
X#define`20USTART`09`091`09`09/*`20if`20rcvd,`20we`20won`20the`20initial`20roll
V`20*/
X#define`20TIE`09`092`09`09/*`20tie`20on`20initial`20roll,`20restart`20*/
X#define`20MOVE`09`093`09`09/*`20send`20a`20move`20*/
X#define`20OFRDBL`09`094`09`09/*`20offer`20to`20double`20*/
X#define`20ACPTDBL`09`095`09`09/*`20double`20accepted`20*/
X#define`20DECDBL`09`096`09`09/*`20double`20declined,`20game`20over`20*/
X#define`20CONCEDE`09`097`09`09/*`20we`20give`20up`20*/
X#define`20RSTART`09`098`09`09/*`20remote`20start`20packet`20*/
X#define`20RESTART`09`099`09`09/*`20repeat`20initial`20roll`20*/
X#define`20MSTART`09`0910`09`09/*`20start`20next`20game`20of`20match`20*/
X#define`20RESEND`09`0911`09`09/*`20resend`20request`20from`20opponent`20*/
X#define`20NOTIFY`09`0912`09`09/*`20tell`20game`20starter`20when`20game`20ends
V`20*/
X#define`20NOP`09`0913`09`09/*`20number`20of`20possible`20operations`20*/
X
X`09`09/*`20termination`20codes`20for`20state`20ST_GAMEOVER`20*/
X#define`20T_ICONCEDE`091`09`09/*`20I`20gave`20up`20*/
X#define`20T_IDECLINE`092`09`09/*`20I`20declined`20double`20*/
X#define`20T_ILOSE`09`093`09`09/*`20opponent`20moved`20all`20pieces`20off`20*/
X#define`20T_OPCONCEDE`094`09`09/*`20opponent`20gave`20up`20*/
X#define`20T_OPDECLINE`095`09`09/*`20opponent`20declined`20double`20*/
X#define`20T_IWIN`09`096`09`09/*`20I`20moved`20all`20pieces`20off`20*/
X
X`09`09/*`20flags`20passed`20to`20apply`20*/
X#define`20A_REDRAW`091`09/*`20redraw`20the`20pieces`20moved`20*/
X#define`20A_CHKONLY`092`09/*`20check`20move`20but`20don't`20move`20pieces`20*/
V
X
X`09`09/*`20codes`20returned`20by`20apply`20*/
X#define`20MVOK`09`090`09/*`20move`20was`20accepted`20by`20apply()`20*/
X#define`20RJ_NOROLL`09-1`09/*`20move`20does`20not`20contain`20valid`20roll`20*
V/
X#define`20RJ_NOOFF`09-2`09/*`20all`20pcs`20not`20in`20inner`20tbl,`20can't`20t
Vhrow`20off`20*/
X#define`20RJ_NOPIECE`09-3`09/*`20no`20piece`20at`20specified`20point`20*/
X#define`20RJ_OCC`09`09-4`09/*`20destination`20occupied`20*/
X#define`20RJ_ONBAR`09-5`09/*`20can't`20move,`20pieces`20are`20on`20bar`20*/
X#define`20RJ_NOTYOURS`09-6`09/*`20wrong`20color,`20dummy`20*/
X#define`20RJ_EXACT`09-7`09/*`20must`20use`20exact`20roll`20except`20for`20oute
Vr`20pc`20*/
X
X`09`09/*`20bits`20for`20flags`20field`20of`20game`20struct`20*/
X#define`20F_IDOUBLED`091`09/*`20I`20doubled`20last`20*/
X#define`20F_SENTNAME`092`09/*`20I've`20sent`20my`20name`20*/
X#define`20F_INVERT`094`09/*`20I`20want`20my`20board`20upside`20down`20*/
X#define`20F_DELETE`098`09/*`20this`20game`20is`20deleted`20*/
X#define`20F_JACOBY`0916`09/*`20jacoby`20rule`20in`20effect`20for`20this`20game
V`20*/
X#define`20F_CRAWFORD`0932`09/*`20crawford`20rule`20in`20effect`20for`20this
V`20game`20*/
X#define`20F_PERM`09`0964`09/*`20permanent`20game`20*/
X#define`20F_EUROPE`09128`09/*`20european`20rule`20(backgammons`20count`20doubl
Ve)`20*/
X#define`20F_DISPLAYED`09256`09/*`20Game`20over,`20keeping`20in`20case`20need
V`20resend`20*/
X#define`20F_CRGAME`09512`09/*`20This`20game`20is`20the`20crawford`20rule`20gam
Ve`20*/
X#define`20F_CRDONE`091024`09/*`20The`20crawford`20rule`20game`20has`20been`20p
Vlayed`20*/
X
X`09`09/*`20field`20types`20for`20reading`20name/value`20files`20*/
X#define`20FT_CHAR`09`091`09/*`20store`20a`20single`20character`20*/
X#define`20FT_INT`09`092`09/*`20store`20a`20single`20integer`20*/
X#define`20FT_STRING`093`09/*`20store`20a`20char`20*`20(use`20save())`20*/
X#define`20FT_MOVE`09`094`09/*`20a`20struct`20mv`20*/
X#define`20FT_BOARD`095`09/*`20a`20board`20image`20*/
X#define`20FT_STRLKUP`096`09/*`20lookup`20string`20in`20table`20`26`20store`20i
Vndex`20*/
X#define`20FT_TIME`09`097`09/*`20a`20timestamp`20*/
X#define`20FT_INTARRAY`098`09/*`20array`20of`20integers`20*/
X#define`20FT_END`09`0999`09/*`20end`20of`20structure`20*/
X
X`09`09/*`20which`20board`20is`20currently`20displayed`20(g->curbd)`20*/
X#define`20BD_BEFOP`090`09/*`20before`20op's`20move`20(after`20my`20previous)
V`20*/
X#define`20BD_AFTOP`091`09/*`20after`20op's`20move`20(before`20my`20next)`20*/
X#define`20BD_CUR`09`092`09/*`20current`20(with`20any`20moves`20I've`20made`20s
Vo`20far)`20*/
X
X`09`09/*`20these`20are`20the`20command`20line`20options`20*/
X#define`20OPT_START`091`09/*`20start`20a`20game`20*/
X#define`20OPT_READ`092`09/*`20read`20incoming`20mail`20*/
X#define`20OPT_PLAY`093`09/*`20play`20any`20games`20that`20are`20waiting`20for
V`20me`20*/
X#define`20OPT_COLOR`094`09/*`20set`20the`20color`20for`20created`20games`20*/
X#define`20OPT_DIRECTION`095`09/*`20set`20the`20direction`20for`20created`20gam
Ves`20*/
X#define`20OPT_RSTART`096`09/*`20remote`20start`20a`20game`20*/
X#define`20OPT_HELP`097`09/*`20print`20long`20help`20*/
X#define`20OPT_CONTROL`098`09/*`20go`20into`20control`20mode`20*/
X#define`20OPT_MYADDR`099`09/*`20set`20my`20e-mail`20address`20(override`20.ldb
Vrc)`20*/
X#define`20OPT_BCAST`0910`09/*`20send`20a`20mail`20message`20to`20all`20opponen
Vts`20*/
X#define`20OPT_JACOBY`0911`09/*`20enable`20the`20jacoby`20rule`20*/
X#define`20OPT_CRAWFORD`0912`09/*`20enable`20the`20crawford`20rule`20*/
X#define`20OPT_PERM`0913`09/*`20make`20game`20permanent`20*/
X#define`20OPT_MATCH`0914`09/*`20set`20number`20of`20points`20in`20match`20*/
X#define`20OPT_EUROPE`0915`09/*`20enable`20european`20rule`20*/
X#define`20OPT_RECONS`0916`09/*`20reconstruct`20a`20game`20from`20opponent's
V`20data`20*/
X#define`20OPT_SCORE`0917`09/*`20print`20cumulative`20scores`20*/
X#define`20OPT_NOTIFY`0918`09/*`20set`20notify`20address`20*/
X
X`09`09/*`20these`20are`20the`20different`20game`20states`20for`20the`20help
V`20call`20*/
X#define`20STATE_CONTROL`091`09/*`20Invoked`20with`20the`20control`20option`20*
V/
X#define`20STATE_MYTURN`092`09/*`20Waiting`20for`20user`20to`20move`20*/
X#define`20STATE_MYMOVE`093`09/*`20User`20has`20rolled`20but`20needs`20to`20mov
Ve`20*/
X#define`20STATE_MYACPT`094`09/*`20Accept`20or`20decline`20the`20double`20*/
X#define`20STATE_GAMEOVER`095`09/*`20The`20game`20is`20over`20*/
X
X#define`20WHO_ME`09`090`09/*`20used`20to`20mean`20local`20player`20*/
X#define`20WHO_OPP`09`091`09/*`20used`20to`20mean`20opponent`20*/
X
X`09/*`20these`20bits`20are`20passed`20to`20findppl`20to`20specify`20whether
V`09*/
X`09/*`20we`20want`20to`20look`20up`20an`20address,`20an`20alias,`20or`20both
V`09*/
X#define`20P_ADDR`09`091`09/*`20look`20for`20a`20address`20*/
X#define`20P_ALIAS`09`092`09/*`20look`20for`20an`20alias`20*/
X
X`09/*`20these`20are`20the`20bits`20to`20set`20in`20rc.debug`20to`20enable`09*/
V
X`09/*`20debug`20messages`20for`20various`20functions.`09`09*/
X#define`20DB_READFILE`091`09/*`20print`20mail`20files`20scanned`20*/
X#define`20DB_RWGAMES`092`09/*`20print`20games`20read/written`20*/
X#define`20DB_GSTART`094`09/*`20print`20games`20started`20*/
X#define`20DB_RSTART`098`09/*`20trace`20remote`20start`20packets`20*/
X
X`09/*`20these`20refer`20to`20the`20elements`20of`20struct`20people->score`20*/
V
X#define`20SC_GAMESWON`090`09/*`20number`20of`20games`20won`20against`20this
V`20guy`20*/
X#define`20SC_GAMESLOST`091`09/*`20number`20of`20games`20lost`20to`20this`20guy
V`20*/
X#define`20SC_PTSWON`092`09/*`20number`20of`20points`20won`20against`20this`20g
Vuy`20*/
X#define`20SC_PTSLOST`093`09/*`20number`20of`20points`20lost`20to`20this`20guy
V`20*/
X#define`20SC_GMNWON`094`09/*`20number`20of`20gammons`20won`20*/
X#define`20SC_GMNLOST`095`09/*`20number`20of`20gammons`20lost`20*/
X#define`20SC_BGWON`096`09/*`20number`20of`20backgammons`20won`20*/
X#define`20SC_BGLOST`097`09/*`20number`20of`20backgammons`20lost`20*/
X#define`20SC_MWON`09`098`09/*`20number`20of`20matches`20won`20*/
X#define`20SC_MLOST`099`09/*`20number`20of`20matches`20lost`20*/
X
Xstruct`20opt`20`7B`09`09`09/*`20used`20to`20make`20list`20of`20command`20line
V`20options`20*/
X`09char`09*name;`09`09/*`20name`20of`20option`20(as`20used`20on`20command`20li
Vne)`20*/
X`09int`09index;`09`09/*`20OPT_*`20*/
X`09char`09*args;`09`09/*`20arguments`20the`20option`20takes,`20if`20any`20*/
X`09char`09*help;`09`09/*`201-line`20help`20string`20for`20option`20*/
X`09`7D;
X
Xstruct`20ldbrc`20`7B`09`09/*`20struct`20where`20all`20fields`20from`20.ldbrc
V`20are`20stored`20*/
X`09char`09*myaddr;`09/*`20my`20e-mail`20address`20*/
X`09char`09*myname;`09/*`20my`20name`20*/
X`09char`09*pfile;`09`09/*`20people`20file`20*/
X`09char`09*gfile;`09`09/*`20games`20file`20*/
X`09char`09*gbackup;`09/*`20where`20to`20save`20old`20game`20file`20*/
X`09char`09*mfile;`09`09/*`20mail`20file`20*/
X`09char`09*delmail;`09/*`20should`20we`20delete`20mail`20files`20after`20readi
Vng?*/
X`09char`09*lockfile;`09/*`20ldb`20mutex`20lock`20file`20*/
X`09char`09*sendcmd;`09/*`20mail`20send`20command`20*/
X`09char`09*tempfile;`09/*`20temp`20file`20for`20sendpkt`20*/
X`09char`09*defclrs;`09/*`20default`20colors`20(2`20from`20`5Brwb`5D)`20*/
X`09char`09*defdir;`09/*`20default`20direction`20(up/down)`20*/
X`09char`09*initboard;`09/*`20init.`20brd`20display`20(before/after/current)
V`20*/
X`09char`09*autoroll;`09/*`20enable`20autoroll?`20(yes/no)`20*/
X`09char`09*automove;`09/*`20enable`20automove?`20(yes/no)`20*/
X`09int`09autodouble;`09/*`20autodouble`20count,`200`20to`20disable`20*/
X`09char`09*supercmd;`09/*`20command`20to`20run`20to`20fool`20supervisor`20*/
X`09char`09superkey;`09/*`20key`20to`20activate`20supercmd`20*/
X`09char`09*chkpt;`09`09/*`20keep`20games`20up`20to`20date?`20*/
X`09int`09acctime;`09/*`20number`20of`20days`20until`20auto`20resend`20*/
X`09int`09keepold;`09/*`20number`20of`20days`20to`20keep`20finished`20games`20*
V/
X`09int`09debug;`09`09/*`20debug`20level,`200`20=`20none`20*/
X`09`7D;
X
X`09`09/*`20the`20following`20structure`20is`20used`20to`20save/load`20*/
X`09`09/*`20the`20games`20file,`20the`20.ldbrc,`20and`20to`20send`09*/
X`09`09/*`20packets`20between`20the`20players.`20`20It`20stores`20a`09*/
X`09`09/*`20name,`20the`20type`20(see`20FT_*`20above),`20and`20the`09*/
X`09`09/*`20offset`20into`20a`20structure.`20`20A`20pointer`20to`20the`09*/
X`09`09/*`20structure`20is`20provided`20at`20runtime.`09`09*/
Xstruct`20namevalue`20`7B
X`20`20`20`20`20`20`20char`20*name;`09`09/*`20name`20of`20the`20field`20*/
X`20`20`20`20`20`20`20char`20type;`09`09/*`20type`20of`20the`20field`20(T_*)
V`20*/
X`20`20`20`20`20`20`20int`20offset;`09`09/*`20where`20to`20store`20value`20*/
X`20`20`20`20`20`20`20int`20dflt;`09`09/*`20default`20value`20*/
X`20`20`20`20`20`20`20`7D;
X
Xunion`20nvtypes`20`7B`09`09`09/*`20convert`20char*`20to/from`20FT_*`20*/
X`09char`09*nvchar;`09/*`20FT_CHAR`20*/
X`09int`09*nvint;`09`09/*`20FT_INT`20*/
X`09long`09*nvtime;`09/*`20FT_TIME`20*/
X`09char`09**nvstring;`09/*`20FT_STRING`20*/
X`09struct`20mv`20*nvmove;`09/*`20FT_MOVE`20*/
X`09struct`20point`20*nvboard;`09/*`20FT_BOARD`20*/
X`09`7D;
X
Xstruct`20flist`20`7B`09`09`09/*`20list`20returned`20by`20filelist()`20*/
X`09char`09*name;`09`09/*`20file`20name`20*/
X`09struct`20flist`20*next;`09/*`20forward`20link`20*/
X`09`7D;
X
Xstruct`20mv`20`7B
X`09char`09roll;`09`09`09/*`20#`20on`201`20die,`200`20=`20DOUBLE,`20-1=empty
V`20*/
X`09char`09pt;`09`09`09/*`20point`20move`20is`20from,`20-1=UNUSED`20*/
X`09`7D;
X
Xstruct`20point`20`7B
X`09char`09qty;`09`09`09/*`20number`20of`20pieces`20on`20this`20point`20*/
X`09char`09color;`09`09`09/*`20color`20of`20pieces`20on`20this`20point`20*/
X`09`7D;
X
Xtypedef`20struct`20point`20board`5BBOARDSIZE`5D;`09/*`20board`20is`20array`20o
Vf`20points`20*/
X
Xstruct`20game`20`7B`09`09`09`09/*`20all`20info`20about`20a`20game`20in`20progr
Vess`20*/
X`09char`09*gameid;`09`09/*`20unique`20game`20id`20*/
X`09char`09*opaddr;`09`09/*`20email`20path`20to`20opponent`20*/
X`09char`09*opname;`09`09/*`20full`20name`20of`20opponent`20*/
X`09char`09*myaddr;`09`09/*`20my`20address`20for`20this`20user`20*/
X`09char`09mycolor;`09`09/*`20char`20to`20represent`20my`20pieces`20*/
X`09char`09opcolor;`09`09/*`20opponent's`20pieces`20*/
X`09char`09mydir;`09`09`09/*`201/-1`20direction`20I`20am`20moving`20*/
+-+-+-+-+-+-+-+- END OF PART 14 +-+-+-+-+-+-+-+-