src/chess/pgn.h

changeset 209
dc4f34426c66
parent 194
619f07c95894
--- a/src/chess/pgn.h	Tue Sep 01 17:47:07 2026 +0200
+++ b/src/chess/pgn.h	Wed Sep 02 17:11:56 2026 +0200
@@ -38,29 +38,36 @@
 extern "C" {
 #endif
 
-enum {
+enum pgn_error_code {
     pgn_no_error = 0,
     pgn_error_missing_quote,
     pgn_error_missing_bracket,
     pgn_error_missing_brace,
     pgn_error_missing_dot,
-    pgn_error_move_syntax,
-    pgn_error_move_semantics,
     pgn_error_result_syntax,
     pgn_error_result_mismatch,
     pgn_error_unexpected_eof,
+    pgn_error_move,
 };
 
-int read_pgn(FILE *stream, GameState *gamestate);
+typedef struct {
+    size_t position;
+    enum pgn_error_code code;
+    int move_error; // TODO: should probably also be an enum eventually
+    unsigned move_half_number;
+} pgn_result;
+
+
+pgn_result read_pgn(FILE *stream, GameState *gamestate);
 int write_pgn(FILE* stream, const GameState *gamestate, bool export_comments);
 
-int parse_pgn(const char *data, GameState *gamestate);
+pgn_result parse_pgn(const char *data, GameState *gamestate);
 char *create_pgn(const GameState *gamestate, bool export_comments);
 
+// TODO: this function looks a bit misplaced
 const char *pgn_player_name(const GameState *gamestate, Color color);
 
 const char* pgn_error_str(int code);
-size_t pgn_error_position(void);
 
 #ifdef	__cplusplus
 }

mercurial