home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume14 / okbrdge2 / part09 < prev    next >
Encoding:
Internet Message Format  |  1993-01-26  |  54.8 KB

  1. Path: uunet!zephyr.ens.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v14i087:  okbridge2 - computer-mediated bridge game, Part09/14
  5. Message-ID: <3526@master.CNA.TEK.COM>
  6. Date: 7 Sep 92 21:42:24 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1758
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: mclegg@cs.UCSD.EDU (Matthew Clegg)
  12. Posting-number: Volume 14, Issue 87
  13. Archive-name: okbridge2/Part09
  14. Supersedes: okbridge: Volume 13, Issue 16-22
  15. Environment: BSD-derived Unix, NeXT, curses, sockets
  16.  
  17.  
  18.  
  19. #! /bin/sh
  20. # This is a shell archive.  Remove anything before this line, then unpack
  21. # it by saving it into a file and typing "sh file".  To overwrite existing
  22. # files, type "sh file -c".  You can also feed this as standard input via
  23. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  24. # will see the following message at the end:
  25. #        "End of archive 9 (of 14)."
  26. # Contents:  commands.h okbridge.help protocol.c
  27. # Wrapped by billr@saab on Mon Sep  7 14:33:37 1992
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'commands.h' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'commands.h'\"
  31. else
  32. echo shar: Extracting \"'commands.h'\" \(8888 characters\)
  33. sed "s/^X//" >'commands.h' <<'END_OF_FILE'
  34. X/* commands.h
  35. X *
  36. X ! Copyright (C) 1990-1992 by Matthew Clegg.  All Rights Reserved
  37. X ! 
  38. X ! OKbridge is made available as a free service to the Internet.
  39. X ! Accordingly, the following restrictions are placed on its use:
  40. X ! 
  41. X ! 1.  OKbridge may not be modified in any way without the explicit 
  42. X !     permission of Matthew Clegg.  
  43. X ! 
  44. X ! 2.  OKbridge may not be used in any way for commercial advantage.
  45. X !     It may not be placed on for-profit networks or on for-profit
  46. X !     computer systems.  It may not be bundled as part of a package
  47. X !     or service provided by a for-profit organization.
  48. X ! 
  49. X ! If you have questions about restrictions on the use of OKbridge,
  50. X ! write to mclegg@cs.ucsd.edu.
  51. X ! 
  52. X ! DISCLAIMER:  The user of OKbridge accepts full responsibility for any
  53. X ! damage which may be caused by OKbridge.
  54. X *
  55. X * This module implements the commands which are available through the
  56. X * input processor.
  57. X *
  58. X */
  59. X
  60. X/*
  61. X *   /ALERT
  62. X *     Alerts your partner's last bid.  If you are playing in FORMAL mode,
  63. X *     the alert is displayed to your opponents only.  Otherwise, the alert
  64. X *     will be displayed to everyone.  Same as ^A.
  65. X *
  66. X *   /ASSIGN <player-name> NORTH|EAST|SOUTH|WEST|OBS
  67. X *     Assigns a player to a given seat.  Can only be used before the
  68. X *     first hand has been dealt or between hands.
  69. X *
  70. X *   /BELL [ON|OFF]
  71. X *     By default, the okbridge program rings the terminal's bell whenever
  72. X *     it requests input from you.  However, this can be disabled by
  73. X *     typing '/BELL OFF'.  The state of the bell can be toggled with ^G.
  74. X *
  75. X *   /CC [NS|EW|MY|BOTH]
  76. X *     Displays the convention card of the specified team(s).
  77. X *     By default, displays the convention card of the opponents.
  78. X *
  79. X *   /CLAIM [n]
  80. X *     This command 'claims' n additional tricks for the declarer.
  81. X *     If n is omitted, then all remaining tricks are claimed.
  82. X *     The other players are shown the declarer's hand and are
  83. X *     asked whether or not they agree to the declarer's request.
  84. X *     If both agree, then the hand is ended early.  This command can
  85. X *     be used only by the declarer and only when it is declarer's or
  86. X *     dummy's turn to play.
  87. X *
  88. X *   /DEFAULT [ON | OFF]
  89. X *     This command controls whether or not defaults will be provided
  90. X *     for bids, plays and questions.  This mode can be toggled with ^D.
  91. X *
  92. X *   /DISCONNECT <player-name>
  93. X *     Closes the connection to the named player.
  94. X *     <player-name> can either be the name of a player (e.g., Worf)
  95. X *     or the name of position (e.g., SOUTH).
  96. X *
  97. X *   /FORMAL [OFF|ON]
  98. X *     Specifies whether formal playing rules will be used or queries which
  99. X *     playing rules are currently use.  In formal play, talk messages
  100. X *     are displayed only to the opponents, alerts are not displayed to the
  101. X *     partner of the alerter, and the dummy is not revealed to anyone
  102. X *     until the opening lead has been made.
  103. X *
  104. X *   /HELP [topic]
  105. X *     Type '/HELP' alone to obtain general help, or type
  106. X *     '/HELP topic' to obtain help about a particular topic.
  107. X *
  108. X *   /LHB <message>
  109. X *     Sends a message to the person who appears to the left of you in the
  110. X *     bidding display.  Same as the /RHO command.
  111. X *
  112. X *   /LHO <message>
  113. X *     Sends a message to the person who will play or bid immediately
  114. X *     after you.  Same as the /RHB command.
  115. X *
  116. X *   /LOG [filename]
  117. X *     Typing '/LOG filename' causes this hand and subsequent hands
  118. X *     to be written to the file with name 'filename'.  Omitting
  119. X *     'filename' causes the current log file to be closed.
  120. X *     Adding a plus sign '+' to the beginning of 'filename' causes
  121. X *     the playing record to be appended to the end of the file.
  122. X *
  123. X *   /NAME <new-name>
  124. X *     Changes your name to <new-name>.
  125. X *
  126. X *   /OPP <message>
  127. X *     Sends a message which will be seen only by the opponents.
  128. X *
  129. X *   /PING
  130. X *     Sends an invisible message to each of the other players, which is
  131. X *     automatically echoed.  Reports the round-trip communication time.
  132. X *
  133. X *   /PROMPT [ON|OFF]
  134. X *     By default, the dummy is asked to press RETURN after the end
  135. X *     of each trick.  This allows the dummy to see each trick as
  136. X *     it is played.  This prompting can be disabled by typing
  137. X *     '/PROMPT OFF' (convenient if you need to run to the wc :-)
  138. X *     The prompt mode can be toggled with ^P.
  139. X *
  140. X *   /QUIT
  141. X *     Terminates the program.
  142. X *
  143. X *   /REVIEW
  144. X *     Displays the bidding for review.  This is intended to be used
  145. X *     during the playing mode.  This command can be abbreviated with ^B.
  146. X *
  147. X *   /REVEAL [<player-name> | NORTH | EAST | SOUTH | WEST | NE | NS | NW |
  148. X *           SE | SW | EW]
  149. X *     This command can only be used by an observer while others are playing.
  150. X *     In this case, the observer enters SPECTATOR mode and the named hands
  151. X *     are revealed.  In SPECTATOR mode, the observer can have complete
  152. X *     information about the game, but may not talk.  SPECTATOR mode is
  153. X *     not available in formal play.  If the name of the player is
  154. X *     omitted, then all hands are revealed.
  155. X *
  156. X *   /RHB <message>
  157. X *     Sends a message to the person who appears to the right of you in
  158. X *     the bidding display.  Same as the /LHO command.
  159. X *
  160. X *   /RHO <message>
  161. X *     Sends a message to the person who bids or plays immediately before
  162. X *     you.  Same as the /LHB command.
  163. X *
  164. X *   /RESET
  165. X *     Resets the program to its initial state.
  166. X *
  167. X *   /SCORE RUBBER|CHICAGO|DUPLICATE|EMAIL|IMP
  168. X *     Selects a scoring mode.  Can only be used before the first hand
  169. X *     has been dealt or between hands.
  170. X *
  171. X *   /SEAT NORTH|EAST|SOUTH|WEST|OBS
  172. X *   /EAST, /NORTH, /OBS, /OBSERVER, /SOUTH, /WEST
  173. X *     Selects a seat.  Can only be used before the first hand or between
  174. X *     hands.  Only one person may sit in the seats north, east, south, west,
  175. X *     but there may be many observers.
  176. X *
  177. X *   /SETCC [<your-convention-card>]
  178. X *     Enters one line of text as your convention card.  This card will
  179. X *     then be announced to your partner and the opponents as the convention
  180. X *     card for your team.  Omitting convention card from this command will
  181. X *     cause your current convention card to be announced to your partner
  182. X *     and opponents.
  183. X *
  184. X *   /SKIP
  185. X *     Ends the current hand immediately, without recording a score for it.
  186. X *     This command is useful in case the connection to one of the
  187. X *     players is lost.
  188. X *
  189. X *   /SPEC [<player-name> | NORTH | EAST | SOUTH | WEST | NE | NS | NW |
  190. X *         SE | SW | EW]
  191. X *     Enters SPECTATOR mode.  In SPECTATOR mode, an observer can see the
  192. X *     hands of the players, but the spectator is not allowed to talk.
  193. X *     The parameters identify the hand(s) which are to be revealed to
  194. X *     the spectator.  SPECTATOR mode is not available during formal play.
  195. X *     (This command is actually the same as the /REVEAL command.)
  196. X *
  197. X *   /TALK message
  198. X *     Sends a short message to the other players.  This command can be used
  199. X *     when the program is waiting for you to enter a bid or a play.
  200. X *     Not needed if the word 'TALK' is displayed to the left of the cursor.
  201. X *
  202. X *   /TIMER [ON|OFF]
  203. X *     Controls whether or not the timer will displayed after each
  204. X *     bid and play.
  205. X *
  206. X *   /WAKEUP [<player-name> | ALL]
  207. X *     Sends a wakeup signal to the named player, or to all players if
  208. X *     "ALL" is specified.  The wakeup signal rings the terminal bell and
  209. X *     prints the words "WAKE UP" in the talk box.  If the name of the
  210. X *     player is omitted, then the signal is sent to your partner.
  211. X *
  212. X *   /WHO
  213. X *     Gives a short list of the other players and their respective seats.
  214. X *
  215. X *   /WHOIS [<player-name>]
  216. X *     Inquires about a specific player.  If the player has listed his/her
  217. X *     full name and email address in the .okbridgerc file, then this
  218. X *     information is given.  If <player-name> is omitted, then inquires
  219. X *     about both of the opponents.
  220. X *
  221. X *   /ZLOG [filename]
  222. X *     This command is similar to the /LOG command in that it also opens
  223. X *     a log file, but the format of the log file is more compact.
  224. X *
  225. X */
  226. X
  227. Xvoid Parse_Input_Command ();
  228. X/* Parses the command contained in the buffer command_buf and executes
  229. X   the corresponding command.  If an error occurs, then displays an
  230. X   appropriate message in the status line. 
  231. X*/
  232. X
  233. Xint Parse_Server_Command ();
  234. X/* void Parse_Server_Command (void *command_buf); */
  235. X/* On entry, command_buf should contain a special request to the server
  236. X   made by a client.  Parses the command and executes it.  Returns 0 if
  237. X   the command was parsed correctly, and 1 if an error occurs.  In the
  238. X   latter case, the error message is placed in the Parser_Error_Buf.
  239. X*/
  240. X
  241. X/* The following procedures are made visible because they can be invoked
  242. X   by control characters: */
  243. X
  244. Xvoid Review_Bidding ();
  245. X/* Generates a review of the bidding. */
  246. X
  247. Xvoid Wakeup_player ();
  248. X/* Sends a wakeup message to the named player. */
  249. X
  250. X
  251. END_OF_FILE
  252. if test 8888 -ne `wc -c <'commands.h'`; then
  253.     echo shar: \"'commands.h'\" unpacked with wrong size!
  254. fi
  255. # end of 'commands.h'
  256. fi
  257. if test -f 'okbridge.help' -a "${1}" != "-c" ; then 
  258.   echo shar: Will not clobber existing file \"'okbridge.help'\"
  259. else
  260. echo shar: Extracting \"'okbridge.help'\" \(23044 characters\)
  261. sed "s/^X//" >'okbridge.help' <<'END_OF_FILE'
  262. X# okbridge.help -- help file for the okbridge program
  263. X#  
  264. X# Copyright (C) 1990-1992 by Matthew Clegg
  265. X#
  266. X# This program may be copied and distributed freely, provided that this
  267. X# is not done for commercial advantage.  Neither this program nor any of its
  268. X# derivatives may be distributed or used in any way for commercial
  269. X# advantage without the explicit written permission of Matthew Clegg.
  270. X# If you modify this program, then include a notice stating plainly that
  271. X# your program is derived from the okbridge program and is not the same
  272. X# as the original okbridge program.
  273. X#
  274. X# Use this program at your own risk.  I cannot accept responsibility for
  275. X# for any damage which may be attributable by this program.
  276. X# 
  277. X# I welcome any suggestions for improvement, and I would be especially
  278. X# happy to receive improved source code.  If you have comments or
  279. X# suggestions, or if you would like to join the okbridge mailing list,
  280. X# then write to
  281. X#
  282. X#   mclegg@cs.ucsd.edu
  283. X# 
  284. X#
  285. X# The help information in this file is organized as a series of topics.
  286. X# The first entry in the file is interpreted to be the main topic, 
  287. X# i.e., it is the entry which is displayed if no particular keyword 
  288. X# is given.  Each topic entry has a header line which contains an 
  289. X# identifying keyword and a descriptive phrase.  This is followed 
  290. X# by the body of the entry and is terminated by an end-of-entry line.  
  291. X#
  292. X# The format of an entry is
  293. X#
  294. X# <keyword> <phrase>
  295. X# help text
  296. X# more help text
  297. X# ...
  298. X# last help text
  299. X# --
  300. X#
  301. X# Comment lines such as this one are not printed in the help display.
  302. X# A page break is given by placing the '^' character on a line by itself.
  303. X#
  304. Xmain          A general description of the program
  305. X
  306. X                    Welcome to OKBRIDGE, version 1.7
  307. X
  308. X     This is a computer-moderated bridge program.  It allows four
  309. Xpeople at different locations on the Internet to play bridge together.
  310. XThe computer shuffles the cards and communicates bids and plays between
  311. Xthe players.
  312. X
  313. X     The help system is organized as a series of topics, each
  314. Xidentified by a keyword.  To obtain information on a particular topic,
  315. Xjust type '/HELP topic'.  If this is your first time playing okbridge,
  316. Xthen you may wish to take a look at the "starting" topic.
  317. X     Good luck at the bridge table!
  318. X
  319. X--
  320. Xbidding     information on how to enter a bid
  321. X
  322. X              Information about Bidding
  323. X                      ----------- ----- -------
  324. X
  325. XThe format of a bid is one of the following:
  326. X
  327. X     <level> <trump>
  328. X     DOUBLE               (or X)
  329. X     REDOUBLE             (or XX)
  330. X     PASS                 (or P)
  331. X
  332. Xwhere 
  333. X     <level> is either 1, 2, 3, 4, 5, 6, or 7
  334. X     <suit>  is one of C, D, H, S, N or NT.
  335. X
  336. XThere should be no space between the <level> and the <suit>.
  337. XYou may alert your own bids by typing an exclamation mark "!" after the bid.
  338. XThe alert will be displayed to the opponents but not to your partner.
  339. X
  340. Xexamples
  341. X     P, 1C!, 1S, 1N, 1NT, X!, DOUBLE, XX, 2c!, 4nt!
  342. X--
  343. Xcommands      Commands for controlling the program
  344. X
  345. X     /ALERT
  346. X       Alerts your partner's last bid.  If you are playing in FORMAL mode,
  347. X       the alert is displayed to your opponents only.  Otherwise, the alert
  348. X       will be displayed to everyone.  Same as ^A.
  349. X
  350. X     /AUTOPASS [ON|OFF]
  351. X       During PRACTICE mode, this command controls whether or not PASS 
  352. X       bids are automatically supplied by the moderator for absent players.  
  353. X
  354. X     /BELL [ON|OFF]
  355. X       By default, the okbridge program rings the terminal's bell whenever
  356. X       it requests input from you.  However, this can be disabled by
  357. X       typing '/BELL OFF'.  The state of the bell can be toggled with ^G.
  358. X
  359. X     /CC [NS|EW|MY|BOTH]
  360. X       Displays the convention card of the specified team(s).
  361. X       By default, displays the convention card of the opponents.
  362. X
  363. X     /CCDEF [<Concention Card Name>] [<Convention-Card>]
  364. X       Stores or displays a named convention card in the internal database.
  365. X^
  366. X     /CLS
  367. X       Clears the talk window.
  368. X
  369. X     /CLAIM [n]
  370. X       This command 'claims' n additional tricks for the declarer.
  371. X       If n is omitted, then all remaining tricks are claimed.
  372. X       The other players are shown the declarer's hand and are
  373. X       asked whether or not they agree to the declarer's request.
  374. X       If both agree, then the hand is ended early.  This command can
  375. X       be used only by the declarer.
  376. X
  377. X     /CONNECT <server_ip> [<port-number>]
  378. X       Attempts to connect to a server at the given address and port.
  379. X       If the port number is omitted, 1729 is assumed.
  380. X
  381. X     /DEFAULT [ON | OFF]
  382. X       This command controls whether or not defaults will be provided
  383. X       for bids, plays and questions.  This mode can be toggled with ^D.
  384. X
  385. X     /EMAIL <your-email-address>
  386. X       Specifies your email address for display to other players.
  387. X^
  388. X     /FULLNAME <your-full-name>
  389. X       Specifies your full name for display to other players.
  390. X
  391. X     /HELP [topic]
  392. X       Type '/HELP' alone to obtain general help, or type
  393. X       '/HELP topic' to obtain help about a particular topic.
  394. X
  395. X     /LHB <message>
  396. X       Sends a message to the person who appears to the left of you in the
  397. X       bidding display.  Same as the /RHO command.
  398. X
  399. X     /LHO <message>
  400. X       Sends a message to the person who will play or bid immediately
  401. X       after you.  Same as the /RHB command.
  402. X
  403. X     /LOAD <filename>
  404. X       Loads a set of email duplicate boards from the given file.
  405. X       Begins playing the first board in the file.
  406. X^
  407. X     /LOG [filename]
  408. X       Typing '/LOG filename' causes this hand and subsequent hands
  409. X       to be written to the file with name 'filename'.  Omitting
  410. X       'filename' causes the current log file to be closed.
  411. X       Adding a plus sign '+' to the beginning of 'filename' causes
  412. X       the playing record to be appended to the end of the file.
  413. X
  414. X     /NAME <new-name>
  415. X       Changes your name to <new-name>
  416. X
  417. X     /OPP <message>
  418. X       Sends a message which will be seen only by the opponents.
  419. X
  420. X     /PAUSE
  421. X       During play, uses the entire screen for a talk window.
  422. X
  423. X     /PING
  424. X       Sends an invisible message to each of the other players, which is
  425. X       automatically echoed.  Reports the round-trip communication time.
  426. X^
  427. X     /PRACTICE [ON|OFF]
  428. X       Enters PRACTICE playing mode.  In this mode, two or three players
  429. X       can practice their bidding and play.  OKbridge will automatically
  430. X       generate "PASS" bids for absent players.  During the play, the
  431. X       hands will be revealed to all of the players for discussion and play.
  432. X
  433. X     /PROMPT [ON|OFF]
  434. X       By default, the dummy is asked to press RETURN after the end
  435. X       of each trick.  This allows the dummy to see each trick as
  436. X       it is played.  This prompting can be disabled by typing
  437. X       '/PROMPT OFF' (convenient if you need to run to the wc :-)
  438. X       The prompt mode can be toggled with ^P.
  439. X
  440. X     /QUIT
  441. X       Terminates the program.
  442. X
  443. X     /REPLAY <replay-file>
  444. X       Loads a set of email duplicate boards from the specified file
  445. X       and begins playing them.  After the last board has been played,
  446. X       saves the boards along with the results of play back to the
  447. X       same file.
  448. X^
  449. X     /REVIEW
  450. X       Displays the bidding for review.  This is intended to be used
  451. X       during the playing mode.  This command can be abbreviated with ^B.
  452. X
  453. X     /RHB <message>
  454. X       Sends a message to the person who appears to the right of you in
  455. X       the bidding display.  Same as the /LHO command.
  456. X
  457. X     /RHO <message>
  458. X       Sends a message to the person who bids or plays immediately before
  459. X       you.  Same as the /LHB command.
  460. X
  461. X     /SAVE [<filename>]
  462. X       Saves the boards which have been played (and/or downloaded) in
  463. X       email duplicate format to the given file.  If the filename is
  464. X       omitted, then saves the boards to the file last specified in a
  465. X       /LOAD command.
  466. X^
  467. X     /SEAT NORTH|EAST|SOUTH|WEST|OBS
  468. X     /EAST, /NORTH, /OBS, /OBSERVER, /SOUTH, /WEST
  469. X       Selects a seat.  Can only be used before the first hand or between
  470. X       hands.  Only one person may sit in the seats north, east, south, west,
  471. X       but there may be many observers.
  472. X
  473. X     /SETCC [<your-convention-card>|<convention-card-name>]
  474. X       Enters one line of text as your convention card.  This card will
  475. X       then be announced to your partner and the opponents as the convention
  476. X       card for your team.  Omitting convention card from this command will
  477. X       cause your current convention card to be announced to your partner
  478. X       and opponents.  If you specify a single word convention card,
  479. X       and this word is the name of a convention card previously specified
  480. X       by the /CCDEF command, the convention card will be set to the card 
  481. X       which corresponds to the name given.
  482. X
  483. X     /SPEC [<player-name> | NORTH | EAST | SOUTH | WEST | NE | NS | NW |
  484. X           SE | SW | EW]
  485. X       Enters SPECTATOR mode.  In SPECTATOR mode, an observer can see the
  486. X       hands of the players, but the spectator is not allowed to talk.
  487. X       The parameters identify the hand(s) which are to be revealed to
  488. X       the spectator.  SPECTATOR mode is not available during formal play.
  489. X^
  490. X     /TALK message
  491. X       Sends a short message to the other players.  This command can be used
  492. X       when the program is waiting for you to enter a bid or a play.  
  493. X       Not needed if the word 'TALK' is displayed to the left of the cursor.
  494. X
  495. X     /WAKEUP [<player-name> | ALL]
  496. X       Sends a wakeup signal to the named player, or to all players if
  497. X       "ALL" is specified.  The wakeup signal rings the terminal bell and
  498. X       prints the words "WAKE UP" in the talk box.  If the name of the
  499. X       player is omitted, then the signal is sent to your partner.
  500. X
  501. X     /WHO
  502. X       Gives a short list of the other players and their respective seats.
  503. X
  504. X     /WHOIS [<player-name>]
  505. X       Inquires about a specific player.  If the player has listed his/her
  506. X       full name and email address in the .okbridgerc file, then this
  507. X       information is given.  If <player-name> is omitted, then inquires
  508. X       about both of the opponents.
  509. X
  510. X     /ZLOG [filename]
  511. X       Writes a more compact log file than the /LOG command.
  512. X--
  513. Xcontrols    Special control characters recognized by the program
  514. XSpecial control characters recognized by the program
  515. X------- ------- ---------- ---------- -- --- -------
  516. X
  517. X ^A   Alerts partner's last bid.
  518. X ^B   When used during the play of a hand, the bidding is displayed
  519. X      for review.
  520. X ^C   Quits the program.  (The program requests confirmation first.)
  521. X ^D   Toggles the default input mode.  See the /DEFAULT command.
  522. X ^G   Toggles the bell.  See the /BELL command.
  523. X ^P   Toggles the prompt.  See the /PROMPT command.
  524. X ^R   Refreshes the screen.
  525. X ^T   Switches between bidding/playing and talk mode.
  526. X ^U   Erases the current input.
  527. X ^W   Sends a wakeup signal to your partner.
  528. X ^X   Exits the program immediately (only if compiled in debug mode).
  529. X
  530. X TAB  Switches between bidding/playing and talk mode (same as ^T).
  531. X
  532. XIn addition, if you press RETURN without typing anything, the program will
  533. Xsupply a default input, which can then be entered by pressing RETURN again.
  534. X
  535. X--
  536. Xcopyright     Copyright notice for the program
  537. X                Copyright Notice
  538. X                    --------- ------
  539. X
  540. X          Copyright (C) 1990-1992 by Matthew Clegg
  541. X           All Rights Reserved
  542. X
  543. XOKbridge is made available as a free service to the Internet.
  544. XAccordingly, the following restrictions are placed on its use:
  545. X
  546. X1.  OKbridge may not be modified in any way without the explicit 
  547. X    permission of Matthew Clegg.  
  548. X
  549. X2.  OKbridge may not be used in any way for commercial advantage.
  550. X    It may not be placed on for-profit networks or on for-profit
  551. X    computer systems.  It may not be bundled as part of a package
  552. X    or service provided by a for-profit organization.
  553. X
  554. XIf you have questions about restrictions on the use of OKbridge,
  555. Xwrite to mclegg@cs.ucsd.edu.
  556. X
  557. XDISCLAIMER:  The user of OKbridge accepts full responsibility for any
  558. Xdamage which may be caused by OKbridge.
  559. X
  560. X--
  561. Xftp            Where okbridge can be obtained on the internet
  562. X
  563. X              Obtaining Okbridge
  564. X              --------- --------
  565. X
  566. XThe source code for okbridge can be obtained by anonymous ftp from the
  567. Xfollowing two locations.  These are the 'official' archive sites for
  568. Xokbridge, and so you will always be able to find the latest version here.
  569. XOkbridge is also available in the comp.sources.games archives.
  570. X
  571. X                     North America             Europe
  572. X                     ----- -------             ------
  573. X   Machine Name      suned.cs.yale.edu         nic.funet.fi
  574. X   IP Number         128.36.21.1               128.214.6.100
  575. X   Directory         pub/okbridge              pub/unix/games
  576. X   Filename          okbridge-1.7.tar.Z        okbridge-1.7A.tar.Z
  577. X
  578. X
  579. X--
  580. Xgps             Global Playing Service
  581. X
  582. XThe Global Playing Service (GPS) is a worldwide database of currently
  583. Xplaying tables.  In the near future, it will also be used for organizing
  584. Xcompetitive games.  The following commands can be used for accessing
  585. Xthe GPS:
  586. X
  587. X  /TABLES
  588. X    Lists the currently playing tables.
  589. X
  590. X  /JOIN [<name>]
  591. X    Joins the table being served by <name>.  If <name> is omitted,
  592. X    then the first table in the list provided by the /TABLES command
  593. X    is joined.
  594. X
  595. X  /SERVE
  596. X    Begins serving a table.  The table will be advertised to the GPS
  597. X    automatically, so that other players may join.
  598. X
  599. X^
  600. XThe Global Player Service also supports a form of duplicate play.   
  601. XIt maintains a database of boards which have been played by other 
  602. Xfoursomes.  These boards can be downloaded, played and scored competitively.
  603. X
  604. X  /DUP [MP|IMP|END]
  605. X    Used by the server to initiate (or end) GPS duplicate play.  The MP
  606. X    parameter is specified to play match point boards, while the IMP
  607. X    parameter is given to play IMP boards.  The default is IMP
  608. X    play.  After each board is downloaded and played, you will be able to
  609. X    see the results of play by other foursomes.
  610. X
  611. X  /RESULTS [<results-file>]
  612. X    Downloads all of the GPS duplicate boards which have been played by
  613. X    the local player.  The results of play for each board are then displayed.
  614. X    If <results-file> is specified, then the results are saved to the given
  615. X    file in email duplicate format.  A more verbose record of the play can
  616. X    then be produced with the oktally command.  WARNING:  If you play often,
  617. X    then you should specify the <results-file> and examine it using oktally.
  618. X
  619. X  /SCOREBOARD
  620. X    Displays the top ten scores in match point and IMP play.
  621. X^
  622. XIn addition, there are the following GPS-related commands:
  623. X
  624. X  /PLAYERS [<name>]
  625. X    Lists the names of all of the players currently at the table
  626. X    served by <name>.  If name is omitted, then lists the lists the
  627. X    players at all of the tables.
  628. X
  629. X  /CONNECT <host_name> [<port_number>]
  630. X    Connects to the table being served at <host_name> with port <port_number>.
  631. X    If <port_number> is omitted, then 1729 is assumed.
  632. X
  633. X  /PERISH
  634. X    Disconnects from the GPS.  If we are serving a table, this table
  635. X    is deleted from the GPS database.
  636. X
  637. X  /PUBLISH
  638. X    Reconnects to the GPS.  If we are serving a table, this table is
  639. X    re-advertised to the GPS.
  640. X--
  641. Xinput         General info about entering input
  642. X              How to Enter Input
  643. X              --- -- ----- -----
  644. X
  645. XDuring normal operation, the okbridge program is always in one of
  646. Xthree 'input modes'.  The input which you type is interpreted according
  647. Xto the input mode.  The input mode is displayed at the beginning of the 
  648. Xline containing the cursor.  The input modes are
  649. X
  650. XMode       Interpretation
  651. X----       --------------
  652. XBID       The program is expecting you to enter your bid.
  653. XPLAY       The program is expecting you to enter the card you wish to play.
  654. XTALK       Any text that you enter will be transmitted to the other players.
  655. X
  656. XAs you type your text, you may use the backspace key to erase the last
  657. Xcharacter.  Press the <TAB> key to switch between input modes.
  658. X
  659. XThere are number of commands which can be given to the program in any 
  660. Xinput mode.  For information on these commands, type '/help commands'.
  661. XAlso, there are a number of special control-characters which are
  662. Xrecognized by the program.  For information about these, type 
  663. X'/help controls.'
  664. X--
  665. Xmaillist        Information about the okbridge mailing lists
  666. X
  667. X              The Okbridge Mailing List
  668. X                      --- -------- ------- ----
  669. X
  670. X   The address of the OKbridge mailing list is
  671. X
  672. X     okbridge@cs.ucsd.edu
  673. X
  674. X   To subscribe to this list, send a message to listserv@cs.ucsd.edu 
  675. X   containing the single line
  676. X
  677. X     ADD okbridge
  678. X
  679. X   To cancel your subscription to the OKbridge mailing list, send a
  680. X   message to listserv@cs.ucsd.edu containing the single line
  681. X
  682. X     DELETE okbridge
  683. X
  684. X--
  685. Xplaying   Information about how to enter a play
  686. X              Information about Playing
  687. X              ----------- ----- -------
  688. X
  689. XA card is played by writing
  690. X     <suit> <rank> or <rank> <suit>
  691. X
  692. Xwhere
  693. X     <suit>  is one of C, D, H or S
  694. X     <rank>  is one of
  695. X         2, 3, ..., 9, T (for Ten), J (for Jack), Q (for Queen),
  696. X         K (for King), A (for Ace)
  697. X
  698. XIf the <suit> is omitted, then the lowest card of the specified <rank>
  699. Xis played.  Similarly, if the <rank> is omitted, then the lowest card in
  700. Xthe given <suit> is played.  In no trump contracts, the suits are ranked
  701. X  clubs < diamonds < hearts < spades.
  702. XFor suit contracts, the trump suit is always the highest ranked suit.
  703. X
  704. XExamples of legal plays:
  705. X  2C, 3D, H4, S6, TC, DJ, QH, SA, C, D, H, S, 2, 3, 9, T, J, K, Q, A
  706. X
  707. X--
  708. Xserver          Commands which can only be used by the server
  709. X
  710. X     /ASSIGN <player-name> NORTH|EAST|SOUTH|WEST|OBS
  711. X       Assigns a player to a given seat.  Can only be used before the
  712. X       first hand has been dealt or between hands.
  713. X
  714. X     /DISCONNECT <player-name>
  715. X       Closes the connection to the named player.  
  716. X       <player-name> can either be the name of a player (e.g., Worf)
  717. X       or the name of position (e.g., SOUTH).
  718. X
  719. X     /FORMAL [OFF|ON]
  720. X       Specifies whether formal playing rules will be used or queries which
  721. X       playing rules are currently use.  In formal play, talk messages
  722. X       are displayed only to the opponents, alerts are not displayed to the
  723. X       partner of the alerter, and the dummy is not revealed to anyone
  724. X       until the opening lead has been made.
  725. X
  726. X^
  727. X     /RESET
  728. X       Resets the program to its initial state. 
  729. X
  730. X     /SCORE RUBBER|DUPLICATE|MP|IMP|CLEAR
  731. X        Selects a scoring mode.  If the selected scoring mode is different 
  732. X        from the current scoring mode, then skips the current hand.  
  733. X        Using '/SCORE CLEAR' will clear the scoreboard.
  734. X
  735. X     /SKIP [n]
  736. X       Ends the current hand immediately, without recording a score for it.
  737. X       This command is useful in case the connection to one of the 
  738. X       players is lost.  The number n specifies a number of hands
  739. X       (including the current one) to skip.
  740. X
  741. X--
  742. Xslam          A special message when a slam is made
  743. X
  744. X
  745. X
  746. X
  747. X     Oh, what a beautiful mornin'!
  748. X     Oh, what a beautiful day!
  749. X     I got a beautiful feelin'
  750. X     Ev'rything's goin' my way.
  751. X     Oh, what a beautiful day.
  752. X
  753. X     ...
  754. X
  755. X              
  756. X          words by Oscar Hammerstein II
  757. X              from the musical, _Oklahoma_
  758. X
  759. X--
  760. Xstarting        How to start a bridge game using okbridge
  761. X
  762. XTo begin with, okbridge requires four players who wish to play bridge
  763. Xwith each other.  One of the players must volunteer to be the
  764. X'server.'  The 'server' will be the central communications point and
  765. Xalso will have control over some of the aspects of the game, such as
  766. Xthe type of scoring which will be used.  The server should provide to
  767. Xthe other players the internet name of the machine he/she will be
  768. Xusing.  
  769. X
  770. XTo begin the game, the server will generally type
  771. X  okbridge -n <name>
  772. Xwhere <name> is an eight character identifying name.  
  773. X
  774. XThe other players (called clients) will type
  775. X  okbridge -n <name> -s <server-machine>
  776. Xwhere <name> again is an eight character identifying name and
  777. X<server-machine> is the internet name of the machine which the
  778. Xserver is using.  If the server has already started okbridge,
  779. Xthen a connection should be established fairly quickly.
  780. X^
  781. X
  782. XAfter all of the players have connected, the players must choose
  783. Xseats.  The seats are named NORTH, EAST, SOUTH, WEST, with NORTH and
  784. XSOUTH being partners and EAST and WEST being partners.  Choose a
  785. Xseat by typing '/<seat>', where <seat> is the name of the seat
  786. Xyou would like to have.
  787. X
  788. XAfter the seats have been chosen, the server can deal the cards
  789. Xsimply by pressing RETURN.  From this point, the use of the program
  790. Xshould be fairly obvious.
  791. X
  792. X--
  793. Xstdam           Standard american conventions
  794. X            Standard American Conventions
  795. X            -------- -------- -----------
  796. X
  797. XA Standard American convention card always begins with the keyword SA.
  798. XThe next keyword on the convention card identifies the major bidding
  799. Xsystem you use:
  800. X
  801. XTrad        -- "Traditional" Standard American (This is the default)
  802. X           Follows _Goren's Bridge Complete_ by Charles Goren
  803. XGoren       -- Follows _Goren's New Bridge Complete_
  804. XYellow_Card -- Follows ACBL Standard Yellow Card System
  805. X
  806. XA series of modifiers may follow the keyword identifying the major
  807. Xsystem.  Modifiers can be negated by putting an exclamation point in
  808. Xfront, i.e., !Ger indicates that the Gerber convention is NOT in use.
  809. XPoint ranges can be specified by giving the range as in 1NT:15-17 and
  810. Xalso by giving the negation of the range as in Mic/Unu!11-15.  A plus
  811. Xsign '+' appearing just after the initial Standard American SA
  812. Xidentifier indicates that other conventions are used that could not be
  813. Xlisted on the convention card.
  814. X
  815. X^
  816. XThe following modifiers may be specified:
  817. X
  818. X5cm       -- Open with a 5-card major.
  819. X1NT:15-7  -- 15-17 hcp for a 1nt opening.
  820. XWk2, Str2 -- An opening 2 bid is weak (resp. strong).
  821. XStm       --*Stayman convention
  822. XGer       --*Gerber convention
  823. XRKC       --*Roman keycard blackwood
  824. XJac       --*Jacoby transfers
  825. XMic/Unu   --*Michaels and Unusual NT
  826. XNegX-3S   -- negative doubles through three spades.
  827. X2/1       -- two-over-one bids forcing to game.
  828. X2LU       -- 2 Lower Unbid (replacement for Unu)
  829. XInv       -- Inverted minors
  830. XSpl       -- Splinters
  831. XSPr       -- Suit preference discards
  832. XRCnt      -- Reverse Count
  833. X
  834. X* indicates that the bid is alertable.  Note that doubles and cue bids
  835. X  are not considered alertable.
  836. X
  837. X^
  838. XExample convention cards
  839. X
  840. XCC SA  Yellow_Card !Jac
  841. X  -- Specifies that the bidder follows the ACBL Yellow Card with the
  842. X     exception that Jacoby transfers are not used.
  843. X
  844. XCC SA  5cm 1NT:15-7 Wk2 Stm Ger RKC
  845. X  -- Specifies a bidding system which is traditional except that
  846. X     the bidder opens with a 5 card major, opens 2 of a suit with a weak
  847. X     hand, 1nt with 15-17 hcp, and uses Stayman Gerber and Roman Keycard
  848. X     Blackwood
  849. X     
  850. XCC SA+ 5cm 1NT:16-8 Wk2 Stm Jac Ger !RKC NegX-3S Mic/Unu!11-15
  851. X  -- Similar to above, except that Roman Keycard Blackwood is NOT used,
  852. X     negative doubles are allowed through 3S, and Michaels/Unusual no trump
  853. X     bids may be made except with a point count in the range 11-15.
  854. X     The plus sign after SA indicates that additional unlisted conventions
  855. X     are also used.
  856. X
  857. X
  858. X
  859. X
  860. END_OF_FILE
  861. if test 23044 -ne `wc -c <'okbridge.help'`; then
  862.     echo shar: \"'okbridge.help'\" unpacked with wrong size!
  863. fi
  864. # end of 'okbridge.help'
  865. fi
  866. if test -f 'protocol.c' -a "${1}" != "-c" ; then 
  867.   echo shar: Will not clobber existing file \"'protocol.c'\"
  868. else
  869. echo shar: Extracting \"'protocol.c'\" \(19876 characters\)
  870. sed "s/^X//" >'protocol.c' <<'END_OF_FILE'
  871. X/* command.c -- Command processor for communications between client
  872. X * and server.
  873. X *
  874. X ! Copyright (C) 1990-1992 by Matthew Clegg.  All Rights Reserved
  875. X ! 
  876. X ! OKbridge is made available as a free service to the Internet.
  877. X ! Accordingly, the following restrictions are placed on its use:
  878. X ! 
  879. X ! 1.  OKbridge may not be modified in any way without the explicit 
  880. X !     permission of Matthew Clegg.  
  881. X ! 
  882. X ! 2.  OKbridge may not be used in any way for commercial advantage.
  883. X !     It may not be placed on for-profit networks or on for-profit
  884. X !     computer systems.  It may not be bundled as part of a package
  885. X !     or service provided by a for-profit organization.
  886. X ! 
  887. X ! If you have questions about restrictions on the use of OKbridge,
  888. X ! write to mclegg@cs.ucsd.edu.
  889. X ! 
  890. X ! DISCLAIMER:  The user of OKbridge accepts full responsibility for any
  891. X ! damage which may be caused by OKbridge.
  892. X *
  893. X */
  894. X
  895. X#include <stdio.h>
  896. X#include <string.h>
  897. X#include <ctype.h>
  898. X
  899. X#define PROTOCOL
  900. X#include "types.h"
  901. X#include "protocol.h"
  902. X#include "state.h"
  903. X#include "parser.h"
  904. X
  905. X#ifdef GCC
  906. Xextern sscanf ();
  907. X#endif
  908. X
  909. Xvoid 
  910. X  Parse_ack (), 
  911. X  Parse_alert (), 
  912. X  Parse_begin (), 
  913. X  Parse_bid (), 
  914. X  Parse_board (),
  915. X  Parse_claim (),
  916. X  Parse_claimreq (),
  917. X  Parse_claimresp (),
  918. X  Parse_cc (), 
  919. X  Parse_comment (), 
  920. X  Parse_connerr (), 
  921. X  Parse_deal (),
  922. X  Parse_echo (), 
  923. X  Parse_email (),
  924. X  Parse_end (), 
  925. X  Parse_fullname (),
  926. X  Parse_hello (), 
  927. X  Parse_mode (),
  928. X  Parse_name (), 
  929. X  Parse_ping (), 
  930. X  Parse_play (), 
  931. X  Parse_playreq (),
  932. X  Parse_quit (), 
  933. X  Parse_reconnect (),
  934. X  Parse_record (),
  935. X  Parse_registry (),
  936. X  Parse_reset (),
  937. X  Parse_seat (), 
  938. X  Parse_seaterr (), 
  939. X  Parse_seatpos (), 
  940. X  Parse_seatreq (),
  941. X  Parse_servereq (),
  942. X  Parse_score (), 
  943. X  Parse_skip (), 
  944. X  Parse_skipack (),
  945. X  Parse_spec (),
  946. X  Parse_table (),
  947. X  Parse_tablereq (),
  948. X  Parse_talk (), 
  949. X  Parse_userec (),
  950. X  Parse_wakeup (),
  951. X  Parse_who (), 
  952. X  Parse_whois (), 
  953. X  Parse_whoresp ();
  954. X
  955. Xstatic Command_Descriptor Commands [] = {
  956. X  {"ACK",    {{F_NAME, "<player-name>"}, 
  957. X          {F_KEYWORD | F_OPTIONAL, PARSER_SEATS}, NOP},  Parse_ack},
  958. X  {"ALERT",  C_KEY("OPP|ALL"), Parse_alert},
  959. X  {"BEGIN",  C_EMPTY, Parse_begin},
  960. X  {"BID",    {{F_BID, "<bid-name>"}, {F_KEYWORD | F_OPTIONAL, "ALERT"},
  961. X        NOP}, Parse_bid},
  962. X  {"BOARD",  {{F_NAME, "<board-name>"}, {F_INT, "<board-number>"}, NOP},
  963. X              Parse_board},
  964. X
  965. X  {"CC",     C_PARAM(F_STRING, "<convention-card>"), Parse_cc},
  966. X  {"CLAIM",  C_INT("<no-tricks>"), Parse_claim},
  967. X  {"CLAIMREQ",  C_INT("<no-tricks>"), Parse_claimreq},
  968. X  {"CLAIMRESP", C_KEY("REJECT|ACCEPT"), Parse_claimresp},
  969. X  {"COMMENT",C_STRING("<message>"), Parse_comment},
  970. X
  971. X  {"CONNERR",C_STRING("<error-message>"), Parse_connerr},
  972. X  {"DEAL",   C_EMPTY, Parse_deal},
  973. X  {"ECHO",   C_PARAM(F_NAME, "<ping-source>"), Parse_echo},
  974. X  {"EMAIL",  C_STRING("<email-address>"), Parse_email},
  975. X  {"END",    C_EMPTY, Parse_end},
  976. X
  977. X  {"FULLNAME", C_STRING("<full-name>"), Parse_fullname},
  978. X  {"HELLO",  {{F_NAME, "<version>"}, {F_NAME, "<player-name>"}, 
  979. X          {F_KEYWORD | F_OPTIONAL, PARSER_SEATS}}, Parse_hello},
  980. X  {"MODE",   C_KEY("CLUB|PRACTICE|FORMAL"), Parse_mode},
  981. X  {"NAME",   C_PARAM(F_NAME, "<new-player-name>"), Parse_name},
  982. X  {"PING",   C_EMPTY, Parse_ping},
  983. X
  984. X  {"PLAY",   C_PARAM(F_CARD, "<card-name>"), Parse_play},
  985. X  {"PLAYREQ", {{F_CARD, "<card-name>"}, {F_INT, "<sequence-number>"}, NOP}, 
  986. X     Parse_play},
  987. X  {"QUIT",   C_EMPTY, Parse_quit},
  988. X  {"RECONNECT", {{F_NAME, "<ip-number>"}, {F_INT, "<port-number>"},
  989. X           {F_KEYWORD, PARSER_SEATS}}, Parse_reconnect},
  990. X  {"RECORD", {{F_NAME, "<board-name>"}, {F_INT, "<board-number>"}, NOP}, 
  991. X              Parse_record},
  992. X
  993. X  {"REGISTRY", C_PARAM(F_NAME, "<identification>"), Parse_registry},
  994. X  {"RESET",  C_EMPTY, Parse_reset},
  995. X  {"SCORE",  {{F_STRING, "<current-scores>"}, NOP, NOP}, Parse_score},
  996. X  {"SEAT",   {{F_KEYWORD, PARSER_SEATS}, {F_KEYWORD, PARSER_SEATS},
  997. X        {F_NAME, "<player-name>"}}, Parse_seat},
  998. X  {"SEATERR",{{F_KEYWORD | F_OPTIONAL, PARSER_SEATS},
  999. X              {F_KEYWORD | F_OPTIONAL, PARSER_SEATS},
  1000. X          {F_KEYWORD | F_OPTIONAL, PARSER_SEATS}}, Parse_seaterr},
  1001. X
  1002. X  {"SEATPOS", {{F_KEYWORD, PARSER_SEATS}, NOP, NOP}, Parse_seatpos},
  1003. X  {"SEATREQ", C_SEAT, Parse_seatreq},
  1004. X  {"SERVEREQ",C_PARAM(F_STRING, "<server-command>"), Parse_servereq},
  1005. X  {"SKIP",    C_EMPTY, Parse_skip},
  1006. X  {"SKIPACK",C_EMPTY, Parse_skipack},
  1007. X
  1008. X  {"SPEC",   C_EMPTY, Parse_spec},
  1009. X  {"TABLE",    C_INT("<table-number>"), Parse_table},
  1010. X  {"TABLEREQ", C_INT("<requested-table-number>"), Parse_tablereq},
  1011. X  {"TALK",   {{F_KEYWORD, "LHO|RHO|OPPS|SPEC|ALL"}, {F_STRING, "<message>"}, 
  1012. X        NOP}, Parse_talk},
  1013. X  {"USEREC", {{F_STRING, "<player-names>"}, NOP, NOP}, Parse_userec},
  1014. X
  1015. X  {"WAKEUP", C_PARAM(F_NAME, "<player-name> | ALL"), Parse_wakeup},
  1016. X  {"WHO",    C_EMPTY, Parse_who},
  1017. X  {"WHOIS",  C_PARAM(F_NAME, "<player-name>"), Parse_whois},
  1018. X  {"WHORESP",{{F_NAME, "<recipient>"}, {F_STRING, "<ident>"}, NOP},
  1019. X     Parse_whoresp},
  1020. X  END_PARSE_TABLE
  1021. X};
  1022. X
  1023. X
  1024. Xstatic char send_buffer [132];
  1025. Xstatic player_command p;
  1026. X
  1027. Xvoid Send_ack (t, player_name, pos)
  1028. X     Table_ptr t; name_buffer player_name; int pos;
  1029. X{
  1030. X  sprintf (send_buffer, "ACK %s %s", player_name,
  1031. X       (pos < 4)? seat_names[pos]: "");
  1032. X  send_message (t, CMD_ACK, send_buffer);
  1033. X}
  1034. X
  1035. Xvoid Send_alert (t, notify_partner)
  1036. X     Table_ptr t; int notify_partner;
  1037. X{
  1038. X  sprintf (send_buffer, "ALERT %s", notify_partner? "ALL": "OPP");
  1039. X  send_message (t, CMD_ALERT, send_buffer);
  1040. X}
  1041. X
  1042. Xvoid Send_begin (t)
  1043. X     Table_ptr t;
  1044. X{
  1045. X  send_message (t, CMD_BEGIN, "BEGIN");
  1046. X}
  1047. X
  1048. Xvoid Send_bid (t, bid, alert)
  1049. X     Table_ptr t;
  1050. X     int bid;
  1051. X     int alert;
  1052. X{
  1053. X  sprintf (send_buffer, "BID %s %s", bid_names[bid],  alert? "ALERT": "");
  1054. X  send_message (t, CMD_BID, send_buffer);
  1055. X}
  1056. X
  1057. Xvoid Send_board (t, b)
  1058. X     Table_ptr t; board_ptr b;
  1059. X{
  1060. X  Message m;
  1061. X
  1062. X  sprintf (send_buffer, "BOARD %s %d", b->source, b->serial_no);
  1063. X  m = send_message (t, CMD_BOARD, send_buffer);
  1064. X  m->p.data.board.record = b;
  1065. X  if (client_mode) 
  1066. X    Transmit_board (t, b);
  1067. X  
  1068. X}
  1069. X
  1070. Xvoid Send_claim (t, no_tricks)
  1071. X     Table_ptr t; int no_tricks;
  1072. X{
  1073. X  sprintf (send_buffer, "CLAIM %d", no_tricks);
  1074. X  send_message (t, CMD_CLAIM, send_buffer);
  1075. X}
  1076. X
  1077. Xvoid Send_claimreq (t, no_tricks)
  1078. X     Table_ptr t; int no_tricks;
  1079. X{
  1080. X  sprintf (send_buffer, "CLAIMREQ %d", no_tricks);
  1081. X  send_message (t, CMD_CLAIMREQ, send_buffer);
  1082. X}
  1083. X
  1084. Xvoid Send_claimresp (t, resp)
  1085. X     Table_ptr t; int resp;
  1086. X{
  1087. X  sprintf (send_buffer, "CLAIMRESP %s", resp? "ACCEPT": "REJECT");
  1088. X  send_message (t, CMD_CLAIMRESP, send_buffer);
  1089. X}
  1090. X
  1091. Xvoid Send_cc (t, convention_card)
  1092. X     Table_ptr t; char *convention_card;
  1093. X{
  1094. X  sprintf (send_buffer, "CC %s", convention_card);
  1095. X  send_message (t, CMD_CC, send_buffer);
  1096. X}
  1097. X
  1098. Xvoid Send_comment (t, comment)
  1099. X     Table_ptr t; message_buffer comment;
  1100. X{
  1101. X  sprintf (send_buffer, "COMMENT %s", comment);
  1102. X  send_message (t, CMD_COMMENT, send_buffer);
  1103. X}
  1104. X
  1105. Xvoid Send_deal (t)
  1106. X     Table_ptr t;
  1107. X{
  1108. X  send_message (t, CMD_DEAL, "DEAL");
  1109. X}
  1110. X
  1111. Xvoid Send_echo (t, ping_source)
  1112. X     Table_ptr t; name_buffer ping_source;
  1113. X{
  1114. X  sprintf (send_buffer, "ECHO %s", ping_source);
  1115. X  send_message (t, CMD_ECHO, send_buffer);
  1116. X}
  1117. X
  1118. Xvoid Send_email (t, email_addr)
  1119. X     Table_ptr t; char *email_addr;
  1120. X{
  1121. X  sprintf (send_buffer, "EMAIL %s", email_addr);
  1122. X  send_message (t, CMD_EMAIL, send_buffer);
  1123. X}
  1124. X
  1125. Xvoid Send_end (t)
  1126. X     Table_ptr t;
  1127. X{
  1128. X  send_message (t, CMD_END, "END");
  1129. X}
  1130. X
  1131. Xvoid Send_fullname (t, fullname)
  1132. X     Table_ptr t; message_buffer fullname;
  1133. X{
  1134. X  sprintf (send_buffer, "FULLNAME %s", fullname);
  1135. X  send_message (t, CMD_FULLNAME, send_buffer);
  1136. X}
  1137. X
  1138. Xvoid Send_hello (t, version, player_name, seat_pos)
  1139. X     Table_ptr t; name_buffer version, player_name; int seat_pos;
  1140. X{
  1141. X  sprintf (send_buffer, "HELLO %s %s %s", version, player_name,
  1142. X       (seat_pos < 4)? seat_names[seat_pos]: "OBS");
  1143. X  send_message (t, CMD_HELLO, send_buffer);
  1144. X}
  1145. X
  1146. Xvoid Send_mode (t, m)
  1147. X     Table_ptr t; int m;
  1148. X{
  1149. X  switch (m) {
  1150. X  case CLUB_PLAYING_MODE: 
  1151. X    send_message (t, CMD_MODE, "MODE CLUB");
  1152. X    break;
  1153. X  case PRACTICE_PLAYING_MODE:
  1154. X    send_message (t, CMD_MODE, "MODE PRACTICE");
  1155. X    break;
  1156. X  case FORMAL_PLAYING_MODE:
  1157. X    send_message (t, CMD_MODE, "MODE FORMAL");
  1158. X    break;
  1159. X  }
  1160. X}
  1161. X
  1162. Xvoid Send_name (t, n)
  1163. X     Table_ptr t; char *n;
  1164. X{
  1165. X  sprintf (send_buffer, "NAME %s", n);
  1166. X  send_message (t, CMD_NAME, send_buffer);
  1167. X}
  1168. X
  1169. Xvoid Send_ping (t)
  1170. X     Table_ptr t;
  1171. X{
  1172. X  send_message (t, CMD_PING, "PING");
  1173. X}
  1174. X
  1175. Xvoid Send_play (t, play)
  1176. X     Table_ptr t; int play;
  1177. X{
  1178. X  sprintf (send_buffer, "PLAY %s", card_names[play]);
  1179. X  send_message (t, CMD_PLAY, send_buffer);
  1180. X}
  1181. X
  1182. Xvoid Send_playreq (t, play, playno)
  1183. X     Table_ptr t; int play, playno;
  1184. X{
  1185. X  sprintf (send_buffer, "PLAYREQ %s %d", card_names[play], playno);
  1186. X  send_message (t, CMD_PLAYREQ, send_buffer);
  1187. X}
  1188. X
  1189. Xvoid Send_quit (t)
  1190. X     Table_ptr t;
  1191. X{
  1192. X  send_message (t, CMD_QUIT, "QUIT");
  1193. X}
  1194. X
  1195. Xvoid Send_reconnect (t, c, ip, port, seat)
  1196. X     Table_ptr t;
  1197. X     Connection c;
  1198. X     char *ip;
  1199. X     int port;
  1200. X     int seat;
  1201. X{
  1202. X  sprintf (send_buffer, "RECONNECT %s %d %s", ip, port, seat_names[seat]);
  1203. X  send_private_message (c, send_buffer);
  1204. X}
  1205. X
  1206. Xvoid Send_record (t, b, p)
  1207. X     Table_ptr t;
  1208. X     board_ptr b;
  1209. X     play_ptr p;
  1210. X{
  1211. X  Message m;
  1212. X
  1213. X  sprintf (send_buffer, "RECORD %s %d", b->source, b->serial_no);
  1214. X  m = send_message (t, CMD_RECORD, send_buffer);
  1215. X  m->p.data.record.play = p;
  1216. X  if (client_mode)
  1217. X    Transmit_play_record (t, p);
  1218. X
  1219. X}
  1220. X
  1221. Xvoid Send_registry (t, id)
  1222. X     Table_ptr t; char *id;
  1223. X{
  1224. X  sprintf (send_buffer, "REGISTRY %s", id);
  1225. X  send_message (t, CMD_REGISTRY, send_buffer);
  1226. X}
  1227. X
  1228. Xvoid Send_reset (t)
  1229. X     Table_ptr t;
  1230. X{
  1231. X  send_message (t, CMD_RESET, "RESET");
  1232. X}
  1233. X
  1234. Xvoid Send_score (t, above, below)
  1235. X     Table_ptr t; int above[]; int below[];
  1236. X{
  1237. X  sprintf (send_buffer, "SCORE %d %d %d %d",
  1238. X       above[0], above[1], below[0], below[1]);
  1239. X  send_server_message (t, CMD_SCORE, send_buffer);
  1240. X}
  1241. X
  1242. Xvoid Send_seat (t, oldseat, newseat, name)
  1243. X     Table_ptr t; int oldseat, newseat; char *name; 
  1244. X{
  1245. X  sprintf (send_buffer, "SEAT %s %s %s", seat_names[oldseat], 
  1246. X       seat_names[newseat], name);
  1247. X  send_message (t, CMD_SEAT, send_buffer);
  1248. X}
  1249. X
  1250. Xvoid Send_seaterr (t, message)
  1251. X     Table_ptr t; message_buffer message;
  1252. X{
  1253. X  sprintf (send_buffer, "SEATERR %s", message);
  1254. X  send_message (t, CMD_SEATERR, send_buffer);
  1255. X}
  1256. X
  1257. Xvoid Send_seatreq (t, seat)
  1258. X     Table_ptr t; int seat;
  1259. X{
  1260. X  sprintf (send_buffer, "SEATREQ %s", seat_names[seat]);
  1261. X  send_message (t, CMD_SEAT, send_buffer);
  1262. X}
  1263. X
  1264. Xvoid Send_servereq (t, request)
  1265. X     Table_ptr t; char *request;
  1266. X{
  1267. X  sprintf (send_buffer, "SERVEREQ %s", request);
  1268. X  send_message (t, CMD_SERVEREQ, send_buffer);
  1269. X}
  1270. X
  1271. Xvoid Send_skip (t)
  1272. X     Table_ptr t;
  1273. X{
  1274. X  send_message (t, CMD_SKIP, "SKIP");
  1275. X}
  1276. X
  1277. Xvoid Send_skipack (t)
  1278. X     Table_ptr t;
  1279. X{
  1280. X  send_message (t, CMD_SKIPACK, "SKIPACK");
  1281. X}
  1282. X
  1283. Xvoid Send_spec (t)
  1284. X     Table_ptr t;
  1285. X{
  1286. X  send_message (t, CMD_SPEC, "SPEC");
  1287. X}
  1288. X
  1289. Xvoid Send_table (t, c, table_no)
  1290. X     Table_ptr t;
  1291. X     Connection c;
  1292. X     int table_no;
  1293. X{
  1294. X  sprintf (send_buffer, "TABLE %d", table_no);
  1295. X  send_private_message (c, send_buffer);
  1296. X}
  1297. X
  1298. Xvoid Send_tablereq (t, table_no)
  1299. X     Table_ptr t;
  1300. X     int table_no;
  1301. X{
  1302. X  sprintf (send_buffer, "TABLEREQ %d", table_no);
  1303. X  send_message (t, CMD_TABLEREQ, send_buffer);
  1304. X}
  1305. X
  1306. Xstatic char *talk_rcpts [] = {"LHO", "RHO", "OPPS", "SPEC", "ALL"};
  1307. X
  1308. Xvoid Send_talk (t, destination, message)
  1309. X     Table_ptr t; int destination; message_buffer message;
  1310. X{
  1311. X
  1312. X  sprintf (send_buffer, "TALK %s %s", talk_rcpts[destination], message);
  1313. X  send_message (t, CMD_TALK, send_buffer);
  1314. X}
  1315. X
  1316. Xvoid Send_userec (t, n, e, s, w)
  1317. X     Table_ptr t;
  1318. X     char *n;
  1319. X     char *e;
  1320. X     char *s;
  1321. X     char *w;
  1322. X{
  1323. X  sprintf (send_buffer, "USEREC %s %s %s %s", n, e, s, w);
  1324. X  send_message (t, CMD_USEREC, send_buffer);
  1325. X}
  1326. X
  1327. Xvoid Send_wakeup (t, p)
  1328. X     Table_ptr t; char *p;
  1329. X{
  1330. X  sprintf (send_buffer, "WAKEUP %s", p);
  1331. X  send_message (t, CMD_WAKEUP, send_buffer);
  1332. X}
  1333. X
  1334. Xvoid Send_who (t)
  1335. X     Table_ptr t;
  1336. X{
  1337. X  send_message (t, CMD_WHO, "WHO");
  1338. X}
  1339. X
  1340. Xvoid Send_whois (t, p)
  1341. X     Table_ptr t; char *p;
  1342. X{
  1343. X  sprintf (send_buffer, "WHOIS %s", p);
  1344. X  send_message (t, CMD_WHOIS, send_buffer);
  1345. X}
  1346. X
  1347. Xvoid Send_whoresp (t, r, i)
  1348. X     Table_ptr t; char *r, *i;
  1349. X{
  1350. X  sprintf (send_buffer, "WHORESP %s %s", r, i);
  1351. X  send_message (t, CMD_WHORESP, send_buffer);
  1352. X}
  1353. X
  1354. Xvoid Parse_ack (player_name, pos)
  1355. X     char *player_name; int *pos;
  1356. X{
  1357. X  p->command = CMD_ACK;
  1358. X  Lcopy (player_name, p->data.ack.player_name, NAME_LENGTH);
  1359. X  p->data.ack.position = (pos == NULL)? 4: *pos;
  1360. X}
  1361. X
  1362. Xvoid Parse_alert (notify_all)
  1363. X     int *notify_all;
  1364. X{
  1365. X  p->command = CMD_ALERT;
  1366. X  p->data.alert = *notify_all;
  1367. X}
  1368. X
  1369. Xvoid Parse_begin ()
  1370. X{
  1371. X  p->command = CMD_BEGIN;
  1372. X}
  1373. X
  1374. Xvoid Parse_bid (bid, alert)
  1375. X     int *bid, *alert;
  1376. X{
  1377. X  p->command = CMD_BID;
  1378. X  p->data.bid.level = *bid;
  1379. X  p->data.bid.alert = (alert == NULL)? 0: 1;
  1380. X}
  1381. X
  1382. Xvoid Parse_board (name, no)
  1383. X     char *name; int *no;
  1384. X{
  1385. X  p->command = CMD_BOARD;
  1386. X  Lcopy (name, p->data.board.board_name, NAME_LENGTH);
  1387. X  p->data.board.board_no = *no;
  1388. X}
  1389. X
  1390. Xvoid Parse_cc (convention_card)
  1391. X     char *convention_card;
  1392. X{
  1393. X  p->command = CMD_CC;
  1394. X  Lcopy (convention_card, p->data.cc, MESSAGE_LENGTH);
  1395. X}
  1396. X
  1397. Xvoid Parse_claim (no_tricks)
  1398. X     int *no_tricks;
  1399. X{
  1400. X  p->command = CMD_CLAIM;
  1401. X  p->data.claim.no_tricks = *no_tricks;
  1402. X}
  1403. X
  1404. Xvoid Parse_claimreq (no_tricks)
  1405. X     int *no_tricks;
  1406. X{
  1407. X  p->command = CMD_CLAIMREQ;
  1408. X  p->data.claimreq.no_tricks = *no_tricks;
  1409. X}
  1410. X
  1411. Xvoid Parse_claimresp (resp)
  1412. X     int *resp;
  1413. X{
  1414. X  p->command = CMD_CLAIMRESP;
  1415. X  p->data.claimresp = *resp;
  1416. X}
  1417. X
  1418. Xvoid Parse_comment (message)
  1419. X     char *message;
  1420. X{
  1421. X  p->command = CMD_COMMENT;
  1422. X  Lcopy (message, p->data.comment, MESSAGE_LENGTH);
  1423. X}
  1424. X
  1425. Xvoid Parse_connerr (message)
  1426. X     char *message;
  1427. X{
  1428. X  p->command = CMD_CONNERR;
  1429. X  Lcopy (message, p->data.connerr, MESSAGE_LENGTH);
  1430. X}
  1431. X
  1432. Xvoid Parse_deal ()
  1433. X{
  1434. X  p->command = CMD_DEAL;
  1435. X}
  1436. X
  1437. Xvoid Parse_echo (ping_source)
  1438. X     char *ping_source;
  1439. X{
  1440. X  p->command = CMD_ECHO;
  1441. X  Lcopy (ping_source, p->data.echo.ping_source, NAME_LENGTH);
  1442. X}
  1443. X
  1444. Xvoid Parse_email (email_addr)
  1445. X     char *email_addr;
  1446. X{
  1447. X  p->command = CMD_EMAIL;
  1448. X  Lcopy (email_addr, p->data.email.addr, MESSAGE_LENGTH);
  1449. X}
  1450. X
  1451. Xvoid Parse_end ()
  1452. X{
  1453. X  p->command = CMD_END;
  1454. X}
  1455. X
  1456. Xvoid Parse_fullname (fullname)
  1457. X     char *fullname;
  1458. X{
  1459. X  p->command = CMD_FULLNAME;
  1460. X  Lcopy (fullname, p->data.fullname.name, MESSAGE_LENGTH);
  1461. X}
  1462. X
  1463. Xvoid Parse_hello (version, player_name, pos)
  1464. X     char *version, *player_name; int *pos;
  1465. X{
  1466. X  p->command = CMD_HELLO;
  1467. X  Lcopy (version, p->data.hello.version, NAME_LENGTH);
  1468. X  Lcopy (player_name, p->data.hello.player_name, NAME_LENGTH);
  1469. X  p->data.hello.seat_req = (pos == NULL)? 4: *pos;
  1470. X}
  1471. X
  1472. Xvoid Parse_mode (m)
  1473. X     int *m;
  1474. X{
  1475. X  p->command = CMD_MODE;
  1476. X  p->data.mode = *m;
  1477. X}
  1478. X
  1479. Xvoid Parse_name (c)
  1480. X     char *c;
  1481. X{
  1482. X  p->command = CMD_NAME;
  1483. X  Lcopy (c, p->data.name.new_name, NAME_LENGTH);
  1484. X}
  1485. X
  1486. Xvoid Parse_ping ()
  1487. X{
  1488. X  p->command = CMD_PING;
  1489. X}
  1490. X
  1491. Xvoid Parse_play (play)
  1492. X     int *play;
  1493. X{
  1494. X  p->command = CMD_PLAY;
  1495. X  p->data.play = *play;
  1496. X}
  1497. X
  1498. Xvoid Parse_playreq (play, seqno)
  1499. X     int *play, *seqno;
  1500. X{
  1501. X  p->command = CMD_PLAYREQ;
  1502. X  p->data.playreq.card = *play;
  1503. X  p->data.playreq.play_no = *seqno;
  1504. X}
  1505. X
  1506. Xvoid Parse_quit ()
  1507. X{
  1508. X  p->command = CMD_QUIT;
  1509. X}
  1510. X
  1511. Xvoid Parse_reconnect (ip, port, seat)
  1512. X     char *ip; int *port; int *seat;
  1513. X{
  1514. X  p->command = CMD_RECONNECT;
  1515. X  Lcopy (ip, p->data.reconnect.ip, NAME_LENGTH);
  1516. X  p->data.reconnect.port = *port;
  1517. X  p->data.reconnect.seat = *seat;
  1518. X}
  1519. X
  1520. X
  1521. Xvoid Parse_record (name, no)
  1522. X     char *name; int *no;
  1523. X{
  1524. X  p->command = CMD_RECORD;
  1525. X  Lcopy (name, p->data.record.board_name, NAME_LENGTH);
  1526. X  p->data.record.board_no = *no;
  1527. X  p->data.record.play = NULL;
  1528. X}
  1529. X
  1530. Xvoid Parse_registry (id)
  1531. X     char *id;
  1532. X{
  1533. X  p->command = CMD_REGISTRY;
  1534. X  Lcopy (id, p->data.registry.id, MESSAGE_LENGTH);
  1535. X}
  1536. X
  1537. Xvoid Parse_reset ()
  1538. X{
  1539. X  p->command = CMD_RESET;
  1540. X}
  1541. X
  1542. Xvoid Parse_seat (old, new, name)
  1543. X     int *old, *new; char *name;
  1544. X{
  1545. X  p->command = CMD_SEAT;
  1546. X  p->data.seat.old_pos = *old;
  1547. X  p->data.seat.new_pos = *new;
  1548. X  Lcopy (name, p->data.seat.player_name, NAME_LENGTH);
  1549. X}
  1550. X
  1551. Xvoid Parse_seaterr (free0, free1, free2)
  1552. X     int *free0, *free1, *free2;
  1553. X{
  1554. X  p->command = CMD_SEATERR;
  1555. X  p->data.seaterr.free_seats[0] = (free0 == NULL)? 4: *free0;
  1556. X  p->data.seaterr.free_seats[1] = (free1 == NULL)? 4: *free1;
  1557. X  p->data.seaterr.free_seats[2] = (free2 == NULL)? 4: *free2;
  1558. X}
  1559. X
  1560. Xvoid Parse_seatpos (s)
  1561. X     int *s;
  1562. X{
  1563. X  p->command = CMD_SEATPOS;
  1564. X  p->data.seatpos = *s;
  1565. X}
  1566. X
  1567. Xvoid Parse_seatreq (s)
  1568. X     int *s;
  1569. X{
  1570. X  p->command = CMD_SEATREQ;
  1571. X  p->data.seatreq = *s;
  1572. X}
  1573. X
  1574. Xvoid Parse_score (current_scores)
  1575. X     char *current_scores;
  1576. X{
  1577. X  p->command = CMD_SCORE;
  1578. X  sscanf (current_scores, "%d %d %d %d", 
  1579. X      p->data.score.above + 0, p->data.score.above + 1,
  1580. X      p->data.score.below + 0, p->data.score.below + 1);
  1581. X}
  1582. X
  1583. Xvoid Parse_servereq (request)
  1584. X     char *request;
  1585. X{
  1586. X  p->command = CMD_SERVEREQ;
  1587. X  Lcopy (request, p->data.servereq.command, MESSAGE_LENGTH);
  1588. X}
  1589. X
  1590. Xvoid Parse_skip ()
  1591. X{
  1592. X  p->command = CMD_SKIP;
  1593. X}
  1594. X
  1595. Xvoid Parse_skipack ()
  1596. X{
  1597. X  p->command = CMD_SKIPACK;
  1598. X}
  1599. X
  1600. Xvoid Parse_spec ()
  1601. X{
  1602. X  p->command = CMD_SPEC;
  1603. X}
  1604. X
  1605. Xvoid Parse_table (table_no)
  1606. X     int *table_no;
  1607. X{
  1608. X  p->command = CMD_TABLE;
  1609. X  p->data.table = *table_no;
  1610. X}
  1611. X
  1612. Xvoid Parse_tablereq (table_no)
  1613. X     int *table_no;
  1614. X{
  1615. X  p->command = CMD_TABLEREQ;
  1616. X  p->data.tablereq = *table_no;
  1617. X}
  1618. X
  1619. Xvoid Parse_talk (recpts, message)
  1620. X     int *recpts; char *message;
  1621. X{
  1622. X  p->command = CMD_TALK;
  1623. X  p->data.talk.recipients = *recpts;
  1624. X  Lcopy (message, p->data.talk.message, MESSAGE_LENGTH);
  1625. X}
  1626. X
  1627. Xvoid Parse_userec (player_names)
  1628. X     char *player_names;
  1629. X{
  1630. X  char north_buf[80], east_buf[80], south_buf[80], west_buf[80];
  1631. X
  1632. X  p->command = CMD_USEREC;
  1633. X  sscanf (player_names, "%s %s %s %s", north_buf, east_buf, 
  1634. X      south_buf, west_buf);
  1635. X  Lcopy (north_buf, p->data.userec.north, NAME_LENGTH);
  1636. X  Lcopy (east_buf,  p->data.userec.east,  NAME_LENGTH);
  1637. X  Lcopy (south_buf, p->data.userec.south, NAME_LENGTH);
  1638. X  Lcopy (west_buf,  p->data.userec.west,  NAME_LENGTH);
  1639. X}
  1640. X
  1641. Xvoid Parse_wakeup (c)
  1642. X     char *c;
  1643. X{
  1644. X  p->command = CMD_WAKEUP;
  1645. X  Lcopy (c, p->data.wakeup.recipient, NAME_LENGTH);
  1646. X}
  1647. X
  1648. Xvoid Parse_who ()
  1649. X{
  1650. X  p->command = CMD_WHO;
  1651. X}
  1652. X
  1653. Xvoid Parse_whois (n)
  1654. X     char *n;
  1655. X{
  1656. X  p->command = CMD_WHOIS;
  1657. X  Lcopy (n, p->data.whois.name, NAME_LENGTH);
  1658. X}
  1659. X
  1660. Xvoid Parse_whoresp (r, i)
  1661. X     char *r, *i;
  1662. X{
  1663. X  p->command = CMD_WHORESP;
  1664. X  Lcopy (r, p->data.whoresp.recipient, NAME_LENGTH);
  1665. X  Lcopy (i, p->data.whoresp.message, MESSAGE_LENGTH);
  1666. X}
  1667. X
  1668. Xint Parse_Command_for_Client (pc)
  1669. X     player_command pc;
  1670. X{
  1671. X  int i, n;
  1672. X  p = pc;
  1673. X
  1674. X  switch (p->command_text[0]) {
  1675. X  case 'N':
  1676. X    p->player_no = PLAYER_NORTH; break;
  1677. X  case 'E':
  1678. X    p->player_no = PLAYER_EAST;  break;
  1679. X  case 'S':
  1680. X    p->player_no = PLAYER_SOUTH; break;
  1681. X  case 'W':
  1682. X    p->player_no = PLAYER_WEST;  break;
  1683. X  case 'M':
  1684. X    p->player_no = PLAYER_SERVER; break;
  1685. X  case 'O':
  1686. X    p->player_no = PLAYER_OBS;   break;
  1687. X  default:
  1688. X    p->command = CMD_ERROR;
  1689. X    sprintf (p->data.error.message, 
  1690. X         "ERROR IN MESSAGE SOURCE");
  1691. X    return (-1);
  1692. X  }
  1693. X
  1694. X  i = 2;
  1695. X  while ((p->command_text[i] != '\0') && !isspace(p->command_text[i])) i++;
  1696. X  while ((p->command_text[i] != '\0') && isspace(p->command_text[i])) i++;
  1697. X  n = 0;
  1698. X  while (p->command_text[i] && !isspace(p->command_text[i])) {
  1699. X    if (n < NAME_LENGTH-1)
  1700. X      p->player_name[n++] = p->command_text[i];
  1701. X    i++;
  1702. X  }
  1703. X  p->player_name[n] = '\0';
  1704. X
  1705. X  if (Parse_Command (Commands, CMD_MAX-1, p->command_text+i)) {
  1706. X    p->command = CMD_ERROR;
  1707. X    Lcopy (Parser_Error_Buf, p->data.error.message, MESSAGE_LENGTH);
  1708. X    return (-1);
  1709. X  }
  1710. X  return (0);
  1711. X
  1712. X}
  1713. X
  1714. Xint Parse_Command_for_Server (pc)
  1715. X     player_command pc;
  1716. X{
  1717. X  int i, n;
  1718. X  p = pc;
  1719. X
  1720. X  i = 0;
  1721. X  while ((p->command_text[i] != '\0') && isspace(p->command_text[i])) i++;
  1722. X  n = 0;
  1723. X  while (p->command_text[i] && !isspace(p->command_text[i])) {
  1724. X    if (n < NAME_LENGTH-1)
  1725. X      p->player_name[n++] = p->command_text[i];
  1726. X    i++;
  1727. X  }
  1728. X  p->player_name[n] = '\0';
  1729. X
  1730. X  if (Parse_Command (Commands, CMD_MAX-1, p->command_text+i)) {
  1731. X    p->command = CMD_ERROR;
  1732. X    Lcopy (Parser_Error_Buf, p->data.error.message, MESSAGE_LENGTH);
  1733. X    return (-1);
  1734. X  }
  1735. X  return (0);
  1736. X
  1737. X}
  1738. X
  1739. Xvoid Initialize_protocols ()
  1740. X/* Initializes the array of message attributes. */
  1741. X{
  1742. X  ;
  1743. X}
  1744. END_OF_FILE
  1745. if test 19876 -ne `wc -c <'protocol.c'`; then
  1746.     echo shar: \"'protocol.c'\" unpacked with wrong size!
  1747. fi
  1748. # end of 'protocol.c'
  1749. fi
  1750. echo shar: End of archive 9 \(of 14\).
  1751. cp /dev/null ark9isdone
  1752. MISSING=""
  1753. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
  1754.     if test ! -f ark${I}isdone ; then
  1755.     MISSING="${MISSING} ${I}"
  1756.     fi
  1757. done
  1758. if test "${MISSING}" = "" ; then
  1759.     echo You have unpacked all 14 archives.
  1760.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1761. else
  1762.     echo You still need to unpack the following archives:
  1763.     echo "        " ${MISSING}
  1764. fi
  1765. ##  End of shell archive.
  1766. exit 0
  1767.