Stop hardcoding filenames inside pat2inc, use commandline parameters.
[gnushogi.git] / gnushogi / pat2inc.c
1 /*
2  * FILE: pat2inc.c
3  *
4  *     Convert GNU Shogi pattern textfile to an include file.
5  *
6  * ----------------------------------------------------------------------
7  * Copyright (c) 1993, 1994, 1995 Matthias Mutz
8  * Copyright (c) 1999 Michael Vanier and the Free Software Foundation
9  *
10  * GNU SHOGI is based on GNU CHESS
11  *
12  * Copyright (c) 1988, 1989, 1990 John Stanback
13  * Copyright (c) 1992 Free Software Foundation
14  *
15  * This file is part of GNU SHOGI.
16  *
17  * GNU Shogi is free software; you can redistribute it and/or modify it
18  * under the terms of the GNU General Public License as published by the
19  * Free Software Foundation; either version 3 of the License,
20  * or (at your option) any later version.
21  *
22  * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT
23  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25  * for more details.
26  *
27  * You should have received a copy of the GNU General Public License along
28  * with GNU Shogi; see the file COPYING. If not, see
29  * <http://www.gnu.org/licenses/>.
30  * ----------------------------------------------------------------------
31  *
32  */
33
34 #include "gnushogi.h"
35 #include "pattern.h"
36
37
38 extern void ReadOpeningSequences(short *pindex, const char* patternfile);
39 extern void WriteOpeningSequences(short pindex, const char* patternincfile);
40
41 small_short board[NO_SQUARES];
42 small_short color[NO_SQUARES];
43
44 int
45 main(int argc, char **argv)
46 {
47     short sq, side, max_pattern_data;
48
49     if (argc != 3) {
50         fprintf(stderr, "Usage: %s gnushogi.pat pattern.inc\n", argv[0]);
51         exit(1);
52     }
53     char* patternfile = argv[1];
54     char* patternincfile = argv[2];
55
56 #ifdef TEST_DISTANCE
57     short d;
58     char  s[80];
59 #endif
60
61     Initialize_data();
62
63     for (sq = 0; sq < NO_SQUARES; sq++)
64     {
65         board[sq] = no_piece;
66         color[sq] = neutral;
67     }
68
69     ClearCaptured();
70
71     for (side = 0; side <= 1; side++)
72         PieceCnt[side] = -1;
73
74 #ifdef TEST_DISTANCE
75     strcpy(s, "g6i k5i g4i p9g p8g r* s3h p7g b8h B* S5f");
76
77     if (string_to_board_color(s))
78     {
79         printf("ERROR IN string_to_board_color");
80         exit(1);
81     }
82     else
83     {
84         UpdateDisplay(0, 0, 1, 0);
85     }
86
87     d = pattern_distance(black, &pattern);
88
89     printf("distance = %d\n", d);
90
91 #endif
92
93     ReadOpeningSequences(&max_pattern_data, patternfile);
94     WriteOpeningSequences(max_pattern_data, patternincfile);
95
96     return 0;
97 }