diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-04-27 12:39:34 +0200 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-04-27 12:39:34 +0200 |
commit | 78bf2b74a6abfd7f58f97e4a8f2000e10ea884c2 (patch) | |
tree | a32523951b8011c7a9c6f4f0c85815cfe1398131 | |
parent | 968d85f3179ebf1444231f1f70b7c0f93db7046e (diff) |
Revised ExamineAdjourned()
-rw-r--r-- | FICS/obsproc.c | 83 |
1 files changed, 50 insertions, 33 deletions
diff --git a/FICS/obsproc.c b/FICS/obsproc.c index 0ed9cac..55d949a 100644 --- a/FICS/obsproc.c +++ b/FICS/obsproc.c @@ -707,45 +707,62 @@ ExamineStored(FILE *fp, int p, char *filename) return g; } -PRIVATE void ExamineAdjourned(int p, int p1, int p2) +PRIVATE void +ExamineAdjourned(int p, int p1, int p2) { - FILE *fp; - char filename[1024]; - char *p1Login, *p2Login; - int g; + FILE *fp; + char *p1Login, *p2Login; + char filename[1024] = { '\0' }; + int g; - p1Login = parray[p1].login; - p2Login = parray[p2].login; + p1Login = parray[p1].login; + p2Login = parray[p2].login; - sprintf(filename, "%s/%c/%s-%s", adj_dir, *p1Login, p1Login, p2Login); - fp = fopen(filename, "r"); - if (!fp) { - sprintf(filename, "%s/%c/%s-%s", adj_dir, *p2Login, p1Login, p2Login); - fp = fopen(filename, "r"); - if (!fp) { - sprintf(filename, "%s/%c/%s-%s", adj_dir, *p2Login, p2Login, p1Login); - fp = fopen(filename, "r"); - if (!fp) { - sprintf(filename, "%s/%c/%s-%s", adj_dir, *p1Login, p2Login, p1Login); + (void)snprintf(filename, sizeof filename, "%s/%c/%s-%s", + adj_dir, *p1Login, p1Login, p2Login); fp = fopen(filename, "r"); + if (!fp) { - pprintf(p, "No stored game between \"%s\" and \"%s\".\n", - parray[p1].name, parray[p2].name); - return; + (void)snprintf(filename, sizeof filename, "%s/%c/%s-%s", + adj_dir, *p2Login, p1Login, p2Login); + fp = fopen(filename, "r"); + + if (!fp) { + (void)snprintf(filename, sizeof filename, + "%s/%c/%s-%s", + adj_dir, *p2Login, p2Login, p1Login); + fp = fopen(filename, "r"); + + if (!fp) { + (void)snprintf(filename, sizeof filename, + "%s/%c/%s-%s", + adj_dir, *p1Login, p2Login, p1Login); + fp = fopen(filename, "r"); + + if (!fp) { + pprintf(p, "No stored game between " + "\"%s\" and \"%s\".\n", + parray[p1].name, + parray[p2].name); + return; + } + } + } + } + + g = ExamineStored(fp, p, filename); + fclose(fp); + + if (g >= 0) { + if (garray[g].white_name[0] == '\0') { + mstrlcpy(garray[g].white_name, p1Login, + sizeof(garray[g].white_name)); + } + if (garray[g].black_name[0] == '\0') { + mstrlcpy(garray[g].black_name, p2Login, + sizeof(garray[g].black_name)); + } } - } - } - } - g = ExamineStored(fp, p, filename); - fclose(fp); - - if (g >= 0) { - if (garray[g].white_name[0] == '\0') - strcpy(garray[g].white_name, p1Login); - if (garray[g].black_name[0] == '\0') - strcpy(garray[g].black_name, p2Login); - } - return; } PRIVATE char * |