fen.c: CGI mode: write output header before play moves - chess-puzzles - chess puzzle book generator
 (HTM) git clone git://git.codemadness.org/chess-puzzles
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit da65c61271ad6e8eb3fde5a8e828ed4d2c882fb2
 (DIR) parent 2037128c8c5a1527bddad29041660177a1cee999
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Mon,  8 Jan 2024 21:36:42 +0100
       
       fen.c: CGI mode: write output header before play moves
       
       ... else PGN output will be before the header is written.
       
       Diffstat:
         M fen.c                               |       5 ++++-
       
       1 file changed, 4 insertions(+), 1 deletion(-)
       ---
 (DIR) diff --git a/fen.c b/fen.c
       @@ -1549,8 +1549,9 @@ cgi_mode(void)
                if ((p = getparam(query, "moves"))) {
                        if (decodeparam(buf, sizeof(buf), p) == -1)
                                goto badrequest;
       -                board_playmoves(&board, buf);
                }
       +        if (!p)
       +                buf[0] = '\0';
        
                fputs("Status: 200 OK\r\n", stdout);
                if (outputmode == ModeSVG)
       @@ -1558,6 +1559,8 @@ cgi_mode(void)
                else
                        fputs("Content-Type: text/plain\r\n\r\n", stdout);
        
       +        board_playmoves(&board, buf);
       +
                output(&board);
        
                return 0;