From 1357b4287c17917fa64916910be205ffab2c2cdf Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Sun, 11 May 2003 23:34:16 +0000
Subject: [PATCH] Fix up makefile, add Synchronet headers.

---
 src/sbbs3/umonitor/GNUmakefile | 122 ++++++++++++++++++++++++++++++---
 src/sbbs3/umonitor/umonitor.c  |  64 ++++++++++++-----
 2 files changed, 160 insertions(+), 26 deletions(-)

diff --git a/src/sbbs3/umonitor/GNUmakefile b/src/sbbs3/umonitor/GNUmakefile
index 91501fde4e..46419aadec 100644
--- a/src/sbbs3/umonitor/GNUmakefile
+++ b/src/sbbs3/umonitor/GNUmakefile
@@ -1,15 +1,119 @@
-CFLAGS	+=	-I../ -I../../xpdev -I../../uifc -DUSE_CURSES -DUSE_SIGNALS -g
+# GNUmakefile
+
+#########################################################################
+# Makefile for Synchronet monitor for Unix								#
+# For use with GNU make and GNU C Compiler or Borland Kylix C++			#
+# @format.tab-size 4, @format.use-tabs true								#
+#																		#
+# gcc: gmake															#
+# Borland (still in testing/debuging stage): gmake bcc=1				#
+#																		#
+# Optional build targets: dlls, utils, mono, all (default)				#
+#########################################################################
+
+# $Id$
+
+# Macros
+ifndef DEBUG
+ ifndef RELEASE
+  DEBUG	:=	1
+ endif
+endif
+
+ifdef DEBUG
+ BUILD	=	debug
+else
+ BUILD	=	release
+endif
+
+ifdef bcc
+ CC		=	bc++ -q
+ CCPRE	:=	bcc
+ CCPP	=	bc++ -q
+ LD		=	ilink -q
+ CFLAGS +=	-mm -md -D__unix__ -w-csu -w-pch -w-ccc -w-rch -w-par -w-aus
+else
+ CFLAGS	+=	-MMD -Wall
+ CCPRE	:=	gcc
+ ifdef BUILD_DEPENDS
+  CC		=	../../build/mkdep -a
+  CCPP	=	../../build/mkdep -a
+  LD		=	echo
+  COMPILE_MSG	:= Depending
+ else
+  CC		=	gcc
+  CCPP	=	g++
+  LD		=	ld
+  COMPILE_MSG	:= Compiling
+ endif
+endif
+OFILE	=	o
+
+LIBFILE	=	.a
+UIFC	=	../../uifc/
+XPDEV	=	../../xpdev/
+SBBS3	=   ../
+
+ifndef os
+ os		:=	$(shell uname)
+endif
+# this line wont work with solaris unless awk in path is actually gawk 
+os      :=	$(shell echo $(os) | tr "[A-Z]" "[a-z]")
+#os      :=	$(shell echo $(os) | awk '/.*/ { print tolower($$1)}')
+# remove '/' from "os/2"
+os      :=  $(shell echo $(os) | tr -d "/")
+
+LIBODIR :=	$(CCPRE).$(os).lib.$(BUILD)
+EXEODIR :=	$(CCPRE).$(os).exe.$(BUILD)
+
+DELETE	=	rm -f
+
+CFLAGS	+=	-I../../include/mozilla/js -I$(XPDEV) -I$(UIFC) -I$(SBBS3)
 LFLAGS	+=	-lcurses
-CC	?=	gcc
-LD	?=	gcc
 
-vpath %.c ../../xpdev ../../uifc
+vpath %.c $(UIFC) $(XPDEV)
+
+OBJS	:=	$(LIBODIR)/filewrap.o \
+			$(LIBODIR)/uifcc.o \
+			$(LIBODIR)/uifcx.o \
+			$(LIBODIR)/sockwrap.o \
+			$(LIBODIR)/dirwrap.o \
+			$(LIBODIR)/genwrap.o \
+			$(LIBODIR)/umonitor.o
+
+all: $(LIBODIR) $(BUILD_DEPENDS)$(EXEODIR)/umonitor
 
-OBJS	:=	filewrap.o uifcc.o uifcx.o umonitor.o sockwrap.o dirwrap.o genwrap.o
+FORCE$(EXEODIR)/umonitor: $(EXEODIR) $(OBJS) $(BUILD_DEPENDS)
 
-umonitor: $(OBJS)
-	$(CC) $(LFLAGS) $(OBJS) -o umonitor
+$(EXEODIR)/umonitor: $(EXEODIR) $(OBJS) $(BUILD_DEPENDS)
+	@echo Linking $@
+	@$(CC) $(LFLAGS) $(OBJS) -o $@
 
 # Implicit C Compile Rule for utils
-$(EXEODIR)/%.o : %.c $(BUILD_DEPENDS)
-	$(CC) $(CFLAGS) -o $@ -c $<
+$(LIBODIR)/%.o : %.c $(LIBODIR) $(BUILD_DEPENDS)
+   ifndef bcc
+	@echo $(COMPILE_MSG) $<
+   endif
+	@$(CC) $(CFLAGS) -o $@ -c $<
+
+$(LIBODIR):
+	mkdir $(LIBODIR)
+
+$(EXEODIR):
+	mkdir $(EXEODIR)
+
+clean:
+	@$(DELETE) $(LIBODIR)$(SLASH)*
+	@$(DELETE) $(EXEODIR)$(SLASH)*
+
+depend:
+	@$(DELETE) $(LIBODIR)/.depend
+	@$(DELETE) $(EXEODIR)/.depend
+	$(MAKE) BUILD_DEPENDS=FORCE
+
+FORCE:
+
+-include $(LIBODIR)/.depend
+-include $(EXEODIR)/.depend
+-include $(LIBODIR)/*.d
+-include $(EXEODIR)/*.d
diff --git a/src/sbbs3/umonitor/umonitor.c b/src/sbbs3/umonitor/umonitor.c
index 60aa9c8d66..cfeafcaf14 100644
--- a/src/sbbs3/umonitor/umonitor.c
+++ b/src/sbbs3/umonitor/umonitor.c
@@ -1,17 +1,55 @@
-#include "sockwrap.h"
+/* umonitor.c */
+
+/* Synchronet for *nix node activity monitor */
+
+/* $Id$ */
+
+/****************************************************************************
+ * @format.tab-size 4		(Plain Text/Source Code File Header)			*
+ * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
+ *																			*
+ * Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html		*
+ *																			*
+ * This program is free software; you can redistribute it and/or			*
+ * modify it under the terms of the GNU General Public License				*
+ * as published by the Free Software Foundation; either version 2			*
+ * of the License, or (at your option) any later version.					*
+ * See the GNU General Public License for more details: gpl.txt or			*
+ * http://www.fsf.org/copyleft/gpl.html										*
+ *																			*
+ * Anonymous FTP access to the most recent released source is available at	*
+ * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net	*
+ *																			*
+ * Anonymous CVS access to the development source and modification history	*
+ * is available at cvs.synchro.net:/cvsroot/sbbs, example:					*
+ * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login			*
+ *     (just hit return, no password is necessary)							*
+ * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src		*
+ *																			*
+ * For Synchronet coding style and modification guidelines, see				*
+ * http://www.synchro.net/source.html										*
+ *																			*
+ * You are encouraged to submit any modifications (preferably in Unix diff	*
+ * format) via e-mail to mods@synchro.net									*
+ *																			*
+ * Note: If this box doesn't appear square, then you need to fix your tabs.	*
+ ****************************************************************************/
+
+#include "conwrap.h"	/* this has to go BEFORE curses.h so getkey() can be macroed around */
+#include <curses.h>
 #include <poll.h>
-#include <termios.h>
-#include <sys/un.h>
 #include <stdio.h>
+#include <termios.h>
 #include <unistd.h>
-#include "conwrap.h"
+#include "sockwrap.h"	/* Must go before <sys/un.h> */
+#include <sys/un.h>
+#include "genwrap.h"
 #include "uifc.h"
 #include "sbbsdefs.h"
 #include "genwrap.h"	/* stricmp */
 #include "dirwrap.h"	/* lock/unlock/sopen */
 #include "filewrap.h"	/* lock/unlock/sopen */
 #include "sockwrap.h"
-#include "genwrap.h"
 
 enum {
 	 MODE_LIST
@@ -168,6 +206,7 @@ int spyon(char *sockname)  {
 		}
 	}
 	tcsetattr(STDIN_FILENO,TCSANOW,&old_tio);
+	return(retval);
 }
 
 char* itoa(int val, char* str, int radix)
@@ -465,7 +504,6 @@ void node_toggles(int nodenum)  {
 	char**	opt;
 	int		i,j;
 	node_t	node;
-	char	buf[80];
 	int		save=0;
 
 	if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
@@ -543,17 +581,11 @@ int main(int argc, char** argv)  {
 	char**	mopt;
 	int		main_dflt=0;
 	int		main_bar=0;
-	BOOL    door_mode=FALSE;
-	int		dist=0;
-	int		server=0;
 	char revision[16];
-	char str[256],str2[256],ctrl_dir[41],*p,debug=0;
+	char str[256],str2[256],ctrl_dir[41],*p;
 	char title[256];
-	int sys_nodes,node_num=0,onoff=0;
-	int i,j,mode=0,misc;
-	int	modify=0;
-	int loop=0;
-	long value=0;
+	int sys_nodes;
+	int i,j;
 	node_t node;
 	char	*buf;
 	int		buffile;
@@ -609,10 +641,8 @@ int main(int argc, char** argv)  {
                     printf("\nusage: %s [ctrl_dir] [options]"
                         "\n\noptions:\n\n"
                         "-c  =  force color mode\n"
-#ifdef USE_CURSES
                         "-e# =  set escape delay to #msec\n"
 						"-i  =  force IBM charset\n"
-#endif
                         "-l# =  set screen lines to #\n"
 						,argv[0]
                         );
-- 
GitLab