
 client.c |   22 ++++++++++++++++++++++
 client.h |    4 ++++
 conf.c   |   23 +++++++++++++++++++++++
 conf.h   |    4 ++++
 ngircd.c |   61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 5 files changed, 111 insertions(+), 3 deletions(-)

Index: src/ngircd/client.c
===================================================================
RCS file: /srv/cvs/ngircd/ngircd/src/ngircd/client.c,v
retrieving revision 1.91
diff -u -r1.91 client.c
--- src/ngircd/client.c	23 Apr 2006 10:37:27 -0000	1.91
+++ src/ngircd/client.c	23 Jul 2006 22:52:38 -0000
@@ -1184,4 +1184,26 @@
 } /* Client_RegisterWhowas */
 
 
+#ifdef DEBUG
+
+GLOBAL void
+Client_DebugDump(void)
+{
+	CLIENT *c;
+
+	Log(LOG_DEBUG, "Client status:");
+	c = My_Clients;
+	while (c) {
+		Log(LOG_DEBUG,
+		    " - %s, type=%d, host=%s, user=%s, conn=%d, start=%ld, flags=%s",
+                   Client_ID(c), Client_Type(c), Client_Hostname(c),
+                   Client_User(c), Client_Conn(c), Client_StartTime(c),
+                   Client_Flags(c));
+		c = (CLIENT *)c->next;
+	}
+} /* Client_DumpClients */
+
+#endif
+
+
 /* -eof- */
Index: src/ngircd/client.h
===================================================================
RCS file: /srv/cvs/ngircd/ngircd/src/ngircd/client.h,v
retrieving revision 1.42
diff -u -r1.42 client.h
--- src/ngircd/client.h	23 Apr 2006 10:37:27 -0000	1.42
+++ src/ngircd/client.h	23 Jul 2006 22:52:38 -0000
@@ -153,6 +153,10 @@
 
 GLOBAL void Client_RegisterWhowas PARAMS(( CLIENT *Client ));
 
+#ifdef DEBUG
+GLOBAL void Client_DebugDump PARAMS((void));
+#endif
+
 
 #endif
 
Index: src/ngircd/conf.c
===================================================================
RCS file: /srv/cvs/ngircd/ngircd/src/ngircd/conf.c,v
retrieving revision 1.92
diff -u -r1.92 conf.c
--- src/ngircd/conf.c	23 Jul 2006 16:42:45 -0000	1.92
+++ src/ngircd/conf.c	23 Jul 2006 22:52:38 -0000
@@ -1085,6 +1085,29 @@
 } /* Config_Error */
 
 
+#ifdef DEBUG
+
+GLOBAL void
+Conf_DebugDump(void)
+{
+	int i;
+
+	Log(LOG_DEBUG, "Configured servers:");
+	for (i = 0; i < MAX_SERVERS; i++) {
+		if (! Conf_Server[i].name[0])
+			continue;
+		Log(LOG_DEBUG,
+		    " - %s: %s:%d, last=%ld, group=%d, flags=%d, conn=%d",
+		    Conf_Server[i].name, Conf_Server[i].host,
+		    Conf_Server[i].port, Conf_Server[i].lasttry,
+		    Conf_Server[i].group, Conf_Server[i].flags,
+		    Conf_Server[i].conn_id);
+	}
+} /* Conf_DebugDump */
+
+#endif
+
+
 static void
 Init_Server_Struct( CONF_SERVER *Server )
 {
Index: src/ngircd/conf.h
===================================================================
RCS file: /srv/cvs/ngircd/ngircd/src/ngircd/conf.h,v
retrieving revision 1.40
diff -u -r1.40 conf.h
--- src/ngircd/conf.h	10 May 2006 21:24:01 -0000	1.40
+++ src/ngircd/conf.h	23 Jul 2006 22:52:38 -0000
@@ -141,6 +141,10 @@
 GLOBAL bool Conf_DisableServer PARAMS(( char *Name ));
 GLOBAL bool Conf_AddServer PARAMS(( char *Name, UINT16 Port, char *Host, char *MyPwd, char *PeerPwd ));
 
+#ifdef DEBUG
+GLOBAL void Conf_DebugDump PARAMS((void));
+#endif
+
 
 #endif
 
Index: src/ngircd/ngircd.c
===================================================================
RCS file: /srv/cvs/ngircd/ngircd/src/ngircd/ngircd.c,v
retrieving revision 1.113
diff -u -r1.113 ngircd.c
--- src/ngircd/ngircd.c	23 Jul 2006 12:07:33 -0000	1.113
+++ src/ngircd/ngircd.c	23 Jul 2006 22:52:38 -0000
@@ -71,6 +71,11 @@
 
 static bool NGIRCd_Init PARAMS(( bool ));
 
+#ifdef DEBUG
+static void Dump_State PARAMS(( void ));
+#endif
+
+
 /**
  * The main() function of ngIRCd.
  * Here all starts: this function is called by the operating system loader,
@@ -487,6 +492,10 @@
 	sigaction(SIGTERM, &saction, NULL);
 	sigaction(SIGHUP, &saction, NULL);
 	sigaction(SIGCHLD, &saction, NULL);
+#ifdef DEBUG
+	sigaction(SIGUSR1, &saction, NULL);
+	sigaction(SIGUSR2, &saction, NULL);
+#endif
 
 	/* einige Signale ignorieren */
 	saction.sa_handler = SIG_IGN;
@@ -500,6 +509,10 @@
 	signal(SIGTERM, Signal_Handler);
 	signal(SIGHUP, Signal_Handler);
 	signal(SIGCHLD, Signal_Handler);
+#ifdef DEBUG
+	signal(SIGUSR1, Signal_Handler);
+	signal(SIGUSR2, Signal_Handler);
+#endif
 
 	/* einige Signale ignorieren */
 	signal(SIGPIPE, SIG_IGN);
@@ -533,10 +546,36 @@
 			while( waitpid( -1, NULL, WNOHANG ) > 0);
 			break;
 #ifdef DEBUG
+		case SIGUSR1:
+			if (! NGIRCd_Debug) {
+				Log(LOG_INFO|LOG_snotice,
+				    "Got SIGUSR1, debug mode activated.");
+#ifdef SNIFFER
+				strcpy(NGIRCd_DebugLevel, "2");
+				NGIRCd_Debug = true;
+				NGIRCd_Sniffer = true;
+#else
+				strcpy(NGIRCd_DebugLevel, "1");
+				NGIRCd_Debug = true;
+#endif /* SNIFFER */
+			} else {
+				Log(LOG_INFO|LOG_snotice,
+				    "Got SIGUSR1, debug mode deactivated.");
+				strcpy(NGIRCd_DebugLevel, "");
+				NGIRCd_Debug = false;
+#ifdef SNIFFER
+				NGIRCd_Sniffer = false;
+#endif /* SNIFFER */
+			}
+			break;
+		case SIGUSR2:
+			if (NGIRCd_Debug)
+				Dump_State();
+			break;
 		default:
 			/* unbekanntes bzw. unbehandeltes Signal */
 			Log( LOG_DEBUG, "Got signal %d! Ignored.", Signal );
-#endif
+#endif /* DEBUG */
 	}
 } /* Signal_Handler */
 
@@ -806,7 +845,23 @@
 		Log( LOG_ERR, "Can't get user informaton for UID %d!?", Conf_UID );
 	}
 
-return true;
-}
+	return true;
+} /* NGIRCd_Init */
+
+
+#ifdef DEBUG
+
+static void
+Dump_State(void)
+{
+	Log(LOG_DEBUG, "--- Internal server state: ---");
+	Log(LOG_DEBUG, "time()=%ld", time(NULL));
+	Conf_DebugDump();
+	Client_DebugDump();
+	Log(LOG_DEBUG, "--- End of state dump ---");
+} /* Dump_State */
+
+#endif
+
 
 /* -eof- */
