home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / OPENSTEP / Games / NeXTGo-3.0-MIS / protocol < prev    next >
Encoding:
Text File  |  1997-07-06  |  10.1 KB  |  438 lines

  1.  
  2. /*
  3.  * Client/Server documentation; IGS External Protocol
  4.  * 
  5.  *  Copyright (C) 1992, 1995   I.NET Technologies Inc.
  6.  *  All rights reserved.  License is hereby given for the use of
  7.  *  this material to develop graphics user interface programs
  8.  *  ("client programs") for the graphic interpretation of data
  9.  *  stored on or transmitted by the Internet Go Server.  Any
  10.  *  other use of this material without the prior written consent
  11.  *  of I.NET Technologies Inc. is expressly prohibited.
  12.  */
  13.  
  14.  
  15. #if 0
  16. $Id: protocol,v 1.1 1997/07/06 19:43:41 ergo Exp $
  17. #endif /* LINT */
  18.  
  19.  
  20. #ifndef SHARED_H
  21. #define SHARED_H
  22.  
  23. #ifdef USE_STDERR /* Dec alpha apperently has a USE_STDERR defined */
  24. #undef USE_STDERR
  25. #endif
  26.  
  27. #ifndef BIT
  28. #define BIT(n) (1L << (n))
  29. #endif /* BIT */
  30. #define MAX_BRD_SZ 19
  31. #define MAX_LANG 5
  32.  
  33. #define DEF_LANG 0
  34.  
  35. /*
  36.  * These message types are put at the beginning of every line
  37.  * of output from the server, with one exception (of course).
  38.  * Some things to be aware of:
  39.  *     If you get an unknown message type, you should probably just
  40.  *     treat it is 'INFO'.  I would guess the same would be true
  41.  *     if there is an error parsing date.  (It would probably be
  42.  *     good to tell the user something is wrong as well.)
  43.  *
  44.  *     To start looking for client messages look for the version message.
  45.  *     If should see:  39 ....  If you see:  IGS entry on mm - dd - yyyy,
  46.  *     you are not in client mode.  But the version string is a way to
  47.  *     tell if you should be looking for IGS messages, as opposed to 
  48.  *     terminal messages.
  49.  *
  50.  *     The IGS client protocol is designed to be a line-by-line protocol,
  51.  *     just like telnet is a line-by-line protocol.
  52.  *
  53.  *     Any IGS output, which is INFO is subject to change.
  54.  */
  55.  
  56. typedef enum {
  57.     UNKNOWN    =  0,
  58.     AUTOMAT    = 35,     /* Automatch anouncement*/
  59.     AUTOASK    = 36,     /* Automatch accept    */
  60.     CHOICES = 38,     /* game choices        */
  61.     CLIVRFY = 41,    /* Client verify message */
  62.     BEEP    =  2,     /* \7 telnet         */
  63.     BOARD    =  3,    /* Board being drawn     */
  64.     DOWN    =  4,    /* The server is going down */
  65.     ERROR    =  5,    /* An error reported    */
  66.     FIL        =  6,    /* File being sent    */
  67.     GAMES    =  7,    /* Games listing    */
  68.     HELP    =  8,    /* Help file        */
  69.     INFO    =  9,    /* Generic info        */
  70.     LAST    = 10,    /* Last command        */
  71.     KIBITZ    = 11,    /* Kibitz strings    */
  72.     LOAD    = 12,    /* Loading a game    */
  73.     LOOK_M    = 13,    /* Look         */
  74.     MESSAGE    = 14,    /* Message lising    */
  75.     MOVE    = 15,    /* Move #:(B) A1    */
  76.     OBSERVE    = 16,    /* Observe report    */
  77.     PROMPT    =  1,    /* A Prompt (never)    */
  78.     REFRESH    = 17,    /* Refresh of a board    */
  79.     SAVED    = 18,    /* Stored command    */
  80.     SAY        = 19,    /* Say string        */
  81.     SCORE_M    = 20,    /* Score report        */
  82.     SGF_M    = 34,    /* SGF variation    */
  83.     SHOUT    = 21,    /* Shout string        */
  84.     SHOW     = 29,    /* Shout string        */
  85.     STATUS    = 22,    /* Current Game status    */
  86.     STORED    = 23,    /* Stored games        */
  87.     TEACH    = 33,    /* teaching game    */
  88.     TELL    = 24,    /* Tell string        */
  89.     DOT        = 40,    /* your . string    */
  90.     THIST    = 25,    /* Thist report        */
  91.     TIM        = 26,    /* times command    */
  92.     TRANS    = 30,    /* Translation info    */
  93.     TTT_BOARD= 37,     /* tic tac toe        */
  94.     WHO        = 27,    /* who command        */
  95.     UNDO    = 28,    /* Undo report        */
  96.     USER    = 42,    /* Long user report    <-- last */
  97.     VERSION = 39,    /* IGS VERSION: IGS entry on %02d - %02d - %04d\r\n
  98.                  comes out just as the last piece of info
  99.                  after verification of the password.
  100.                  mm - dd - yyyy <== last Message Type value */
  101.     YELL    = 32,    /* Channel yelling    */
  102. } MessageType;
  103.  
  104.  
  105. /*
  106.  * The states are used, after the prompt line, to tell what state a player
  107.  * is in on IGS.  The '1 1' state (meaning PROMPT message while the prompt
  108.  * in text mode would be 'Password:') the client should not echo characters,
  109.  * or should change the font to display spaces for characters.  The states
  110.  * 2, 4 and 4 are no longer used, because of registration.  State 5 is the
  111.  * 'WAITing' for a game state, from there one can go into the playing,
  112.  * teaching, or observing states.  The states are not exclusive.
  113.  * Here is an example:
  114.  *      1 5
  115.  *      ob 1
  116.  *      9 Adding game to observation list.
  117.  *      15 Game 1 I: death (0 4937 -1) vs Bob (0 4883 -1)
  118.  *      15  62(B): G4
  119.  *      1 8
  120.  * At this point, you can either ask for the moves from a game with the
  121.  * moves command, or you can get the board state from the status command.
  122.  * These are the various states:
  123.  */
  124. #define LOGGEDON WAITING
  125. typedef enum {
  126.     LOGON        = 0,  /* initial state */
  127.     PASSWORD    = 1,  /* getting password */
  128.     PASSWD_NEW    = 2,  /* verifiying password: not used, registration */
  129.     PASSWD_CONFIRM    = 3,  /* ditto */
  130.     REGISTER    = 4,  /* not used */
  131.     WAITING        = 5,  /* After login the basic state */
  132.     PLAYING        = 6,  /* Playing a game */
  133.     SCORING        = 7,  /* Scoring a game */
  134.     OBSERVING    = 8,  /* Observing (and playing?) a game */
  135.     TEACHING    = 9,  /* In teaching mode, can move for W and B */
  136.     COMPLETE    = 10  /* game complete */
  137. } State;
  138.  
  139. /*
  140.  * GAMES:  Displays all of the games being played, or the game specified.
  141.  *         The players listed in the games listing, may or may not be real
  142.  *         players because of the teach command.
  143.  *[##]  white name [ rk ]      black name [ rk ] (Move size H Komi BY FR) (###)
  144.  *
  145.  * MOVES:  comes out in the form: 
  146.  *             15 Game 1 I: death (4 4629 -1) vs Bob (2 4486 -1)
  147.  *             15   0(B): Handicap 2
  148.  *             15   1(W): P3
  149.  *             15   2(B): D16
  150.  *                 .
  151.  *                 .
  152.  *                 .
  153.  *
  154.  *          Or generally:
  155.  *             15   #(c): <move> <move, move,...,move>
  156.  *          Where the following move list are dead stones as a result of
  157.  *          the move.
  158.  *
  159.  * STATUS: used to get what is a game current status is.
  160.  *              status 1
  161.  *              22 white rank captured time <byo-yomi stones> T|F komi handicap
  162.  *              22 black rank captured time <byo-yomi stones> T|F komi handicap
  163.  *              22  0: 2222222222222222222
  164.  *              22  1: 2221222222122221102
  165.  *              22  2: 2201212102222122022
  166.  *              22  3: 2000120101222220222
  167.  *              22  4: 2111211001222122222
  168.  *              22  5: 2122210001222200222
  169.  *              22  6: 2211110211222110222
  170.  *              22  7: 2200100122222221022
  171.  *              22  8: 2201001102122121022
  172.  *              22  9: 2206011006220100022
  173.  *              22 10: 2222210022102002222
  174.  *              22 11: 2222202202210212222
  175.  *              22 12: 2222000002210210022
  176.  *              22 13: 2200121222120111222
  177.  *              22 14: 2201112222220102122
  178.  *              22 15: 2220222221211020122
  179.  *              22 16: 2202212222100021222
  180.  *              22 17: 2221222221021201222
  181.  *              22 18: 2222222222200222222
  182.  *              1 5
  183.  *         NOTE: The board for a status is flipped along the diagonal
  184.  *               with respect to the rest of IGS/SGF output.
  185.  *               If the line for the player is 'T', then the player is in
  186.  *               byo-yomi.  Otherwise, the byo-yomi stones can be ignored.
  187.  *         Should there be a mention of the rule set for the game?
  188.  *
  189.  * INFO: String to be passed to the user, with the '9 ' stripped out.
  190.  *
  191.  * ERROR: String to be passed to the user, with the '5 ' stripped out.
  192.  *        If you can handle errors in a rational way, then the difference
  193.  *        between INFO and ERROR are useful.
  194.  *
  195.  * DOT: Has the name of the player which is the players '.'
  196.  *
  197.  * FIL: Used to send a file.  The format is differnt then any other command:
  198.  *           help match
  199.  *           6 <type>
  200.  *           text of help match
  201.  *           6 <type>
  202.  *           1 5
  203.  *      In the above example, type would be HELP.  Although type can be
  204.  *      nearly any line type, it currently is only MESSAGE, HELP, and INFO.
  205.  *
  206.  */
  207.  
  208.  
  209. /*
  210.  * All possible tokens read in by the parser.
  211.  */
  212. typedef enum {
  213.     Unkn_t = 0,
  214.     AYT_t,
  215.     Ping_t,
  216.     Free_t,
  217.     Auto_t,
  218.     Game_t,
  219.     Goto_t,
  220.     Help_t,
  221.     Hand_t,
  222.     Addr_t,
  223.     Chan_t,
  224.     Char_t,
  225.     Decr_t,
  226.     Defs_t,
  227.     Incr_t,
  228.     Back_t,
  229.     Best_t,
  230.     Bet_t,
  231.     Bloc_t,
  232.     DOT_t,
  233.     AcRe_t,
  234.     Adjo_t,
  235.     Addt_t,
  236.     Appe_t,
  237.     AKil_t,
  238.     Alia_t,
  239.     All_t,
  240.     AMai_t,
  241.     Bug_t,
  242.     Chat_t,
  243.     Choi_t,
  244.     Comm_t,
  245.     Conn_t,
  246.     Cron_t,
  247.     Curr_t,
  248.     Dagg_t,
  249.     Decl_t,
  250.     Dele_t,
  251.     Disa_t,
  252.     Done_t,
  253.     Draw_t,
  254.     DpyR_t,
  255.     Dump_t,
  256.     Eras_t,
  257.     Exit_t,
  258.     FdIs_t,
  259.     Fill_t,
  260.     Find_t,
  261.     Forw_t,
  262.     Full_t,
  263.     GMat_t,
  264.     Gran_t,
  265.     GTea_t,
  266.     Host_t,
  267.     Info_t,
  268.     Kibi_t,
  269.     Kill_t,
  270.     KIdl_t,
  271.     Komi_t,
  272.     Lang_t,
  273.     Last_t,
  274.     Load_t,
  275.     Loca_t,
  276.     Lock_t,
  277.     Logi_t,
  278.     Look_t,
  279.     Mail_t,
  280.     Matc_t,
  281.     Mess_t,
  282.     Move_t,
  283.     Name_t,
  284.     Noti_t,
  285.     Obse_t,
  286.     Pass_t,
  287.     Play_t,
  288.     PlMv_t,
  289.     PMat_t,
  290.     Prob_t,
  291.     PSMa_t,
  292.     Quit_t,
  293.     Rank_t,
  294.     Rati_t,
  295.     Rnks_t,
  296.     Refr_t,
  297.     Regi_t,
  298.     Reha_t,
  299.     Remo_t,
  300.     Rese_t,
  301.     Resi_t,
  302.     Revi_t,
  303.     Save_t,
  304.     Say_t,
  305.     Scor_t,
  306.     Sgf_t,
  307.     Shou_t,
  308.     Show_t,
  309.     Shut_t,
  310.     Slee_t,
  311.     Spy_t,
  312.     Stus_t,
  313.     Stat_t,
  314.     Stor_t,
  315.     Supe_t,
  316.     Teac_t,
  317.     Team_t,
  318.     Tell_t,
  319.     This_t,
  320.     TIC_t,
  321.     Time_t,
  322.     Titl_t,
  323.     TGMa_t,
  324.     TMat_t,
  325.     Togg_t,
  326.     Touc_t,
  327.     Tran_t,
  328.     UnAl_t,
  329.     Undo_t,
  330.     UnOb_t,
  331.     UnRe_t,
  332.     Upti_t,
  333.     Viol_t,
  334.     Vari_t,
  335.     Watc_t,
  336.     Shel_t,
  337.     Who_t,
  338.     User_t,
  339.     Xsho_t,
  340.     GmRe_t,
  341.     AskM_t,
  342.     InBy_t,
  343.     CnSn_t,
  344.     Ambi_t,
  345.     Exac_t,
  346.     True_t,
  347.     Fals_t,
  348.     Yell_t,
  349.             /* toggles */
  350.     T_AUTOMAIL,
  351.     T_OPEN,
  352.     T_VERBOSE,
  353.     T_BELL,
  354.     T_QUIET,
  355.     T_CLIENT,
  356.     T_CHATTER,
  357.     T_AUTOSAVE,
  358.     T_LOOK,
  359.     T_KIBI,
  360.     T_SHOUT,
  361.     T_RANK,
  362.     T_NEW,
  363.             /* SGF stuff */
  364.     Comments_t,
  365.     Label_t,
  366.     Letters_t,
  367.     Marks_t,
  368.     Variations_t,
  369.     Add_ch,
  370.     Clean_ch,
  371.     Debug_ch,
  372.     Help_ch,
  373.     Hide_ch,
  374.     Moderator_ch,
  375.     Open_ch,
  376.     Remove_ch,
  377.     Title_ch,
  378.     NAgr_t,
  379. } CommandToken;
  380.  
  381. /*
  382.  * A string to token struct.
  383.  * DiskIO is for stats and debugging on bsdserver.
  384.  */
  385. typedef struct {
  386.     char *str;
  387.     CommandToken tok;
  388.     unsigned long count;
  389.     char NeedArg;
  390.     char SuperCommand;
  391.     char DiskIO;
  392.     unsigned char amb;
  393.     char *enabled;
  394.     char reg;
  395.     unsigned long at;
  396. } SearchComm;
  397.  
  398.  
  399. /*
  400.  * aliases have a limit
  401.  */
  402. #define NAME_LEN 20
  403. typedef struct _alias {
  404.     char alias[NAME_LEN];
  405.     char sub[NAME_LEN*2];
  406.     struct _alias *next;
  407. } Alias;
  408.  
  409. #define NUM_RANKS num_ranks
  410. #define NUM_SPECIAL 2
  411.  
  412. /*
  413.  * verticies
  414.  */
  415. #define TOP 0
  416. #define MID 1
  417. #define BOT 2
  418.  
  419.  
  420. extern int verts[3][MAX_BRD_SZ+1];
  421. extern int num_ranks;
  422. extern char *ranks[], *comranks[];
  423. extern char *prompts[];
  424.  
  425. #ifdef __STDC__
  426. extern SearchComm *GetCommandToken( char *orig, char **args, Alias *aliases[]);
  427. #else /* __STDC__ */
  428. extern SearchComm *GetCommandToken();
  429. #endif /* __STDC__ */
  430.  
  431. #if 0
  432. extern SearchComm *ToggleCommand(char * str);
  433. extern SearchComm *SearchTbl(char *str, SearchComm *tbl, int tbllen);
  434. extern char *BreakList(char *str, char **rest);
  435. #endif
  436. #endif /* SHARED_H */
  437.  
  438.