home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * Client/Server documentation; IGS External Protocol
- *
- * Copyright (C) 1992, 1995 I.NET Technologies Inc.
- * All rights reserved. License is hereby given for the use of
- * this material to develop graphics user interface programs
- * ("client programs") for the graphic interpretation of data
- * stored on or transmitted by the Internet Go Server. Any
- * other use of this material without the prior written consent
- * of I.NET Technologies Inc. is expressly prohibited.
- */
-
-
- #if 0
- $Id: protocol,v 1.1 1997/07/06 19:43:41 ergo Exp $
- #endif /* LINT */
-
-
- #ifndef SHARED_H
- #define SHARED_H
-
- #ifdef USE_STDERR /* Dec alpha apperently has a USE_STDERR defined */
- #undef USE_STDERR
- #endif
-
- #ifndef BIT
- #define BIT(n) (1L << (n))
- #endif /* BIT */
- #define MAX_BRD_SZ 19
- #define MAX_LANG 5
-
- #define DEF_LANG 0
-
- /*
- * These message types are put at the beginning of every line
- * of output from the server, with one exception (of course).
- * Some things to be aware of:
- * If you get an unknown message type, you should probably just
- * treat it is 'INFO'. I would guess the same would be true
- * if there is an error parsing date. (It would probably be
- * good to tell the user something is wrong as well.)
- *
- * To start looking for client messages look for the version message.
- * If should see: 39 .... If you see: IGS entry on mm - dd - yyyy,
- * you are not in client mode. But the version string is a way to
- * tell if you should be looking for IGS messages, as opposed to
- * terminal messages.
- *
- * The IGS client protocol is designed to be a line-by-line protocol,
- * just like telnet is a line-by-line protocol.
- *
- * Any IGS output, which is INFO is subject to change.
- */
-
- typedef enum {
- UNKNOWN = 0,
- AUTOMAT = 35, /* Automatch anouncement*/
- AUTOASK = 36, /* Automatch accept */
- CHOICES = 38, /* game choices */
- CLIVRFY = 41, /* Client verify message */
- BEEP = 2, /* \7 telnet */
- BOARD = 3, /* Board being drawn */
- DOWN = 4, /* The server is going down */
- ERROR = 5, /* An error reported */
- FIL = 6, /* File being sent */
- GAMES = 7, /* Games listing */
- HELP = 8, /* Help file */
- INFO = 9, /* Generic info */
- LAST = 10, /* Last command */
- KIBITZ = 11, /* Kibitz strings */
- LOAD = 12, /* Loading a game */
- LOOK_M = 13, /* Look */
- MESSAGE = 14, /* Message lising */
- MOVE = 15, /* Move #:(B) A1 */
- OBSERVE = 16, /* Observe report */
- PROMPT = 1, /* A Prompt (never) */
- REFRESH = 17, /* Refresh of a board */
- SAVED = 18, /* Stored command */
- SAY = 19, /* Say string */
- SCORE_M = 20, /* Score report */
- SGF_M = 34, /* SGF variation */
- SHOUT = 21, /* Shout string */
- SHOW = 29, /* Shout string */
- STATUS = 22, /* Current Game status */
- STORED = 23, /* Stored games */
- TEACH = 33, /* teaching game */
- TELL = 24, /* Tell string */
- DOT = 40, /* your . string */
- THIST = 25, /* Thist report */
- TIM = 26, /* times command */
- TRANS = 30, /* Translation info */
- TTT_BOARD= 37, /* tic tac toe */
- WHO = 27, /* who command */
- UNDO = 28, /* Undo report */
- USER = 42, /* Long user report <-- last */
- VERSION = 39, /* IGS VERSION: IGS entry on %02d - %02d - %04d\r\n
- comes out just as the last piece of info
- after verification of the password.
- mm - dd - yyyy <== last Message Type value */
- YELL = 32, /* Channel yelling */
- } MessageType;
-
-
- /*
- * The states are used, after the prompt line, to tell what state a player
- * is in on IGS. The '1 1' state (meaning PROMPT message while the prompt
- * in text mode would be 'Password:') the client should not echo characters,
- * or should change the font to display spaces for characters. The states
- * 2, 4 and 4 are no longer used, because of registration. State 5 is the
- * 'WAITing' for a game state, from there one can go into the playing,
- * teaching, or observing states. The states are not exclusive.
- * Here is an example:
- * 1 5
- * ob 1
- * 9 Adding game to observation list.
- * 15 Game 1 I: death (0 4937 -1) vs Bob (0 4883 -1)
- * 15 62(B): G4
- * 1 8
- * At this point, you can either ask for the moves from a game with the
- * moves command, or you can get the board state from the status command.
- * These are the various states:
- */
- #define LOGGEDON WAITING
- typedef enum {
- LOGON = 0, /* initial state */
- PASSWORD = 1, /* getting password */
- PASSWD_NEW = 2, /* verifiying password: not used, registration */
- PASSWD_CONFIRM = 3, /* ditto */
- REGISTER = 4, /* not used */
- WAITING = 5, /* After login the basic state */
- PLAYING = 6, /* Playing a game */
- SCORING = 7, /* Scoring a game */
- OBSERVING = 8, /* Observing (and playing?) a game */
- TEACHING = 9, /* In teaching mode, can move for W and B */
- COMPLETE = 10 /* game complete */
- } State;
-
- /*
- * GAMES: Displays all of the games being played, or the game specified.
- * The players listed in the games listing, may or may not be real
- * players because of the teach command.
- *[##] white name [ rk ] black name [ rk ] (Move size H Komi BY FR) (###)
- *
- * MOVES: comes out in the form:
- * 15 Game 1 I: death (4 4629 -1) vs Bob (2 4486 -1)
- * 15 0(B): Handicap 2
- * 15 1(W): P3
- * 15 2(B): D16
- * .
- * .
- * .
- *
- * Or generally:
- * 15 #(c): <move> <move, move,...,move>
- * Where the following move list are dead stones as a result of
- * the move.
- *
- * STATUS: used to get what is a game current status is.
- * status 1
- * 22 white rank captured time <byo-yomi stones> T|F komi handicap
- * 22 black rank captured time <byo-yomi stones> T|F komi handicap
- * 22 0: 2222222222222222222
- * 22 1: 2221222222122221102
- * 22 2: 2201212102222122022
- * 22 3: 2000120101222220222
- * 22 4: 2111211001222122222
- * 22 5: 2122210001222200222
- * 22 6: 2211110211222110222
- * 22 7: 2200100122222221022
- * 22 8: 2201001102122121022
- * 22 9: 2206011006220100022
- * 22 10: 2222210022102002222
- * 22 11: 2222202202210212222
- * 22 12: 2222000002210210022
- * 22 13: 2200121222120111222
- * 22 14: 2201112222220102122
- * 22 15: 2220222221211020122
- * 22 16: 2202212222100021222
- * 22 17: 2221222221021201222
- * 22 18: 2222222222200222222
- * 1 5
- * NOTE: The board for a status is flipped along the diagonal
- * with respect to the rest of IGS/SGF output.
- * If the line for the player is 'T', then the player is in
- * byo-yomi. Otherwise, the byo-yomi stones can be ignored.
- * Should there be a mention of the rule set for the game?
- *
- * INFO: String to be passed to the user, with the '9 ' stripped out.
- *
- * ERROR: String to be passed to the user, with the '5 ' stripped out.
- * If you can handle errors in a rational way, then the difference
- * between INFO and ERROR are useful.
- *
- * DOT: Has the name of the player which is the players '.'
- *
- * FIL: Used to send a file. The format is differnt then any other command:
- * help match
- * 6 <type>
- * text of help match
- * 6 <type>
- * 1 5
- * In the above example, type would be HELP. Although type can be
- * nearly any line type, it currently is only MESSAGE, HELP, and INFO.
- *
- */
-
-
- /*
- * All possible tokens read in by the parser.
- */
- typedef enum {
- Unkn_t = 0,
- AYT_t,
- Ping_t,
- Free_t,
- Auto_t,
- Game_t,
- Goto_t,
- Help_t,
- Hand_t,
- Addr_t,
- Chan_t,
- Char_t,
- Decr_t,
- Defs_t,
- Incr_t,
- Back_t,
- Best_t,
- Bet_t,
- Bloc_t,
- DOT_t,
- AcRe_t,
- Adjo_t,
- Addt_t,
- Appe_t,
- AKil_t,
- Alia_t,
- All_t,
- AMai_t,
- Bug_t,
- Chat_t,
- Choi_t,
- Comm_t,
- Conn_t,
- Cron_t,
- Curr_t,
- Dagg_t,
- Decl_t,
- Dele_t,
- Disa_t,
- Done_t,
- Draw_t,
- DpyR_t,
- Dump_t,
- Eras_t,
- Exit_t,
- FdIs_t,
- Fill_t,
- Find_t,
- Forw_t,
- Full_t,
- GMat_t,
- Gran_t,
- GTea_t,
- Host_t,
- Info_t,
- Kibi_t,
- Kill_t,
- KIdl_t,
- Komi_t,
- Lang_t,
- Last_t,
- Load_t,
- Loca_t,
- Lock_t,
- Logi_t,
- Look_t,
- Mail_t,
- Matc_t,
- Mess_t,
- Move_t,
- Name_t,
- Noti_t,
- Obse_t,
- Pass_t,
- Play_t,
- PlMv_t,
- PMat_t,
- Prob_t,
- PSMa_t,
- Quit_t,
- Rank_t,
- Rati_t,
- Rnks_t,
- Refr_t,
- Regi_t,
- Reha_t,
- Remo_t,
- Rese_t,
- Resi_t,
- Revi_t,
- Save_t,
- Say_t,
- Scor_t,
- Sgf_t,
- Shou_t,
- Show_t,
- Shut_t,
- Slee_t,
- Spy_t,
- Stus_t,
- Stat_t,
- Stor_t,
- Supe_t,
- Teac_t,
- Team_t,
- Tell_t,
- This_t,
- TIC_t,
- Time_t,
- Titl_t,
- TGMa_t,
- TMat_t,
- Togg_t,
- Touc_t,
- Tran_t,
- UnAl_t,
- Undo_t,
- UnOb_t,
- UnRe_t,
- Upti_t,
- Viol_t,
- Vari_t,
- Watc_t,
- Shel_t,
- Who_t,
- User_t,
- Xsho_t,
- GmRe_t,
- AskM_t,
- InBy_t,
- CnSn_t,
- Ambi_t,
- Exac_t,
- True_t,
- Fals_t,
- Yell_t,
- /* toggles */
- T_AUTOMAIL,
- T_OPEN,
- T_VERBOSE,
- T_BELL,
- T_QUIET,
- T_CLIENT,
- T_CHATTER,
- T_AUTOSAVE,
- T_LOOK,
- T_KIBI,
- T_SHOUT,
- T_RANK,
- T_NEW,
- /* SGF stuff */
- Comments_t,
- Label_t,
- Letters_t,
- Marks_t,
- Variations_t,
- Add_ch,
- Clean_ch,
- Debug_ch,
- Help_ch,
- Hide_ch,
- Moderator_ch,
- Open_ch,
- Remove_ch,
- Title_ch,
- NAgr_t,
- } CommandToken;
-
- /*
- * A string to token struct.
- * DiskIO is for stats and debugging on bsdserver.
- */
- typedef struct {
- char *str;
- CommandToken tok;
- unsigned long count;
- char NeedArg;
- char SuperCommand;
- char DiskIO;
- unsigned char amb;
- char *enabled;
- char reg;
- unsigned long at;
- } SearchComm;
-
-
- /*
- * aliases have a limit
- */
- #define NAME_LEN 20
- typedef struct _alias {
- char alias[NAME_LEN];
- char sub[NAME_LEN*2];
- struct _alias *next;
- } Alias;
-
- #define NUM_RANKS num_ranks
- #define NUM_SPECIAL 2
-
- /*
- * verticies
- */
- #define TOP 0
- #define MID 1
- #define BOT 2
-
-
- extern int verts[3][MAX_BRD_SZ+1];
- extern int num_ranks;
- extern char *ranks[], *comranks[];
- extern char *prompts[];
-
- #ifdef __STDC__
- extern SearchComm *GetCommandToken( char *orig, char **args, Alias *aliases[]);
- #else /* __STDC__ */
- extern SearchComm *GetCommandToken();
- #endif /* __STDC__ */
-
- #if 0
- extern SearchComm *ToggleCommand(char * str);
- extern SearchComm *SearchTbl(char *str, SearchComm *tbl, int tbllen);
- extern char *BreakList(char *str, char **rest);
- #endif
- #endif /* SHARED_H */
-
-