Index: trunk/src/sh_portcheck.c
===================================================================
--- trunk/src/sh_portcheck.c	(revision 376)
+++ trunk/src/sh_portcheck.c	(revision 380)
@@ -321,5 +321,5 @@
 #ifdef TEST_ONLY
 
-static int portchk_debug = 0;
+static int portchk_debug = 0; 
 #define SH_ALLOC       malloc
 #define SH_FREE        free
@@ -433,8 +433,4 @@
   struct sh_portentry * new = SH_ALLOC (sizeof(struct sh_portentry));
 
-  if (portchk_debug)
-    fprintf(stderr, _("add to list: port %d/%s %d %d (%s)\n"),
-	    port, SH_PROTO_STR(proto), flag, status, service ? service : _("undef"));
-
   new->port = port;
   sh_ipvx_ntoa(new->interface, SH_INTERFACE_SIZE, paddr);
@@ -443,4 +439,9 @@
 
   new->error  = NULL;
+
+  if (portchk_debug)
+    fprintf(stderr, _("add to list: port %d/%s %d %d (%s) %s\n"),
+	    port, SH_PROTO_STR(proto), flag, status, service ? service : _("undef"),
+	    new->interface);
 
   if (service)
@@ -648,5 +649,6 @@
       
 
-static void sh_portchk_cmp_to_list (int proto, int port, struct sh_sockaddr * paddr, char * service)
+static void sh_portchk_cmp_to_list (int proto, int port, 
+				    struct sh_sockaddr * paddr, char * service)
 {
   struct sh_portentry * portent;
@@ -669,8 +671,10 @@
 	  snprintf (errbuf, sizeof(errbuf), _("port: %s:%d/%s (%s)"), 
 		    saddr, port, SH_PROTO_STR(proto), service);
-#ifdef TEST_ONLY
-	  fprintf(stderr, _("open port: %s:%d/%s (%s)\n"), 
-		  saddr, port, SH_PROTO_STR(proto), service);
-#else
+
+	  if (portchk_debug)
+	    fprintf(stderr, _("cmp_to_list: open port: %s:%d/%s (%s)\n"), 
+		    saddr, port, SH_PROTO_STR(proto), service);
+
+#ifndef TEST_ONLY
 	  path = sh_port2proc_query(proto, paddr, port, &qpid, user, sizeof(user));
 	  SH_MUTEX_LOCK(mutex_thread_nolog);
@@ -751,8 +755,10 @@
 	  snprintf (errbuf, sizeof(errbuf), _("port: %s:%d/%s (%s)"), 
 		    saddr, port, SH_PROTO_STR(proto), check_services(port, proto));
-#ifdef TEST_ONLY
-	  fprintf(stderr, _("open port: %s:%d/%s (%s)\n"), 
-		  saddr, port, SH_PROTO_STR(proto), check_services(port, proto));
-#else
+
+	  if (portchk_debug)
+	    fprintf(stderr, _("cmp_to_list: open port: %s:%d/%s (%s) check_services\n"), 
+		    saddr, port, SH_PROTO_STR(proto), check_services(port, proto));
+
+#ifndef TEST_ONLY
 	  path = sh_port2proc_query(proto, paddr, port, &qpid, user, sizeof(user));
 	  SH_MUTEX_LOCK(mutex_thread_nolog);
@@ -908,5 +914,5 @@
 	  sh_ipvx_ntoa(ipbuf, sizeof(ipbuf), paddr);
 	  if (portchk_debug)
-	    fprintf(stderr, _("check port: %5d/udp on %15s established/time_wait\n"),
+	    fprintf(stderr, _("check port_udp: %5d/udp on %15s established/time_wait\n"),
 		    port, ipbuf);
 	}
@@ -932,7 +938,9 @@
 	      if (paddr->ss_family == AF_INET)
 		{
-		  p = check_rpc_list (port, (struct sockaddr_in *) sh_ipvx_sockaddr_cast(paddr), IPPROTO_UDP);
+		  p = check_rpc_list (port, 
+				      (struct sockaddr_in *) sh_ipvx_sockaddr_cast(paddr), 
+				      IPPROTO_UDP);
 		}
-	      
+
 	      sh_portchk_cmp_to_list (IPPROTO_UDP, port, paddr, p ? p : NULL);
 	      
@@ -945,5 +953,5 @@
 		{
 		  sh_ipvx_ntoa(ipbuf, sizeof(ipbuf), paddr);
-		  fprintf(stderr, _("check port: %5d/udp on %15s open %s\n"), 
+		  fprintf(stderr, _("check port_udp: %5d/udp on %15s open %s\n"), 
 			  port, ipbuf, p);
 		}
@@ -979,5 +987,5 @@
 	{
 	  sh_ipvx_ntoa(ipbuf, sizeof(ipbuf), paddr);
-	  fprintf(stderr, _("check port: %5d on %15s established/time_wait\n"),
+	  fprintf(stderr, _("check port_tcp: %5d on %15s established/time_wait\n"),
 		  port, ipbuf);
 	}
@@ -1005,5 +1013,7 @@
       if (paddr->ss_family == AF_INET)
 	{
-	  p = check_rpc_list (port, (struct sockaddr_in *) sh_ipvx_sockaddr_cast(paddr), IPPROTO_TCP);
+	  p = check_rpc_list (port, 
+			      (struct sockaddr_in *) sh_ipvx_sockaddr_cast(paddr), 
+			      IPPROTO_TCP);
 	}
 
@@ -1018,5 +1028,5 @@
 	{
 	  sh_ipvx_ntoa(ipbuf, sizeof(ipbuf), paddr);
-	  fprintf(stderr, _("check port: %5d on %15s open %s\n"), 
+	  fprintf(stderr, _("check port_tcp: %5d on %15s open %s\n"), 
 		  port, ipbuf, p);
 	}
@@ -1137,4 +1147,11 @@
       sh_ipvx_save(&(iface_list.iface[iface_list.used]), 
 		   AF_INET, (struct sockaddr *)&sin);
+      
+      if (portchk_debug)
+	{
+	  char buf[256];
+	  sh_ipvx_ntoa(buf, sizeof(buf), &(iface_list.iface[iface_list.used]));
+	  fprintf(stderr, _("interface[%d]: %s\n"), i, buf); 
+	}
       ++iface_list.used;
       ++i;
@@ -1634,5 +1651,9 @@
       portent = sh_portchk_get_from_list (proto, -1, &saddr, buf);
       if (!portent)
-	sh_portchk_add_to_list (proto,   -1, &saddr,  buf, type, SH_PORT_UNKN);
+	{
+	  if (portchk_debug)
+	    fprintf(stderr, _("add_required_port\n"));
+	  sh_portchk_add_to_list (proto,   -1, &saddr,  buf, type, SH_PORT_UNKN);
+	}
       else
 	{
@@ -1652,5 +1673,10 @@
       portent = sh_portchk_get_from_list (proto, port, &saddr, NULL);
       if (!portent)
-	sh_portchk_add_to_list (proto, port, &saddr, NULL, type, SH_PORT_UNKN);
+	{
+	  if (portchk_debug)
+	    fprintf(stderr, _("add_required_port: open port: %d/%s\n"), 
+		    (int) port, SH_PROTO_STR(proto));
+	  sh_portchk_add_to_list (proto, port, &saddr, NULL, type, SH_PORT_UNKN);
+	}
       else
 	{
