diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-04-01 18:54:27 +0200 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-04-01 18:54:27 +0200 |
commit | 1894a200e2946bb86b6b6f792a7c52dcf199873b (patch) | |
tree | fea967086ad2d511e334cc7ab5e48ff90a340909 /FICS | |
parent | 8742a71ac444ee9a2b3c9079994c3ab1a414acb6 (diff) |
Reformatted set_busy() and replaced the sprintf() call
Diffstat (limited to 'FICS')
-rw-r--r-- | FICS/variable.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/FICS/variable.c b/FICS/variable.c index d2e2d69..777d3e3 100644 --- a/FICS/variable.c +++ b/FICS/variable.c @@ -43,6 +43,10 @@ #include "utils.h" #include "variable.h" +#if __linux__ +#include <bsd/string.h> +#endif + PRIVATE int set_boolean_var(int *var, char *val) { int v = -1; @@ -585,22 +589,27 @@ PRIVATE int set_partner(int p, char *var, char *val) return VAR_OK; } -PRIVATE int set_busy(int p, char *var, char *val) +PRIVATE int +set_busy(int p, char *var, char *val) { - if (!val) { - parray[p].busy[0] = '\0'; - pprintf(p, "Your \"busy\" string was cleared.\n"); - return VAR_OK; - } - if ((val) && (!printablestring(val))) - return VAR_BADVAL; - if (strlen(val) > 50) { - pprintf(p, "That string is too long.\n"); - return VAR_BADVAL; - } - sprintf(parray[p].busy, "%s", val); - pprintf(p, "Your \"busy\" string was set to \" %s\"\n", parray[p].busy); - return VAR_OK; + if (!val) { + parray[p].busy[0] = '\0'; + pprintf(p, "Your \"busy\" string was cleared.\n"); + return VAR_OK; + } + + if (val && !printablestring(val)) + return VAR_BADVAL; + + if (strlen(val) > 50) { + pprintf(p, "That string is too long.\n"); + return VAR_BADVAL; + } + + strlcpy(parray[p].busy, val, sizeof(parray[p].busy)); + + pprintf(p, "Your \"busy\" string was set to \" %s\"\n", parray[p].busy); + return VAR_OK; } PRIVATE int |