aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-03-30 11:30:11 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2024-03-30 11:30:11 +0100
commite72a1467e9f29a61fb72a27d240fd0f0f4d53a00 (patch)
treec914a7fb0b03457543dffb316a734a809b094389 /FICS
parentc04a418c92e1bba97af4260db59a1730be66a155 (diff)
Reformatted com_boards() and replaced sprintf() calls
Diffstat (limited to 'FICS')
-rw-r--r--FICS/gameproc.c62
1 files changed, 32 insertions, 30 deletions
diff --git a/FICS/gameproc.c b/FICS/gameproc.c
index 258e0f4..cff355b 100644
--- a/FICS/gameproc.c
+++ b/FICS/gameproc.c
@@ -1330,43 +1330,45 @@ PUBLIC int com_time(int p, param_list param)
return COM_OK;
}
-PUBLIC int com_boards(int p, param_list param)
+PUBLIC int
+com_boards(int p, param_list param)
{
- char *category = NULL;
- char dname[MAX_FILENAME_SIZE];
- DIR *dirp;
+ DIR *dirp;
+ char *category = NULL;
+ char dname[MAX_FILENAME_SIZE] = { '\0' };
#ifdef USE_DIRENT
- struct dirent *dp;
+ struct dirent *dp;
#else
- struct direct *dp;
+ struct direct *dp;
#endif
- if (param[0].type == TYPE_WORD)
- category = param[0].val.word;
- if (category) {
- pprintf(p, "Boards Available For Category %s:\n", category);
- sprintf(dname, "%s/%s", board_dir, category);
- } else {
- pprintf(p, "Categories Available:\n");
- sprintf(dname, "%s", board_dir);
- }
- dirp = opendir(dname);
- if (!dirp) {
- pprintf(p, "No such category %s, try \"boards\".\n", category);
- return COM_OK;
- }
+ if (param[0].type == TYPE_WORD)
+ category = param[0].val.word;
-/* YUK! what a mess, how about printing an ordered directory? - DAV*/
+ if (category) {
+ pprintf(p, "Boards Available For Category %s:\n", category);
+ snprintf(dname, sizeof dname, "%s/%s", board_dir, category);
+ } else {
+ pprintf(p, "Categories Available:\n");
+ snprintf(dname, sizeof dname, "%s", board_dir);
+ }
- for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
- if (!strcmp(dp->d_name, "."))
- continue;
- if (!strcmp(dp->d_name, ".."))
- continue;
- pprintf(p, "%s\n", dp->d_name);
- }
- closedir(dirp);
- return COM_OK;
+ if ((dirp = opendir(dname)) == NULL) {
+ pprintf(p, "No such category %s, try \"boards\".\n", category);
+ return COM_OK;
+ }
+
+ // YUK! What a mess, how about printing an ordered directory? - DAV
+ for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
+ if (!strcmp(dp->d_name, "."))
+ continue;
+ if (!strcmp(dp->d_name, ".."))
+ continue;
+ pprintf(p, "%s\n", dp->d_name);
+ }
+
+ closedir(dirp);
+ return COM_OK;
}
PUBLIC int