aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-04-23 19:53:15 +0200
committerMarkus Uhlin <markus@nifty-networks.net>2024-04-23 19:53:15 +0200
commit968d85f3179ebf1444231f1f70b7c0f93db7046e (patch)
treec5be66e6844ce69ef3491b319282bef51e2a1ea3
parent7dea096ff40e206d2f4cd0e5b8512903481b3c5e (diff)
Revised FindHistory()
-rw-r--r--FICS/obsproc.c57
1 files changed, 31 insertions, 26 deletions
diff --git a/FICS/obsproc.c b/FICS/obsproc.c
index cdd2a26..0ed9cac 100644
--- a/FICS/obsproc.c
+++ b/FICS/obsproc.c
@@ -748,34 +748,39 @@ PRIVATE void ExamineAdjourned(int p, int p1, int p2)
return;
}
-PRIVATE char *FindHistory(int p, int p1, int game)
+PRIVATE char *
+FindHistory(int p, int p1, int game)
{
- FILE *fpHist;
- static char fileName[MAX_FILENAME_SIZE];
- int index;
- long when;
-
- sprintf(fileName, "%s/player_data/%c/%s.%s", stats_dir,
- parray[p1].login[0], parray[p1].login, STATS_GAMES);
- fpHist = fopen(fileName, "r");
- if (fpHist == NULL) {
- pprintf(p, "No games in history for %s.\n", parray[p1].name);
- return(NULL);
- }
- do {
- fscanf(fpHist, "%d %*c %*d %*c %*d %*s %*s %*d %*d %*d %*d %*s %*s %ld",
- &index, &when);
- } while (!feof(fpHist) && index != game);
-
- if (feof(fpHist)) {
- pprintf(p, "There is no history game %d for %s.\n", game, parray[p1].name);
- fclose(fpHist);
- return(NULL);
- }
- fclose(fpHist);
+ FILE *fpHist;
+ int index;
+ long int when;
+ static char fileName[MAX_FILENAME_SIZE];
+
+ msnprintf(fileName, sizeof fileName, "%s/player_data/%c/%s.%s",
+ stats_dir, parray[p1].login[0], parray[p1].login, STATS_GAMES);
+
+ if ((fpHist = fopen(fileName, "r")) == NULL) {
+ pprintf(p, "No games in history for %s.\n", parray[p1].name);
+ return NULL;
+ }
- sprintf(fileName, "%s/%ld/%ld", hist_dir, when % 100, when);
- return(fileName);
+ do {
+ fscanf(fpHist, "%d %*c %*d %*c %*d %*s %*s %*d %*d %*d %*d "
+ "%*s %*s %ld", &index, &when);
+ } while (!feof(fpHist) && index != game);
+
+ if (feof(fpHist)) {
+ pprintf(p, "There is no history game %d for %s.\n", game,
+ parray[p1].name);
+ fclose(fpHist);
+ return NULL;
+ }
+
+ fclose(fpHist);
+
+ msnprintf(fileName, sizeof fileName, "%s/%ld/%ld", hist_dir,
+ (when % 100), when);
+ return (&fileName[0]);
}
PRIVATE char *