aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-16 18:02:23 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-16 18:02:23 +0100
commitc58d496140421d5c831e40e87c3e5c473f93cbc3 (patch)
treebe726956052fa6430dc0143cd3a1fd98d4003a39 /FICS
parent62ce6dc4e8599d24ecf1b55de5d051ddc6f5ddfe (diff)
Reformatted ECO_init()
Diffstat (limited to 'FICS')
-rw-r--r--FICS/eco.c99
1 files changed, 58 insertions, 41 deletions
diff --git a/FICS/eco.c b/FICS/eco.c
index 1f6870a..9dda24e 100644
--- a/FICS/eco.c
+++ b/FICS/eco.c
@@ -144,48 +144,65 @@ char *boardToFEN(int g)
return FENstring;
}
-void ECO_init()
+void
+ECO_init()
{
- FILE *fp;
- char tmp[1024];
- char *ptmp= tmp;
- char FENpos[73], ECO[4], onMove[2];
- char filename[1024];
- int i=0;
-
- sprintf(filename, "%s/eco999.idx", book_dir);
- fp= fopen(filename, "r");
- if (!fp) {
- fprintf(stderr, "Could not open ECO file (%s)\n", filename);
- exit(1);
- }
- while (!feof(fp)) {
- strcpy(ptmp, "");
- fgets(ptmp, 1024, fp);
- if (feof(fp)) continue;
- sscanf(ptmp, "%[\x21-z] %s", FENpos, onMove);
- sprintf(FENpos, "%s %s", FENpos, onMove);
- strcpy(ptmp, "");
- fgets(ptmp, 1024, fp);
- if (feof(fp)) continue;
- sscanf(ptmp, "%[0-z]", ECO);
- ECO_book[i]= (ECO_entry *) malloc(sizeof(ECO_entry));
- if (ECO_book[i]==NULL) {
- fprintf(stderr, "Cound not alloc mem for ECO entry %d.\n", i);
- exit(1);
- }
- strcpy(ECO_book[i]->ECO, ECO);
- strcpy(ECO_book[i]->FENpos, FENpos);
- ++i;
- }
- fclose(fp);
- ECO_book[i]=NULL;
- fprintf(stderr, "%d entries in ECO book\n", i);
- ECO_entries = i;
-
- while (--i >= 0)
- if (ECO_book[i] == NULL)
- fprintf(stderr, "ERROR! ECO book position number %d is NULL.", i);
+ FILE *fp;
+ char ECO[4];
+ char FENpos[73];
+ char filename[1024];
+ char onMove[2];
+ char tmp[1024];
+ char *ptmp = tmp;
+ int i = 0;
+
+ sprintf(filename, "%s/eco999.idx", book_dir);
+
+ if ((fp = fopen(filename, "r")) == NULL) {
+ fprintf(stderr, "Could not open ECO file (%s)\n", filename);
+ exit(1);
+ }
+
+ while (!feof(fp)) {
+ strcpy(ptmp, "");
+ fgets(ptmp, 1024, fp);
+
+ if (feof(fp))
+ continue;
+
+ sscanf(ptmp, "%[\x21-z] %s", FENpos, onMove);
+ sprintf(FENpos, "%s %s", FENpos, onMove);
+
+ strcpy(ptmp, "");
+ fgets(ptmp, 1024, fp);
+ if (feof(fp))
+ continue;
+ sscanf(ptmp, "%[0-z]", ECO);
+
+ if ((ECO_book[i] = malloc(sizeof(ECO_entry))) == NULL) {
+ fprintf(stderr, "Cound not alloc mem for ECO "
+ "entry %d.\n", i);
+ exit(1);
+ }
+
+ strcpy(ECO_book[i]->ECO, ECO);
+ strcpy(ECO_book[i]->FENpos, FENpos);
+
+ ++i;
+ }
+
+ fclose(fp);
+ ECO_book[i] = NULL;
+
+ fprintf(stderr, "%d entries in ECO book\n", i);
+ ECO_entries = i;
+
+ while (--i >= 0) {
+ if (ECO_book[i] == NULL) {
+ fprintf(stderr, "ERROR! ECO book position number %d "
+ "is NULL.", i);
+ }
+ }
}
void