diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2023-12-18 20:18:20 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2023-12-18 20:18:20 +0100 |
commit | b5b384404c626e720f0acfea75e75a3396e22494 (patch) | |
tree | 248c3e2f307d5a70342eb2a49b8884bb2eb42105 | |
parent | 1dca955a8a97db844172a972ddbe48b77ea6f952 (diff) |
Reformatted player_lastdisconnect() and changed its return type
-rw-r--r-- | FICS/playerdb.c | 54 | ||||
-rw-r--r-- | FICS/playerdb.h | 2 |
2 files changed, 32 insertions, 24 deletions
diff --git a/FICS/playerdb.c b/FICS/playerdb.c index 1d0fa2e..d407df1 100644 --- a/FICS/playerdb.c +++ b/FICS/playerdb.c @@ -1240,30 +1240,38 @@ PUBLIC int player_lastconnect(int p) return last; } -PUBLIC int player_lastdisconnect(int p) -{ - char fname[MAX_FILENAME_SIZE]; - FILE *fp; - int inout, thetime, registered; - int last = 0; - char ipstr[20]; - char loginName[MAX_LOGIN_NAME]; +PUBLIC time_t +player_lastdisconnect(int p) +{ + FILE *fp; + char fname[MAX_FILENAME_SIZE]; + char ipstr[20]; + char loginName[MAX_LOGIN_NAME]; + int inout, registered; + long int lval; + time_t last = 0; + + sprintf(fname, "%s/player_data/%c/%s.%s", stats_dir, parray[p].login[0], + parray[p].login, STATS_LOGONS); + + if ((fp = fopen(fname, "r")) == NULL) + return 0; + + while (!feof(fp)) { + if (fscanf(fp, "%d %s %ld %d %s\n", &inout, loginName, &lval, + ®istered, ipstr) != 5) { + fprintf(stderr, "FICS: Error in login info format. %s" + "\n", fname); + fclose(fp); + return 0; + } - sprintf(fname, "%s/player_data/%c/%s.%s", stats_dir, parray[p].login[0], parray[p].login, STATS_LOGONS); - fp = fopen(fname, "r"); - if (!fp) - return 0; - while (!feof(fp)) { - if (fscanf(fp, "%d %s %d %d %s\n", &inout, loginName, &thetime, ®istered, ipstr) != 5) { - fprintf(stderr, "FICS: Error in login info format. %s\n", fname); - fclose(fp); - return 0; - } - if (inout == P_LOGOUT) - last = thetime; - } - fclose(fp); - return last; + if (inout == P_LOGOUT) + last = lval; + } + + fclose(fp); + return last; } PUBLIC void player_pend_print(int p, pending *pend) diff --git a/FICS/playerdb.h b/FICS/playerdb.h index f3924c7..8cb73ef 100644 --- a/FICS/playerdb.h +++ b/FICS/playerdb.h @@ -226,7 +226,7 @@ extern int player_clear(int); extern void player_write_login(int); extern void player_write_logout(int); extern int player_lastconnect(int); -extern int player_lastdisconnect(int); +extern time_t player_lastdisconnect(int); extern void player_pend_print(int, pending *); |