aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/eco.c
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-16 17:37:39 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-16 17:37:39 +0100
commitc7006ed5f5300a473fb917019f74b1bbc5742ae6 (patch)
treed04f2f5a0ea4477f21eccb87ba37a0b65a841cba /FICS/eco.c
parent4dea62206172c23449bbb34cb201c7a9e3de751c (diff)
Reformatted NIC_init()
Diffstat (limited to 'FICS/eco.c')
-rw-r--r--FICS/eco.c86
1 files changed, 50 insertions, 36 deletions
diff --git a/FICS/eco.c b/FICS/eco.c
index ddb5fd0..7777606 100644
--- a/FICS/eco.c
+++ b/FICS/eco.c
@@ -188,44 +188,58 @@ void ECO_init()
fprintf(stderr, "ERROR! ECO book position number %d is NULL.", i);
}
-void NIC_init()
+void
+NIC_init()
{
- FILE *fp;
- char tmp[1024];
- char *ptmp= tmp;
- char FENpos[73], NIC[6], onMove[2];
- char filename[1024];
- int i=0;
+ FILE *fp;
+ char *ptmp = tmp;
+ char FENpos[73];
+ char NIC[6];
+ char filename[1024];
+ char onMove[2];
+ char tmp[1024];
+ int i = 0;
- sprintf(filename, "%s/nic999.idx", book_dir);
- fp= fopen(filename, "r");
- if (!fp) {
- fprintf(stderr, "Could not open NIC 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, "%[.-z]", NIC);
- NIC_book[i]= (NIC_entry *) malloc(sizeof(NIC_entry));
- if (NIC_book[i]==NULL) {
- fprintf(stderr, "Cound not alloc mem for NIC entry %d.\n", i);
- exit(1);
- }
- strcpy(NIC_book[i]->NIC, NIC);
- strcpy(NIC_book[i]->FENpos, FENpos);
- ++i;
- }
- fclose(fp);
- NIC_book[i]=NULL;
- fprintf(stderr, "%d entries in NIC book\n", i);
- NIC_entries = i;
+ sprintf(filename, "%s/nic999.idx", book_dir);
+
+ if ((fp = fopen(filename, "r")) == NULL) {
+ fprintf(stderr, "Could not open NIC 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, "%[.-z]", NIC);
+
+ if ((NIC_book[i] = malloc(sizeof(NIC_entry))) == NULL) {
+ fprintf(stderr, "Cound not alloc mem for NIC "
+ "entry %d.\n", i);
+ exit(1);
+ }
+
+ strcpy(NIC_book[i]->NIC, NIC);
+ strcpy(NIC_book[i]->FENpos, FENpos);
+
+ ++i;
+ }
+
+ fclose(fp);
+ NIC_book[i] = NULL;
+
+ fprintf(stderr, "%d entries in NIC book\n", i);
+ NIC_entries = i;
}
void