Update of /cvsroot/netrek/server/Vanilla/ntserv
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv693/ntserv

Modified Files:
	Makefile.in commands.c data.c gencmds.c main.c socket.c 
Log Message:
libnetrek.a

Index: Makefile.in
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/Makefile.in,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Makefile.in	10 Apr 2006 10:56:31 -0000	1.4
+++ Makefile.in	22 Apr 2006 11:31:53 -0000	1.5
@@ -1,5 +1,3 @@
-#	Change CONFIG to your .mk file
-
 VPATH = @srcdir@
 srcdir = @srcdir@
 
@@ -11,25 +9,41 @@
 INSTALLPROG = @INSTALL_PROGRAM@
 INSTALLDATA = @INSTALL_DATA@
 
-#	Do not edit below here. Everything should be setup in config
+#	libnetrek object files
+
+L_OBJS = bay.o \
+	coup.o \
+	data.o db.o detonate.o distress.o \
+	enter.o \
+	feature.o features.o \
+	gencmds.o genspkt.o getpath.o getship.o glog.o \
+	interface.o \
+	ltd_stats.o \
+	openmem.o orbit.o \
+	phaser.o ping.o plasma.o \
+	rsa_key.o reserved.o \
+	salt.o slotmaint.o sintab.o smessage.o socket.o startrobot.o sysdefaults.o \
+	torp.o transwarp.o \
+	util.o \
+	warning.o
 
 #	ntserv object files
 
-R_OBJS =    cluecheck.o coup.o data.o db.o death.o detonate.o enter.o \
-	    findslot.o  getentry.o  getname.o  salt.o getship.o  input.o \
+R_OBJS =    cluecheck.o coup.o db.o death.o detonate.o enter.o \
+	    findslot.o  getentry.o  getname.o  getship.o  input.o \
 	    interface.o  main.o  orbit.o  phaser.o  plasma.o  redraw.o \
 	    reserved.o  sintab.o  socket.o  genspkt.o  smessage.o  \
 	    startrobot.o  sysdefaults.o  timecheck.o  torp.o  util.o  \
-	    warning.o ping.o $(RANDOMO) getpath.o $(STRDUPO) features.o \
+	    warning.o ping.o $(RANDOMO) $(STRDUPO) features.o \
 	    distress.o transwarp.o gencmds.o ntscmds.o openmem.o feature.o \
-	    queue.o slotmaint.o rsa_key.o ltd_stats.o bay.o
+	    queue.o slotmaint.o rsa_key.o ltd_stats.o libnetrek.a
 
 
 #	daemonII object files
 
-D_OBJS =    daemonII.o  sintab.o  sysdefaults.o  data.o  slotmaint.o \
-	    util.o  $(RANDOMO) getpath.o getship.o smessage.o  queue.o \
-	    wander2.o openmem.o solicit.o ltd_stats.o bay.o
+D_OBJS =    daemonII.o  sintab.o  sysdefaults.o  slotmaint.o \
+	    util.o  $(RANDOMO) getship.o smessage.o  queue.o \
+	    wander2.o openmem.o solicit.o ltd_stats.o libnetrek.a
 
 #	Src files
 
@@ -48,15 +62,14 @@
             ${srcdir}/features.c ${srcdir}/distress.c ${srcdir}/transwarp.c \
             ${srcdir}/gencmds.c ${srcdir}/ntscmds.c ${srcdir}/openmem.c \
             ${srcdir}/feature.c ${srcdir}/queue.c ${srcdir}/slotmaint.c \
-            ${srcdir}/wander2.c ${srcdir}/sysdefaults.c ${srcdir}/rsa_key.c \
-            ${srcdir}/bay.c
+            ${srcdir}/wander2.c ${srcdir}/sysdefaults.c ${srcdir}/rsa_key.c
 
 SRC = 	    $(R_FILES)  data.h  defs.h planets.h  struct.h \
 	    packets.h  copyright.h
 
 LIBS = $(RSA_LIB) $(EXTRALIBS)
 
-INCS = $(RSA_INCS) $(EXTRAINCS) -I. -I${srcdir} -I../include -I${srcdir}/../include
+INCS = $(RSA_INCS) $(EXTRAINCS) -I../include
 
 CFLAGS = $(FLAGS) $(INCS)
 
@@ -71,6 +84,13 @@
 daemonII: $(PMAKE) $(D_OBJS)
 	$(CC) $(CFLAGS) ${LDFLAGS} -o daemonII $(D_OBJS) $(EXTRALIBS)
 
+libnetrek.a: $(L_OBJS)
+	ar cru $@ $(L_OBJS)
+	ranlib $@
+
+libnetrek.so: $(L_OBJS)
+	gcc -shared -Wl,-soname,$@ -o $@ $(L_OBJS) -lc
+
 commands.o: $(PMAKE) ${srcdir}/commands.c
 	$(CC) $(CFLAGS) $(DEP) -c ${srcdir}/commands.c
 
@@ -88,12 +108,11 @@
 	ling $(LINTFLAGS) $(SRC)
 
 clean: rmdependencies
-	/bin/rm -f *.o *.ln make.out core
+	/bin/rm -f *.a *.o *.ln make.out core
 
 reallyclean:  clean
 	rm -f ntserv daemonII .motd *~ #*#
 
-
 uninstall:
 	-cd $(XTREKDIR); rm -f daemonII .motd .sysdef; rm -rf slots
 	-cd $(LIBDIR); rm -f ntserv ; rm -rf slots

Index: data.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/data.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- data.c	27 Sep 2005 12:26:37 -0000	1.3
+++ data.c	22 Apr 2006 11:31:53 -0000	1.4
@@ -26,11 +26,7 @@
 
 int	oldalert = PFGREEN;	/* Avoid changing more than we have to */
 
-#ifdef XSG
-int     remap[16] = { 0, 1, 2, 0, 3, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0 };
-#else
 int 	remap[9] = { 0, 1, 2, -1, 3, -1, -1, -1, 4 };
-#endif
 int	reality = 10;		/* reality updates per second */
 int	minskip = 10;		/* maximum client updates per second */
 int	defskip = 5;		/* default client updates per second */
@@ -409,3 +405,4 @@
 int remoteaddr = -1;		/* inet address in net format */
 int whitelisted = 0;
 int blacklisted = 0;
+int ignored[MAXPLAYER];

Index: commands.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/commands.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- commands.c	22 Apr 2006 02:16:46 -0000	1.2
+++ commands.c	22 Apr 2006 11:31:53 -0000	1.3
@@ -1080,7 +1080,6 @@
     char *current;
     int pcount=0;  /* Total players in game */
     int vcount=0;  /* Number who've voted recently */
-    FILE *glog;
     int mflag = 0;
     int sendto = 0;
 
@@ -1094,22 +1093,19 @@
 #endif
 
     if ( votes[num].tag & VC_GLOG ){
-      if (!(glog = fopen(GodLog,"a")) )       /* Log votes for God to see */
-        perror(GodLog);
-      else {
+      if (glog_open() == 0) {	/* Log votes for God to see */
         time_t    t = time(NULL);
         char      tbuf[40];
         struct tm *tmv = localtime(&t);
       
 #ifdef STRFTIME
-      sprintf(tbuf, "%02d/%02d %d/%d", tmv->tm_hour,tmv->tm_min,
-              tmv->tm_mday,tmv->tm_mon);
+	sprintf(tbuf, "%02d/%02d %d/%d", tmv->tm_hour,tmv->tm_min,
+		tmv->tm_mday,tmv->tm_mon);
 #else
 	strftime(tbuf, 39, "%R %D", tmv);
 #endif
-        fprintf(glog, "VOTE: %s %s@%s \"%s\"\n", tbuf, players[who].p_login, 
-		players[who].p_monitor, comm);
- 	fclose(glog);
+        glog_printf("VOTE: %s %s@%s \"%s\"\n", tbuf, players[who].p_login, 
+		    players[who].p_ip, comm);
       }
     }
 
@@ -1184,11 +1180,8 @@
       pmessage(sendto, mflag, addr_mess(sendto,mflag), 
              "The motion %s passes", current);
       if ( votes[num].tag & VC_GLOG ){
-        if (!(glog = fopen(GodLog,"a")) )       /* Log pass for God to see */
-          perror(GodLog);
-        else {
- 	  fprintf(glog, "VOTE: The motion %s passes\n", current);
-	  fclose(glog);
+        if (glog_open() == 0) {	/* Log pass for God to see */
+ 	  glog_printf("VOTE: The motion %s passes\n", current);
 	}
       }
       

Index: main.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/main.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- main.c	10 Apr 2006 10:38:22 -0000	1.5
+++ main.c	22 Apr 2006 11:31:53 -0000	1.6
@@ -44,9 +44,7 @@
 static void printStats(void);
 static int checkbanned(char *login, char *host);
 
-
-int ignored[MAXPLAYER];	/* change 7/24/91 TC */
-
+extern int ignored[MAXPLAYER];
 int indie = 0;			/* always be indie 8/28/91 TC */
 int living = 1;			/* our ship is living, reset by death */
 
@@ -232,6 +230,7 @@
     else
 	STRNCPY(login, "Bozo", NAME_LEN);
     login[NAME_LEN - 1] = '\0';
+    endpwent();
 
     strcpy(pseudo, "Guest");
 

Index: gencmds.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/gencmds.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gencmds.c	21 Mar 2005 05:23:43 -0000	1.1
+++ gencmds.c	22 Apr 2006 11:31:53 -0000	1.2
@@ -49,7 +49,6 @@
 {
   int i, len;
   char *comm;
-  FILE *glog;
 
   if (!(mess->m_flags & MINDIV)) return 0;	/* double-check */
 
@@ -89,10 +88,7 @@
       /* Record vote in GodLog if C_GLOG is set */
       if (cmds[i].tag & C_GLOG )
       {
-	if (!(glog = fopen(GodLog,"a")) )       /* Log votes for God to see */
-	  perror(GodLog);
-	else
-	{
+	if (glog_open() == 0) {	/* Log votes for God to see */
 	  time_t    t = time(NULL);
 	  char      tbuf[40];
 	  struct tm *tmv = localtime(&t);
@@ -103,10 +99,9 @@
 #else
 	  strftime(tbuf, 39, "%R %D", tmv);
 #endif
-	  fprintf(glog, "VOTE: %s %s@%s \"%s\"\n", tbuf,
+	  glog_printf("VOTE: %s %s@%s \"%s\"\n", tbuf,
 		  players[mess->m_from].p_login, 
 		  players[mess->m_from].p_monitor, comm);
-	  fclose(glog);
 	}
       } /* !C_GLOG */
 
@@ -117,12 +112,8 @@
 	{
 	  if ( cmds[i].tag & C_GLOG ) {
 
-	    if (!(glog = fopen(GodLog,"a")) )       /* Log pass for God to see */
-	      perror(GodLog);
-	    else
-	    {
-	      fprintf(glog, "VOTE: The motion %s passes\n", comm);
-	      fclose(glog);
+	    if (glog_open() == 0) {	/* Log pass for God to see */
+	      glog_printf("VOTE: The motion %s passes\n", comm);
 	    }
           }
 	}

Index: socket.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/socket.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- socket.c	22 Apr 2006 02:16:46 -0000	1.6
+++ socket.c	22 Apr 2006 11:31:53 -0000	1.7
@@ -300,7 +300,7 @@
 #define MAX_NONFAT	10		/* if we have this much left, stop */
 
 #ifdef CHECKMESG
-static FILE	*mlog, *glog;
+static FILE	*mlog;
 #endif
 
 /*int           send_short        = 0;*/ /* is now in data.c , because of robotII.c */
@@ -507,10 +507,7 @@
 	if (!mlog) mlog = fopen(MesgLog, "a");
 	if (!mlog) perror(MesgLog);
     }
-    if (loggod) {
-	if (!glog) glog = fopen(GodLog,"a");
-	if (!glog) perror(GodLog);
-    }
+    if (loggod) glog_open();
 #endif
 
     clientDead=0;
@@ -627,10 +624,7 @@
 	if(!mlog) mlog = fopen(MesgLog, "a");
 	if(!mlog) perror(MesgLog);
     }
-    if(loggod){
-	if(!glog) glog = fopen(GodLog, "a");
-	if(!glog) perror(GodLog);
-    }
+    if (loggod) glog_open();
 #endif
 
     if(commMode == COMM_UDP) addSequenceFlags(udpbuf);
@@ -1844,8 +1838,8 @@
     if (packet->mesg[0] != '@')
 	return FALSE;
 
+    /* FIXME: never freed */
     version = (char *)strdup(INDEX(packet->mesg,'@')+1);
-    version[strlen(version)] = '\0';
     return TRUE;
 }
 
@@ -2841,12 +2835,9 @@
 		      (packet->group & MGOD))){
 	    static int counter = 0;
 
-	    if(!glog) {
-		ERROR(1,( "ntserv: ERROR, null glog file descriptor\n"));
-		return 0;
-	    }
-	    fprintf(glog, "%s\n", buf);
-	    fflush(glog);
+	    if(glog_open() != 0) return;
+	    glog_printf("%s\n", buf);
+	    glog_flush();
 	    counter++;
 
 	    /* response */