diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2023-12-17 19:46:31 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2023-12-17 19:46:31 +0100 |
commit | 1b88c6776032b06126d9c5b7763bd8c9d8fe75ac (patch) | |
tree | ee91fabed1c2a9cff0d0fd85a9dddc2183f2f459 | |
parent | 80a57b28738c0bfa093a27740a56a36cb544b500 (diff) |
Reformatted plogins() and fixed the type of the var passed to strltime()
-rw-r--r-- | FICS/comproc.c | 63 |
1 files 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) |