aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/playerdb.c
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-29 02:25:32 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-29 02:25:32 +0100
commitf2d951c1c7fa5ff076221864008e8c8f52f07a91 (patch)
tree4d9ca79c5f78c2924fb63b353b87d5f47b067806 /FICS/playerdb.c
parent1cd60383e19c2fb7c7e40890d4dcedbe268ff1a8 (diff)
Reformatted LoadMsgRange()
Diffstat (limited to 'FICS/playerdb.c')
-rw-r--r--FICS/playerdb.c85
1 files changed, 46 insertions, 39 deletions
diff --git a/FICS/playerdb.c b/FICS/playerdb.c
index 31e3fcb..f01a8ba 100644
--- a/FICS/playerdb.c
+++ b/FICS/playerdb.c
@@ -2045,46 +2045,53 @@ PRIVATE int LoadMsgs(int p, int which, textlist **Head)
return nSave;
}
-/* start > 0 and end > start (or end = 0) to save messages in range;
- start < 0 and end < start (or end = 0) to clear messages in range;
- if end = 0, range goes to end of file (not tested yet). */
-PRIVATE int LoadMsgRange(int p, int start, int end, textlist **Head)
+/*
+ * start > 0 and end > start (or end = 0) to save messages in range;
+ * start < 0 and end < start (or end = 0) to clear messages in range;
+ * if end = 0, range goes to end of file (not tested yet).
+ */
+PRIVATE int
+LoadMsgRange(int p, int start, int end, textlist **Head)
{
- FILE *fp;
- char fName[MAX_FILENAME_SIZE];
- char line[MAX_LINE_SIZE];
- textlist **Cur = Head;
- int n=1, nSave=0, nKill=0;
+ FILE *fp;
+ char fName[MAX_FILENAME_SIZE];
+ char line[MAX_LINE_SIZE];
+ int n = 1, nSave = 0, nKill = 0;
+ textlist** Cur = Head;
- *Head = NULL;
- GetMsgFile (p, fName);
- fp = fopen (fName, "r");
- if (fp == NULL) {
- pprintf (p, "You have no messages.\n");
- return -1;
- }
- for (n=1; n <= end || end <= 0; n++) {
- fgets (line, MAX_LINE_SIZE, fp);
- if (feof(fp))
- break;
- if ((start < 0 && (n < -start || n > -end))
- || (start >= 0 && n >= start)) {
- SaveTextListEntry (Cur, line, n);
- Cur = &(*Cur)->next;
- nSave++;
- }
- else nKill++;
- }
- fclose (fp);
- if (start < 0) {
- if (n <= -start)
- pprintf (p, "You do not have a message %d.\n", -start);
- return nKill;
- } else {
- if (n <= start)
- pprintf (p, "You do not have a message %d.\n", start);
- return nSave;
- }
+ *Head = NULL;
+ GetMsgFile(p, fName);
+
+ if ((fp = fopen(fName, "r")) == NULL) {
+ pprintf(p, "You have no messages.\n");
+ return -1;
+ }
+
+ for (n = 1; n <= end || end <= 0; n++) {
+ fgets(line, sizeof line, fp);
+
+ if (feof(fp))
+ break;
+ if ((start < 0 && (n < -start || n > -end)) ||
+ (start >= 0 && n >= start)) {
+ SaveTextListEntry (Cur, line, n);
+ Cur = &(*Cur)->next;
+ nSave++;
+ } else
+ nKill++;
+ }
+
+ fclose(fp);
+
+ if (start < 0) {
+ if (n <= -start)
+ pprintf(p, "You do not have a message %d.\n", -start);
+ return nKill;
+ } else {
+ if (n <= start)
+ pprintf(p, "You do not have a message %d.\n", start);
+ return nSave;
+ }
}
PRIVATE int
@@ -2159,7 +2166,7 @@ player_show_messages(int p)
int n;
textlist *Head;
- n = LoadMsgs (p, 0, &Head);
+ n = LoadMsgs(p, 0, &Head);
if (n <= 0) {
pprintf(p, "You have no messages.\n");