aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-10 01:31:09 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-10 01:31:09 +0100
commit9aabcc4bf2bf8d66a50c6a934f743c5dede3fd43 (patch)
treeb687361165ea191718842e12f53630b0d7bd73c1 /FICS
parente49c6b0d673fec46519e3c6fb4150480026f7025 (diff)
strdup() -> xstrdup()
Diffstat (limited to 'FICS')
-rw-r--r--FICS/adminproc.c24
-rw-r--r--FICS/command.c2
-rw-r--r--FICS/comproc.c8
-rw-r--r--FICS/fics_addplayer.c10
-rw-r--r--FICS/formula.c2
-rw-r--r--FICS/gameproc.c2
-rw-r--r--FICS/lists.c4
-rw-r--r--FICS/multicol.c6
-rw-r--r--FICS/playerdb.c58
-rw-r--r--FICS/talkproc.c2
-rw-r--r--FICS/utils.c4
-rw-r--r--FICS/utils.h2
-rw-r--r--FICS/variable.c6
13 files changed, 65 insertions, 65 deletions
diff --git a/FICS/adminproc.c b/FICS/adminproc.c
index b4b4ced..b739291 100644
--- a/FICS/adminproc.c
+++ b/FICS/adminproc.c
@@ -770,7 +770,7 @@ PUBLIC int com_raisedead(int p, param_list param)
p2 = player_new();
if (!(lookup = player_read(p2, newplayerlower))) {
strfree(parray[p2].name);
- parray[p2].name = strdup(newplayer);
+ parray[p2].name = xstrdup(newplayer);
player_save(p2);
if (parray[p2].s_stats.rating > 0)
UpdateRank(TYPE_STAND, newplayer, &parray[p2].s_stats, newplayer);
@@ -831,10 +831,10 @@ PUBLIC int com_addplayer(int p, param_list param)
player_remove(p1);
return COM_OK;
}
- parray[p1].name = strdup(newplayer);
- parray[p1].login = strdup(newplayerlower);
- parray[p1].fullName = strdup(newname);
- parray[p1].emailAddress = strdup(newemail);
+ parray[p1].name = xstrdup(newplayer);
+ parray[p1].login = xstrdup(newplayerlower);
+ parray[p1].fullName = xstrdup(newname);
+ parray[p1].emailAddress = xstrdup(newemail);
if (strcmp(newemail, "none")) {
for (i = 0; i < PASSLEN; i++) {
password[i] = 'a' + rand() % 26;
@@ -843,10 +843,10 @@ PUBLIC int com_addplayer(int p, param_list param)
salt[0] = 'a' + rand() % 26;
salt[1] = 'a' + rand() % 26;
salt[2] = '\0';
- parray[p1].passwd = strdup(crypt(password, salt));
+ parray[p1].passwd = xstrdup(crypt(password, salt));
} else {
password[0] = '\0';
- parray[p1].passwd = strdup(password);
+ parray[p1].passwd = xstrdup(password);
}
parray[p1].registered = 1;
/* parray[p1].network_player = 0; */
@@ -1049,14 +1049,14 @@ PUBLIC int com_asetpasswd(int p, param_list param)
if (parray[p1].passwd)
rfree(parray[p1].passwd);
if (param[1].val.word[0] == '*') {
- parray[p1].passwd = strdup(param[1].val.word);
+ parray[p1].passwd = xstrdup(param[1].val.word);
pprintf(p, "Account %s locked!\n", parray[p1].name);
sprintf(text, "Password of %s is now useless. Your account at our FICS has been locked.\n", parray[p1].name);
} else {
salt[0] = 'a' + rand() % 26;
salt[1] = 'a' + rand() % 26;
salt[2] = '\0';
- parray[p1].passwd = strdup(crypt(param[1].val.word, salt));
+ parray[p1].passwd = xstrdup(crypt(param[1].val.word, salt));
sprintf(text, "Password of %s changed to \"%s\".\n", parray[p1].name, param[1].val.word);
pprintf(p, "%s", text);
}
@@ -1108,7 +1108,7 @@ PUBLIC int com_asetemail(int p, param_list param)
parray[p1].emailAddress = NULL;
pprintf(p, "Email address for %s removed\n", parray[p1].name);
} else {
- parray[p1].emailAddress = strdup(param[1].val.word);
+ parray[p1].emailAddress = xstrdup(param[1].val.word);
pprintf(p, "Email address of %s changed to \"%s\".\n", parray[p1].name, param[1].val.word);
}
player_save(p1);
@@ -1152,7 +1152,7 @@ PUBLIC int com_asetrealname(int p, param_list param)
parray[p1].fullName = NULL;
pprintf(p, "Real name for %s removed\n", parray[p1].name);
} else {
- parray[p1].fullName = strdup(param[1].val.word);
+ parray[p1].fullName = xstrdup(param[1].val.word);
pprintf(p, "Real name of %s changed to \"%s\".\n", parray[p1].name, param[1].val.word);
}
player_save(p1);
@@ -1222,7 +1222,7 @@ PUBLIC int com_asethandle(int p, param_list param)
if ((!player_rename(playerlower, newplayerlower)) && (!player_read(p1, newplayerlower))) {
pprintf(p, "Player %s renamed to %s.\n", player, newplayer);
strfree(parray[p1].name);
- parray[p1].name = strdup(newplayer);
+ parray[p1].name = xstrdup(newplayer);
player_save(p1);
if (parray[p1].s_stats.rating > 0)
UpdateRank(TYPE_STAND, newplayer, &parray[p1].s_stats, player);
diff --git a/FICS/command.c b/FICS/command.c
index a53f305..edc300b 100644
--- a/FICS/command.c
+++ b/FICS/command.c
@@ -435,7 +435,7 @@ PRIVATE int process_login(int p, char *loginname)
if (!*loginname) { /* do something in here? */
} else {
- char *loginnameii = strdup(loginname);
+ char *loginnameii = xstrdup(loginname);
stolower(loginname);
if (!alphastring(loginname)) {
pprintf(p, "\nSorry, names can only consist of lower and upper case letters. Try again.\n");
diff --git a/FICS/comproc.c b/FICS/comproc.c
index 3d33473..b85a445 100644
--- a/FICS/comproc.c
+++ b/FICS/comproc.c
@@ -458,7 +458,7 @@ PUBLIC int com_password(int p, param_list param)
salt[0] = 'a' + rand() % 26;
salt[1] = 'a' + rand() % 26;
salt[2] = '\0';
- parray[p].passwd = strdup(crypt(newpassword, salt));
+ parray[p].passwd = xstrdup(crypt(newpassword, salt));
pprintf(p, "Password changed to \"%s\".\n", newpassword);
return COM_OK;
}
@@ -1285,9 +1285,9 @@ PUBLIC int com_alias(int p, param_list param)
pprintf(p, "You can't alias this command.\n");
} else {
parray[p].alias_list[parray[p].numAlias].comm_name =
- strdup(param[0].val.word);
+ xstrdup(param[0].val.word);
parray[p].alias_list[parray[p].numAlias].alias =
- strdup(param[1].val.string);
+ xstrdup(param[1].val.string);
parray[p].numAlias++;
pprintf(p, "Alias set.\n");
@@ -1295,7 +1295,7 @@ PUBLIC int com_alias(int p, param_list param)
}
} else {
rfree(parray[p].alias_list[al].alias);
- parray[p].alias_list[al].alias = strdup(param[1].val.string);
+ parray[p].alias_list[al].alias = xstrdup(param[1].val.string);
pprintf(p, "Alias replaced.\n");
}
parray[p].alias_list[parray[p].numAlias].comm_name = NULL;
diff --git a/FICS/fics_addplayer.c b/FICS/fics_addplayer.c
index 2a9e22e..6837e32 100644
--- a/FICS/fics_addplayer.c
+++ b/FICS/fics_addplayer.c
@@ -104,11 +104,11 @@ main(int argc, char *argv[])
fprintf(stderr, "%s already exists.\n", funame);
exit(0);
}
- parray[p].name = strdup(funame);
- parray[p].login = strdup(funame);
+ parray[p].name = xstrdup(funame);
+ parray[p].login = xstrdup(funame);
stolower(parray[p].login);
- parray[p].fullName = strdup(fname);
- parray[p].emailAddress = strdup(email);
+ parray[p].fullName = xstrdup(fname);
+ parray[p].emailAddress = xstrdup(email);
for (i = 0; i < PASSLEN; i++) {
password[i] = 'a' + rand() % 26;
}
@@ -116,7 +116,7 @@ main(int argc, char *argv[])
salt[0] = 'a' + rand() % 26;
salt[1] = 'a' + rand() % 26;
salt[2] = '\0';
- parray[p].passwd = strdup(crypt(password, salt));
+ parray[p].passwd = xstrdup(crypt(password, salt));
parray[p].registered = 1;
// parray[p].network_player = !local;
parray[p].rated = 1;
diff --git a/FICS/formula.c b/FICS/formula.c
index dbdd798..a8487a0 100644
--- a/FICS/formula.c
+++ b/FICS/formula.c
@@ -554,7 +554,7 @@ int SetValidFormula (int p, int clause, char *string)
if (string != NULL) {
string = eatwhite(string);
- *Cur = (*string != '\0' ? strdup (string) : NULL);
+ *Cur = (*string != '\0' ? xstrdup (string) : NULL);
}
else *Cur = NULL;
diff --git a/FICS/gameproc.c b/FICS/gameproc.c
index cf07200..c142386 100644
--- a/FICS/gameproc.c
+++ b/FICS/gameproc.c
@@ -1199,7 +1199,7 @@ PUBLIC int com_switch(int p, param_list param)
garray[g].white = garray[g].black;
garray[g].black = tmp;
parray[p].side = (parray[p].side == WHITE) ? BLACK : WHITE;
- strTmp = strdup(garray[g].white_name);
+ strTmp = xstrdup(garray[g].white_name);
strcpy(garray[g].white_name, garray[g].black_name);
strcpy(garray[g].black_name, strTmp);
strfree(strTmp);
diff --git a/FICS/lists.c b/FICS/lists.c
index 7e3748d..46c67f9 100644
--- a/FICS/lists.c
+++ b/FICS/lists.c
@@ -91,7 +91,7 @@ PRIVATE List *list_find(int p, enum ListWhich l)
while (!feof(fp)) {
if (fgets(listmember, 100, fp) != NULL) {
listmember[strlen(listmember) - 1] = '\0';
- tempList->member[count++] = strdup(listmember);
+ tempList->member[count++] = xstrdup(listmember);
}
}
fclose(fp);
@@ -110,7 +110,7 @@ PUBLIC int list_add(int p, enum ListWhich l, char *s)
if (gl) {
if (gl->numMembers < MAX_GLOBAL_LIST_SIZE) {
- gl->member[gl->numMembers] = strdup(s);
+ gl->member[gl->numMembers] = xstrdup(s);
gl->numMembers++;
return 0;
} else {
diff --git a/FICS/multicol.c b/FICS/multicol.c
index 8d52b04..d9fa653 100644
--- a/FICS/multicol.c
+++ b/FICS/multicol.c
@@ -56,7 +56,7 @@ PUBLIC int multicol_store(multicol * m, char *str)
return -1;
if (!str)
return -1;
- m->strArray[m->num] = strdup(str);
+ m->strArray[m->num] = xstrdup(str);
m->num++;
return 0;
}
@@ -73,13 +73,13 @@ PUBLIC int multicol_store_sorted(multicol * m, char *str)
for (i = m->num; (i > 0) && (!found); i--) {
if (strcasecmp(str, m->strArray[i - 1]) >= 0) {
found = 1;
- m->strArray[i] = strdup(str);
+ m->strArray[i] = xstrdup(str);
} else {
m->strArray[i] = m->strArray[i - 1];
}
}
if (!found)
- m->strArray[0] = strdup(str);
+ m->strArray[0] = xstrdup(str);
m->num++;
return 0;
}
diff --git a/FICS/playerdb.c b/FICS/playerdb.c
index 2cb30c5..a474d28 100644
--- a/FICS/playerdb.c
+++ b/FICS/playerdb.c
@@ -82,12 +82,12 @@ PUBLIC void player_init(int startConsole)
if (startConsole) {
net_addConnection(0, 0);
p = player_new();
- parray[p].login = strdup("console");
- parray[p].name = strdup("console");
- parray[p].passwd = strdup("*");
- parray[p].fullName = strdup("The Operator");
+ parray[p].login = xstrdup("console");
+ parray[p].name = xstrdup("console");
+ parray[p].passwd = xstrdup("*");
+ parray[p].fullName = xstrdup("The Operator");
parray[p].emailAddress = NULL;
- parray[p].prompt = strdup("fics%");
+ parray[p].prompt = xstrdup("fics%");
parray[p].adminLevel = ADMIN_GOD;
parray[p].socket = 0;
parray[p].busy[0] = '\0';
@@ -335,25 +335,25 @@ void ReadV1PlayerFmt(int p,player *pp, FILE * fp, char *file, int version)
fgets(tmp2, MAX_STRING_LENGTH, fp);
if (strcmp(tmp2,"NONE\n")) {
tmp2[strlen(tmp2)-1] = '\0';
- pp->name = strdup (tmp2);
+ pp->name = xstrdup (tmp2);
} else
pp->name = NULL;
fgets(tmp2, MAX_STRING_LENGTH, fp);
if (strcmp(tmp2,"NONE\n")) {
tmp2[strlen(tmp2)-1] = '\0';
- pp->fullName = strdup (tmp2);
+ pp->fullName = xstrdup (tmp2);
} else
pp->fullName = NULL;
fgets(tmp2, MAX_STRING_LENGTH, fp);
if (strcmp(tmp2,"NONE\n")) {
tmp2[strlen(tmp2)-1] = '\0';
- pp->passwd = strdup (tmp2);
+ pp->passwd = xstrdup (tmp2);
} else
pp->passwd = NULL;
fgets(tmp2, MAX_STRING_LENGTH, fp);
if (strcmp(tmp2,"NONE\n")) {
tmp2[strlen(tmp2)-1] = '\0';
- pp->emailAddress = strdup (tmp2);
+ pp->emailAddress = xstrdup (tmp2);
} else
pp->emailAddress = NULL;
if (fscanf(fp, "%u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %d\n",
@@ -390,7 +390,7 @@ void ReadV1PlayerFmt(int p,player *pp, FILE * fp, char *file, int version)
fgets (tmp2, MAX_STRING_LENGTH, fp);
tmp2[strlen(tmp2)-1] = '\0';
- pp->prompt = strdup(tmp2);
+ pp->prompt = xstrdup(tmp2);
if (fscanf (fp, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
&pp->open, &pp->rated, &pp->ropen, &pp->timeOfReg,
&pp->totalTime, &pp->bell, &pp->pgn, &pp->notifiedby,
@@ -416,7 +416,7 @@ void ReadV1PlayerFmt(int p,player *pp, FILE * fp, char *file, int version)
pp->num_plan--;
} else {
tmp2[len - 1] = '\0'; /* Get rid of '\n' */
- pp->planLines[i] = (len > 1) ? strdup(tmp2) : NULL;
+ pp->planLines[i] = (len > 1) ? xstrdup(tmp2) : NULL;
}
}
}
@@ -429,7 +429,7 @@ void ReadV1PlayerFmt(int p,player *pp, FILE * fp, char *file, int version)
pp->num_formula--;
} else {
tmp2[len - 1] = '\0'; /* Get rid of '\n' */
- pp->formulaLines[i] = (len > 1) ? strdup(tmp2) : NULL;
+ pp->formulaLines[i] = (len > 1) ? xstrdup(tmp2) : NULL;
}
}
}
@@ -438,7 +438,7 @@ void ReadV1PlayerFmt(int p,player *pp, FILE * fp, char *file, int version)
if (!strcmp (tmp2,"NONE"))
pp->formula = NULL;
else
- pp->formula = strdup(tmp2);
+ pp->formula = xstrdup(tmp2);
if (pp->numAlias > 0) {
for (i = 0; i < pp->numAlias; i++) {
@@ -454,8 +454,8 @@ void ReadV1PlayerFmt(int p,player *pp, FILE * fp, char *file, int version)
*tmp = '\0';
tmp++;
tmp = eatwhite(tmp);
- pp->alias_list[i].comm_name = strdup(tmp2);
- pp->alias_list[i].alias = strdup(tmp);
+ pp->alias_list[i].comm_name = xstrdup(tmp2);
+ pp->alias_list[i].alias = xstrdup(tmp);
}
}
}
@@ -492,15 +492,15 @@ PRIVATE int got_attr_value_player(int p, char *attr, char *value, FILE * fp, cha
char tmp[MAX_LINE_SIZE], *tmp1;
if (!strcmp(attr, "name:")) {
- parray[p].name = strdup(value);
+ parray[p].name = xstrdup(value);
} else if (!strcmp(attr, "password:")) {
- parray[p].passwd = strdup(value);
+ parray[p].passwd = xstrdup(value);
} else if (!strcmp(attr, "fullname:")) {
- parray[p].fullName = strdup(value);
+ parray[p].fullName = xstrdup(value);
} else if (!strcmp(attr, "email:")) {
- parray[p].emailAddress = strdup(value);
+ parray[p].emailAddress = xstrdup(value);
} else if (!strcmp(attr, "prompt:")) {
- parray[p].prompt = strdup(value);
+ parray[p].prompt = xstrdup(value);
} else if (!strcmp(attr, "s_num:")) {
parray[p].s_stats.num = atoi(value);
} else if (!strcmp(attr, "s_win:")) {
@@ -642,7 +642,7 @@ PRIVATE int got_attr_value_player(int p, char *attr, char *value, FILE * fp, cha
parray[p].num_plan--;
} else {
tmp[len - 1] = '\0'; /* Get rid of '\n' */
- parray[p].planLines[i] = (len > 1) ? strdup(tmp) : NULL;
+ parray[p].planLines[i] = (len > 1) ? xstrdup(tmp) : NULL;
}
}
}
@@ -657,12 +657,12 @@ PRIVATE int got_attr_value_player(int p, char *attr, char *value, FILE * fp, cha
parray[p].num_formula--;
} else {
tmp[len - 1] = '\0'; /* Get rid of '\n' */
- parray[p].formulaLines[i] = (len > 1) ? strdup(tmp) : NULL;
+ parray[p].formulaLines[i] = (len > 1) ? xstrdup(tmp) : NULL;
}
}
}
} else if (!strcmp(attr, "formula:")) {
- parray[p].formula = strdup(value);
+ parray[p].formula = xstrdup(value);
} else if (!strcmp(attr, "num_alias:")) {
parray[p].numAlias = atoi(value);
if (parray[p].numAlias > 0) {
@@ -679,8 +679,8 @@ PRIVATE int got_attr_value_player(int p, char *attr, char *value, FILE * fp, cha
*tmp1 = '\0';
tmp1++;
tmp1 = eatwhite(tmp1);
- parray[p].alias_list[i].comm_name = strdup(tmp);
- parray[p].alias_list[i].alias = strdup(tmp1);
+ parray[p].alias_list[i].comm_name = xstrdup(tmp);
+ parray[p].alias_list[i].alias = xstrdup(tmp1);
}
}
}
@@ -743,13 +743,13 @@ PUBLIC int player_read(int p, char *name)
int len;
int version = 0;
- parray[p].login = stolower(strdup(name));
+ parray[p].login = stolower(xstrdup(name));
sprintf(fname, "%s/%c/%s", player_dir, parray[p].login[0], parray[p].login);
fp = fopen(fname, "r");
if (!fp) { /* unregistered player */
- parray[p].name = strdup(name);
+ parray[p].name = xstrdup(name);
parray[p].registered = 0;
return -1;
}
@@ -794,7 +794,7 @@ PUBLIC int player_read(int p, char *name)
player_save (p); /* ensure old files are quickly converted eg when someone
fingers */
if (!parray[p].name) {
- parray[p].name = strdup(name);
+ parray[p].name = xstrdup(name);
pprintf(p, "\n*** WARNING: Your Data file is corrupt. Please tell an admin ***\n");
}
return 0;
@@ -2039,7 +2039,7 @@ PUBLIC int player_show_messages(int p)
PUBLIC void SaveTextListEntry(textlist **Entry, char *string, int n)
{
*Entry = (textlist *) rmalloc(sizeof(textlist));
- (*Entry)->text = strdup(string);
+ (*Entry)->text = xstrdup(string);
(*Entry)->index = n;
(*Entry)->next = NULL;
}
diff --git a/FICS/talkproc.c b/FICS/talkproc.c
index cfd35b6..f04fed4 100644
--- a/FICS/talkproc.c
+++ b/FICS/talkproc.c
@@ -687,7 +687,7 @@ PRIVATE int notorcen(int p, param_list param, int *num, int max,
pprintf(p, "You can't %s yourself.\n", listname);
return COM_OK;
}
- list[*num] = strdup(parray[p1].name);
+ list[*num] = xstrdup(parray[p1].name);
++(*num);
pprintf(p, "%s is now on your %s list.\n", parray[p1].name, listname);
if (!connected)
diff --git a/FICS/utils.c b/FICS/utils.c
index d6a93a9..955d56f 100644
--- a/FICS/utils.c
+++ b/FICS/utils.c
@@ -406,7 +406,7 @@ PUBLIC int psend_file(int p, char *dir, char *file)
}
}
if (!feof(fp)) {
- parray[p].last_file = strdup(fname);
+ parray[p].last_file = xstrdup(fname);
parray[p].last_file_byte = ftell(fp);
pprintf(p, "Type [next] to see next page.\n");
}
@@ -571,7 +571,7 @@ PUBLIC int printablestring(char *str)
return 1;
}
-PUBLIC char *strdup(const char *str)
+PUBLIC char *xstrdup(const char *str)
{
char *tmp;
diff --git a/FICS/utils.h b/FICS/utils.h
index 4920c79..704ad7d 100644
--- a/FICS/utils.h
+++ b/FICS/utils.h
@@ -82,7 +82,7 @@ extern int safechar( );
extern int safestring( );
extern int alphastring( );
extern int printablestring( );
-extern char *strdup( ); /* XXX */
+extern char *xstrdup( ); /* XXX */
extern char *hms_desc();
extern char *hms();
diff --git a/FICS/variable.c b/FICS/variable.c
index b53664d..725b8a8 100644
--- a/FICS/variable.c
+++ b/FICS/variable.c
@@ -631,7 +631,7 @@ PRIVATE int set_plan(int p, char *var, char *val)
}
if (parray[p].num_plan < MAX_PLAN)
parray[p].num_plan++;
- parray[p].planLines[0] = ((val == NULL) ? NULL : strdup(val));
+ parray[p].planLines[0] = ((val == NULL) ? NULL : xstrdup(val));
pprintf(p, "\nPlan variable %d changed to '%s'.\n", which+1, parray[p].planLines[which]);
pprintf(p, "All other variables moved down.\n");
return VAR_OK;
@@ -645,7 +645,7 @@ PRIVATE int set_plan(int p, char *var, char *val)
} else {
parray[p].num_plan++;
}
- parray[p].planLines[which - 1] = ((val == NULL) ? NULL : strdup(val));
+ parray[p].planLines[which - 1] = ((val == NULL) ? NULL : xstrdup(val));
pprintf(p, "\nPlan variable %d changed to '%s'.\n", which, parray[p].planLines[which-1]);
return VAR_OK;
}
@@ -654,7 +654,7 @@ PRIVATE int set_plan(int p, char *var, char *val)
rfree(parray[p].planLines[which]);
}
if (val != NULL) {
- parray[p].planLines[which] = strdup(val);
+ parray[p].planLines[which] = xstrdup(val);
pprintf(p, "\nPlan variable %d changed to '%s'.\n", which+1, parray[p].planLines[which]);
} else {
parray[p].planLines[which] = NULL;