From 1b88c6776032b06126d9c5b7763bd8c9d8fe75ac Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sun, 17 Dec 2023 19:46:31 +0100 Subject: Reformatted plogins() and fixed the type of the var passed to strltime() --- FICS/comproc.c | 63 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/FICS/comproc.c b/FICS/comproc.c index 28dfc41..3536693 100644 --- a/FICS/comproc.c +++ b/FICS/comproc.c @@ -521,36 +521,43 @@ char *inout_string[] = { "login", "logout" }; -PRIVATE int plogins(p, fname) -int p; -char *fname; +PRIVATE int +plogins(int p, char *fname) { - FILE *fp; - int inout, thetime, registered; - char loginName[MAX_LOGIN_NAME + 1]; - char ipstr[20]; + FILE *fp; + char ipstr[20]; + char loginName[MAX_LOGIN_NAME + 1]; + int inout, registered; + long int lval; + time_t tval; + + if ((fp = fopen(fname, "r")) == NULL) { + pprintf(p, "Sorry, no login information available.\n"); + return COM_OK; + } - fp = fopen(fname, "r"); - if (!fp) { - pprintf(p, "Sorry, no login information available.\n"); - return COM_OK; - } - 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 COM_OK; - } - pprintf(p, "%s: %-17s %-6s", strltime(&thetime), loginName, - inout_string[inout]); - if (parray[p].adminLevel > 0) { - pprintf(p, " from %s\n", ipstr); - } else - pprintf(p, "\n"); - } - fclose(fp); - return COM_OK; + 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 COM_OK; + } + + tval = lval; + + pprintf(p, "%s: %-17s %-6s", strltime(&tval), loginName, + inout_string[inout]); + + if (parray[p].adminLevel > 0) + pprintf(p, " from %s\n", ipstr); + else + pprintf(p, "\n"); + } + + fclose(fp); + return COM_OK; } PUBLIC int com_llogons(int p, param_list param) -- cgit v1.2.3