aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/command.c
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-03-31 13:43:57 +0200
committerMarkus Uhlin <markus@nifty-networks.net>2024-03-31 13:43:57 +0200
commiteafa10064ae0fe329e7f71750a7a708493e8e8e1 (patch)
tree620f3a932cbe5549fd219a31757fbd4311f97b4e /FICS/command.c
parent7a6bdc1d305aa18e91cf3d8d59ee900d64b066df (diff)
Improved commands_init()
Diffstat (limited to 'FICS/command.c')
-rw-r--r--FICS/command.c58
1 files changed, 31 insertions, 27 deletions
diff --git a/FICS/command.c b/FICS/command.c
index 04e538c..5d27580 100644
--- a/FICS/command.c
+++ b/FICS/command.c
@@ -1042,35 +1042,39 @@ process_heartbeat(int *fd)
return COM_OK;
}
-PUBLIC void commands_init()
+PUBLIC void
+commands_init(void)
{
- FILE *fp, *afp;
- char fname[MAX_FILENAME_SIZE];
- int i = 0;
+ FILE *fp, *afp;
+ char fname[MAX_FILENAME_SIZE];
+ int i = 0;
- sprintf(fname, "%s/commands", comhelp_dir);
- fp = fopen(fname, "w");
- if (!fp) {
- fprintf(stderr, "FICS: Could not write commands help file.\n");
- return;
- }
- sprintf(fname, "%s/admin_commands", adhelp_dir);
- afp = fopen(fname, "w");
- if (!afp) {
- fprintf(stderr, "FICS: Could not write admin_commands help file.\n");
- fclose(fp);
- return;
- }
- while (command_list[i].comm_name) {
- if (command_list[i].adminLevel >= ADMIN_ADMIN) {
- fprintf(afp, "%s\n", command_list[i].comm_name);
- } else {
- fprintf(fp, "%s\n", command_list[i].comm_name);
- }
- i++;
- }
- fclose(fp);
- fclose(afp);
+ snprintf(fname, sizeof fname, "%s/commands", comhelp_dir);
+
+ if ((fp = fopen(fname, "w")) == NULL) {
+ fprintf(stderr, "FICS: Could not write commands help file.\n");
+ return;
+ }
+
+ snprintf(fname, sizeof fname, "%s/admin_commands", adhelp_dir);
+
+ if ((afp = fopen(fname, "w")) == NULL) {
+ fprintf(stderr, "FICS: Could not write admin_commands help "
+ "file.\n");
+ fclose(fp);
+ return;
+ }
+
+ while (command_list[i].comm_name) {
+ if (command_list[i].adminLevel >= ADMIN_ADMIN)
+ fprintf(afp, "%s\n", command_list[i].comm_name);
+ else
+ fprintf(fp, "%s\n", command_list[i].comm_name);
+ i++;
+ }
+
+ fclose(fp);
+ fclose(afp);
}
/* Need to save rated games */