aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-29 00:17:55 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-29 00:17:55 +0100
commit3b19243ace0f1c58e652fda2188db97986d1faaf (patch)
tree8f545250ee15314b4a388efa819a04ba7a243cf1 /FICS
parent7dd697ee891109f60b646a49de5612e7a2f50deb (diff)
Reformatted player_rename and switched to usage of snprintf()
Diffstat (limited to 'FICS')
-rw-r--r--FICS/playerdb.c53
1 files changed, 35 insertions, 18 deletions
diff --git a/FICS/playerdb.c b/FICS/playerdb.c
index 6ad941a..ce69b42 100644
--- a/FICS/playerdb.c
+++ b/FICS/playerdb.c
@@ -2326,26 +2326,43 @@ PUBLIC int player_kill(char *name)
return 0;
}
-PUBLIC int player_rename(char *name, char *newname)
+PUBLIC int
+player_rename(char *name, char *newname)
{
- char fname[MAX_FILENAME_SIZE], fname2[MAX_FILENAME_SIZE];
+ char fname[MAX_FILENAME_SIZE];
+ char fname2[MAX_FILENAME_SIZE];
- sprintf(fname, "%s/%c/%s", player_dir, name[0], name);
- sprintf(fname2, "%s/%c/%s", player_dir, newname[0], newname);
- rename(fname, fname2);
- sprintf(fname, "%s/player_data/%c/%s.games", stats_dir, name[0], name);
- sprintf(fname2, "%s/player_data/%c/%s.games", stats_dir, newname[0], newname);
- rename(fname, fname2);
- sprintf(fname, "%s/player_data/%c/%s.comments", stats_dir, name[0], name);
- sprintf(fname2, "%s/player_data/%c/%s.comments", stats_dir, newname[0], newname);
- rename(fname, fname2);
- sprintf(fname, "%s/player_data/%c/%s.logons", stats_dir, name[0], name);
- sprintf(fname2, "%s/player_data/%c/%s.logons", stats_dir, newname[0], newname);
- rename(fname, fname2);
- sprintf(fname, "%s/player_data/%c/%s.messages", stats_dir, name[0], name);
- sprintf(fname2, "%s/player_data/%c/%s.messages", stats_dir, newname[0], newname);
- rename(fname, fname2);
- return 0;
+ snprintf(fname, sizeof fname, "%s/%c/%s", player_dir, name[0],
+ name);
+ snprintf(fname2, sizeof fname2, "%s/%c/%s", player_dir, newname[0],
+ newname);
+ rename(fname, fname2);
+
+ snprintf(fname, sizeof fname, "%s/player_data/%c/%s.games",
+ stats_dir, name[0], name);
+ snprintf(fname2, sizeof fname2, "%s/player_data/%c/%s.games",
+ stats_dir, newname[0], newname);
+ rename(fname, fname2);
+
+ snprintf(fname, sizeof fname, "%s/player_data/%c/%s.comments",
+ stats_dir, name[0], name);
+ snprintf(fname2, sizeof fname2, "%s/player_data/%c/%s.comments",
+ stats_dir, newname[0], newname);
+ rename(fname, fname2);
+
+ snprintf(fname, sizeof fname, "%s/player_data/%c/%s.logons",
+ stats_dir, name[0], name);
+ snprintf(fname2, sizeof fname2, "%s/player_data/%c/%s.logons",
+ stats_dir, newname[0], newname);
+ rename(fname, fname2);
+
+ snprintf(fname, sizeof fname, "%s/player_data/%c/%s.messages",
+ stats_dir, name[0], name);
+ snprintf(fname2, sizeof fname2, "%s/player_data/%c/%s.messages",
+ stats_dir, newname[0], newname);
+ rename(fname, fname2);
+
+ return 0;
}
PUBLIC int