aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-25 18:19:31 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-25 18:19:31 +0100
commitea65c237644a6f3d90402c9e0bc1694855993617 (patch)
treecb8c11a90e27b13d70f0eb8678e766c2862218a6 /FICS
parent1f85eec03ba42d8077b28d212f11eeaaeed3c50b (diff)
Reformatted psend_file()
Diffstat (limited to 'FICS')
-rw-r--r--FICS/utils.c62
1 files changed, 33 insertions, 29 deletions
diff --git a/FICS/utils.c b/FICS/utils.c
index a20eb5b..962a2aa 100644
--- a/FICS/utils.c
+++ b/FICS/utils.c
@@ -361,38 +361,42 @@ PUBLIC int psend_raw_file(int p, char *dir, char *file)
return 0;
}
-PUBLIC int psend_file(int p, char *dir, char *file)
+PUBLIC int
+psend_file(int p, char *dir, char *file)
{
- FILE *fp;
- char tmp[MAX_LINE_SIZE];
- char fname[MAX_FILENAME_SIZE];
- int lcount = parray[p].d_height - 1;
+ FILE *fp;
+ char fname[MAX_FILENAME_SIZE];
+ char tmp[MAX_LINE_SIZE];
+ int lcount = (parray[p].d_height - 1);
- if (parray[p].last_file)
- rfree(parray[p].last_file);
- parray[p].last_file = NULL;
- parray[p].last_file_byte = 0L;
+ if (parray[p].last_file)
+ rfree(parray[p].last_file);
+ parray[p].last_file = NULL;
+ parray[p].last_file_byte = 0L;
- if (dir)
- sprintf(fname, "%s/%s", dir, file);
- else
- strcpy(fname, file);
- fp = fopen(fname, "r");
- if (!fp)
- return -1;
- while (!feof(fp) && (--lcount > 0)) {
- fgets(tmp, MAX_LINE_SIZE - 1, fp);
- if (!feof(fp)) {
- net_send_string(parray[p].socket, tmp, 1);
- }
- }
- if (!feof(fp)) {
- parray[p].last_file = xstrdup(fname);
- parray[p].last_file_byte = ftell(fp);
- pprintf(p, "Type [next] to see next page.\n");
- }
- fclose(fp);
- return 0;
+ if (dir)
+ sprintf(fname, "%s/%s", dir, file);
+ else
+ strcpy(fname, file);
+
+ if ((fp = fopen(fname, "r")) == NULL)
+ return -1;
+
+ while (!feof(fp) && --lcount > 0) {
+ fgets(tmp, MAX_LINE_SIZE - 1, fp);
+
+ if (!feof(fp))
+ net_send_string(parray[p].socket, tmp, 1);
+ }
+
+ if (!feof(fp)) {
+ parray[p].last_file = xstrdup(fname);
+ parray[p].last_file_byte = ftell(fp);
+ pprintf(p, "Type [next] to see next page.\n");
+ }
+
+ fclose(fp);
+ return 0;
}
/*