Vanilla Development Maling List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS update: Vanilla/ntserv
Date: Tuesday June 15, 1999 @ 19:30
Author: unbelver
Update of /home/netrek/cvsroot/Vanilla/ntserv
In directory cvs.castle.real-time.com:/var/tmp/cvs-serv6733
Modified Files:
solicit.c
Log Message:
Grabbed the non-printable stripper from tools/players.c to avoid weird
looking output on the extended info port on the metaserver. (3522)
Control characters were screwing up the output.
--Carlos V.
****************************************
Index: Vanilla/ntserv/solicit.c
diff -u Vanilla/ntserv/solicit.c:1.6 Vanilla/ntserv/solicit.c:1.7
--- Vanilla/ntserv/solicit.c:1.6 Fri May 28 03:40:43 1999
+++ Vanilla/ntserv/solicit.c Tue Jun 15 19:30:50 1999
@@ -17,6 +17,25 @@
/* initialisation done flag */
static int initialised = 0;
+/* remove non-printable chars in a string. Lifted from tools/players.c */
+/* with a minor addition: error checking on the strdup */
+char *name_fix(name)
+ char *name;
+{
+ char *new = strdup(name); /* xx, never freed */
+ register
+ char *r = new;
+
+ if(!new) return new; /* don't play with null ptr */
+
+ while(*name){
+ *r++ = (*name <= 32)?'_':*name;
+ name++;
+ }
+ *r = 0;
+ return new;
+}
+
/* attach to a metaserver, i.e. prepare the socket */
static int udp_attach(struct metaserver *m)
{
@@ -76,6 +95,8 @@
int i, nplayers=0, nfree=0;
char packet[MAXMETABYTES];
/* static char prior[MAXMETABYTES];*/
+ char *fixed_name;
+ int caughtnull = 0;
char *here = packet;
time_t now = time(NULL);
int gamefull = 0; /* is the game full? */
@@ -189,6 +210,7 @@
players[j].p_stats.st_tticks == 0)
#endif
continue;
+ fixed_name = name_fix(players[j].p_name); /*get rid of non-printables*/
sprintf(here, "%c\n%c\n%d\n%d\n%s\n%s@%s\n",
/* number */ players[j].p_mapchars[1],
/* team */ players[j].p_mapchars[0],
@@ -196,10 +218,11 @@
/* ??? note change from design, ship type number not string */
/* rank */ players[j].p_stats.st_rank,
/* ??? note change from design, rank number not string */
- /* name */ players[j].p_name,
+ /* name */ (!fixed_name) ? fixed_name : players[j].p_name,
/* user */ players[j].p_login,
/* host */ players[j].p_monitor );
here += strlen(here);
+ free(fixed_name);
}
}