 .cvsignore          |    1 
 src/ngircd/client.c |   22 ++++++++++++++++++
 src/ngircd/client.h |    4 +++
 src/ngircd/conf.c   |   23 +++++++++++++++++++
 src/ngircd/conf.h   |    4 +++
 src/ngircd/ngircd.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++++---
 6 files changed, 112 insertions(+), 3 deletions(-)

Index: .cvsignore
===================================================================
RCS file: /srv/cvs/ngircd/ngircd/.cvsignore,v
retrieving revision 1.1
diff -u -p -r1.1 .cvsignore
--- .cvsignore	28 Dec 2006 13:20:07 -0000	1.1
+++ .cvsignore	9 Apr 2008 08:30:58 -0000
@@ -5,3 +5,4 @@ autom4te.cache
 config.log
 config.status
 configure
+configure.lineno
Index: src/ngircd/client.c
===================================================================
RCS file: /srv/cvs/ngircd/ngircd/src/ngircd/client.c,v
retrieving revision 1.98
diff -u -p -r1.98 client.c
--- src/ngircd/client.c	4 Apr 2008 19:30:01 -0000	1.98
+++ src/ngircd/client.c	9 Apr 2008 08:30:58 -0000
@@ -1142,4 +1142,26 @@ Client_RegisterWhowas( CLIENT *Client )
 } /* 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.46
diff -u -p -r1.46 client.h
--- src/ngircd/client.h	23 Jan 2007 16:07:19 -0000	1.46
+++ src/ngircd/client.h	9 Apr 2008 08:30:58 -0000
@@ -149,6 +149,10 @@ GLOBAL int Client_GetLastWhowasIndex PAR
 
 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.105
diff -u -p -r1.105 conf.c
--- src/ngircd/conf.c	18 Mar 2008 20:12:47 -0000	1.105
+++ src/ngircd/conf.c	9 Apr 2008 08:30:58 -0000
@@ -1201,6 +1201,29 @@ va_dcl
 } /* 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.49
diff -u -p -r1.49 conf.h
--- src/ngircd/conf.h	18 Mar 2008 20:12:47 -0000	1.49
+++ src/ngircd/conf.h	9 Apr 2008 08:30:58 -0000
@@ -160,6 +160,10 @@ GLOBAL bool Conf_EnablePassiveServer PAR
 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.119
diff -u -p -r1.119 ngircd.c
--- src/ngircd/ngircd.c	18 Mar 2008 20:12:47 -0000	1.119
+++ src/ngircd/ngircd.c	9 Apr 2008 08:30:58 -0000
@@ -71,6 +71,11 @@ static void Setup_FDStreams PARAMS(( voi
 
 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,
@@ -497,6 +502,10 @@ Initialize_Signal_Handler( void )
 	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;
@@ -510,6 +519,10 @@ Initialize_Signal_Handler( void )
 	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);
@@ -543,10 +556,36 @@ Signal_Handler( int Signal )
 			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 */
 
@@ -816,7 +855,23 @@ NGIRCd_Init( bool NGIRCd_NoDaemon ) 
 		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- */
