aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-31 17:48:33 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-31 17:48:33 +0100
commit7078821e5c3b327db486e73a501c7f04c89e5f96 (patch)
treefbfff899d7599a048275e6367ad3116f56ad5079 /FICS
parente719c1472211b92171430447b8e80a1525a83585 (diff)
Reformatted player_save() and replaced sprintf() with snprintf()
Diffstat (limited to 'FICS')
-rw-r--r--FICS/playerdb.c52
1 files changed, 29 insertions, 23 deletions
diff --git a/FICS/playerdb.c b/FICS/playerdb.c
index d4bb0a3..e05221a 100644
--- a/FICS/playerdb.c
+++ b/FICS/playerdb.c
@@ -948,33 +948,39 @@ WritePlayerFile(FILE *fp, int p)
list_print(fp, p, L_CHANNEL);
}
-PUBLIC int player_save(int p)
+PUBLIC int
+player_save(int p)
{
- FILE *fp;
- char fname[MAX_FILENAME_SIZE];
+ FILE *fp;
+ char fname[MAX_FILENAME_SIZE];
- if (!parray[p].registered) { /* Player must not be registered */
- return -1;
- }
- if (parray[p].name == NULL) { /* fixes a bug if name is null */
- pprintf(p, "WARNING: Your player file could not be updated, due to corrupt data.\n");
- return -1;
- }
- if (strcasecmp(parray[p].login, parray[p].name)) {
- pprintf(p, "WARNING: Your player file could not be updated, due to corrupt data.\n");
- return -1;
- }
+ if (!parray[p].registered) // Player must not be registered
+ return -1;
- sprintf(fname, "%s/%c/%s", player_dir, parray[p].login[0], parray[p].login);
- fp = fopen(fname, "w");
- if (!fp) {
- fprintf(stderr, "FICS: Problem opening file %s for write\n", fname);
- return -1;
- }
+ if (parray[p].name == NULL) { // Fixes a bug if name is null
+ pprintf(p, "WARNING: Your player file could not be updated, "
+ "due to corrupt data.\n");
+ return -1;
+ }
- WritePlayerFile(fp,p);
- fclose(fp);
- return 0;
+ if (strcasecmp(parray[p].login, parray[p].name)) {
+ pprintf(p, "WARNING: Your player file could not be updated, "
+ "due to corrupt data.\n");
+ return -1;
+ }
+
+ snprintf(fname, sizeof fname, "%s/%c/%s", player_dir,
+ parray[p].login[0], parray[p].login);
+
+ if ((fp = fopen(fname, "w")) == NULL) {
+ fprintf(stderr, "FICS: Problem opening file %s for write\n",
+ fname);
+ return -1;
+ }
+
+ WritePlayerFile(fp, p);
+ fclose(fp);
+ return 0;
}
PUBLIC int