Fix compile time warnings and a couple other cleanups.
[cboard.git] / src / cboard.h
blob7a51eb651398adecb60f643a4ed17f228e43e9a8
1 /* vim:tw=78:ts=8:sw=4:set ft=c: */
2 /*
3 Copyright (C) 2002-2006 Ben Kibbey <bjk@arbornet.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef CBOARD_H
20 #define CBOARD_H
22 #define COPYRIGHT "Copyright (C) 2002-2006 " PACKAGE_BUGREPORT
23 #define LINE_GRAPHIC(c) ((!config.linegraphics) ? ' ' : c)
24 #define ROWTOMATRIX(r) ((8 - r) * 2 + 2 - 1)
25 #define COLTOMATRIX(c) ((c == 1) ? 1 : c * 4 - 3)
26 #define BOARD_HEIGHT 18
27 #define BOARD_WIDTH 34
28 #define STATUS_HEIGHT (BOARD_HEIGHT + HISTORY_HEIGHT - TAG_HEIGHT)
29 #define STATUS_WIDTH (COLS - BOARD_WIDTH)
30 #define TAG_HEIGHT 10
31 #define TAG_WIDTH (COLS - BOARD_WIDTH)
32 #define HISTORY_HEIGHT 6
33 #define HISTORY_WIDTH (COLS - STATUS_WIDTH)
35 enum {
36 UP, DOWN, LEFT, RIGHT
39 /* The order must match the BOOK_... enumeration on common.h. */
40 const char *book_methods[] = {
41 BOOK_OFF_STR, BOOK_PREFER_STR, BOOK_BEST_STR, BOOK_WORST_STR,
42 BOOK_RANDOM_STR
45 WINDOW *boardw;
46 PANEL *boardp;
47 WINDOW *tagw;
48 PANEL *tagp;
49 WINDOW *statusw;
50 PANEL *statusp;
51 WINDOW *historyw;
52 PANEL *historyp;
54 BOARD board;
55 int quit;
56 char **agony;
57 int paused;
59 const char *cmdlinehelp[] = {
60 #ifdef DEBUG
61 "Usage: cboard [-hvND] [-VS] [-pf <file>] [-i hostname[:port]] "
62 #else
63 "Usage: cboard [-hvN] [-VS] [-pf <file>] [-i hostname[:port]] "
64 #endif
65 "[-u username[:passwd]]\n",
66 " -p Load PGN file.\n",
67 " -f Load FEN file.\n",
68 " -i ICS hostname and optional port.\n",
69 " -u ICS username and optional password.\n",
70 " -V Validate a game file.\n",
71 " -S Validate and output a PGN formatted game.\n",
72 " -N Don't enable the chess engine (two human players).\n",
73 #ifdef DEBUG
74 " -D Enable debugging.\n",
75 #endif
76 " -v Version information.\n",
77 " -h This help text.\n",
78 NULL
81 const char *historyhelp[] = {
82 " UP/DOWN - next or previous history with jump count *",
83 "RIGHT/LEFT - next or previous history *",
84 " SPACE - toggle half move stepping",
85 " j - jump to move number *",
86 " / - specify a new move text search expression *",
87 " ] - find the next move text expression *",
88 " [ - find the previous move text expression *",
89 " a - edit comments for the previous move",
90 " v - view comments for the next move",
91 " V - view comments for the previous move",
92 " h - toggle history mode",
93 NULL
96 const char *mainhelp[] = {
97 "p - play mode keys",
98 "h - history mode keys",
99 "e - board edit mode keys",
100 "g - other game keys",
101 NULL
104 const char *edithelp[] = {
105 " 0...9 - cursor repeat count",
106 "UP/DOWN/LEFT/RIGHT - position cursor *",
107 " !-*A-H - position cursor at rank or file",
108 " SPACE - select piece under cursor for movement",
109 " ENTER - commit selected piece",
110 " ESCAPE - cancel selected piece",
111 " x - delete the piece under the cursor",
112 " I - insert a new piece",
113 " e - toggle board edit mode",
114 NULL,
117 const char *gamehelp[] = {
118 " 0...9 - command repeat count",
119 " t - edit the current games roster tags",
120 " i - view the current games roster tags",
121 " ? - specify a new roster tag expression *",
122 " } - find the next roster tag expression *",
123 " { - find the previous roster tag expression *",
124 " n - start new game or round",
125 " N - start new game from scratch resetting all other games",
126 " > - next game or round *",
127 " < - previous game or round *",
128 " J - jump to game or round *",
129 " x - toggle game delete flag *",
130 " X - delete the current or all flagged games",
131 " r - resume a saved game",
132 " s - save game",
133 " S - save game and prompt",
134 " q - quit",
135 NULL
138 const char *playhelp[] = {
139 " 0...9 - cursor repeat count",
140 "UP/DOWN/LEFT/RIGHT - position cursor *",
141 " !-*A-H - position cursor at rank or file",
142 " SPACE - select piece under cursor for movement",
143 " ENTER - commit selected piece",
144 " ESCAPE - cancel selected piece",
145 " + - increase engine depth level *",
146 " _ - decrease engine depth level *",
147 " b - cycle through book modes",
148 " w - switch playing side",
149 " u - undo previous move *",
150 " g - force engine to make the next move",
151 " c - send a command to the chess engine",
152 NULL
155 pid_t init_chess_engine(void);
156 int parse_pgn_file(BOARD, const char *);
157 void update_history(void);
158 void reset_history(void);
159 TAG *edit_tags(BOARD, TAG *, int, int);
160 void parse_engine_output(BOARD, char *);
161 char *real_filename(char *);
162 void send_to_engine(const char *, ...);
163 int get_history_by_index(int, HISTORY *);
164 void history_next(BOARD, int, int *, int *);
165 void history_previous(BOARD, int, int *, int *);
166 void init_history(BOARD);
167 void parse_rcfile(const char *);
168 char *history_edit_nag(void *);
169 void view_annotation(int);
170 int save_pgn(const char *, int, int);
171 void set_engine_defaults(void);
172 int start_chess_engine(void);
173 void stop_engine(void);
174 int help(const char *, const char *, const char **);
175 void draw_window_title(WINDOW *, const char *, int, chtype, chtype);
176 void init_color_pairs(void);
177 char *browse_directory(void *);
178 char *a2a4tosan(BOARD, char *);
179 int add_tag(TAG **, int *, const char *, const char *);
180 void new_game(BOARD);
181 void *Malloc(size_t);
182 int isinteger(const char *);
183 int parse_ics_output(char *);
184 char *compression_cmd(const char *, int);
185 int piece_to_int(int);
186 int int_to_piece(int);
187 void free_tag_data(TAG *, int);
188 void free_historydata(HISTORY **, int, int);
189 void get_valid_moves(BOARD, int, int, int, int *, int *, int *, int *);
190 void reset_valid_moves(BOARD);
191 int parse_move_text(BOARD, char *);
192 void parse_history_move(BOARD, int);
193 void switch_turn(void);
194 char *str_etc(const char *, int, int);
195 char *tilde_expand(char *);
196 int parse_fen_file(BOARD, const char *);
197 char *board_to_fen(BOARD, GAME);
198 void set_defaults(void);
199 void add_to_history(HISTORY **, int *, int *, const char *);
200 void update_all(void);
201 void pgn_dumpgame(FILE *, GAME *, int, int);
203 #endif