diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-05-02 21:52:33 +0200 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-05-02 21:52:33 +0200 |
commit | 648644e08b5bc9fad4dd33f807dc3c447429de8a (patch) | |
tree | 6f92fc06db11f634e8b261daa13ab103da9932dc /FICS | |
parent | 5a38a16f5da22eaf07dda8946767510dd28ec6f9 (diff) |
Reformatted journal_get_info()
Diffstat (limited to 'FICS')
-rw-r--r-- | FICS/gamedb.c | 73 |
1 files changed, 38 insertions, 35 deletions
diff --git a/FICS/gamedb.c b/FICS/gamedb.c index a72e39a..28d443a 100644 --- a/FICS/gamedb.c +++ b/FICS/gamedb.c @@ -1461,43 +1461,46 @@ PRIVATE void write_g_out(int g, char *file, int maxlines, int isDraw, /* Find from_spot in journal list - return 0 if corrupted */ -PUBLIC int journal_get_info(int p,char from_spot,char* WhiteName, int* WhiteRating, - char* BlackName, int* BlackRating, char* type,int* t,int* i,char* eco, - char* ending,char* result, char *fname) +PUBLIC int +journal_get_info(int p, char from_spot, char *WhiteName, int *WhiteRating, + char *BlackName, int *BlackRating, char *type, int *t, int *i, char *eco, + char *ending, char *result, char *fname) { - char count; - FILE *fp; + FILE *fp; + char count; - fp = fopen(fname, "r"); - if (!fp) { - fprintf (stderr, "Corrupt journal file! %s\n",fname); - pprintf (p, "The journal file is corrupt! See an admin.\n"); - return 0; - } - while (!feof(fp)) { - if (fscanf(fp, "%c %s %d %s %d %s %d %d %s %s %s\n", - &count, - WhiteName, - &(*WhiteRating), - BlackName, - &(*BlackRating), - type, - &(*t), &(*i), - eco, - ending, - result) != 11) { - fprintf(stderr, "FICS: Error in journal info format. %s\n", fname); - pprintf(p, "The journal file is corrupt! Error in internal format.\n"); - fclose(fp); - return 0; - } - if (tolower(count) == from_spot) { - fclose(fp); - return 1; - } - } - fclose(fp); - return 0; + if ((fp = fopen(fname, "r")) == NULL) { + fprintf(stderr, "Corrupt journal file! %s\n", fname); + pprintf(p, "The journal file is corrupt! See an admin.\n"); + return 0; + } + + while (!feof(fp)) { + if (fscanf(fp, "%c %s %d %s %d %s %d %d %s %s %s\n", + &count, + WhiteName, &(*WhiteRating), + BlackName, &(*BlackRating), + type, + &(*t), &(*i), + eco, + ending, + result) != 11) { + fprintf(stderr, "FICS: Error in journal info format. " + "%s\n", fname); + pprintf(p, "The journal file is corrupt! Error in " + "internal format.\n"); + fclose(fp); + return 0; + } + + if (tolower(count) == from_spot) { + fclose(fp); + return 1; + } + } + + fclose(fp); + return 0; } PUBLIC void |