diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2023-12-25 18:27:48 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2023-12-25 18:27:48 +0100 |
commit | e047a9074a87e895b48bf1fb447a415b3772b9c6 (patch) | |
tree | d41446470f55329a178a9f08346e4e65b35e0ad7 /FICS/utils.c | |
parent | ea65c237644a6f3d90402c9e0bc1694855993617 (diff) |
Reformatted functions
Diffstat (limited to 'FICS/utils.c')
-rw-r--r-- | FICS/utils.c | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/FICS/utils.c b/FICS/utils.c index 962a2aa..4a5e4b0 100644 --- a/FICS/utils.c +++ b/FICS/utils.c @@ -318,47 +318,47 @@ PUBLIC int pprintf_prompt(int p, char *format,...) return retval; } -PUBLIC int pprintf_noformat(int p, char *format,...) +PUBLIC int +pprintf_noformat(int p, char *format,...) { - char tmp[10 * MAX_LINE_SIZE]; /* Make sure you can handle 10 lines worth of - stuff */ - int retval; - va_list ap; + char tmp[10 * MAX_LINE_SIZE]; + int retval; + va_list ap; - va_start(ap, format); + va_start(ap, format); + retval = vsprintf(tmp, format, ap); + va_end(ap); - retval = vsprintf(tmp, format, ap); - if (strlen(tmp) > 10 * MAX_LINE_SIZE) { - fprintf(stderr, "FICS: pprintf_noformat buffer overflow\n"); - } - net_send_string(parray[p].socket, tmp, 0); - va_end(ap); - return retval; -} + if (strlen(tmp) > 10 * MAX_LINE_SIZE) + fprintf(stderr, "FICS: %s: buffer overflow\n", __func__); + net_send_string(parray[p].socket, tmp, 0); + return retval; +} -/******************* grimm *************/ -/******************* added below *************/ -PUBLIC int psend_raw_file(int p, char *dir, char *file) +PUBLIC int +psend_raw_file(int p, char *dir, char *file) { - FILE *fp; - char tmp[MAX_LINE_SIZE]; - char fname[MAX_FILENAME_SIZE]; - int num; - - if (dir) - sprintf(fname, "%s/%s", dir, file); - else - strcpy(fname, file); - fp = fopen(fname, "r"); - if (!fp) - return -1; - while ((num = fread(tmp, sizeof(char), MAX_LINE_SIZE - 1, fp)) > 0) { - tmp[num] = '\0'; - net_send_string(parray[p].socket, tmp, 1); - } - fclose(fp); - return 0; + FILE *fp; + char fname[MAX_FILENAME_SIZE]; + char tmp[MAX_LINE_SIZE]; + int num; + + if (dir) + sprintf(fname, "%s/%s", dir, file); + else + strcpy(fname, file); + + if ((fp = fopen(fname, "r")) == NULL) + return -1; + + while ((num = fread(tmp, sizeof(char), MAX_LINE_SIZE - 1, fp)) > 0) { + tmp[num] = '\0'; + net_send_string(parray[p].socket, tmp, 1); + } + + fclose(fp); + return 0; } PUBLIC int |