| 36 |
36 |
| 37 #ifdef __cplusplus |
37 #ifdef __cplusplus |
| 38 extern "C" { |
38 extern "C" { |
| 39 #endif |
39 #endif |
| 40 |
40 |
| 41 enum { |
41 enum pgn_error_code { |
| 42 pgn_no_error = 0, |
42 pgn_no_error = 0, |
| 43 pgn_error_missing_quote, |
43 pgn_error_missing_quote, |
| 44 pgn_error_missing_bracket, |
44 pgn_error_missing_bracket, |
| 45 pgn_error_missing_brace, |
45 pgn_error_missing_brace, |
| 46 pgn_error_missing_dot, |
46 pgn_error_missing_dot, |
| 47 pgn_error_move_syntax, |
|
| 48 pgn_error_move_semantics, |
|
| 49 pgn_error_result_syntax, |
47 pgn_error_result_syntax, |
| 50 pgn_error_result_mismatch, |
48 pgn_error_result_mismatch, |
| 51 pgn_error_unexpected_eof, |
49 pgn_error_unexpected_eof, |
| |
50 pgn_error_move, |
| 52 }; |
51 }; |
| 53 |
52 |
| 54 int read_pgn(FILE *stream, GameState *gamestate); |
53 typedef struct { |
| |
54 size_t position; |
| |
55 enum pgn_error_code code; |
| |
56 int move_error; // TODO: should probably also be an enum eventually |
| |
57 unsigned move_half_number; |
| |
58 } pgn_result; |
| |
59 |
| |
60 |
| |
61 pgn_result read_pgn(FILE *stream, GameState *gamestate); |
| 55 int write_pgn(FILE* stream, const GameState *gamestate, bool export_comments); |
62 int write_pgn(FILE* stream, const GameState *gamestate, bool export_comments); |
| 56 |
63 |
| 57 int parse_pgn(const char *data, GameState *gamestate); |
64 pgn_result parse_pgn(const char *data, GameState *gamestate); |
| 58 char *create_pgn(const GameState *gamestate, bool export_comments); |
65 char *create_pgn(const GameState *gamestate, bool export_comments); |
| 59 |
66 |
| |
67 // TODO: this function looks a bit misplaced |
| 60 const char *pgn_player_name(const GameState *gamestate, Color color); |
68 const char *pgn_player_name(const GameState *gamestate, Color color); |
| 61 |
69 |
| 62 const char* pgn_error_str(int code); |
70 const char* pgn_error_str(int code); |
| 63 size_t pgn_error_position(void); |
|
| 64 |
71 |
| 65 #ifdef __cplusplus |
72 #ifdef __cplusplus |
| 66 } |
73 } |
| 67 #endif |
74 #endif |
| 68 |
75 |