aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
Diffstat (limited to 'FICS')
-rw-r--r--FICS/eco.c89
1 files changed, 52 insertions, 37 deletions
diff --git a/FICS/eco.c b/FICS/eco.c
index b17afd9..ef35f46 100644
--- a/FICS/eco.c
+++ b/FICS/eco.c
@@ -228,44 +228,59 @@ void NIC_init()
NIC_entries = i;
}
-void LONG_init()
+void
+LONG_init()
{
- FILE *fp;
- char tmp[1024];
- char *ptmp= tmp;
- char FENpos[73], LONG[256], onMove[2];
- char filename[1024];
- int i=0;
-
- sprintf(filename, "%s/long999.idx", book_dir);
- fp= fopen(filename, "r");
- if (!fp) {
- fprintf(stderr, "Could not open LONG file\n");
- 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, "%[^*\n]", LONG);
- LONG_book[i]= (LONG_entry *) malloc(sizeof(LONG_entry));
- if (LONG_book[i]==NULL) {
- fprintf(stderr, "Cound not alloc mem for LONG entry %d.\n", i);
- exit(1);
- }
- strcpy(LONG_book[i]->LONG, LONG);
- strcpy(LONG_book[i]->FENpos, FENpos);
- ++i;
- }
- fclose(fp);
- LONG_book[i]=NULL;
- fprintf(stderr, "%d entries in LONG book\n", i);
- LONG_entries = i;
+ FILE *fp;
+ char FENpos[73];
+ char LONG[256];
+ char filename[1024];
+ char onMove[2];
+ char tmp[1024];
+ char *ptmp = tmp;
+ int i = 0;
+
+ sprintf(filename, "%s/long999.idx", book_dir);
+
+ if ((fp = fopen(filename, "r")) == NULL) {
+ fprintf(stderr, "Could not open LONG file\n");
+ 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, "%[^*\n]", LONG);
+
+ LONG_book[i] = malloc(sizeof(LONG_entry));
+ if (LONG_book[i] == NULL) {
+ fprintf(stderr, "Cound not alloc mem for "
+ "LONG entry %d.\n", i);
+ exit(1);
+ }
+
+ strcpy(LONG_book[i]->LONG, LONG);
+ strcpy(LONG_book[i]->FENpos, FENpos);
+
+ ++i;
+ }
+
+ fclose(fp);
+ LONG_book[i] = NULL;
+
+ fprintf(stderr, "%d entries in LONG book\n", i);
+ LONG_entries = i;
}
void BookInit()