1.1 --- a/src/game.h Wed Mar 26 13:16:49 2014 +0100 1.2 +++ b/src/game.h Wed Mar 26 14:12:59 2014 +0100 1.3 @@ -78,11 +78,21 @@ 1.4 1.5 #define POS_UNSPECIFIED UINT8_MAX 1.6 1.7 +#define isidx(idx) ((uint8_t)idx < 8) 1.8 + 1.9 #define isfile(file) (file >= 'a' && file <= 'h') 1.10 #define isrow(row) (row >= '1' && row <= '8') 1.11 + 1.12 #define rowidx(row) (row-'1') 1.13 #define fileidx(file) (file-'a') 1.14 1.15 +#define chkidx(move) (isidx(move->fromfile) && isidx(move->fromrow) && \ 1.16 + isidx(move->tofile) && isidx(move->torow)) 1.17 + 1.18 +/* secure versions - use, if index is not checked with isidx() */ 1.19 +#define fileidx_s(c) (isfile(c)?fileidx(c):POS_UNSPECIFIED) 1.20 +#define rowidx_s(c) (isrow(c)?rowidx(c):POS_UNSPECIFIED) 1.21 + 1.22 void game_start(Settings *settings, int opponent); 1.23 1.24 #ifdef __cplusplus