From 436c2c2bf609ee2da75bf416c4aba9ced14445a1 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Mon, 25 Dec 2023 18:03:29 +0100 Subject: Reformatted psend_command() --- FICS/utils.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/FICS/utils.c b/FICS/utils.c index 9f8ef39..ad7e6ee 100644 --- a/FICS/utils.c +++ b/FICS/utils.c @@ -465,29 +465,32 @@ PUBLIC int pmore_file(int p) return 0; } -PUBLIC int psend_command(int p, char *command, char *input) +PUBLIC int +psend_command(int p, char *command, char *input) { - FILE *fp; - char tmp[MAX_LINE_SIZE]; - int num; + FILE *fp; + char tmp[MAX_LINE_SIZE]; + int num; - if (input) - fp = popen(command, "w"); - else - fp = popen(command, "r"); - if (!fp) - return -1; - if (input) { - fwrite(input, sizeof(char), strlen(input), fp); - } else { - while (!feof(fp)) { - num = fread(tmp, sizeof(char), MAX_LINE_SIZE - 1, fp); - tmp[num] = '\0'; - net_send_string(parray[p].socket, tmp, 1); - } - } - pclose(fp); - return 0; + if (input) + fp = popen(command, "w"); + else + fp = popen(command, "r"); + if (!fp) + return -1; + + if (input) { + fwrite(input, sizeof(char), strlen(input), fp); + } else { + while (!feof(fp)) { + num = fread(tmp, sizeof(char), MAX_LINE_SIZE - 1, fp); + tmp[num] = '\0'; + net_send_string(parray[p].socket, tmp, 1); + } + } + + pclose(fp); + return 0; } PUBLIC char * -- cgit v1.2.3