home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume36 / ldb / part01 < prev    next >
Encoding:
Text File  |  1993-04-10  |  55.3 KB  |  1,515 lines

  1. Newsgroups: comp.sources.misc
  2. From: ross@teserv.den.mmc.com (Perry R. Ross)
  3. Subject: v36i098:  ldb - Play backgammon by e-mail, v1.3, Part01/12
  4. Message-ID: <csm-v36i098=ldb.182548@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 976b9d8d0e4003c411b0310f66b22256
  6. Date: Sun, 11 Apr 1993 23:26:24 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: ross@teserv.den.mmc.com (Perry R. Ross)
  10. Posting-number: Volume 36, Issue 98
  11. Archive-name: ldb/part01
  12. Environment: UNIX, C, VMS, VAXC, CURSES, 32BIT
  13. Supersedes: ldb: Volume 28, Issue 93-97
  14.  
  15.         Long Distance Backgammon
  16.  
  17.     This is a program that lets two people easily play backgammon
  18. by e-mail.  It currently runs only on character-oriented terminals
  19. (or emulators thereof) under the curses package.  It runs on most
  20. flavors of UNIX, as well as VMS version 5.0 and above.
  21.  
  22.     Ldb takes care of rolling dice, checking moves, and
  23. communicating with your opponent's ldb via e-mail.  Duplicated mail
  24. messages are rejected, and lost messages may be regenerated easily.
  25. Gammons and backgammons are detected, and the game value is automatically
  26. calculated at the end of the game.  Doubling is fully supported, and
  27. automatic doubles (when there is a tied opening roll) may be enabled
  28. at the user's option.  Ldb also allows you to enclose a two-line comment
  29. with each move which will be displayed on your opponent's screen.
  30.  
  31.     This is version 1.3 of ldb, containing many new features over
  32. the previously posted version, which was version 1.0.  For those wondering
  33. what happened to 1.1 and 1.2, see the README file.  This file also contains
  34. installation instructions.
  35.  
  36.     These are a few of the new features in ldb 1.3.  The README
  37. file contains a more complete list.  Earle Ake contributed much of the new
  38. stuff in ldb 1.3.  Thanks, Earle.
  39.  
  40.     - Context-sensitive help
  41.     - Match play
  42.     - Crawford and Jacoby rules
  43.     - Pip count display
  44.     - Cumulative score-keeping by opponent
  45.     - Permanent games (for people you play continuously)
  46.  
  47.     Ldb 1.3 is designed to maintain full compatibility with older
  48. versions of ldb.  You should be able to upgrade to 1.3 without damaging
  49. any games in progress.  Prudence would suggest, however, that you save
  50. a copy of ldb 1.0 and your old .ldbdata until after you are sure 1.3
  51. is working.  Ignore problems with garbled comments; this will only
  52. happen for one move, then comments should start working normally again.
  53. You might want to warn your opponents that you are about to upgrade,
  54. and your next comment might be garbled.
  55.  
  56.     An astounding 5 of the 12 parts of this distribution are devoted
  57. to documentation.  One part is the nroff source to the manual, one is
  58. this same manual converted to tex source, and 3 are the that manual
  59. converted to postscript.  To reassemble the postscript version, you'll
  60. have to concatenate ldb-man.ps1 through ldb-man.ps3.  Thanks to Earle Ake
  61. for converting the manuals.
  62.  
  63. #! /bin/sh
  64. # This is a shell archive.  Remove anything before this line, then unpack
  65. # it by saving it into a file and typing "sh file".  To overwrite existing
  66. # files, type "sh file -c".  You can also feed this as standard input via
  67. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  68. # will see the following message at the end:
  69. #        "End of archive 1 (of 12)."
  70. # Contents:  MANIFEST Makefile README TODO board.c dohelp.c
  71. #   flist_none.c flist_vms.c ldb.opt lock.c makefile.vms makeldb.com
  72. #   patchlevel.h rename.c t_email.c
  73. # Wrapped by ross@teserv.den.mmc.com on Tue Apr  6 14:52:16 1993
  74. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  75. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  76.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  77. else
  78. echo shar: Extracting \"'MANIFEST'\" \(2460 characters\)
  79. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  80. X   File Name        Archive #    Description
  81. X-----------------------------------------------------------
  82. X MANIFEST                   1    List of files
  83. X Makefile                   1    Compilation instructions
  84. X README                     1    Info file
  85. X TODO                       1    Future enhancement ideas
  86. X board.c                    1    Routines pertaining to setting up boards
  87. X check.c                    3    Routines that check for legal moves
  88. X control.c                  2    Function to handle the -control option
  89. X dohelp.c                   1    Function to display on-line help
  90. X dostats.c                  2    Routines to display roll statistics
  91. X fe_curses.c               10    Front end routines, based on curses package
  92. X flist_none.c               1    Last resort if flist_unix/flist_vms don't work
  93. X flist_unix.c               3    Filename globbing in UNIX
  94. X flist_vms.c                1    Filename globbing in VMS
  95. X game.c                     4    Functions to create/delete/find games
  96. X ldb-man.ps1                9    Ldb manual in postscript format, part 1
  97. X ldb-man.ps2                8    "cat ldb-man.ps? > ldb-man.ps" to reassemble
  98. X ldb-man.ps3                7    Ldb manual in postscript format, part 3
  99. X ldb-man.tex               12    Ldb manual in tex format
  100. X ldb.h                      4    Master include file
  101. X ldb.man                   11    The user's manual source ("make ldb.doc")
  102. X ldb.opt                    1    Option file for makefile.vms and makeldb.com
  103. X ldbstarter                 2    A game starter script, if you want to try it
  104. X lock.c                     1    Code to lock ldb data files while in use
  105. X main.c                     6    The main program
  106. X makefile.vms               1    Makefile for vms (see also makeldb.com)
  107. X makeldb.com                1    Command file to build ldb under vax c
  108. X misc.c                     5    Miscellaneous handy routines
  109. X move.c                     2    Performing/checking moves
  110. X patchlevel.h               1    Patch level (for patch program)
  111. X process.c                  4    Routines to perform local game processing
  112. X r_xrand.c                  2    Roll routine, based on xrand
  113. X rcvop.c                    3    Routines to handle received operations
  114. X readmail.c                 3    Routines that read & process incoming mail
  115. X rename.c                   1    Rename routine for systems that don't have one
  116. X save.c                     5    Routines that save and load things
  117. X t_email.c                  1    Transport routine, based on mail
  118. X vars.c                     2    All global variables.
  119. END_OF_FILE
  120. if test 2460 -ne `wc -c <'MANIFEST'`; then
  121.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  122. fi
  123. # end of 'MANIFEST'
  124. fi
  125. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  126.   echo shar: Will not clobber existing file \"'Makefile'\"
  127. else
  128. echo shar: Extracting \"'Makefile'\" \(4861 characters\)
  129. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  130. X# Makefile for ldb    8/3/91
  131. X#
  132. X# Copyright 1991  Perry R. Ross
  133. X#
  134. X# Permission to use, copy, modify, and distribute this software and its
  135. X# documentation without fee is hereby granted, subject to the restrictions
  136. X# detailed in the README file, which is included here by reference.
  137. X# Any other use requires written permission from the author.  This software
  138. X# is distributed "as is" without any warranty, including any implied
  139. X# warranties of merchantability or fitness for a particular purpose.
  140. X# The author shall not be liable for any damages resulting from the
  141. X# use of this software.  By using this software, the user agrees
  142. X# to these terms.
  143. X
  144. X### INSTALLATION OPTIONS ###
  145. X# If your host uses an ancient version of curses (e.g. VAX-C, Sequent),
  146. X# uncomment the following line.  To tell if you need this option,
  147. X# first try compiling without it and see if your linker complains
  148. X# about cbreak() and nocbreak() not being defined.  If it does,
  149. X# you need this option.
  150. XOLDCURSES=
  151. X#OLDCURSES=-DOLD_CURSES
  152. X
  153. X# If your system uses index and rindex rather than strchr and strrchr,
  154. X# uncomment the following line.  If you don't know, just try compiling
  155. X# and see if you get an error.  These days most systems will take strchr
  156. X# and strrchr.
  157. XUSE_INDEX=
  158. X#USE_INDEX=-DUSE_INDEX
  159. X
  160. X# If your libc doesn't have a rename function, uncomment the
  161. X# following to use the one that's included.  DO NOT use this
  162. X# rename if your system already has one.
  163. XRENAME=
  164. X#RENAME=rename.o
  165. X
  166. X# Uncomment the following lines only if you are using Eunice.
  167. X# If you don't know what it is, believe me, you're not using it.
  168. XUNIXTOVMS=true
  169. XVMSTOUNIX=true
  170. X#UNIXTOVMS=unixtovms
  171. X#VMSTOUNIX=vmstounix
  172. X
  173. X# Uncomment this line if your UNIX does not have the Berkeley
  174. X# variable-length directory routines.  These are opendir,
  175. X# readdir, closedir, etc.
  176. XNEED_READDIR=
  177. X# NEED_READDIR=-DNEED_READDIR
  178. X
  179. X# Put the name of the filename of the appropriate pattern matcher here.
  180. X# For UNIX systems, this should be flist_unix.  For VMS, this should
  181. X# be flist_vms.  If for some reason the flist file does not work on
  182. X# your system, 1) please send me mail telling me, and 2) you can
  183. X# plug in flist_none, which disables pattern matching but allows
  184. X# ldb to compile.
  185. XFLIST=flist_unix
  186. X
  187. X# Put the name of the front-end you want to compile in here.
  188. X# NOTE: there is currently only one available front-end (curses).
  189. XFE_FILE=fe_curses
  190. X
  191. X# Put the name of the transport you want to compile in here.
  192. X# NOTE: there is currently only one available transport (email).
  193. XT_FILE=t_email
  194. X
  195. X# Put the name of the dice roller you want to compile in here.
  196. X# If you want to write your own dice roller, you can.  I would
  197. X# prefer people all used the same one, since that is more fair,
  198. X# but as long as it is really a random number generator, you're ok.
  199. X# If you put in a fake dice roller (e.g. one that asks you what
  200. X# roll you want), you are in violation of the copyright.  Read
  201. X# the README file for more information.
  202. XR_FILE=r_xrand
  203. X
  204. X# Put compiler flags here.
  205. XCFLAGS=-O $(OLDCURSES) $(NEED_READDIR)
  206. XLIBS=-lcurses -ltermcap
  207. X
  208. X# use these 2 lines for SCO XENIX (also SCO UNIX?)
  209. X#CFLAGS= -O -Mle -LARGE -Zi -DM_TERMCAP $(OLDCURSES)
  210. X#LIBS=-lx -ltcap -ltermlib
  211. XLINTFLAGS=
  212. X
  213. X# Name of ldb executable.
  214. XLDB=ldb
  215. X# LDB=ldb.exe
  216. X
  217. X# Page length to format manual with.  62 for VMS or Eunice, 66 for most others.
  218. XPAGELEN=66
  219. X
  220. X# If you want to use gcc, plug it in here.  Ldb has been tested with
  221. X# gcc 2.3.3, should work with other versions.  (?)  Ignore warnings.
  222. XCC=cc
  223. X
  224. X### END OF INSTALLATION OPTIONS ###
  225. X
  226. XCFILES=    board.c game.c main.c misc.c move.c process.c rcvop.c control.c \
  227. X    check.c readmail.c save.c vars.c fe_curses.c t_email.c r_xrand.c \
  228. X    dohelp.c dostats.c rename.c flist_unix.c flist_vms.c flist_none.c \
  229. X    lock.c
  230. XHFILES=ldb.h patchlevel.h
  231. XOFILES=    board.o game.o main.o misc.o move.o process.o rcvop.o control.o \
  232. X    check.o readmail.o save.o vars.o $(FE_FILE).o $(T_FILE).o $(R_FILE).o \
  233. X    dohelp.o dostats.o $(RENAME) $(FLIST).o lock.o
  234. XSHARFILES=MANIFEST README TODO Makefile $(CFILES) $(HFILES) makefile.vms \
  235. X    ldb-man.ps1 ldb-man.ps2 ldb-man.ps3 ldb-man.tex makeldb.com \
  236. X    ldb.man ldbstarter ldb.opt
  237. X
  238. X$(LDB): $(OFILES)
  239. X    $(CC) $(CFLAGS) -s -o $(LDB) $(OFILES) $(LIBS)
  240. X
  241. Xall: $(LDB) ldb.doc
  242. X
  243. Xldb.doc: ldb.man
  244. X    nroff -rT$(PAGELEN) -man ldb.man >ldb.doc
  245. X    $(UNIXTOVMS) ldb.doc
  246. X
  247. Xldb.doc60: ldb.man
  248. X    nroff -rT60 -man ldb.man >ldb.doc60
  249. X    $(UNIXTOVMS) ldb.doc60
  250. X
  251. Xldb.doc62: ldb.man
  252. X    nroff -rT62 -man ldb.man >ldb.doc62
  253. X    $(UNIXTOVMS) ldb.doc62
  254. X
  255. Xldb.doc66: ldb.man
  256. X    nroff -rT66 -man ldb.man >ldb.doc66
  257. X    $(UNIXTOVMS) ldb.doc66
  258. X
  259. Xlint: .XXX
  260. X    lint $(LINTFLAGS) $(CFILES) > lint.out
  261. X
  262. Xclean: .XXX
  263. X    rm -f $(OFILES) ldb *.obj ldb.exe make.out .mk lint.out MANIFEST.BAK
  264. X
  265. Xshar: $(SHARFILES)
  266. X    $(VMSTOUNIX) $(SHARFILES)
  267. X    makekit -m
  268. X
  269. Xtar: $(SHARFILES)
  270. X    tar cvf ldb.tar $(SHARFILES)
  271. X
  272. Xtags: .XXX
  273. X    ctags $(CFILES)
  274. X    sed 's/Mmain/main/' <tags | sort >.tags
  275. X    mv .tags tags
  276. X
  277. X.XXX:
  278. END_OF_FILE
  279. if test 4861 -ne `wc -c <'Makefile'`; then
  280.     echo shar: \"'Makefile'\" unpacked with wrong size!
  281. fi
  282. # end of 'Makefile'
  283. fi
  284. if test -f 'README' -a "${1}" != "-c" ; then 
  285.   echo shar: Will not clobber existing file \"'README'\"
  286. else
  287. echo shar: Extracting \"'README'\" \(9736 characters\)
  288. sed "s/^X//" >'README' <<'END_OF_FILE'
  289. X        Long Distance Backgammon
  290. X        ------------------------
  291. X
  292. X    This is a program that lets two people easily play backgammon
  293. Xby e-mail.  It currently runs only on character-oriented terminals
  294. X(or emulators thereof) under the curses package.  It runs on most
  295. Xflavors of UNIX, as well as VMS version 5.0 and above.
  296. X
  297. X    To build ldb, create a directory, copy all the parts into
  298. Xthat directory, strip the usenet or mail headers with a text editor,
  299. Xand execute them with a shell (e.g. sh Part1; sh Part2; ...).
  300. XThe installation options are documented in the Makefile.
  301. X
  302. X    Suggestions and problems are cheerfully accepted, all the more
  303. Xso when accompanied by appropriate patches, in any format the patch
  304. Xprogram understands (e.g. context diff).  E-mail to ross@emf780.den.mmc.com.
  305. X
  306. X    This file is for version 1.3 of ldb.  For those upgrading from
  307. X1.0 who are wondering what happened to 1.1, it was only released on
  308. Xthe DECUS tape.  Because of time constraints, it had to be released
  309. Xwithout some of the planned features, so it was assigned a unique rev number.
  310. X1.2 was to be the next version, but it was released so widely for beta
  311. Xtest that there were countless different "versions" of version 1.2.
  312. X
  313. X        New Features
  314. X        ------------
  315. X
  316. X    A complete listing of the changes for rev 1.1, 1.2, and 1.3 is in
  317. Xthe comments at the top of main.c.  Briefly, they are:
  318. X    - Ldb has a context-sensitive help function that is activated
  319. X      whenever you press ? or h.
  320. X    - Match play is now supported.
  321. X    - The Crawford and Jacoby rules are supported, as is the european
  322. X      scoring of backgammons as double rather than triple games.
  323. X    - You can now declare a game to be "permanent", meaning that it
  324. X      will be automatically restarted when it ends.  This is for
  325. X      people you play continuously.
  326. X    - The current pip count for you and your opponent is displayed
  327. X      above the board.
  328. X    - You can obtain detailed statistics about the rolls you and
  329. X      your opponent have received, including a histogram of
  330. X      relative frequency, by pressing the % or # keys.
  331. X    - You can use the -score option to print a summary of games
  332. X      won/lost by opponent.
  333. X    - You can press ESC while entering a message to get back to
  334. X      your game and abort the operation.
  335. X    - Ldb will not ask for the second digit of a 1-digit point number
  336. X      unless it needs to (e.g. to tell the difference between 1 and 12)
  337. X    - Comments are rot13'd before they are sent.  That way you won't
  338. X      accidentally read the comment while extracting your mail and
  339. X      ruin the surprise.  If ldb sees that your opponent is running
  340. X      an old version of ldb, comments work like they used to.
  341. X    - Concede now scores gammons/backgammons, so a player cannot
  342. X      concede to avoid a gammon or backgammon.
  343. X    - A lock file is used to prevent more than one ldb from running
  344. X      at the same time in any account.
  345. X    - The name, mail address, and an alias for all your opponents are
  346. X      stored in a new file.  This file also keeps track of games
  347. X      won and lost to that opponent.
  348. X    - If you clobber your data file, ldb can reconstruct it from your
  349. X      opponents' data files.
  350. X    - Reverse video now works on VMS, as does the screen redraw and
  351. X      the supervisor key.
  352. X    - Any printing characters may be used to draw the game pieces.
  353. X    - You can dump the screen to a file from the -control menu.
  354. X    - You can have ldb automatically notify your opponents when
  355. X      your e-mail address changes, provided they are using version
  356. X      1.3 or better.
  357. X
  358. X
  359. X        Automatic Game Starters
  360. X        -----------------------
  361. X
  362. X    An automatic game starter has been set up by Mark Rubin on
  363. Xcs.umb.edu.  This matches people by ability and automatically starts a
  364. Xgame between them.  The ability categories are novice, intermediate, and
  365. Xexpert.  For example, if you consider yourself an expert, you would
  366. Xmail to:
  367. X
  368. X        ldb-expert@cs.umb.edu
  369. X
  370. Xwhereupon you will be matched at random with someone else who mailed to the
  371. Xsame address, and your game will be started using the remotestart
  372. Xfunction of ldb.
  373. X
  374. X    For more information, mail to:
  375. X
  376. X        ldb-help@cs.umb.edu
  377. X
  378. XYou will receive an automated reply by return mail.
  379. X
  380. XFor those wishing to set up their own game starter, the shellscript used
  381. Xto do it is included in this distribution as ldbstarter.
  382. XGetting it to work on your system may take a little work.
  383. X
  384. X
  385. X        Running Ldb
  386. X        -----------
  387. X
  388. X    The first time ldb is run, it will create a file in your home
  389. Xdirectory called ".ldbrc".  If this name is inconvenient, define the
  390. Xenvironment variable LDBRC to be the name you want before running it
  391. Xthe first time (and all times after that).  Ldb will ask for your
  392. Xpersonal, human-type name and your e-mail address.  All other options
  393. Xwill be set to their defaults, as explained in the manual.  The "sendcmd"
  394. Xoption in .ldbrc may need to be modified to work with the mail program
  395. Xon your system.  This option tells ldb how to send mail to your opponent,
  396. Xand must be correctly set for ldb to work.  This string after "sendcmd="
  397. Xis executed by ldb after making the following substitutions:
  398. X    $a    is replaced by the address to mail to.
  399. X    $f    is replaced by the file containing the message.
  400. X    $s    is replaced by the subject line of the message.
  401. X    $$    is replaced by a single $.
  402. XThe default, which should work with most UNIX systems, is:
  403. X    mail -s '$s' $a < $f
  404. XNote that ldb performs the substitutions, not the shell, so the substitutions
  405. Xare not subject to any quoting.  All other characters, including shell
  406. Xmetacharacters, are passed to the system unchanged.
  407. X
  408. XVMS users will have the following default sendcmd set:
  409. X
  410. X    sendcmd=MAIL/SUBJECT="$s" $f IN%"""$a"""
  411. X
  412. XThis is correct if you are using the IN% SMTP mailer.  If not,
  413. Xyou may need to change the sendcmd= line as follows:
  414. X
  415. XIf you are using VMS mail only, use the line:
  416. X
  417. X    sendcmd=MAIL/SUBJECT="$s" $f $a
  418. X
  419. XDepending on which SMTP mailer you have, the IN% may need to be
  420. Xchanged to WINS% (for Wollongong), etc.
  421. X
  422. X
  423. X        Starting A Game
  424. X        ---------------
  425. X
  426. X    To start a game, type:
  427. X        ldb -start opponent's-email-address
  428. Xand everything is automatic from there.  You may have to exchange
  429. Xseveral mail messages before you are ready to play, since your ldb has to
  430. Xdo the initial roll with the remote ldb, and if there is a tie, the
  431. Xinitial roll is repeated.  Eventually, you will see a board drawn on
  432. Xthe screen.  The commands are in the bottom right corner.  The moves by
  433. Xyou and your opponent are above that, on the right side of the screen, and
  434. Xthe bottom of the screen contains a place for you to enclose a 2-line
  435. Xmessage with each move.  This is useful for taunting, pleading, etc.
  436. XYou will need to press 'r' to roll the dice, then press the number of the roll
  437. Xyou want to use followed by the point you want to move from.  For example,
  438. Xif you roll 5 2, and you want to move the piece on the 11 point 5, press
  439. X5 1 1.  You don't need to hit return.  After you have used one of your rolls,
  440. Xthere are 3 shortcuts you can use for the remainder of your roll:
  441. X    <space bar>    Continues the last move.  The piece you last moved
  442. X            is moved by the amount of the other/next roll.
  443. X    <return>    Repeat the last move.  The other/next roll is applied
  444. X            to the same point you moved from last time.
  445. X    p        Make point.  This gets a little tricky.  Ldb attempts
  446. X            to use the other/next roll to move one of your pieces
  447. X            so that it ends up on the same point as your last move
  448. X            ended on.  That is, if you roll 5 2 and use the 5
  449. X            to move from the 6 point to the 11 point, and hit "p",
  450. X            ldb will move one of your pieces from the 9 point to
  451. X            the 11 point to make the 11 point.  This assumes,
  452. X            of course, that you have a piece on the 9 point.
  453. X
  454. X    Ldb checks your moves for all conceivable errors.  These
  455. Xare listed in the manual.
  456. X
  457. X    To move off the bar, merely select a roll.  That roll will
  458. Xautomatically bring you off the bar, since you have no other legal
  459. Xmove anyway.  To bear pieces off, you can either enter the point
  460. Xnumber like normal, or press "o" to have it bear off for you automatically.
  461. X
  462. X    When a move arrives in your mail, go into mail and save the message
  463. Xinto a file.  Delete the message from your mail, exit mail, and run
  464. Xldb with the name of the file as an argument.  There are easier ways
  465. Xto feed incoming mail to ldb; these are discussed in the manual.
  466. X
  467. X    For more options, read the manual and the comments at the top
  468. Xof main.c.
  469. X
  470. X    Good luck!
  471. X
  472. X                        Perry R. Ross
  473. X                        ross@emf780.den.mmc.com
  474. X
  475. X-----------------------------------------------------------------------------
  476. X
  477. X    Really Scary and Hopefully Bulletproof Legal Statement:
  478. X
  479. XThis software is copyright 1991 by Perry R. Ross.  Permission to use,
  480. Xcopy, modify, and redistribute it is granted provided:
  481. X    (1) It is not sold.
  482. X    (2) This notice accompanies all copies, and is kept intact.
  483. X    (3) Users do not cheat by any method, including but not limited to:
  484. X        A. modifying the roll generated by the random number generator,
  485. X        B. modifying the code to provide any roll other than that
  486. X           generated by a bona-fide random number generator,
  487. X        C. taking advantage of any non-randomness in a random
  488. X           number generator to predict upcoming rolls,
  489. X        D. changing the contents of an incoming message or of the
  490. X           .ldbdata file to modify the normal progression of a
  491. X           game in any way, or
  492. X        E. generating a roll before offering to double.
  493. X       Persons guilty of cheating in any way while using this software
  494. X       are denied permission to use or distribute this software
  495. X       in perpetuity.  Excluded from the definition of cheating is
  496. X       any action whose intention is to test or debug this software,
  497. X       as long as the opponent is aware that these actions are being
  498. X       performed, and the game is considered "unofficial".
  499. XThe above restrictions are made in all seriousness, and with every
  500. Xintention of enforcement by any and all legal means where practical.
  501. X
  502. X(Sounds almost as good as the real thing, doesn't it?)
  503. END_OF_FILE
  504. if test 9736 -ne `wc -c <'README'`; then
  505.     echo shar: \"'README'\" unpacked with wrong size!
  506. fi
  507. # end of 'README'
  508. fi
  509. if test -f 'TODO' -a "${1}" != "-c" ; then 
  510.   echo shar: Will not clobber existing file \"'TODO'\"
  511. else
  512. echo shar: Extracting \"'TODO'\" \(2429 characters\)
  513. sed "s/^X//" >'TODO' <<'END_OF_FILE'
  514. Xdelete redundant fields from game structure (opaddr, myaddr, etc)
  515. X
  516. Xdelmail option should work on system mail file.
  517. X
  518. XMake superkey work instantly, instead of only when waiting for a character.
  519. X
  520. XWay of changing local colors for a game, or for setting local colors
  521. Xindependent of colors specified in START.
  522. X
  523. XIndication of last access time for a game in -control.
  524. X
  525. XInstead of keeping 3 board images Bef, Aft, Cur, keep log file of
  526. Xall prior moves, with board image, player, & move made.  Use ^ and v
  527. Xcommands (or ku & kd from termcap?) to scroll backward and forward through
  528. Xlog file, displaying board & pieces moved at each step.  Delete log file
  529. Xwhen game is deleted?  Use name like .ldblogXXXXX for log file,
  530. Xput log file name into game structure.  Scan directory for unused
  531. Xlog files when games are read, so they can be deleted?  Maybe, each
  532. Xscroll back is in two steps, before move was made & after.  That is,
  533. XCur, -1 After, -1 Before, -2 After, -2 Before, ...
  534. X
  535. XWay of specifying that board should invert if necessary automatically
  536. Xso that play is always in the desired direction.
  537. X
  538. Xallow unlimited length comments, scroll window.
  539. X
  540. XWay to print board to file, load board from file.  Allow board
  541. Xto be set up in any desired configuration.
  542. X
  543. XSecurity from (1) advance knowledge of rolls, (2) generating false rolls.
  544. X
  545. XMultiple language support.
  546. X
  547. Xregister vars
  548. X
  549. XFlip board left/right.
  550. X
  551. XFlush input before reading.
  552. X
  553. XSocket transport.
  554. X
  555. XMotif front-end.  Open Look?  Xlib?
  556. X
  557. XVMS command line interface.  Maybe, separate out all host-specific
  558. Xstuff into a separate file, & only compile in the one you need.
  559. X
  560. XOption to display "scratch" screen, move any piece.  Don't save.
  561. XInitial setup?
  562. X
  563. XProtect critical sections from SIGINT.  Catch more signals?
  564. XCatch SIGSTOP/SIGTSTP/SIGCONT & reset tty modes.
  565. X
  566. XAllow multiple rolls without sending packet when opponent is closed out.
  567. XAllow opponent's roll to be generated locally when piece is on the bar,
  568. X& skip if he cannot move.  Conflicts with secure dice roller?  How
  569. Xto send multiple moves in one packet?
  570. X
  571. XProcess id in lock file, look to see if process still exists.
  572. XPortability?  How in VMS?
  573. X
  574. XPlug memory leaks.
  575. X
  576. XFaster start protocol, have starting host perform entire opening roll
  577. Xand reroll ties immediately.  Conflicts with: 1) backward compatibility,
  578. X2) autodoubling, 3) secure roller.
  579. X
  580. XCatch failure in sending mail, return to move state.
  581. X
  582. Xhandle failed write better.  "" in writegames.
  583. END_OF_FILE
  584. if test 2429 -ne `wc -c <'TODO'`; then
  585.     echo shar: \"'TODO'\" unpacked with wrong size!
  586. fi
  587. # end of 'TODO'
  588. fi
  589. if test -f 'board.c' -a "${1}" != "-c" ; then 
  590.   echo shar: Will not clobber existing file \"'board.c'\"
  591. else
  592. echo shar: Extracting \"'board.c'\" \(2195 characters\)
  593. sed "s/^X//" >'board.c' <<'END_OF_FILE'
  594. X/* board.c        8/3/91
  595. X *
  596. X * Copyright 1991  Perry R. Ross
  597. X *
  598. X * Permission to use, copy, modify, and distribute this software and its
  599. X * documentation without fee is hereby granted, subject to the restrictions
  600. X * detailed in the README file, which is included here by reference.
  601. X * Any other use requires written permission from the author.  This software
  602. X * is distributed "as is" without any warranty, including any implied
  603. X * warranties of merchantability or fitness for a particular purpose.
  604. X * The author shall not be liable for any damages resulting from the
  605. X * use of this software.  By using this software, the user agrees
  606. X * to these terms.
  607. X */
  608. X
  609. X#include "ldb.h"
  610. X
  611. X/*----------------------------------------------------------------------
  612. X *    newboard -- set up a board array for a new game
  613. X *
  614. X * This function initializes a board array so that it is set up
  615. X * properly for a new game.  It is passed two characters that are
  616. X * used to draw the pieces for the board.  C1 is the color for the
  617. X * upbound player, and c2 is the color for the downbound player.
  618. X *----------------------------------------------------------------------
  619. X */
  620. X
  621. Xnewboard(b,c1,c2)
  622. Xboard b;
  623. Xchar c1, c2;
  624. X{
  625. Xint i;
  626. X
  627. Xfor (i = 0; i < BOARDSIZE; i++) {
  628. X    b[i].qty = 0;            /* init to empty */
  629. X    b[i].color = '-';        /* init to invalid color */
  630. X    }
  631. Xb[1].qty = 2;                /* 2 c1's on 1 point */
  632. Xb[1].color = c1;
  633. Xb[6].qty = 5;                /* 5 c2's on 6 point */
  634. Xb[6].color = c2;
  635. Xb[8].qty = 3;                /* 3 c2's on 8 point */
  636. Xb[8].color = c2;
  637. Xb[12].qty = 5;                /* 5 c1's on 12 point */
  638. Xb[12].color = c1;
  639. Xb[13].qty = 5;                /* 5 c2's on 13 point */
  640. Xb[13].color = c2;
  641. Xb[17].qty = 3;                /* 3 c1's on 17 point */
  642. Xb[17].color = c1;
  643. Xb[19].qty = 5;                /* 5 c1's on 19 point */
  644. Xb[19].color = c1;
  645. Xb[24].qty = 2;                /* 2 c2's on 24 point */
  646. Xb[24].color = c2;
  647. X}
  648. X
  649. X
  650. X/*----------------------------------------------------------------------
  651. X *    copyboard -- make a copy a board array
  652. X *
  653. X * This is a convenience function that copies an entire board. The
  654. X * source is given as "f", and the destination as "t".
  655. X *----------------------------------------------------------------------
  656. X */
  657. X
  658. Xcopyboard(f,t)
  659. Xboard f, t;
  660. X{
  661. Xint i;
  662. X
  663. Xfor (i = 0; i < BOARDSIZE; i++)
  664. X    t[i] = f[i];
  665. X}
  666. END_OF_FILE
  667. if test 2195 -ne `wc -c <'board.c'`; then
  668.     echo shar: \"'board.c'\" unpacked with wrong size!
  669. fi
  670. # end of 'board.c'
  671. fi
  672. if test -f 'dohelp.c' -a "${1}" != "-c" ; then 
  673.   echo shar: Will not clobber existing file \"'dohelp.c'\"
  674. else
  675. echo shar: Extracting \"'dohelp.c'\" \(4994 characters\)
  676. sed "s/^X//" >'dohelp.c' <<'END_OF_FILE'
  677. X/* dohelp.c        3/27/92
  678. X *
  679. X * Copyright 1992  Earle F. Ake
  680. X *
  681. X * Permission to use, copy, modify, and distribute this software and its
  682. X * documentation without fee is hereby granted, subject to the restrictions
  683. X * detailed in the README file, which is included here by reference.
  684. X * Any other use requires written permission from the author.  This software
  685. X * is distributed "as is" without any warranty, including any implied
  686. X * warranties of merchantability or fitness for a particular purpose.
  687. X * The author shall not be liable for any damages resulting from the
  688. X * use of this software.  By using this software, the user agrees
  689. X * to these terms.
  690. X *
  691. X * Original coding by Earle F. Ake <ake@dayton.saic.com> - 27 March 1992.
  692. X *
  693. X */
  694. X
  695. X#include "ldb.h"
  696. X
  697. X/*----------------------------------------------------------------------
  698. X *    dohelp -- display online help for the user
  699. X *
  700. X * This function creates a new curses window and displays command help
  701. X * to the user.  The user then presses any key to return to the game.
  702. X *----------------------------------------------------------------------
  703. X */
  704. X
  705. Xdohelp()
  706. X{
  707. XWINDOW *helpwin;
  708. Xint row;
  709. X
  710. Xhelpwin = newwin(0,0,0,0);    /* get a new window to post help to */
  711. X
  712. Xmvwaddstr(helpwin,0,30,"ldb Command Summary");        /* print title */
  713. Xmvwaddstr(helpwin,1,30,"-------------------");        /* underline title */
  714. Xrow = 3;
  715. X
  716. Xif(GameState == STATE_MYACPT) {
  717. X    mvwaddstr(helpwin,row,0,"Accept -");
  718. X    mvwaddstr(helpwin,row++,15,"Accept the double and the game continues.");
  719. X    row++;
  720. X    mvwaddstr(helpwin,row,0,"Decline -");
  721. X    mvwaddstr(helpwin,row++,15,"You decline the double and lose the game for the current");
  722. X    mvwaddstr(helpwin,row++,15,"game value.");
  723. X    row++;
  724. X    }
  725. X
  726. Xif(GameState == STATE_CONTROL) {
  727. X    mvwaddstr(helpwin,row,0,"Invert -");
  728. X    mvwaddstr(helpwin,row++,15,"Invert the board for this game.  Pressing Invert again will");
  729. X    mvwaddstr(helpwin,row++,15,"put it back to normal.  Inverting the board does not affect");
  730. X    mvwaddstr(helpwin,row++,15,"point numbering.");
  731. X    row++;
  732. X    mvwaddstr(helpwin,row,0,"Resend -");
  733. X    mvwaddstr(helpwin,row++,15,"Resend your last move command to your opponent.");
  734. X    row++;
  735. X    mvwaddstr(helpwin,row,0,"Get Resend -");
  736. X    mvwaddstr(helpwin,row++,15,"Request a resend from your opponent.");
  737. X    row++;
  738. X    mvwaddstr(helpwin,row,0,"Screen Dump -");
  739. X    mvwaddstr(helpwin,row++,15,"Dump the screen to ldb_screen.dmp");
  740. X    row++;
  741. X    mvwaddstr(helpwin,row,0,"Delete Game -");
  742. X    mvwaddstr(helpwin,row++,15,"This marks a game for deletion.  The game is not deleted");
  743. X    mvwaddstr(helpwin,row++,15,"until you quit and you can undelete it by pressing D again.");
  744. X    row++;
  745. X    }
  746. X
  747. Xif(GameState == STATE_MYTURN) {
  748. X    mvwaddstr(helpwin,row,0,"Roll -");
  749. X    mvwaddstr(helpwin,row++,15,"Roll the dice.  Your roll will appear in your move block.");
  750. X    mvwaddstr(helpwin,row++,15,"You will see two numbers appear or four if you have");
  751. X    mvwaddstr(helpwin,row++,15,"rolled doubles.");
  752. X    row++;
  753. X    mvwaddstr(helpwin,row,0,"Double -");
  754. X    mvwaddstr(helpwin,row++,15,"Choose to double the current game value.  A message will");
  755. X    mvwaddstr(helpwin,row++,15,"be sent to your opponent and ldb then will automatically");
  756. X    mvwaddstr(helpwin,row++,15,"select roll.");
  757. X    row++;
  758. X    }
  759. X
  760. Xif(GameState == STATE_MYMOVE) {
  761. X    mvwaddstr(helpwin,row,0,"Point -");
  762. X    mvwaddstr(helpwin,row++,15,"Attempt to make the point your last move ended on.");
  763. X    row++;
  764. X    mvwaddstr(helpwin,row,0,"Off -");
  765. X    mvwaddstr(helpwin,row++,15,"Bear off a piece by using the next UNUSED roll.");
  766. X    row++;
  767. X    mvwaddstr(helpwin,row,0,"Reset -");
  768. X    mvwaddstr(helpwin,row++,15,"Reset your rolls to UNUSED and put the board back how it was");
  769. X    mvwaddstr(helpwin,row++,15,"before you moved.  You can then enter some different moves.");
  770. X    row++;
  771. X    mvwaddstr(helpwin,row,0,"Send -");
  772. X    mvwaddstr(helpwin,row++,15,"Send your move to your opponent.  You will be able to");
  773. X    mvwaddstr(helpwin,row++,15,"enter 2 lines of 56 characters to send with your move.");
  774. X    row++;
  775. X    }
  776. X
  777. Xif(GameState != STATE_CONTROL) {
  778. X    mvwaddstr(helpwin,row,0,"Board -");
  779. X    mvwaddstr(helpwin,row++,15,"Cycle between the current board, the board before your");
  780. X    mvwaddstr(helpwin,row++,15,"opponent's last move, and the board after your opponent's");
  781. X    mvwaddstr(helpwin,row++,15,"last move.");
  782. X    row++;
  783. X    }
  784. X
  785. Xif((GameState == STATE_MYTURN) || (GameState == STATE_MYMOVE)) {
  786. X    mvwaddstr(helpwin,row,0,"Concede -");
  787. X    mvwaddstr(helpwin,row++,15,"Concede the current game.");
  788. X    row++;
  789. X    }
  790. X
  791. Xmvwaddstr(helpwin,row,0,"Next Game -");
  792. Xmvwaddstr(helpwin,row++,15,"The next game is displayed.  If there is no next game, quit.");
  793. Xrow++;
  794. Xmvwaddstr(helpwin,row,0,"Quit -");
  795. Xmvwaddstr(helpwin,row++,15,"Quit the current ldb session.");
  796. X
  797. Xmvwaddstr(helpwin,23,25,"Press <return> to continue: ");
  798. X
  799. Xtouchwin(helpwin);        /* Make sure the screen is updated */
  800. Xwrefresh(helpwin);        /* update the help window clearing screen */
  801. Xwgetch(helpwin);        /* Wait for user response */
  802. Xwclear(helpwin);        /* clear the help window */
  803. Xwrefresh(helpwin);        /* update the help window clearing screen */
  804. Xdelwin(helpwin);        /* delete the help window */
  805. X}
  806. END_OF_FILE
  807. if test 4994 -ne `wc -c <'dohelp.c'`; then
  808.     echo shar: \"'dohelp.c'\" unpacked with wrong size!
  809. fi
  810. # end of 'dohelp.c'
  811. fi
  812. if test -f 'flist_none.c' -a "${1}" != "-c" ; then 
  813.   echo shar: Will not clobber existing file \"'flist_none.c'\"
  814. else
  815. echo shar: Extracting \"'flist_none.c'\" \(1317 characters\)
  816. sed "s/^X//" >'flist_none.c' <<'END_OF_FILE'
  817. X/*    flist_none.c        4/24/91
  818. X *
  819. X * Copyright 1991  Perry R. Ross
  820. X *
  821. X * Permission to use, copy, modify, and distribute this software and its
  822. X * documentation without fee is hereby granted, subject to the restrictions
  823. X * detailed in the README file, which is included here by reference.
  824. X * Any other use requires written permission from the author.  This software
  825. X * is distributed "as is" without any warranty, including any implied
  826. X * warranties of merchantability or fitness for a particular purpose.
  827. X * The author shall not be liable for any damages resulting from the
  828. X * use of this software.  By using this software, the user agrees
  829. X * to these terms.
  830. X */
  831. X
  832. X#include "ldb.h"
  833. X
  834. X
  835. X/*----------------------------------------------------------------------
  836. X *    filelist -- generate a list of all matching files.
  837. X *
  838. X * This is a dummy function that can be used to disable filename
  839. X * matching.  It just copies the pattern into a 1-element list
  840. X * and returns it.  This can be used if flist_unix does not work,
  841. X * or if filename matching is not desired.
  842. X *----------------------------------------------------------------------
  843. X */
  844. X
  845. Xstruct flist *filelist(ptn)
  846. Xchar *ptn;
  847. X{
  848. Xstruct flist *cur;
  849. X
  850. Xif ( (cur = (struct flist *) calloc(sizeof(struct flist),1)) == NULL)
  851. X    fatal("Out of memory!");
  852. Xcur->name = save(ptn);
  853. Xreturn(cur);
  854. X}
  855. END_OF_FILE
  856. if test 1317 -ne `wc -c <'flist_none.c'`; then
  857.     echo shar: \"'flist_none.c'\" unpacked with wrong size!
  858. fi
  859. # end of 'flist_none.c'
  860. fi
  861. if test -f 'flist_vms.c' -a "${1}" != "-c" ; then 
  862.   echo shar: Will not clobber existing file \"'flist_vms.c'\"
  863. else
  864. echo shar: Extracting \"'flist_vms.c'\" \(3176 characters\)
  865. sed "s/^X//" >'flist_vms.c' <<'END_OF_FILE'
  866. X/*    flist_vms.c        4/24/92
  867. X *
  868. X * Copyright 1992  Earle Ake and Perry Ross
  869. X *
  870. X * Permission to use, copy, modify, and distribute this software and its
  871. X * documentation without fee is hereby granted, subject to the restrictions
  872. X * detailed in the README file, which is included here by reference.
  873. X * Any other use requires written permission from the author.  This software
  874. X * is distributed "as is" without any warranty, including any implied
  875. X * warranties of merchantability or fitness for a particular purpose.
  876. X * The author shall not be liable for any damages resulting from the
  877. X * use of this software.  By using this software, the user agrees
  878. X * to these terms.
  879. X */
  880. X
  881. X#include "ldb.h"
  882. X
  883. X
  884. X/*----------------------------------------------------------------------
  885. X *    filelist -- generate a list of all matching files.
  886. X *
  887. X * This function generates a list of all files that match a pattern.
  888. X * Each file is stored in an instance of struct flist, which just
  889. X * links the names in a linked list.  A pointer to the beginning of
  890. X * the list is returned.  It is the callers responsibility to free
  891. X * the list when it is no longer needed.
  892. X *----------------------------------------------------------------------
  893. X */
  894. X
  895. Xstruct flist *filelist(ptn)
  896. Xchar *ptn;
  897. X{
  898. Xchar nextfile[257];
  899. Xint context = 0;
  900. Xstruct flist *head, *tail, *cur;
  901. X
  902. Xhead = NULL;
  903. Xwhile (1) {
  904. X    if (scan_files(ptn,&nextfile,&context) == 0)
  905. X        return(head);
  906. X    if ( (cur = (struct flist *) calloc(sizeof(struct flist),1)) == NULL)
  907. X        fatal("Out of memory!");
  908. X    if (head == NULL) {
  909. X        head = cur;
  910. X        tail = cur;
  911. X        }
  912. X    else {
  913. X        tail->next = cur;
  914. X        tail = cur;
  915. X        }
  916. X    cur->name = save(nextfile);
  917. X    }
  918. X}
  919. X
  920. X
  921. X/*----------------------------------------------------------------------
  922. X *    scan_files -- find the next file matching a pattern
  923. X *
  924. X * This function finds the next (or first) file matching a given
  925. X * pattern.  The pattern is interpreted in the same way as DCL.
  926. X * If the pattern does not specify a version number, ';*' is
  927. X * the default.  scan_files returns 1 if a file was found,
  928. X * 0 if there are no more matching files.
  929. X *----------------------------------------------------------------------
  930. X */
  931. X
  932. Xint scan_files(itm_files,nextfile,context)
  933. X    char *itm_files, *nextfile;
  934. X    int *context;
  935. X{
  936. X    char *def_spec = ";*";
  937. X    int status;
  938. X    unsigned key[2];
  939. X    char fnam[257], *s;
  940. X    static struct RAB itmrab;
  941. X    static struct dsc$descriptor itm_dsc, defspec_dsc;
  942. X    $DESCRIPTOR(fnam_dsc,fnam);
  943. X
  944. X    if (*context == 0) {
  945. X        itm_dsc.dsc$w_length = strlen(itm_files);
  946. X        itm_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
  947. X        itm_dsc.dsc$b_class = DSC$K_CLASS_S;
  948. X        itm_dsc.dsc$a_pointer = itm_files;
  949. X
  950. X        defspec_dsc.dsc$w_length = strlen(def_spec);
  951. X        defspec_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
  952. X        defspec_dsc.dsc$b_class = DSC$K_CLASS_S;
  953. X        defspec_dsc.dsc$a_pointer = def_spec;
  954. X
  955. X        itmrab.rab$l_kbf = (char *) key;
  956. X        itmrab.rab$b_krf = 0;
  957. X        itmrab.rab$b_ksz = 8;
  958. X        itmrab.rab$l_rop = RAB$M_RRL | RAB$M_NLK ;
  959. X        itmrab.rab$b_rac = RAB$C_KEY;
  960. X    }
  961. X
  962. X    if ((status = lib$find_file(&itm_dsc,&fnam_dsc,context,
  963. X        &defspec_dsc,0,0,0)) & 1) {
  964. X
  965. X        fnam[256] = '\0';
  966. X
  967. X        if (s = strchr(fnam,' ')) *s = '\0';
  968. X        strcpy(nextfile,&fnam);
  969. X        return 1;
  970. X        }
  971. X    else {
  972. X        lib$find_file_end(context);
  973. X    }
  974. X    return 0;
  975. X}
  976. END_OF_FILE
  977. if test 3176 -ne `wc -c <'flist_vms.c'`; then
  978.     echo shar: \"'flist_vms.c'\" unpacked with wrong size!
  979. fi
  980. # end of 'flist_vms.c'
  981. fi
  982. if test -f 'ldb.opt' -a "${1}" != "-c" ; then 
  983.   echo shar: Will not clobber existing file \"'ldb.opt'\"
  984. else
  985. echo shar: Extracting \"'ldb.opt'\" \(24 characters\)
  986. sed "s/^X//" >'ldb.opt' <<'END_OF_FILE'
  987. Xsys$share:vaxcrtl/share
  988. END_OF_FILE
  989. if test 24 -ne `wc -c <'ldb.opt'`; then
  990.     echo shar: \"'ldb.opt'\" unpacked with wrong size!
  991. fi
  992. # end of 'ldb.opt'
  993. fi
  994. if test -f 'lock.c' -a "${1}" != "-c" ; then 
  995.   echo shar: Will not clobber existing file \"'lock.c'\"
  996. else
  997. echo shar: Extracting \"'lock.c'\" \(2218 characters\)
  998. sed "s/^X//" >'lock.c' <<'END_OF_FILE'
  999. X/*    lock.c        4/28/92
  1000. X *
  1001. X * Copyright 1992  Perry R. Ross
  1002. X *
  1003. X * Permission to use, copy, modify, and distribute this software and its
  1004. X * documentation without fee is hereby granted, subject to the restrictions
  1005. X * detailed in the README file, which is included here by reference.
  1006. X * Any other use requires written permission from the author.  This software
  1007. X * is distributed "as is" without any warranty, including any implied
  1008. X * warranties of merchantability or fitness for a particular purpose.
  1009. X * The author shall not be liable for any damages resulting from the
  1010. X * use of this software.  By using this software, the user agrees
  1011. X * to these terms.
  1012. X */
  1013. X
  1014. X#include "ldb.h"
  1015. X
  1016. X
  1017. X/*----------------------------------------------------------------------
  1018. X *    get_lock -- attempt to open a lock file, exit if it exists
  1019. X *
  1020. X * This function attempts to create a file in such a way that,
  1021. X * if the file exists, the create will fail.  If the create succeeds,
  1022. X * we "own" the ldb lock, and have the exclusive right to access
  1023. X * the ldb data files in this directory.  If the create fails,
  1024. X * some other ldb already has the lock and we exit.
  1025. X *
  1026. X * This uses the O_EXCL flag to open, which as far as I know is
  1027. X * supported on all UNIX flavors.  If it isn't on yours:
  1028. X *    a. Please mail me at ross@emf780.den.mmc.com and tell me
  1029. X *       what your system is.
  1030. X *    b. try replacing open(fn,O_...,0644) with creat(fn,0444).
  1031. X *----------------------------------------------------------------------
  1032. X */
  1033. X
  1034. Xget_lock(fn)
  1035. Xchar *fn;
  1036. X{
  1037. Xint fd;
  1038. Xstruct stat s;
  1039. X
  1040. Xif ( (fd = open(fn,O_WRONLY|O_CREAT|O_EXCL,0644)) < 0) {
  1041. X    printf("ERROR: Ldb is already running in this account -- exiting.\n\n");
  1042. X    printf("If you are sure no other ldb is active, you can remove\n");
  1043. X    printf("the lock with the following command:\n\n");
  1044. X#ifdef VMS
  1045. X    printf("\t$ delete sys$login:%s;*\n",fn);
  1046. X#else
  1047. X    if (*fn == '/')
  1048. X        printf("\t$ rm %s\n",fn);
  1049. X    else
  1050. X        printf("\t$ rm $HOME/%s\n",fn);
  1051. X#endif
  1052. X    printf(
  1053. X    "\nPlease be certain no other ldb is running before doing this.\n\n");
  1054. X    if (stat(fn,&s) >= 0)
  1055. X        printf("The lock file was created %s\n",ctime(&s.st_ctime));
  1056. X    exit(STAT_ABORT);    /* DON'T call ldbexit, it calls release_lock */
  1057. X    }
  1058. Xclose(fd);        /* success, close the file and return */
  1059. X}
  1060. END_OF_FILE
  1061. if test 2218 -ne `wc -c <'lock.c'`; then
  1062.     echo shar: \"'lock.c'\" unpacked with wrong size!
  1063. fi
  1064. # end of 'lock.c'
  1065. fi
  1066. if test -f 'makefile.vms' -a "${1}" != "-c" ; then 
  1067.   echo shar: Will not clobber existing file \"'makefile.vms'\"
  1068. else
  1069. echo shar: Extracting \"'makefile.vms'\" \(3736 characters\)
  1070. sed "s/^X//" >'makefile.vms' <<'END_OF_FILE'
  1071. X# Makefile for ldb under vms    5/1/92
  1072. X#
  1073. X# Copyright 1992  Earle F. Ake
  1074. X#
  1075. X# Permission to use, copy, modify, and distribute this software and its
  1076. X# documentation without fee is hereby granted, subject to the restrictions
  1077. X# detailed in the README file, which is included here by reference.
  1078. X# Any other use requires written permission from the author.  This software
  1079. X# is distributed "as is" without any warranty, including any implied
  1080. X# warranties of merchantability or fitness for a particular purpose.
  1081. X# The author shall not be liable for any damages resulting from the
  1082. X# use of this software.  By using this software, the user agrees
  1083. X# to these terms.
  1084. X
  1085. X# This makefile is for the vms make program written by Todd Aven and
  1086. X# used by DECUS UUCP.  This file should be renamed to makefile.
  1087. X# before it is used.  If you do not have make on your system, you
  1088. X# can compile ldb with @makeldb.com.  If you use this file, you
  1089. X# shouldn't need to modify any of the installation options below.
  1090. X
  1091. X### INSTALLATION OPTIONS ###
  1092. X# If your host uses an ancient version of curses (e.g. VAX-C, Sequent),
  1093. X# uncomment the following line.  To tell if you need this option,
  1094. X# first try compiling without it and see if your linker complains
  1095. X# about cbreak() and nocbreak() not being defined.  If it does,
  1096. X# you need this option.
  1097. X#OLDCURSES=
  1098. X#OLDCURSES=-DOLD_CURSES
  1099. X
  1100. X# If your libc doesn't have a rename function, uncomment the
  1101. X# following to use the one that's included.  DO NOT use this
  1102. X# rename if your system already has one.
  1103. X#RENAME=
  1104. X#RENAME=rename.o
  1105. X
  1106. X# Uncomment the following lines only if you are using Eunice.
  1107. X# If you don't know what it is, believe me, you're not using it.
  1108. X#UNIXTOVMS=true
  1109. X#VMSTOUNIX=true
  1110. X# UNIXTOVMS=unixtovms
  1111. X# VMSTOUNIX=vmstounix
  1112. X
  1113. X# Put the name of the front-end you want to compile in here.
  1114. X# NOTE: there is currently only one available front-end (curses).
  1115. XFE_FILE=fe_curses
  1116. X
  1117. X# Put the name of the transport you want to compile in here.
  1118. X# NOTE: there is currently only one available transport (email).
  1119. XT_FILE=t_email
  1120. X
  1121. X# Put the name of the dice roller you want to compile in here.
  1122. X# If you want to write your own dice roller, you can.  I would
  1123. X# prefer people all used the same one, since that is more fair,
  1124. X# but as long as it is really a random number generator, you're ok.
  1125. X# If you put in a fake dice roller (e.g. one that asks you what
  1126. X# roll you want), you are in violation of the copyright.  Read
  1127. X# the README file for more information.
  1128. XR_FILE=r_xrand
  1129. X
  1130. X# Put compiler flags here.
  1131. XCFLAGS=/nolist
  1132. X#LIBS=-lcurses -ltermcap
  1133. X
  1134. X# use these 2 lines for SCO XENIX (also SCO UNIX?)
  1135. X#CFLAGS= -O -Mle -LARGE -Zi -DM_TERMCAP $(OLDCURSES)
  1136. X#LIBS=-lx -ltcap -ltermlib
  1137. X#LINTFLAGS=
  1138. X
  1139. X# Name of ldb executable.
  1140. X#LDB=ldb
  1141. XLDB=ldb.exe
  1142. X
  1143. X# Page length to format manual with.  62 for VMS or Eunice, 66 for most others.
  1144. X#PAGELEN=66
  1145. X
  1146. X#CC=cc
  1147. X
  1148. X### END OF INSTALLATION OPTIONS ###
  1149. X
  1150. X*.obj :    *.c
  1151. X    write sys$output "Compiling $*"
  1152. X    cc $(CFLAGS) $*
  1153. X    purge/nolog $*.obj
  1154. X    rename $*.obj *.*;1
  1155. X
  1156. Xldb :    $(LDB)
  1157. X    write sys$output "ldb Build finished."
  1158. X
  1159. Xldb_objs = board.obj,game.obj,main.obj,misc.obj,move.obj,process.obj,\
  1160. X    rcvop.obj,control.obj,\
  1161. X    check.obj,readmail.obj,save.obj,vars.obj,$(FE_FILE).obj,\
  1162. X    $(T_FILE).obj,$(R_FILE).obj,\
  1163. X    dohelp.obj,dostats.obj,flist_vms.obj,lock.obj
  1164. X
  1165. X#
  1166. X#    Include all the sources necessary to build under VMS or unix
  1167. X#
  1168. X
  1169. XSHARFILES=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
  1170. X
  1171. X$(LDB) : $(ldb_objs)
  1172. X    write sys$output "Linking $(LDB)"
  1173. X     link/exe=$(LDB)/notrace/nodebug/nomap $(ldb_objs),\
  1174. X    sys$share:vaxccurse.olb/library,\
  1175. X    sys$disk:[]ldb.opt/options
  1176. X
  1177. X$(ldb_objs) : ldb.h patchlevel.h
  1178. X
  1179. Xvms_share : $(SHARFILES)
  1180. X    vms_share $(SHARFILES) ldb_src
  1181. END_OF_FILE
  1182. if test 3736 -ne `wc -c <'makefile.vms'`; then
  1183.     echo shar: \"'makefile.vms'\" unpacked with wrong size!
  1184. fi
  1185. # end of 'makefile.vms'
  1186. fi
  1187. if test -f 'makeldb.com' -a "${1}" != "-c" ; then 
  1188.   echo shar: Will not clobber existing file \"'makeldb.com'\"
  1189. else
  1190. echo shar: Extracting \"'makeldb.com'\" \(634 characters\)
  1191. sed "s/^X//" >'makeldb.com' <<'END_OF_FILE'
  1192. X$ set verify
  1193. X$ assign "sys$library" vaxc$include
  1194. X$ cc/nolist board
  1195. X$ cc/nolist check
  1196. X$ cc/nolist control
  1197. X$ cc/nolist dohelp
  1198. X$ cc/nolist dostats
  1199. X$ cc/nolist fe_curses
  1200. X$ cc/nolist flist_vms
  1201. X$ cc/nolist game
  1202. X$ cc/nolist lock
  1203. X$ cc/nolist main
  1204. X$ cc/nolist misc
  1205. X$ cc/nolist move
  1206. X$ cc/nolist process
  1207. X$ cc/nolist r_xrand
  1208. X$ cc/nolist rcvop
  1209. X$ cc/nolist readmail
  1210. X$ cc/nolist save
  1211. X$ cc/nolist t_email
  1212. X$ cc/nolist vars
  1213. X$ link/exe=ldb sys$input/opt
  1214. Xboard,check,control,dohelp,dostats,fe_curses,flist_vms,game,lock,main
  1215. Xmisc,move,process,r_xrand,rcvop,readmail,save,t_email,vars
  1216. Xsys$share:vaxccurse.olb/library
  1217. Xldb.opt/options
  1218. X$ set noverify
  1219. X$ exit
  1220. END_OF_FILE
  1221. if test 634 -ne `wc -c <'makeldb.com'`; then
  1222.     echo shar: \"'makeldb.com'\" unpacked with wrong size!
  1223. fi
  1224. # end of 'makeldb.com'
  1225. fi
  1226. if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  1227.   echo shar: Will not clobber existing file \"'patchlevel.h'\"
  1228. else
  1229. echo shar: Extracting \"'patchlevel.h'\" \(1761 characters\)
  1230. sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
  1231. X/*    patchlevel.h    9/9/91
  1232. X *
  1233. X * adapted from the file "patchlevel", which is part of the
  1234. X * "xloadimage" package by Jim Frost, and used within the terms
  1235. X * of the original copyright notice, which appears below.
  1236. X * Please note that the copyright notice below applies only to
  1237. X * this file.
  1238. X */
  1239. X
  1240. X/*
  1241. X * Copyright 1989, 1990, 1991 Jim Frost
  1242. X *
  1243. X * Permission to use, copy, modify, distribute, and sell this software
  1244. X * and its documentation for any purpose is hereby granted without fee,
  1245. X * provided that the above copyright notice appear in all copies and
  1246. X * that both that copyright notice and this permission notice appear
  1247. X * in supporting documentation.  The author makes no representations
  1248. X * about the suitability of this software for any purpose.  It is
  1249. X * provided "as is" without express or implied warranty.
  1250. X *
  1251. X * THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  1252. X * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
  1253. X * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  1254. X * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
  1255. X * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  1256. X * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
  1257. X * USE OR PERFORMANCE OF THIS SOFTWARE.
  1258. X */
  1259. X
  1260. X    /* REVISION and PATCHLEVEL can't be more than 9            */
  1261. X    /* due to the way the version field is coded in outgoing    */
  1262. X    /* messages (i.e. only 1 digit each).  I would suggest        */
  1263. X    /* rolling REVISION if PATCHLEVEL gets to 9, and similarly    */
  1264. X    /* rolling VERSION if REVISION gets to 9.  VERSION is        */
  1265. X    /* essentially unlimited.                    */
  1266. X
  1267. X#define VERSION        1
  1268. X#define REVISION    3        /* no more than 9 */
  1269. X#define PATCHLEVEL    0        /* no more than 9 */
  1270. X#define AUTHOR_EMAIL    "ross@emf780.den.mmc.com"
  1271. END_OF_FILE
  1272. if test 1761 -ne `wc -c <'patchlevel.h'`; then
  1273.     echo shar: \"'patchlevel.h'\" unpacked with wrong size!
  1274. fi
  1275. # end of 'patchlevel.h'
  1276. fi
  1277. if test -f 'rename.c' -a "${1}" != "-c" ; then 
  1278.   echo shar: Will not clobber existing file \"'rename.c'\"
  1279. else
  1280. echo shar: Extracting \"'rename.c'\" \(1665 characters\)
  1281. sed "s/^X//" >'rename.c' <<'END_OF_FILE'
  1282. X/*    rename.c        4/10/92
  1283. X *
  1284. X * Copyright 1991  Perry R. Ross
  1285. X *
  1286. X * Permission to use, copy, modify, and distribute this software and its
  1287. X * documentation without fee is hereby granted, subject to the restrictions
  1288. X * detailed in the README file, which is included here by reference.
  1289. X * Any other use requires written permission from the author.  This software
  1290. X * is distributed "as is" without any warranty, including any implied
  1291. X * warranties of merchantability or fitness for a particular purpose.
  1292. X * The author shall not be liable for any damages resulting from the
  1293. X * use of this software.  By using this software, the user agrees
  1294. X * to these terms.
  1295. X */
  1296. X
  1297. X#include "ldb.h"
  1298. X
  1299. X
  1300. X/*----------------------------------------------------------------------
  1301. X *    rename -- rename a file
  1302. X *
  1303. X * This function may be used to rename a file if the local C library
  1304. X * does not have such a function.  It uses the link and unlink calls,
  1305. X * which should be on all systems, but is not atomic like real rename's.
  1306. X * This rename is not meant for general use, as it does no error checking.
  1307. X * Since it is only used to save the old copy of a file as a backup,
  1308. X * it is better to fail silently than complain about something the user
  1309. X * can't do anything about anyway.  The old file is always unlinked,
  1310. X * even if the link to the new name succeeded, since the next thing
  1311. X * we are going to do is write over the old file anyway.
  1312. X *----------------------------------------------------------------------
  1313. X */
  1314. X
  1315. Xrename(old,new)
  1316. Xchar *old;
  1317. Xchar *new;
  1318. X{
  1319. X
  1320. Xunlink(new);        /* get rid of existing file named NEW */
  1321. Xlink(old,new);        /* make link from OLD to NEW */
  1322. Xunlink(old);        /* get rid of link to OLD */
  1323. X}
  1324. END_OF_FILE
  1325. if test 1665 -ne `wc -c <'rename.c'`; then
  1326.     echo shar: \"'rename.c'\" unpacked with wrong size!
  1327. fi
  1328. # end of 'rename.c'
  1329. fi
  1330. if test -f 't_email.c' -a "${1}" != "-c" ; then 
  1331.   echo shar: Will not clobber existing file \"'t_email.c'\"
  1332. else
  1333. echo shar: Extracting \"'t_email.c'\" \(4960 characters\)
  1334. sed "s/^X//" >'t_email.c' <<'END_OF_FILE'
  1335. X/*    t_email.c        9/5/91
  1336. X *
  1337. X * Copyright 1991  Perry R. Ross
  1338. X *
  1339. X * Permission to use, copy, modify, and distribute this software and its
  1340. X * documentation without fee is hereby granted, subject to the restrictions
  1341. X * detailed in the README file, which is included here by reference.
  1342. X * Any other use requires written permission from the author.  This software
  1343. X * is distributed "as is" without any warranty, including any implied
  1344. X * warranties of merchantability or fitness for a particular purpose.
  1345. X * The author shall not be liable for any damages resulting from the
  1346. X * use of this software.  By using this software, the user agrees
  1347. X * to these terms.
  1348. X */
  1349. X
  1350. X#include "ldb.h"
  1351. X
  1352. X/*======================================================================
  1353. X * This file is the e-mail transport for the ldb program.  It is
  1354. X * modularized to allow other transports to be substituted, most
  1355. X * notably a socket transport to allow interactive network backgammon.
  1356. X * For now, though, this is the only transport available.
  1357. X *
  1358. X * Packets are sent via TSendPacket, which takes an instance of
  1359. X * struct packet and an address, and sends the packet to that address.
  1360. X * TInitialize must be called before any calls to TSendPacket, and
  1361. X * TFinishSession must be called before exiting.
  1362. X *
  1363. X * Individual files may be sent by calling TSendFile.  These files
  1364. X * need not be related to a game.
  1365. X *======================================================================
  1366. X */
  1367. X
  1368. XPRIVATE PStringSub();
  1369. X
  1370. X
  1371. X/*----------------------------------------------------------------------
  1372. X *    TInitialize -- initialize the transport
  1373. X *
  1374. X * This function is called before the transport is used.  As you can
  1375. X * see, email doesn't require a great deal of initialization.
  1376. X *----------------------------------------------------------------------
  1377. X */
  1378. X
  1379. XTInitialize()
  1380. X{
  1381. X}
  1382. X
  1383. X
  1384. X/*----------------------------------------------------------------------
  1385. X *    FeDrawMenu -- draw menu choices in menu box
  1386. X *
  1387. X * This function closes down the transport.
  1388. X *----------------------------------------------------------------------
  1389. X */
  1390. X
  1391. XTFinishSession()
  1392. X{
  1393. X}
  1394. X
  1395. X
  1396. X
  1397. X/*----------------------------------------------------------------------
  1398. X *    TSendPacket -- send a packet to an email address
  1399. X *
  1400. X * This function sends a packet to an email address.  It returns 1 if
  1401. X * the packet was sent, 0 if an error occurred.
  1402. X *----------------------------------------------------------------------
  1403. X */
  1404. X
  1405. XTSendPacket(p,addr)
  1406. Xstruct packet *p;
  1407. Xchar *addr;
  1408. X{
  1409. Xchar subject[80];
  1410. XFILE *fp;
  1411. Xint status;
  1412. X
  1413. X
  1414. Xif ((fp = fopen(rc.tempfile,"w")) == NULL) {    /* open temp file */
  1415. X    message("ERROR: can't create %s!\n",rc.tempfile);
  1416. X    return;
  1417. X    }
  1418. Xfprintf(fp,"<<<===LDB===>>>\n");    /* send magic header text */
  1419. Xnvwrite(fp,nv_packet,p);    /* write the contents of the packet */
  1420. Xfclose(fp);                /* close temp file */
  1421. Xsprintf(subject,"<=LDB=> from %s (Long Distance Backgammon)", rc.myname);
  1422. Xstatus = TSendFile(addr,rc.tempfile,subject);    /* send the file */
  1423. Xunlink(rc.tempfile);        /* delete the temp file */
  1424. Xreturn(status);
  1425. X}
  1426. X
  1427. X
  1428. X/*----------------------------------------------------------------------
  1429. X *    TSendFile -- send a file to an address
  1430. X *
  1431. X * This function takes an e-mail address, a file, and a subject line,
  1432. X * and sends the contents of the file to the specified address.  The
  1433. X * subject is set to the contents of the subject argument, which should
  1434. X * be one line.  TSendFile returns a 1 if the message was sent,
  1435. X * and a 0 if an error occurred.
  1436. X *----------------------------------------------------------------------
  1437. X */
  1438. X
  1439. XTSendFile(addr,file,subj)
  1440. Xchar *addr, *file, *subj;
  1441. X{
  1442. Xchar cmd[256];
  1443. Xchar *subs[3];
  1444. Xint s;
  1445. X
  1446. Xsubs[0] = addr;            /* substitute $a with opponent address */
  1447. Xsubs[1] = file;            /* substitue $f with file */
  1448. Xsubs[2] = subj;            /* substitute $s with subject */
  1449. XPStringSub(rc.sendcmd,"afs",subs,cmd);
  1450. Xs = system(cmd);            /* execute email command */
  1451. Xreturn(s == SYS_GOOD);
  1452. X}
  1453. X
  1454. X
  1455. X
  1456. X/*----------------------------------------------------------------------
  1457. X *    PStringSub -- substitute variables in a string
  1458. X *
  1459. X * This function copies str to obuf, replacing occurrences of $x to
  1460. X * a corresponding string.  The characters which can appear after
  1461. X * the $ are passed in a single string in the "chars" argument, and
  1462. X * the strings to replace them with are passed, in the same order as
  1463. X * the characters appear in "chars", in the "strings" argument.
  1464. X *----------------------------------------------------------------------
  1465. X */
  1466. X
  1467. XPRIVATE PStringSub(str,chars,strings,obuf)
  1468. Xchar *str, *chars, *strings[], obuf[];
  1469. X{
  1470. Xchar *s, *o, *t;
  1471. X
  1472. Xfor (s = str, o = obuf; *s; s++) {
  1473. X    if (*s != '$') {    /* as long as we don't see a $ */
  1474. X        *o++ = *s;    /* just keep copying */
  1475. X        continue;
  1476. X        }
  1477. X    s++;
  1478. X    if (*s == '$') {    /* $$ is a single $ */
  1479. X        *o++ = '$';
  1480. X        continue;
  1481. X        }
  1482. X    if ( (t = strchr(chars,*s)) == NULL)    /* skip invalid $ subs */
  1483. X        continue;
  1484. X    t = strings[t - chars];        /* get ptr to replacement string */
  1485. X    while (*t)            /* copy it to obuf */
  1486. X        *o++ = *t++;
  1487. X    }
  1488. X*o = '\0';                /* null terminate obuf */
  1489. X}
  1490. END_OF_FILE
  1491. if test 4960 -ne `wc -c <'t_email.c'`; then
  1492.     echo shar: \"'t_email.c'\" unpacked with wrong size!
  1493. fi
  1494. # end of 't_email.c'
  1495. fi
  1496. echo shar: End of archive 1 \(of 12\).
  1497. cp /dev/null ark1isdone
  1498. MISSING=""
  1499. for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
  1500.     if test ! -f ark${I}isdone ; then
  1501.     MISSING="${MISSING} ${I}"
  1502.     fi
  1503. done
  1504. if test "${MISSING}" = "" ; then
  1505.     echo You have unpacked all 12 archives.
  1506.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1507. else
  1508.     echo You still need to unpack the following archives:
  1509.     echo "        " ${MISSING}
  1510. fi
  1511. ##  End of shell archive.
  1512. exit 0
  1513.  
  1514. exit 0 # Just in case...
  1515.