aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-17 18:32:57 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-17 18:32:57 +0100
commit14a34482da2a77a69550bd6f9b3fa3ab4219e4e5 (patch)
treecac8a6aa07a593897c63992fb53365be1a8dd3b4
parent3ae7f34539e42f96b9f2e3212a23d82e128544f9 (diff)
Reformatted player_add_message() and fixed the type of the var passed to strltime()
-rw-r--r--FICS/playerdb.c65
1 files changed, 37 insertions, 28 deletions
diff --git a/FICS/playerdb.c b/FICS/playerdb.c
index 5628d15..1ab9b13 100644
--- a/FICS/playerdb.c
+++ b/FICS/playerdb.c
@@ -1872,36 +1872,45 @@ PUBLIC int player_num_messages(int p)
return lines_file(fname);
}
-PUBLIC int player_add_message(int top, int fromp, char *message)
+PUBLIC int
+player_add_message(int top, int fromp, char *message)
{
-/* char command[MAX_FILENAME_SIZE]; */
- char fname[MAX_FILENAME_SIZE];
- FILE *fp;
- char subj[256];
- char messbody[1024];
- int t = time(0);
+ FILE *fp;
+ char fname[MAX_FILENAME_SIZE];
+ char messbody[1024];
+ char subj[256];
+ time_t t = time(NULL);
- if (!parray[top].registered)
- return -1;
- if (!parray[fromp].registered)
- return -1;
- GetMsgFile (top, fname);
- if ((lines_file(fname) >= MAX_MESSAGES) && (parray[top].adminLevel == 0))
- return -1;
- fp = fopen(fname, "a");
- if (!fp)
- return -1;
- fprintf(fp, "%s at %s: %s\n", parray[fromp].name, strltime(&t), message);
- fclose(fp);
- pprintf(fromp, "\nThe following message was sent ");
- if (parray[top].i_mailmess) {
- sprintf(subj, "FICS message from %s at FICS %s (Do not reply by mail)", parray[fromp].name, fics_hostname);
- sprintf(messbody, "%s at %s: %s\n", parray[fromp].name, strltime(&t), message);
- mail_string_to_user(top, subj, messbody);
- pprintf(fromp, "(and emailed) ");
- }
- pprintf(fromp, "to %s: \n %s\n", parray[top].name, message);
- return 0;
+ if (!parray[top].registered)
+ return -1;
+ if (!parray[fromp].registered)
+ return -1;
+
+ GetMsgFile(top, fname);
+
+ if (lines_file(fname) >= MAX_MESSAGES && parray[top].adminLevel == 0)
+ return -1;
+
+ if ((fp = fopen(fname, "a")) == NULL)
+ return -1;
+ fprintf(fp, "%s at %s: %s\n", parray[fromp].name, strltime(&t),
+ message);
+ fclose(fp);
+
+ pprintf(fromp, "\nThe following message was sent ");
+
+ if (parray[top].i_mailmess) {
+ sprintf(subj, "FICS message from %s at FICS %s "
+ "(Do not reply by mail)", parray[fromp].name,
+ fics_hostname);
+ sprintf(messbody, "%s at %s: %s\n", parray[fromp].name,
+ strltime(&t), message);
+ mail_string_to_user(top, subj, messbody);
+ pprintf(fromp, "(and emailed) ");
+ }
+
+ pprintf(fromp, "to %s: \n %s\n", parray[top].name, message);
+ return 0;
}
PUBLIC void SaveTextListEntry(textlist **Entry, char *string, int n)