[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [patch] inputmethod/kinput2 ( by gcc-4)



In message <20060718.111102.92561783.taca@back-street.net>
	on Tue, 18 Jul 2006 11:11:02 +0900 (JST),
	Takahiro Kambe <taca@back-street.net> wrote:
> In message <yfmodvnlm07.wl%makoto@ki.nu>
> 	on Tue, 18 Jul 2006 10:50:16 +0900,
> 	藤原 誠/ Makoto Fujiwara <makoto@ki.nu> wrote:
> > 神戸さん、ありがとうございました。send-pr はどうしましょう ?
> 私の方でコミットします。
調子に乗って、修正を加えすぎたかもしれません。

% make patch

した後で、このメールのパッチを当ててbuildできるか確認していただけると
幸いです。

-- 
神戸 隆博 / Takahiro Kambe


$NetBSD$

--- address.c.orig	2002-01-20 23:19:42.000000000 +0900
+++ address.c
@@ -42,6 +42,8 @@
 # include "extern.h"
 # include "smtp.h"
 
+static void dnsstatus P((struct recipient *, int, char *));
+
 int
 addmyalias(name)
 char *name;
@@ -58,12 +60,12 @@
 		ha = (struct hostalias *)MALLOC(sizeof(struct hostalias));
 		if (ha == NULL)
 		{
-			log(LOG_NOTICE, "out of memory (addmyalias)");
+			mylog(LOG_NOTICE, "out of memory (addmyalias)");
 			return -1;
 		}
 		/* bzero(ha, sizeof(struct hostalias)); */
 		if (cnf.debug & DEBUG_ADDRESS)
-		log(LOG_DEBUG, "adding alias: %s", name);
+		mylog(LOG_DEBUG, "adding alias: %s", name);
 		len = strlen(name);
 		/* strip trailing dot */
 		while (len > 0 && name[len-1] == '.')
@@ -114,7 +116,7 @@
 			hostp = (struct host *)MALLOC(sizeof(struct host));
 			if (hostp == NULL)
 			{
-				log(LOG_NOTICE,
+				mylog(LOG_NOTICE,
 					"out of memory (addinetaddress)");
 				return -1;
 			}
@@ -153,7 +155,7 @@
 	if (addr == NULL)	/* just link from mxp */
 	{
 		if (cnf.debug & DEBUG_ADDRESS)
-		log(LOG_DEBUG, "address info for %s linked", mxp->name);
+		mylog(LOG_DEBUG, "address info for %s linked", mxp->name);
 		return 0;
 	}
 
@@ -170,13 +172,13 @@
 		{
 		  case AF_INET:
 			bcopy(addr, &sin, sizeof(sin));
-			log(LOG_INFO, "got new address %s for %s, state reset",
+			mylog(LOG_INFO, "got new address %s for %s, state reset",
 				inet_ntoa(sin), mxp->name);
 			break;
 #if INET6
 		  case AF_INET6:
 			inet_ntop(AF_INET6, addr, buf, sizeof(buf));
-			log(LOG_INFO, "got new address %s for %s, state reset",
+			mylog(LOG_INFO, "got new address %s for %s, state reset",
 				buf, mxp->name);
 
 			break;
@@ -193,19 +195,19 @@
 		{
 		  case AF_INET:
 			bcopy(addr, &sin, sizeof(sin));
-			log(LOG_DEBUG, "DNS: registering %s=%s",
+			mylog(LOG_DEBUG, "DNS: registering %s=%s",
 				mxp->name, inet_ntoa(sin));
 			break;
 #if INET6
 		  case AF_INET6:
 			inet_ntop(AF_INET6, addr, buf, sizeof(buf));
-			log(LOG_DEBUG, "DNS: registering %s=%s",
+			mylog(LOG_DEBUG, "DNS: registering %s=%s",
 				mxp->name, buf);
 
 			break;
 #endif
 		  default:
-			log(LOG_NOTICE,
+			mylog(LOG_NOTICE,
 				"DNS: invalid inet_domain %d at addinetaddress",
 				inet_domain);
 		} 
@@ -226,7 +228,7 @@
 	iap = (struct inetaddr *)MALLOC(sizeof(struct inetaddr));
 	if (iap == NULL)
 	{
-		log(LOG_NOTICE, "out of memory (addinetaddress)");
+		mylog(LOG_NOTICE, "out of memory (addinetaddress)");
 		return -1;
 	}
 	bzero(iap, sizeof(struct inetaddr));
@@ -235,7 +237,7 @@
 	iap->address = (char *)MALLOC(len);
 	if (iap->address == NULL)
 	{
-		log(LOG_NOTICE, "out of memory (addinetaddress)");
+		mylog(LOG_NOTICE, "out of memory (addinetaddress)");
 		return -1;
 	}
 	bcopy(addr, iap->address, len);
@@ -462,12 +464,12 @@
 	struct domain *d, **hashp;
 
 	if (cnf.debug & DEBUG_LMTP)
-	log(LOG_DEBUG, "RCPT TO: %s notify=%s orcpt=%s", addr,
+	mylog(LOG_DEBUG, "RCPT TO: %s notify=%s orcpt=%s", addr,
 		(notify == NULL)?"":notify, (orcpt == NULL)?"":orcpt);
 	rcpt = (struct recipient *)MALLOC(sizeof(struct recipient));
 	if (rcpt == NULL)
 	{
-		log(LOG_NOTICE, "out of memory (addrecipient)");
+		mylog(LOG_NOTICE, "out of memory (addrecipient)");
 		return -1;
 	}
 	bzero(rcpt, sizeof(struct recipient));
@@ -493,7 +495,7 @@
 	if (d == NULL)
 	{
 		if (cnf.debug & DEBUG_LMTP)
-		log(LOG_DEBUG, "new domain: %s", domain);
+		mylog(LOG_DEBUG, "new domain: %s", domain);
 		rcpt->domain = (struct domain *)MALLOC(sizeof(struct domain));
 		bzero(rcpt->domain, sizeof(struct domain));
 		rcpt->domain->name = newstr(domain);
@@ -540,13 +542,13 @@
 	return 0;
 }
 
-void
+static void
 dnsstatus(rcpt, rcode, response)
 struct recipient *rcpt;
 int rcode;
 char *response;
 {
-	log(LOG_INFO, "(%d+%d+%d+%d/%d) relay=%s to=%s proto=%s delay=%d code=%d (%s)",            
+	mylog(LOG_INFO, "(%d+%d+%d+%d/%d) relay=%s to=%s proto=%s delay=%d code=%d (%s)",            
 		sti.nsent, sti.ndeferred, sti.nnsfailed,
 		sti.nsmtpfailed, sti.nrcpt, "unknown",
 		rcpt->address, "unknown", 0, rcode,   
$NetBSD$

--- common.h.orig	2002-01-20 23:20:44.000000000 +0900
+++ common.h
@@ -425,3 +425,9 @@
 #endif
 };
 typedef union SockAddrUnion SockAddr;
+
+#ifdef __STDC__
+#define P(c)	c
+#else
+#define P(c)
+#endif
$NetBSD$

--- dns.c.orig	2002-03-15 11:03:39.000000000 +0900
+++ dns.c
@@ -79,6 +79,19 @@
 # define RES_INSECURE1	0x00000400	/* type 1 security disabled */
 #endif
 
+static int query_domain P((char *, int));
+static int process_query P((int));
+static int make_query P((struct dns_stat *, int));
+#if INET6
+static int whichserver P((const SockAddr *));
+#else
+static int whichserver P((const struct sockaddr_in *));
+#endif
+static void got_answer P((struct query_chain *, u_char *, int));
+static void remove_query P((struct query_chain *));
+static struct mx* newmx P((char *, int, int, struct domain *, long));
+static void show_query P((u_char *, u_char *, u_char *));
+
 int
 pregetmx(dl)
 struct domain *dl;
@@ -87,7 +100,6 @@
 	char **map_arg;
 	long stime, etime;
 	int n;
-	static int query_domain(), process_query();
 #ifdef INET6
 	SockAddr dsin;	/* dummy */
 #endif
@@ -109,7 +121,7 @@
 		}
 	}
 
-	log(LOG_DEBUG, "start getting MXRRs with caching");
+	mylog(LOG_DEBUG, "start getting MXRRs with caching");
 	n = 0;
 	stime = time(NULL);
 	if (env.queueid != NULL)
@@ -120,7 +132,7 @@
 	if (cnf.pgateway != NULL)
 	{
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "pregetting A of protocol gateway: %s",
+		mylog(LOG_DEBUG, "pregetting A of protocol gateway: %s",
 			cnf.pgateway);
 #ifdef INET6
 		if (cnf.inetdom & SMTP_V4)
@@ -144,7 +156,7 @@
 	if (cnf.fallbackmx != NULL)
 	{
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "pregetting A of fallbackmx: %s",
+		mylog(LOG_DEBUG, "pregetting A of fallbackmx: %s",
 			cnf.fallbackmx);
 #ifdef INET6
 		if (cnf.inetdom & SMTP_V4)
@@ -185,7 +197,7 @@
 #endif
 			{
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG,
+				mylog(LOG_DEBUG,
 					"pregetting A of sourceIP: %s", p);
 #ifdef INET6
 				if (cnf.inetdom & SMTP_V4)
@@ -243,7 +255,7 @@
 			 || (strcasecmp(*map_arg, "MX?") == 0))
 			{
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "pregetting MX: %s", dp->name);
+				mylog(LOG_DEBUG, "pregetting MX: %s", dp->name);
 				if (query_domain(dp->name, T_MX) < 0)
 					return -1;
 				n++;
@@ -251,7 +263,7 @@
 			else if (strcasecmp(*map_arg, "A") == 0)
 			{
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "pregetting A: %s", dp->name);
+				mylog(LOG_DEBUG, "pregetting A: %s", dp->name);
 #ifdef INET6
 				if (cnf.inetdom & SMTP_V4)
 				{
@@ -272,7 +284,7 @@
 			else if (**map_arg != '[')
 			{
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "pregetting MX: %s", *map_arg);
+				mylog(LOG_DEBUG, "pregetting MX: %s", *map_arg);
 				if (query_domain(*map_arg, T_MX) < 0)
 					return -1;
 				n++;
@@ -291,7 +303,7 @@
 					goto skip_preget_a;
 
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG,
+				mylog(LOG_DEBUG,
 					"pregetting A of sourceIP: %s",
 					(*map_arg) + 1);
 #ifdef INET6
@@ -333,16 +345,16 @@
 		else
 			setproctitle("syncing MX: %d", n);
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "syncing responses of MXRRs");
+		mylog(LOG_DEBUG, "syncing responses of MXRRs");
 		if (process_query(1) < 0)	/* sync */
 			return -1;
 		etime = time(NULL);
-		log(LOG_DEBUG, "got MXRRs: %d MXs in %d seconds",
+		mylog(LOG_DEBUG, "got MXRRs: %d MXs in %d seconds",
 			n, etime - stime);
 	}
 	else
 	{
-		log(LOG_DEBUG, "no MXRRs to sync");
+		mylog(LOG_DEBUG, "no MXRRs to sync");
 	}
 	return 0;
 }
@@ -353,7 +365,6 @@
 int type;
 {
 	struct dns_stat *qrp, **hashp;
-	static int make_query();
 
 	qrp = hash_query_lookup(name, &hashp);
 	if (qrp == NULL) {
@@ -361,7 +372,7 @@
 		bzero(qrp, sizeof(struct dns_stat));
 		if (qrp == NULL)
 		{
-			log(LOG_NOTICE, "out of memory (dns_query)");
+			mylog(LOG_NOTICE, "out of memory (dns_query)");
 			return -1;
 		}
 		qrp->name = newstr(name);
@@ -375,7 +386,7 @@
 	  case T_AAAA:
 		break;
 	  default:
-		log(LOG_NOTICE, "query_domain: unknown query type: %d", type);
+		mylog(LOG_NOTICE, "query_domain: unknown query type: %d", type);
 		return 0;
 	}
 
@@ -396,7 +407,6 @@
 	u_char buf[MAXPACKET];
 	int n;
 	struct query_chain *qchain;
-	static int process_query();
 
 	switch (type) {
 	  case T_MX:
@@ -419,7 +429,7 @@
 	{
 		/* already got */
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "ignore request n=%s t=%d",
+		mylog(LOG_DEBUG, "ignore request n=%s t=%d",
 			qrp->name, type);
 		return 0;
 	}
@@ -439,18 +449,18 @@
 	{
 		/* already in processing */
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "skip request n=%s t=%d", qrp->name, type);
+		mylog(LOG_DEBUG, "skip request n=%s t=%d", qrp->name, type);
 		return 0;
 	}
 
 	if (cnf.debug & DEBUG_DNS)
-	log(LOG_DEBUG, "res_mkquery n=%s t=%d", qrp->name, type);
+	mylog(LOG_DEBUG, "res_mkquery n=%s t=%d", qrp->name, type);
 	n = res_mkquery(QUERY, qrp->name, C_IN, type, NULL, 0, NULL,
 			buf, sizeof(buf));
 	if (n <= 0)
 	{
 		/* error */
-		log(LOG_NOTICE, "res_mkquery failed for %s type %d",
+		mylog(LOG_NOTICE, "res_mkquery failed for %s type %d",
 			qrp->name, type);
 		return -1;
 	}
@@ -459,7 +469,7 @@
 	if (qchain == NULL)
 	{
 		/* error */
-		log(LOG_NOTICE, "out of memory (make_query)");
+		mylog(LOG_NOTICE, "out of memory (make_query)");
 		return -1;
 	}
 	bzero(qchain, sizeof(struct query_chain));
@@ -469,7 +479,7 @@
 	if (qchain->request == NULL)
 	{
 		/* error */
-		log(LOG_NOTICE, "out of memory (make_query)");
+		mylog(LOG_NOTICE, "out of memory (make_query)");
 		return -1;
 	}
 	bcopy(buf, qchain->request, n);
@@ -492,7 +502,7 @@
 	qchain->prev = NULL;
 	query_chain_count++;
 	if (cnf.debug & DEBUG_DNS)
-	log(LOG_DEBUG, "DNS: query concurrency = %d", query_chain_count);
+	mylog(LOG_DEBUG, "DNS: query concurrency = %d", query_chain_count);
 	if (sti.maxcquery < query_chain_count)
 		sti.maxcquery = query_chain_count;
 
@@ -501,10 +511,10 @@
 	{
 		struct query_chain *qcp;
 
-		log(LOG_DEBUG, "Chain after linked:");
+		mylog(LOG_DEBUG, "Chain after linked:");
 		for (qcp = QueryChain; qcp != NULL; qcp = qcp->next)
 		{
-			log(LOG_DEBUG, " %s", qcp->stat->name);
+			mylog(LOG_DEBUG, " %s", qcp->stat->name);
 		}
 	}
 #endif
@@ -514,7 +524,7 @@
 	return 0;
 }
 
-int
+static int
 whichserver(inp)
 #if INET6
 const SockAddr *inp;
@@ -591,14 +601,12 @@
 	char nbuf[MAXDNAME+1];
 	struct dns_stat *qrp;
 	int pending;
-	static void got_answer();
-	static void remove_query();
 
 	if (sync == 0 && cnf.cquery_max != 0
 	 && query_chain_count >= cnf.cquery_max)
 	{
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "reached to max concurrency (%d)....syncing",
+		mylog(LOG_DEBUG, "reached to max concurrency (%d)....syncing",
 			query_chain_count);
 		sync = -1;
 	}
@@ -612,7 +620,7 @@
 			s = socket(AF_INET, SOCK_DGRAM, PF_UNSPEC);
 			if (s < 0) {
 				/* error */
-				log(LOG_NOTICE,
+				mylog(LOG_NOTICE,
 					"socket failed (process_query)");
 				return -1;
 			}
@@ -622,7 +630,7 @@
 			s6 = socket(AF_INET6, SOCK_DGRAM, PF_UNSPEC);
 			if (s6 < 0) {
 				/* error */
-				log(LOG_NOTICE,
+				mylog(LOG_NOTICE,
 					"socket(INET6) failed (process_query)");
 				return -1;
 			}
@@ -633,7 +641,7 @@
 		s = socket(AF_INET, SOCK_DGRAM, PF_UNSPEC);
 		if (s < 0) {
 			/* error */
-			log(LOG_NOTICE, "socket failed (process_query)");
+			mylog(LOG_NOTICE, "socket failed (process_query)");
 			return -1;
 		}
 	}
@@ -663,14 +671,14 @@
 					nextqcp = qcp->next;
 					remove_query(qcp);
 					if (cnf.debug & DEBUG_DNS)
-					log(LOG_DEBUG, "DNS: no valid ns, removing %s type %d",
+					mylog(LOG_DEBUG, "DNS: no valid ns, removing %s type %d",
 						qcp->stat->name, qcp->type);
 					qcp = nextqcp;
 					continue;
 				}
 				qcp->try++;
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "DNS: retry count=%d", qcp->try);
+				mylog(LOG_DEBUG, "DNS: retry count=%d", qcp->try);
 			}
 		}
 		if (qcp->try >= (u_char)_res.retry)
@@ -680,7 +688,7 @@
 			nextqcp = qcp->next;
 			remove_query(qcp);
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "DNS: no valid ns, removing %s type %d",
+			mylog(LOG_DEBUG, "DNS: no valid ns, removing %s type %d",
 				qcp->stat->name, qcp->type);
 			qcp = nextqcp;
 			continue;
@@ -689,7 +697,7 @@
 		{
 			itvl = _res.retrans << qcp->try;
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "DNS: waiting %d sec.", itvl);
+			mylog(LOG_DEBUG, "DNS: waiting %d sec.", itvl);
 			if (qcp->try > 0)
 				itvl /= _res.nscount;
 			if (itvl <= 0)
@@ -700,7 +708,7 @@
 			if (nsap->in.sin_family == AF_INET)
 			{
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "send query n=%s t=%d (s=%s)",
+				mylog(LOG_DEBUG, "send query n=%s t=%d (s=%s)",
 					qcp->stat->name, qcp->type,
 					inet_ntoa(nsap->in.sin_addr));
 
@@ -711,7 +719,7 @@
 				{
 					qcp->badns |= 1<<qcp->ns;
 					if (cnf.debug & DEBUG_DNS)
-					log(LOG_DEBUG, "sendto failed: invalid ns (%s)", strerror(errno));
+					mylog(LOG_DEBUG, "sendto failed: invalid ns (%s)", strerror(errno));
 				}
 			}
 			if (nsap->in6.sin6_family == AF_INET6)
@@ -722,7 +730,7 @@
 				{
 				inet_ntop(AF_INET6, &nsap->in6.sin6_addr,
 					buf, sizeof(buf));
-				log(LOG_DEBUG, "send query n=%s t=%d (s=%s)",
+				mylog(LOG_DEBUG, "send query n=%s t=%d (s=%s)",
 					qcp->stat->name, qcp->type, buf);
 				}
 
@@ -733,13 +741,13 @@
 				{
 					qcp->badns |= 1<<qcp->ns;
 					if (cnf.debug & DEBUG_DNS)
-					log(LOG_DEBUG, "sendto failed: invalid ns (%s)", strerror(errno));
+					mylog(LOG_DEBUG, "sendto failed: invalid ns (%s)", strerror(errno));
 				}
 			}
 #else
 			nsap = &NSADDR_LIST(qcp->ns);
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "send query n=%s t=%d (s=%s)",
+			mylog(LOG_DEBUG, "send query n=%s t=%d (s=%s)",
 				qcp->stat->name, qcp->type,
 				inet_ntoa(nsap->sin_addr));
 
@@ -749,7 +757,7 @@
 			{
 				qcp->badns |= 1<<qcp->ns;
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "sendto failed: invalid ns");
+				mylog(LOG_DEBUG, "sendto failed: invalid ns");
 			}
 #endif
 			sti.nqueries++;
@@ -793,7 +801,7 @@
 			timeout.tv_usec = 0;
 		}
 		if ((cnf.debug & DEBUG_DNS) && (timeout.tv_sec > 0))
-		log(LOG_DEBUG, "DNS: waiting %d sec in %s mode",
+		mylog(LOG_DEBUG, "DNS: waiting %d sec in %s mode",
 			timeout.tv_sec, sync?"sync":"nosync");
 		FD_ZERO(&dsmask);
 #if INET6
@@ -825,7 +833,7 @@
 				resplen = recvfrom(s, &answer, anssiz, 0,
 					   (struct sockaddr *)&from, &fromlen);
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "DNS: got answer from %s",
+				mylog(LOG_DEBUG, "DNS: got answer from %s",
 					inet_ntoa(from.in.sin_addr));
 			}
 			else if (s6 >= 0 && FD_ISSET(s6, &dsmask))
@@ -838,7 +846,7 @@
 				{
 					inet_ntop(AF_INET6, &from.in6.sin6_addr,
 						buf, sizeof(buf));
-					log(LOG_DEBUG,
+					mylog(LOG_DEBUG,
 						"DNS: got answer from %s", buf);
 				}
 			}
@@ -846,19 +854,20 @@
 			resplen = recvfrom(s, &answer, anssiz, 0,
 					   (struct sockaddr *)&from, &fromlen);
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "DNS: got answer from %s",
+			mylog(LOG_DEBUG, "DNS: got answer from %s",
 				inet_ntoa(from.sin_addr));
 #endif
 
 			if (0) {
 				show_query("DNS: answer received",
-					&answer, &answer+resplen);
+					(u_char *)&answer,
+					(u_char *)&answer+resplen);
 			}
 			now = time(NULL);
 
 			if (resplen <= 0) {
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "DNS: bad anssiz %d",
+				mylog(LOG_DEBUG, "DNS: bad anssiz %d",
 					resplen);
 				continue;	/* error */
 			}
@@ -870,7 +879,7 @@
 				if (!(_res.options & RES_INSECURE1))
 				{
 					if (cnf.debug & DEBUG_DNS)
-					log(LOG_DEBUG,
+					mylog(LOG_DEBUG,
 						"DNS: not from our server");
 					continue;
 				}
@@ -888,14 +897,15 @@
 			GETSHORT(class, ap);
  
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "DNS: got answer for %s type %d",
+			mylog(LOG_DEBUG, "DNS: got answer for %s type %d",
 				nbuf, type);
 
 			qrp = hash_query_lookup(nbuf, NULL);
 			if (qrp == NULL)
 			{
 				show_query("DNS: no associated query sent",
-					&answer, &answer+resplen);
+					(u_char *)&answer,
+					(u_char *)&answer+resplen);
 				continue;	/* no associated request */
 			}
 			qcp = qrp->requests;
@@ -904,7 +914,8 @@
 			if (qcp == NULL)
 			{
 				show_query("DNS: no associated query",
-					&answer, &answer+resplen);
+					(u_char *)&answer,
+					(u_char *)&answer+resplen);
 				continue;	/* no associated request */
 			}
 
@@ -915,7 +926,7 @@
 			{
 				qcp->badns |= (1<<ns);
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "DNS: badnsF rcode=%d %x/%x",
+				mylog(LOG_DEBUG, "DNS: badnsF rcode=%d %x/%x",
 					hp->rcode,
 					qcp->badns, (1<<_res.nscount)-1);
 				if (qcp->badns != (1<<_res.nscount)-1)
@@ -924,7 +935,7 @@
 				qrp->rr_timeout |= qcp->need;
 				remove_query(qcp);
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "DNS: TCP requested, removing %s type %d",
+				mylog(LOG_DEBUG, "DNS: TCP requested, removing %s type %d",
 					qcp->stat->name, qcp->type);
 				continue;
 			}
@@ -933,7 +944,7 @@
 				qrp->rr_timeout |= qcp->need;
 				remove_query(qcp);
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "DNS: TCP requested, removing %s type %d",
+				mylog(LOG_DEBUG, "DNS: TCP requested, removing %s type %d",
 					qcp->stat->name, qcp->type);
 				continue;
 			}
@@ -952,7 +963,7 @@
 	if (sync != 0) {
 		pending = 0;
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "DNS: sync: get nearest timeout from %d", now);
+		mylog(LOG_DEBUG, "DNS: sync: get nearest timeout from %d", now);
 		for (qcp = QueryChain; qcp != NULL;)
 		{
 			if (qcp->try >= (u_char)_res.retry)
@@ -962,7 +973,7 @@
 				nextqcp = qcp->next;
 				remove_query(qcp);
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "DNS: sync timeout (n=%s, t=%d)",
+				mylog(LOG_DEBUG, "DNS: sync timeout (n=%s, t=%d)",
 					qcp->stat->name, qcp->type);
 				qcp = nextqcp;
 				continue;
@@ -970,7 +981,7 @@
 
 			pending++;
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "DNS: event timeout=%d", qcp->time);
+			mylog(LOG_DEBUG, "DNS: event timeout=%d", qcp->time);
 			qcp = qcp->next;
 		}
 		if (sync < 0)
@@ -978,7 +989,7 @@
 		if (pending)
 		{
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "DNS: retry in sync mode");
+			mylog(LOG_DEBUG, "DNS: retry in sync mode");
 			/* sleep(1); * XXX */
 			goto again;
 		}
@@ -989,12 +1000,12 @@
 			nextqcp = qcp->next;
 			remove_query(qcp);
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "DNS: final timeout (n=%s, t=%d)",
+			mylog(LOG_DEBUG, "DNS: final timeout (n=%s, t=%d)",
 				qcp->stat->name, qcp->type);
 			qcp = nextqcp;
 		}
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "DNS: closing socket");
+		mylog(LOG_DEBUG, "DNS: closing socket");
 #if INET6
 		if (s >= 0)
 		{
@@ -1038,10 +1049,10 @@
 #if 0
 	if (cnf.debug & DEBUG_DNS)
 	{
-		log(LOG_DEBUG, "Chain after removed:");
+		mylog(LOG_DEBUG, "Chain after removed:");
 		for (qcp = QueryChain; qcp != NULL; qcp = qcp->next)
 		{
-			log(LOG_DEBUG, " %s", qcp->stat->name);
+			mylog(LOG_DEBUG, " %s", qcp->stat->name);
 		}
 	}
 #endif
@@ -1070,7 +1081,7 @@
 
 	remove_query(qcp);
 	if (cnf.debug & DEBUG_DNS)
-	log(LOG_DEBUG, "DNS: got answer, removing %s type %d",
+	mylog(LOG_DEBUG, "DNS: got answer, removing %s type %d",
 		qcp->stat->name, qcp->type);
 
 	b  = (u_char *) answer;
@@ -1087,7 +1098,7 @@
 	if (hp->aa == 0 && hp->ra == 0) {
 		/* this nameserver does not support recursion */
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "non recursive ns=%d", qcp->ns);
+		mylog(LOG_DEBUG, "non recursive ns=%d", qcp->ns);
 		qcp->badns |= 1<<qcp->ns;
 		return;
 	}
@@ -1097,7 +1108,7 @@
 	{
 		/* host not found */
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "DNS: host (any other data) not found");
+		mylog(LOG_DEBUG, "DNS: host (any other data) not found");
 
 		qcp->stat->rr_noex = RR_ALL;
 		return;
@@ -1108,7 +1119,7 @@
 	{
 		/* no data, other data exist */
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "DNS: no data for %d", qcp->type);
+		mylog(LOG_DEBUG, "DNS: no data for %d", qcp->type);
 
 		if (qcp->type == T_ANY)
 		{
@@ -1152,7 +1163,7 @@
 	}
 
 	if (cnf.debug & DEBUG_DNS)
-	log(LOG_DEBUG, "DNS: valid data");
+	mylog(LOG_DEBUG, "DNS: valid data");
 
 	while (qdcount--)
 	{
@@ -1160,7 +1171,7 @@
 		ap += n;
 		if (ap + INT16SZ*2 > eom)
 		{
-			/* log(LOG_NOTICE, "corrupt DNS answer"); */
+			/* mylog(LOG_NOTICE, "corrupt DNS answer"); */
 			return;
 		}
 		GETSHORT(type, ap);
@@ -1180,7 +1191,7 @@
 		ap += n;
 		if (ap + INT16SZ*3 + INT32SZ > eom)
 		{
-			/* log(LOG_NOTICE, "corrupt DNS answer"); */
+			/* mylog(LOG_NOTICE, "corrupt DNS answer"); */
 			return;
 		}
 		GETSHORT(type, ap);
@@ -1189,13 +1200,13 @@
 		GETSHORT(n, ap);
 		if (ap + n > eom)
 		{
-			/* log(LOG_NOTICE, "corrupt DNS answer"); */
+			/* mylog(LOG_NOTICE, "corrupt DNS answer"); */
 			return;
 		}
 		if (class != C_IN)
 		{
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "DNS: unexpected class %d in an", class);
+			mylog(LOG_DEBUG, "DNS: unexpected class %d in an", class);
 			ap += n;
 			continue;
 		}
@@ -1229,7 +1240,7 @@
 					return;
 
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "DNS: got MX for %s, %s p=%d",
+				mylog(LOG_DEBUG, "DNS: got MX for %s, %s p=%d",
 					nbuf, nbuf2, pref);
 
 				qrp->rr_got |= RR_MX;
@@ -1268,7 +1279,7 @@
 			{
 				addr_found = 1;
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "DNS: got AAAA for %s",
+				mylog(LOG_DEBUG, "DNS: got AAAA for %s",
 					qcp->stat->name);
 
 				qcp->stat->rr_got |= RR_AAAA;
@@ -1278,7 +1289,7 @@
 				/* may be address for an alias */
 				cname_found = 0;
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "DNS: got aliased (%s) AAAA for %s",
+				mylog(LOG_DEBUG, "DNS: got aliased (%s) AAAA for %s",
 					nbuf, qcp->stat->name);
 				qrp = hash_query_lookup(nbuf, NULL);
 				if (qrp == NULL)
@@ -1309,7 +1320,7 @@
 			{
 				addr_found = 1;
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "DNS: got A for %s",
+				mylog(LOG_DEBUG, "DNS: got A for %s",
 					qcp->stat->name);
 
 				qcp->stat->rr_got |= RR_A;
@@ -1319,7 +1330,7 @@
 				cname_found = 0;
 				/* may be address for an alias */
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "DNS: got aliased (%s) A for %s",
+				mylog(LOG_DEBUG, "DNS: got aliased (%s) A for %s",
 					nbuf, qcp->stat->name);
 				qrp = hash_query_lookup(nbuf, NULL);
 				if (qrp == NULL)
@@ -1342,13 +1353,13 @@
 				return;
 
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "DNS: got CNAME %s for %s",
+			mylog(LOG_DEBUG, "DNS: got CNAME %s for %s",
 				nbuf2, nbuf);
 
 			if (strcasecmp(nbuf, nbuf2) == 0)
 			{
 				/* CNAME points back itself, ignore it */
-				log(LOG_INFO,
+				mylog(LOG_INFO,
 					"CNAME %s points back itself (q=%d)",
 					nbuf, qcp->type);
 				return;
@@ -1376,7 +1387,7 @@
 				bzero(qrp2, sizeof(struct dns_stat));
 				if (qrp2 == NULL)
 				{
-					log(LOG_NOTICE,
+					mylog(LOG_NOTICE,
 						"out of memory (dns_query)");
 					return;
 				}
@@ -1441,13 +1452,13 @@
 		ap += INT16SZ + INT16SZ + INT32SZ;
 		if (ap + INT16SZ > eom)
 		{
-			/* log(LOG_NOTICE, "corrupt DNS answer"); */
+			/* mylog(LOG_NOTICE, "corrupt DNS answer"); */
 			return;
 		}
 		GETSHORT(n, ap);
 		if (ap + n > eom)
 		{
-			/* log(LOG_NOTICE, "corrupt DNS answer"); */
+			/* mylog(LOG_NOTICE, "corrupt DNS answer"); */
 			return;
 		}
 		ap += n;
@@ -1460,13 +1471,13 @@
  		ap += INT16SZ + INT16SZ + INT32SZ;
 		if (ap + INT16SZ > eom)
 		{
-			/* log(LOG_NOTICE, "corrupt DNS answer"); */
+			/* mylog(LOG_NOTICE, "corrupt DNS answer"); */
 			return;
 		}
 		GETSHORT(n, ap);
 		if (ap + n > eom)
 		{
-			/* log(LOG_NOTICE, "corrupt DNS answer"); */
+			/* mylog(LOG_NOTICE, "corrupt DNS answer"); */
 			return;
 		}
 		ap += n;
@@ -1481,7 +1492,7 @@
 		ap += n;
 		if (ap + INT16SZ*3 + INT32SZ > eom)
 		{
-			/* log(LOG_NOTICE, "corrupt DNS answer"); */
+			/* mylog(LOG_NOTICE, "corrupt DNS answer"); */
 			return;
 		}
 		GETSHORT(type, ap);
@@ -1490,13 +1501,13 @@
 		GETSHORT(addrsize, ap);
 		if (ap + addrsize > eom)
 		{
-			/* log(LOG_NOTICE, "corrupt DNS answer"); */
+			/* mylog(LOG_NOTICE, "corrupt DNS answer"); */
 			return;
 		}
 		if (class != C_IN)
 		{
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "DNS: unexpected class %d in ar", class);
+			mylog(LOG_DEBUG, "DNS: unexpected class %d in ar", class);
 			ap += addrsize;
 			continue;
 		}
@@ -1529,7 +1540,7 @@
 		}
 
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "DNS: got additional Address RR for %s type=%d",
+		mylog(LOG_DEBUG, "DNS: got additional Address RR for %s type=%d",
 			nbuf, type);
 
 #if FAKE_AR_CHECK
@@ -1545,7 +1556,7 @@
 		if (!found)
 		{
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "DNS: ignoring additional Address RR");
+			mylog(LOG_DEBUG, "DNS: ignoring additional Address RR");
 			ap += addrsize;
 			continue;
 		}
@@ -1558,7 +1569,7 @@
 			bzero(qrp, sizeof(struct dns_stat));
 			if (qrp == NULL)
 			{
-				log(LOG_NOTICE, "out of memory (dns_query)");
+				mylog(LOG_NOTICE, "out of memory (dns_query)");
 				return;
 			}
 			qrp->name = newstr(nbuf);
@@ -1592,7 +1603,7 @@
 				bzero(qrp, sizeof(struct dns_stat));
 				if (qrp == NULL)
 				{
-					log(LOG_NOTICE,
+					mylog(LOG_NOTICE,
 						"out of memory (dns_query)");
 					return;
 				}
@@ -1605,20 +1616,20 @@
 			if (cnf.inetdom & SMTP_V6 || cnf.v4v6fallback)
 			{
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "DNS: getting AAAA RR for %s",
+				mylog(LOG_DEBUG, "DNS: getting AAAA RR for %s",
 					mxp->name);
 				make_query(qrp, T_AAAA);
 			}
 			if (cnf.inetdom & SMTP_V4 || cnf.v4v6fallback)
 			{
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "DNS: getting A RR for %s",
+				mylog(LOG_DEBUG, "DNS: getting A RR for %s",
 					mxp->name);
 				make_query(qrp, T_A);
 			}
 #else
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "DNS: getting A RR for %s",
+			mylog(LOG_DEBUG, "DNS: getting A RR for %s",
 				mxp->name);
 			make_query(qrp, T_A);
 			if (cnf.v4v6fallback)
@@ -1653,7 +1664,7 @@
 			continue;
 
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "getting MX for %s", dp->name);
+		mylog(LOG_DEBUG, "getting MX for %s", dp->name);
 
 		offset = 0;
 		needfindaddr = 0;
@@ -1701,15 +1712,15 @@
 		{
 			struct mx *mxp;
 
-			log(LOG_DEBUG, "final MX list for %s", dp->name);
+			mylog(LOG_DEBUG, "final MX list for %s", dp->name);
 			mxp = dp->firstmx;
 			if (mxp == NULL)
 			{
-				log(LOG_DEBUG, " NO MX!");
+				mylog(LOG_DEBUG, " NO MX!");
 			}
 			while (mxp != NULL)
 			{
-				log(LOG_DEBUG, " %s(%d, %d)", mxp->name,
+				mylog(LOG_DEBUG, " %s(%d, %d)", mxp->name,
 					mxp->pref, mxp->weight);
 				mxp = mxp->next;
 			}
@@ -1733,12 +1744,12 @@
 			int found = 0;
 
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "protocol gateway checking for %s",
+			mylog(LOG_DEBUG, "protocol gateway checking for %s",
 				dp->name);
 			for (mxp = dp->firstmx; mxp != NULL; mxp = mxp->next)
 			{
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "checking MX: %s", mxp->name);
+				mylog(LOG_DEBUG, "checking MX: %s", mxp->name);
 				if (mxp->host == NULL)
 				{
 					/* no hosts, try next MX */
@@ -1750,7 +1761,7 @@
 				{
 /*
 					if (cnf.debug & DEBUG_DNS)
-					log(LOG_DEBUG, "proto: %d",
+					mylog(LOG_DEBUG, "proto: %d",
 						addrp->domain);
 */
 #ifdef INET6
@@ -1763,10 +1774,9 @@
 #endif
 					{
 						struct mx *gwmxp;
-						static struct mx* newmx();
 
 						if (cnf.debug & DEBUG_DNS)
-						log(LOG_DEBUG, "setting protocol gateway as first MX");
+						mylog(LOG_DEBUG, "setting protocol gateway as first MX");
 						if ((gwmxp = newmx(cnf.pgateway,
 								  -2, 0, dp, 0))
 						    == NULL)
@@ -1817,7 +1827,7 @@
 	if (mxpp == NULL)
 	{
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "linking MX %s(%d) at the top",
+		mylog(LOG_DEBUG, "linking MX %s(%d) at the top",
 			newmxp->name, newmxp->pref);
 
 		domp->firstmx = newmxp;
@@ -1825,7 +1835,7 @@
 	else
 	{
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "linking MX %s(%d) after MX %s(%d)",
+		mylog(LOG_DEBUG, "linking MX %s(%d) after MX %s(%d)",
 			newmxp->name, newmxp->pref,
 			mxpp->name, mxpp->pref);
 
@@ -1856,14 +1866,14 @@
 	{
 		/* already registered, drop lower one */
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "duplicated MX %s(%d) found",
+		mylog(LOG_DEBUG, "duplicated MX %s(%d) found",
 			mxp->name, mxp->pref);
 
 		if (mxp->pref > pref
 		 || (mxp->pref == pref && mxp->weight > weight))
 		{
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "remove it and reuse");
+			mylog(LOG_DEBUG, "remove it and reuse");
 
 			if (mxp == dp->firstmx)
 				dp->firstmx = mxp->next;
@@ -1873,7 +1883,7 @@
 		else
 		{
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "leave it and ignore newer");
+			mylog(LOG_DEBUG, "leave it and ignore newer");
 
 			return mxp;	/* do nothing */
 		}
@@ -1885,7 +1895,7 @@
 		mxp = (struct mx*)MALLOC(sizeof(struct mx));
 		if (mxp == NULL)
 		{
-			log(LOG_NOTICE, "out of memory (newmx)");
+			mylog(LOG_NOTICE, "out of memory (newmx)");
 			return NULL;
 		}
 		bzero(mxp, sizeof(struct mx));
@@ -1922,7 +1932,7 @@
 	char msgbuf[MAXLINE], *mxname;
 
 	if (cnf.debug & DEBUG_DNS)
-	log(LOG_DEBUG, "getmxrr(%s, %s) offset=%d opt=%x",
+	mylog(LOG_DEBUG, "getmxrr(%s, %s) offset=%d opt=%x",
 		name, dp->name, offset, opt);
 
 	if (!query_mx)
@@ -1961,7 +1971,7 @@
 			if (mxp == NULL)
 				return -1;
 			addinetaddress(mxp, AF_INET, sizeof(nsin.in.sin_addr),
-				&nsin.in.sin_addr);
+				(u_char *)&nsin.in.sin_addr);
 		}
 #ifdef INET6
 		else if (inet_pton(INET6, name + 1, &nsin.in6.sin6_addr) > 0)
@@ -1973,7 +1983,7 @@
 				return -1;
 			addinetaddress(mxp, AF_INET6,
 				sizeof(nsin.in6.sin6_addr),
-				&nsin.in6.sin6_addr);
+				(u_char *)&nsin.in6.sin6_addr);
 		}
 #endif
 		else
@@ -1999,7 +2009,7 @@
 		qrp = qrp->cname;
 
 	if (cnf.debug & DEBUG_DNS && cnamechain > 0)
-	log(LOG_DEBUG, "CNAME traced: %s", qrp->name);
+	mylog(LOG_DEBUG, "CNAME traced: %s", qrp->name);
 
 	if (cnamechain >= CNAMELOOPMAX)
 	{
@@ -2009,7 +2019,7 @@
 	}
 
 	if (cnf.debug & DEBUG_DNS)
-	log(LOG_DEBUG, "%s: timeout=%x noex=%x got=%x",
+	mylog(LOG_DEBUG, "%s: timeout=%x noex=%x got=%x",
 		qrp->name, qrp->rr_timeout, qrp->rr_noex, qrp->rr_got);
 
 	if (qrp == NULL || qrp->rr_timeout & RR_MX) {
@@ -2044,7 +2054,7 @@
 				return -1;
 		}
 		else
-			log(LOG_INFO, "No MX/A on %s for %s; ignored",
+			mylog(LOG_INFO, "No MX/A on %s for %s; ignored",
 				name, dp->name);
 		return 0;
 	}
@@ -2089,12 +2099,12 @@
 		mxname = cmxp->name;
 #if 0
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "mx=%s pref=%d", mxname, cmxp->pref);
+		mylog(LOG_DEBUG, "mx=%s pref=%d", mxname, cmxp->pref);
 #endif
 		if (isamyalias(mxname))
 		{
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "found localhost (%s) in MX list",
+			mylog(LOG_DEBUG, "found localhost (%s) in MX list",
 				mxname);
 			if (!seenlocal || cmxp->pref < localpref)
 				localpref = cmxp->pref;
@@ -2136,13 +2146,13 @@
 			/* already registered, drop lower one */
 
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "duplicated MX %s(%d) found",
+			mylog(LOG_DEBUG, "duplicated MX %s(%d) found",
 				mxp->name, mxp->pref);
 
 			if (mxp->pref > offset + cmxp->pref)
 			{
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "remove it for re-link");
+				mylog(LOG_DEBUG, "remove it for re-link");
 				mxp->pref = offset + cmxp->pref;
 				if (mxp == dp->firstmx)
 					dp->firstmx = mxp->next;
@@ -2220,6 +2230,7 @@
 	return 0;
 }
 
+static void
 show_query(t, b, e)
 u_char *t, *b, *e;
 {
@@ -2246,13 +2257,13 @@
 		ap += n;
 		if (ap + INT16SZ*2 > eom)
 		{
-			/* log(LOG_NOTICE, "corrupt DNS answer"); */
+			/* mylog(LOG_NOTICE, "corrupt DNS answer"); */
 			return;
 		}
 		GETSHORT(class, ap);
 		GETSHORT(type, ap);
 		if (cnf.debug & DEBUG_DNS)
-		log(LOG_DEBUG, "%s: %s(%d,%d), rcode=%d",
+		mylog(LOG_DEBUG, "%s: %s(%d,%d), rcode=%d",
 			t, nbuf, class, type, ntohs(hp->rcode));
 	}
 
@@ -2267,7 +2278,7 @@
 		ap += n;
 		if (ap + INT16SZ*3 + INT32SZ > eom)
 		{
-			/* log(LOG_NOTICE, "corrupt DNS answer"); */
+			/* mylog(LOG_NOTICE, "corrupt DNS answer"); */
 			return;
 		}
 		GETSHORT(class, ap);
@@ -2276,13 +2287,13 @@
 		GETSHORT(n, ap);
 		if (ap + n > eom)
 		{
-			/* log(LOG_NOTICE, "corrupt DNS answer"); */
+			/* mylog(LOG_NOTICE, "corrupt DNS answer"); */
 			return;
 		}
 		if (class != C_IN)
 		{
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "DNS: unexpected class %d in an", class);
+			mylog(LOG_DEBUG, "DNS: unexpected class %d in an", class);
 			ap += n;
 			continue;
 		}
@@ -2293,20 +2304,20 @@
 				break;
 			ap += n;
 			if (cnf.debug & DEBUG_DNS)
-			log(LOG_DEBUG, "got MX pref=%d,host=(%s)", pref, nbuf);
+			mylog(LOG_DEBUG, "got MX pref=%d,host=(%s)", pref, nbuf);
 #if 0 /* for debug */
 			hep = gethostbyname(nbuf);
 			if (hep == NULL) {
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "get A --  h_errno=%d", h_errno);
+				mylog(LOG_DEBUG, "get A --  h_errno=%d", h_errno);
 			} else {
 				if (cnf.debug & DEBUG_DNS)
-				log(LOG_DEBUG, "get A -- OK");
+				mylog(LOG_DEBUG, "get A -- OK");
 			}
 #endif
 		} else {
 			ap += n;
-			/* log(LOG_DEBUG, "unexpected answer type: %d", type); */
+			/* mylog(LOG_DEBUG, "unexpected answer type: %d", type); */
 		}
 	}
 }
$NetBSD$

--- extern.h.orig	2002-01-20 23:20:46.000000000 +0900
+++ extern.h	2006-07-18 13:14:05.000000000 +0900
@@ -37,52 +37,55 @@
  */
 
-char *newstr();
-void strlower();
-char *parse_address();
-void setsender();
-int addrecipient();
-void addalias();
-int getmxrr();
-void init_log();
-int addmyalias();
-int isamyalias();
-void lmtp();
-void lmtp_data_response();
-void deliver();
-int pregetmx();
-int getmxlist();
-void finalstatus();
-int addinetaddress();
-void set_timeout();
-void resource_usage();
+#ifdef __STDC__
+#define P(c)	c
+#else
+#define P(c)
+#endif
+
+char *newstr P((char *));
+void strlower P((char *));
+char *parse_address P((char *, char **, char **, char **));
+int addrecipient P((char *, char *, char *, char *));
+int getmxrr P((char *, struct domain *, int, int, int, long));
+void init_log P((void));
+int addmyalias P((char *));
+int isamyalias P((char *));
+void lmtp P((void));
+void lmtp_data_response P((int));
+void deliver P((void));
+int pregetmx P((struct domain *));
+int getmxlist P((struct domain *));
+void finalstatus P((void));
+int addinetaddress P((struct mx *, int, int, u_char *));
+void set_timeout P((char *));
+void resource_usage P((char *));
 struct dns_stat *hash_query_lookup();
-struct domain *hash_domain_lookup();
-struct host *hash_host_lookup();
-struct host_map *hash_map_lookup();
-int host_map_load();
-char **host_map_lookup();
-int mxrand();
-int hash_domain_rcpts_lookup();
-void hash_domain_rcpts_enter();
-int isnumeric();
-int rcpts_def_load();
+struct domain *hash_domain_lookup P((char *, struct domain ***));
+struct host *hash_host_lookup P((char *, struct host ***));
+struct host_map *hash_map_lookup P((char *, struct host_map ***));
+int host_map_load P((void));
+char **host_map_lookup P((char *));
+int mxrand P((char *, char *));
+int hash_domain_rcpts_lookup P((char *));
+void hash_domain_rcpts_enter P((char *, struct domain_rcpts *));
+int isnumeric P((char *));
+int rcpts_def_load P((void));
+
+#if SPT_TYPE != SPT_BUILTIN
+void initsetproctitle P((int, char **, char **));
+void setproctitle P((const char *, ...));
+#endif
 
-void initsetproctitle();
 #ifdef JAZ_HACK2
 void show_cache();
 #endif
-# ifdef __STDC__
-void log(int, const char *, ...);
-void setproctitle(const char *, ...);
-# else
-void log();
-void setproctitle();
-# endif
+
+void mylog P((int, const char *, ...));
 
 # if !HAVE_STRERROR
-char *strerror();
+char *strerror P((int));
 # endif
 # if !HAVE_SNPRINTF
-int snprintf();
+int snprintf P((char *, size_t, const char *, ...));
 # endif
 
$NetBSD$

--- lmtp.c.orig	2002-01-20 23:19:42.000000000 +0900
+++ lmtp.c
@@ -67,8 +67,22 @@
 static	int	state;
 static	int	save_rcpts_trans;
 
+static void sig_quit P((int));
+static void lmtp_greeting P((void));
+static int lmtp_lhlo P((char *));
+static int lmtp_mail P((char *));
+static int lmtp_rcpt P((char *));
+static int lmtp_data P((char *));
+static int lmtp_quit P((void));
+static int lmtp_rset P((void));
+static int lmtp_noop P((void));
+static int lmtp_help P((char *));
+static int lmtp_nocmd P((void));
+static int read_message P((void));
+
 static void
-sig_quit()
+sig_quit(dummy)
+	int dummy;
 {
 	exit(EX_TEMPFAIL);
 }
@@ -116,7 +130,7 @@
 			if (strcasecmp(lmtpbuf, cmdp->cmd) == 0) {
 
 				if (cnf.debug & DEBUG_LMTP)
-				log(LOG_DEBUG, "LMTP input: %s %s", lmtpbuf,
+				mylog(LOG_DEBUG, "LMTP input: %s %s", lmtpbuf,
 					(p == NULL)?"":p);
 				ret = (*cmdp->func)(p);
 				fflush (LmtpOut);
@@ -242,7 +256,7 @@
 		return 0;
 	}
 	if (cnf.debug & DEBUG_LMTP)
-	log(LOG_DEBUG, "MAIL FROM: %s size=%s body=%s envid=%s ret=%s", addr,
+	mylog(LOG_DEBUG, "MAIL FROM: %s size=%s body=%s envid=%s ret=%s", addr,
 		(env.size == NULL)?"":env.size, (env.body == NULL)?"":env.body,
 		(env.envid == NULL)?"":env.envid, (env.ret == NULL)?"":env.ret);
 	fprintf (LmtpOut, "250 %s Sender ok\n", addr);
@@ -358,7 +372,7 @@
 	deliver();		/* delivery with SMTP */
 	lmtp_data_response(1);
 
-	log(LOG_INFO, "nquery=%d/%d nconnect=%d/%d ntimeout=%d ntrans=%d/%d nsent=%d/%d ndeferred=%d nerror=%d+%d dnsmaxcq=%d maxsock=%d tmx=%d tdelivery=%d/%d maxdelay=%d tdelay=%d tsendmail=%d dns_i/o=%d/%d smtp_i/o=%d/%d mem=%d",
+	mylog(LOG_INFO, "nquery=%d/%d nconnect=%d/%d ntimeout=%d ntrans=%d/%d nsent=%d/%d ndeferred=%d nerror=%d+%d dnsmaxcq=%d maxsock=%d tmx=%d tdelivery=%d/%d maxdelay=%d tdelay=%d tsendmail=%d dns_i/o=%d/%d smtp_i/o=%d/%d mem=%d",
 		sti.nanswers, sti.nqueries, sti.nquitok, sti.nconnect,
 		sti.ntimeout, sti.noktrans, sti.ntrans, sti.nsent, sti.nrcpt,
 		sti.ndeferred, sti.nnsfailed, sti.nsmtpfailed,
@@ -521,7 +535,7 @@
 			if (strstr(rcptp->response, rcptp->address) == NULL)
 			{
 				if (cnf.debug & DEBUG_LMTP)
-				log(LOG_DEBUG, "%d %s... %s",
+				mylog(LOG_DEBUG, "%d %s... %s",
 					rcptp->result, rcptp->address,
 					rcptp->response);
 				fprintf (LmtpOut, "%d %s... %s\n",
@@ -529,7 +543,7 @@
 					rcptp->response);
 			} else {
 				if (cnf.debug & DEBUG_LMTP)
-				log(LOG_DEBUG, "%d %s",
+				mylog(LOG_DEBUG, "%d %s",
 					rcptp->result, rcptp->response);
 				fprintf (LmtpOut, "%d %s\n",
 					rcptp->result, rcptp->response);
@@ -542,7 +556,7 @@
 
 			sti.ndeferred++;
 			if (cnf.debug & DEBUG_LMTP)
-			log(LOG_DEBUG, "%d %s... %s",
+			mylog(LOG_DEBUG, "%d %s... %s",
 				SMTP_TEMPFAIL(51), rcptp->address, msg);
 			fprintf (LmtpOut, "%d %s... %s\n",
 				SMTP_TEMPFAIL(51), rcptp->address, msg);
@@ -709,7 +723,7 @@
 		{
 			msgp->data = (char *)MALLOC(CHUNKSIZE);
 			if (cnf.debug & DEBUG_LMTP)
-			log(LOG_DEBUG, "new chunk %d", ++chunk_num);
+			mylog(LOG_DEBUG, "new chunk %d", ++chunk_num);
 			if (msgp->data == NULL)
 			{
 				outofmemory = 1;
@@ -725,7 +739,7 @@
 
 	if (outofmemory)
 	{
-		log(LOG_NOTICE, "out of memory (LMTP data buffer allocation)");
+		mylog(LOG_NOTICE, "out of memory (LMTP data buffer allocation)");
 		return -1;
 	}
 	return 0;
$NetBSD$

--- log.c.orig	2002-01-20 23:19:43.000000000 +0900
+++ log.c
@@ -73,7 +73,7 @@
 	{
 		syslog_fd = fd_before;
 		if (cnf.debug & DEBUG_TRANS)
-		log(LOG_DEBUG, "file descriptor for syslog: %d", syslog_fd);
+		mylog(LOG_DEBUG, "file descriptor for syslog: %d", syslog_fd);
 	}
 #endif
 }
@@ -85,9 +85,9 @@
 
 void
 # ifdef __STDC__
-log(int level, const char *fmt, ...)
+mylog(int level, const char *fmt, ...)
 # else
-log(level, fmt, va_alist)
+mylog(level, fmt, va_alist)
 int level;
 char *fmt;
 va_dcl
$NetBSD$

--- main.c.orig	2002-03-15 11:12:59.000000000 +0900
+++ main.c
@@ -46,7 +46,10 @@
 # define MAIN	1
 # include "extern.h"
 
-void
+static void usage P((char *));
+static void sig_quit P((int));
+
+static void
 usage(progname)
 char *progname;
 {
@@ -96,7 +99,8 @@
 }
 
 static void
-sig_quit()
+sig_quit(dummy)
+	int dummy;
 {
 	exit(EX_TEMPFAIL);
 }
@@ -155,7 +159,9 @@
         else
                 cnf.dst_port = 25;
 
+#if SPT_TYPE != SPT_BUILTIN
 	initsetproctitle(argc, argv, envp);
+#endif
 
 	opterr = 0;
 #ifdef INET6
@@ -455,14 +461,14 @@
 		switch (peername.in.sin_family)
 		{
 		    case AF_INET:
-			log(LOG_INFO, "connected from %s",
+			mylog(LOG_INFO, "connected from %s",
 				inet_ntoa(peername.in.sin_addr));
 			break;
 #ifdef INET6
 		    case AF_INET6:
 			inet_ntop(AF_INET6, &peername.in6.sin6_addr,
 				buf, sizeof(buf));
-			log(LOG_INFO, "connected from %s", buf);
+			mylog(LOG_INFO, "connected from %s", buf);
 			break;
 #endif
 		}
@@ -470,7 +476,7 @@
 
 	if (cnf.sd_max > MAX_SOCK)
 	{
-		log(LOG_INFO, "cnf.sd_max should not be greater than %d, recompile smtpfeed with greater FD_SETSIZE", MAX_SOCK);
+		mylog(LOG_INFO, "cnf.sd_max should not be greater than %d, recompile smtpfeed with greater FD_SETSIZE", MAX_SOCK);
 		cnf.sd_max = MAX_SOCK;
 	}
 #ifdef RLIMIT_NOFILE
@@ -478,14 +484,14 @@
 	{
 		if (limit.rlim_max - 1 < cnf.sd_max)
 		{
-			log(LOG_INFO, "cnf.sd_max should be %d",
+			mylog(LOG_INFO, "cnf.sd_max should be %d",
 				limit.rlim_max - 1);
 			cnf.sd_max = limit.rlim_max - 1;
 		}
 		limit.rlim_cur = limit.rlim_max; /* make soft limit the max */
 		if (setrlimit(RLIMIT_NOFILE, &limit) == -1)
 		{
-			log(LOG_NOTICE, "can't set max sd to %d",
+			mylog(LOG_NOTICE, "can't set max sd to %d",
 				limit.rlim_cur);
 		}
 	}
@@ -494,18 +500,18 @@
 #if SHOW_UID
 	uid = geteuid();
 #ifdef INET6
-        log(LOG_DEBUG, "%s (with IPv6) started (uid %d with %d descriptors)",
+        mylog(LOG_DEBUG, "%s (with IPv6) started (uid %d with %d descriptors)",
 		version, uid, cnf.sd_max);
 #else
-        log(LOG_DEBUG, "%s started (uid %d with %d descriptors)",
+        mylog(LOG_DEBUG, "%s started (uid %d with %d descriptors)",
 		version, uid, cnf.sd_max);
 #endif
 #else
 #ifdef INET6
-        log(LOG_DEBUG, "%s (with IPv6) started (with %d descriptors)",
+        mylog(LOG_DEBUG, "%s (with IPv6) started (with %d descriptors)",
 		version, cnf.sd_max);
 #else
-        log(LOG_DEBUG, "%s started (with %d descriptors)",
+        mylog(LOG_DEBUG, "%s started (with %d descriptors)",
 		version, cnf.sd_max);
 #endif
 #endif
@@ -551,7 +557,7 @@
 			}
 		}
 		if (strchr(myname, '.') == NULL)
-			log(LOG_INFO, "hostname (%s) is not a FQDN", myname);
+			mylog(LOG_INFO, "hostname (%s) is not a FQDN", myname);
 	}
 	if (addmyalias(myname) < 0)
 	{
@@ -559,13 +565,13 @@
 	}
 	if (cnf.fallbackmx != NULL && isamyalias(cnf.fallbackmx))
 	{
-		log(LOG_INFO, "ignoring fallbackmx (%s)", cnf.fallbackmx);
+		mylog(LOG_INFO, "ignoring fallbackmx (%s)", cnf.fallbackmx);
 		free(cnf.fallbackmx);
 		cnf.fallbackmx = NULL;
 	}
 	if (cnf.pgateway != NULL && isamyalias(cnf.pgateway))
 	{
-		log(LOG_INFO, "ignoring protocol gateway (%s)", cnf.pgateway);
+		mylog(LOG_INFO, "ignoring protocol gateway (%s)", cnf.pgateway);
 		free(cnf.pgateway);
 		cnf.pgateway = NULL;
 	}
@@ -574,7 +580,7 @@
 	{
 		if(rcpts_def_load() < 0)
 		{
-			log(LOG_INFO, "ignoring R option (%s)", cnf.rcpts_def);
+			mylog(LOG_INFO, "ignoring R option (%s)", cnf.rcpts_def);
 			free(cnf.rcpts_def);
 			cnf.rcpts_def = NULL;
 		}
$NetBSD$

--- mxrand.c.orig	2002-01-20 23:19:43.000000000 +0900
+++ mxrand.c
@@ -75,6 +75,8 @@
 
 # include "common.h"
 
+static time_t curtime P((void));
+
 /*
 **  CURTIME -- return current time.
 **
@@ -88,7 +90,7 @@
 **		none.
 */
 
-time_t
+static time_t
 curtime()
 {
 	auto time_t t;
@@ -117,7 +119,7 @@
 
 int
 mxrand(host1, host2)
-	register char *host1, *host2;
+	char *host1, *host2;
 {
 	int hfunc;
 	static unsigned int seed;
$NetBSD$

--- proctitle.c.orig	2002-01-20 23:19:43.000000000 +0900
+++ proctitle.c
@@ -156,6 +156,8 @@
 
 #endif /* SPT_TYPE != SPT_NONE && SPT_TYPE != SPT_BUILTIN */
 
+#if SPT_TYPE != SPT_BUILTIN
+
 /*
 **  Pointers for setproctitle.
 **	This allows "ps" listings to give more useful information.
@@ -211,9 +213,6 @@
 		LastArgv = argv[argc - 1] + strlen(argv[argc - 1]);
 }
 
-#if SPT_TYPE != SPT_BUILTIN
-
-
 /*VARARGS1*/
 void
 # ifdef __STDC__
$NetBSD$

--- smtp.c.orig	2002-02-23 19:20:05.000000000 +0900
+++ smtp.c
@@ -49,32 +49,42 @@
 static	int FirstRead, FirstWrite;
 static	int Terminate, NewTransCheck, NeedTrimDomain, MoreFreeSlot;
 
+static void sig_alarm P((int));
+static void sig_int P((int));
+static void sig_hup P((int));
+static void sig_term P((int));
+static void smtp P((void));
+
 static void
-sig_alarm()
+sig_alarm(dummy)
+	int dummy;
 {
 	errno = ETIMEDOUT;
 	if (cnf.debug & DEBUG_EVENT)
-	log(LOG_DEBUG, "alarm clock");
+	mylog(LOG_DEBUG, "alarm clock");
 }
 
 static void
-sig_int()
+sig_int(dummy)
+	int dummy;
 {
-	log(LOG_INFO, "SIGINT received: internal states dumped");
+	mylog(LOG_INFO, "SIGINT received: internal states dumped");
 	dump_internal();
 }
 
 static void
-sig_hup()
+sig_hup(dummy)
+	int dummy;
 {
-	log(LOG_INFO, "SIGHUP received: graceful termination");
+	mylog(LOG_INFO, "SIGHUP received: graceful termination");
 	forced_terminate();
 }
 
 static void
-sig_term()
+sig_term(dummy)
+	int dummy;
 {
-	log(LOG_INFO, "SIGTERM received: semi graceful termination");
+	mylog(LOG_INFO, "SIGTERM received: semi graceful termination");
 	markstatus(env.rcpt_list, SMTP_TEMPFAIL(51),
 		"Aborted by INT signal", 1);
 	longjmp(jmp_env, 1);
@@ -87,10 +97,10 @@
 	int s;
 
 	while((s = dup(0)) < 253);
-	log(LOG_DEBUG, "descriptor reserved till %d", s);
+	mylog(LOG_DEBUG, "descriptor reserved till %d", s);
 #endif
 
-	log(LOG_INFO, "from=%s size=%d nrcpt=%d msgid=%s",
+	mylog(LOG_INFO, "from=%s size=%d nrcpt=%d msgid=%s",
 		env.sender, env.realsize, sti.nrcpt,
 		(env.mid == NULL)?"none":env.mid);
 
@@ -99,7 +109,7 @@
 		FILE *fp;
 
 		if (cnf.debug & DEBUG_TRANS)
-			log(LOG_DEBUG, "searching sender address %s in %s",
+			mylog(LOG_DEBUG, "searching sender address %s in %s",
 				env.sender, cnf.src_mod_path);
 		if ((fp = fopen(cnf.src_mod_path, "r")) == NULL)
 		{
@@ -127,7 +137,7 @@
 			fclose(fp);
 			if (found)
 			{
-				log(LOG_INFO,
+				mylog(LOG_INFO,
 					"recipients/transaction changed to 1");
 				cnf.rcpts_trans == 1;
 			}
@@ -207,15 +217,53 @@
 	resource_usage("finalstatus done");
 }
 
-static int smtp_connected(), smtp_greeted(), smtp_flush();
-static int smtp_helo_r(), smtp_helo_r();
-static int smtp_mail_r(), smtp_rcpt_r(), smtp_rcpt_s();
-static int smtp_data_r(), smtp_data_body(), smtp_data_t();
-static int smtp_rset_r(), smtp_quit_r();
+static int smtp_connected P((struct connection *));
+static int smtp_flush P((struct connection *));
+static int smtp_greeted P((struct connection *));
+static int smtp_helo_r P((struct connection *));
+static int smtp_mail_r P((struct connection *));
+static int smtp_rcpt_r P((struct connection *));
+static int smtp_data_r P((struct connection *));
+static int smtp_data_body P((struct connection *));
+static int smtp_data_t P((struct connection *));
+static int smtp_rset_r P((struct connection *));
+static int smtp_quit_r P((struct connection *));
+
+static int smtp_helo_s P((struct connection *));
+static int smtp_mail_s P((struct connection *));
+static int smtp_rcpt_s P((struct connection *));
+static int smtp_data_s P((struct connection *));
+static int smtp_rset_s P((struct connection *));
+static int smtp_quit_s P((struct connection *));
+
+static int new_transaction P((void));
+static void process_connection P((fd_set *, fd_set *, int, int));
+static void markstatus P((struct recipient *, int, char *, int));
+static struct connection *open_transaction P((struct recipient *));
+static void close_transaction P((struct connection *, int));
+static void trim_rcpts P((struct domain *));
+static int trim_domain P((void));
+static void forced_terminate P((void));
+
+static int smtp_connect P((struct connection *));
+void smtp_close P((int));
+static int smtp_read P((struct connection *, char *, int, int *));
+static int smtp_write P((struct connection *, char *, int, int));
+static int smtp_get_reply P((struct connection *,
+			     void (*) P((struct connection *, char *)),
+			     char *, int, int *));
+static int smtp_send_command P((struct connection *, char *, int, int));
+static void esmtp_check P((struct connection *, char *));
+static void ehlo_opt P((struct connection *, char *));
+static char *skipaddr P((char *, char *addr));
+static int may_be_reused P((struct connection *));
+static int smtp_timeout P((struct connection *));
+static void dump_internal P((void));
+static char *smtpstrerror P((int));
 
 static struct	{
-	int (*recv)();
-	int (*send)();
+	int (*recv) P((struct connection *));
+	int (*send) P((struct connection *));
 	time_t tout;
 	char *name;
 } state_tbl[] = {
@@ -356,13 +404,13 @@
 		if (rcptp->domain == NULL)
 		{
 			rcptp->stat = RCPT_DONE;
-			log(LOG_NOTICE, "no domain for %s", rcptp->address);
+			mylog(LOG_NOTICE, "no domain for %s", rcptp->address);
 			continue;
 		}
 		if (rcptp->domain->firstmx == NULL)
 		{
 			rcptp->stat = RCPT_DONE;
-			log(LOG_NOTICE, "no MX for %s", rcptp->address);
+			mylog(LOG_NOTICE, "no MX for %s", rcptp->address);
 			continue;
 		}
 	}
@@ -375,7 +423,7 @@
 		if (domp->rcpt_top == NULL)
 			continue;
 		if (cnf.debug & DEBUG_TRANS)
-		log(LOG_DEBUG, "pick up domain: %s", domp->name);
+		mylog(LOG_DEBUG, "pick up domain: %s", domp->name);
 		if (wdomp == NULL)
 			env.work_domain = domp;
 		else
@@ -395,7 +443,7 @@
 		{
 			/* all recipients had been processed */
 			if (cnf.debug & DEBUG_CONNECT)
-			log(LOG_DEBUG, "closing all sockets");
+			mylog(LOG_DEBUG, "closing all sockets");
 			all_done = 1;
 			for (i = 0; i < cnf.sd_max; i++)
 			{
@@ -424,7 +472,7 @@
 			}
 
 			if (cnf.debug & DEBUG_TRANS)
-			log(LOG_DEBUG, "in_use=%d, max_sock=%d, min_sock=%d",
+			mylog(LOG_DEBUG, "in_use=%d, max_sock=%d, min_sock=%d",
 				in_use, max_sock, sti.minsock);
 
 			if (in_use > (max_sock - sti.minsock))
@@ -439,7 +487,7 @@
 					if (connwork[i].host->state != STAT_SENT)
 						continue;
 					if (cnf.debug & DEBUG_CONNECT)
-					log(LOG_DEBUG, "%d/%d: closing idle socket",
+					mylog(LOG_DEBUG, "%d/%d: closing idle socket",
 						connwork[i].seq,
 						connwork[i].socket);
 					smtp_quit_s(&connwork[i]);
@@ -458,7 +506,7 @@
 				if (!connwork[i].reuse)
 					break;
 				if (cnf.debug & DEBUG_CONNECT)
-				log(LOG_DEBUG, "%d/%d: closing idle socket",
+				mylog(LOG_DEBUG, "%d/%d: closing idle socket",
 					connwork[i].seq,
 					connwork[i].socket);
 				smtp_quit_s(&connwork[i]);
@@ -479,7 +527,7 @@
 			}
 #if 1
 			if (cnf.debug & DEBUG_TRANS)
-			log(LOG_DEBUG, "new transaction: trans=%d, sock=%d",
+			mylog(LOG_DEBUG, "new transaction: trans=%d, sock=%d",
 				num_trans, num_sock);
 #endif
 			if (new_transaction() < 0)
@@ -514,7 +562,7 @@
 		if (all_done && fds < 0)
 		{
 			if (cnf.debug & DEBUG_CONNECT)
-			log(LOG_DEBUG, "all sockets are closed");
+			mylog(LOG_DEBUG, "all sockets are closed");
 #if 0
 			dump_internal();
 #endif
@@ -523,7 +571,7 @@
 
 		if (fds < 0)	/* XXX */
 		{
-			log(LOG_INFO, "No active sockets");
+			mylog(LOG_INFO, "No active sockets");
 			if (bad_state++ > 5)
 			{
 				markstatus(env.rcpt_list, SMTP_TEMPFAIL(51),
@@ -561,12 +609,12 @@
 		{
 			/* time up */
 			forced_terminate();
-			log(LOG_INFO, "total processing timed out (%d sec)",
+			mylog(LOG_INFO, "total processing timed out (%d sec)",
 				cnf.t_timeout);
 		}
 		if (rc < 0)
 		{
-			log(LOG_INFO, "select returns %d (fds=%d, errno=%d)",
+			mylog(LOG_INFO, "select returns %d (fds=%d, errno=%d)",
 				rc, fds, errno);
 			sleep(1);
 		}
@@ -594,7 +642,7 @@
 	{ 
 #if 1
 		if (cnf.debug & DEBUG_TRANS)
-		log(LOG_DEBUG, "checking domain: %s", domp->name);
+		mylog(LOG_DEBUG, "checking domain: %s", domp->name);
 #endif
 		/* first time for the domain? */
 #if 1
@@ -615,7 +663,7 @@
 		      || domp->curmx->host->addr == NULL))))
 		{
 			if (domp->curmx->host == NULL)
-				log(LOG_INFO, "skipping bad MX: %s for %s",
+				mylog(LOG_INFO, "skipping bad MX: %s for %s",
 					domp->curmx->name, domp->name);
 			else
 			{
@@ -697,7 +745,7 @@
 	}
 #if 1
 	if (cnf.debug & DEBUG_TRANS)
-	log(LOG_DEBUG, "no new transaction");
+	mylog(LOG_DEBUG, "no new transaction");
 #endif
 	NewTransCheck = 0;
 	return -1;	/* no new transaction */
@@ -721,7 +769,7 @@
 
 		snprintf(msgbuf, sizeof(msgbuf),
 			"No address known for %s", conn->host->name);
-		log(LOG_INFO, msgbuf, conn->host->name);
+		mylog(LOG_INFO, msgbuf, conn->host->name);
 
 		rcode = SMTP_TEMPFAIL(52);
 		if (cnf.absentAok)
@@ -798,7 +846,7 @@
 			/* timeout! */
 			sti.ntimeout++;
 			if (cnf.debug & DEBUG_CONNECT)
-			log(LOG_DEBUG, "%d/%d: timeout (%s)", conn->seq,
+			mylog(LOG_DEBUG, "%d/%d: timeout (%s)", conn->seq,
 				conn->socket, STATE(st));
 			if (st == STAT_DTERMSENT)
 			{
@@ -814,7 +862,7 @@
 		if (FD_ISSET(conn->socket, w_fds))
 		{
 			if (cnf.debug & DEBUG_EVENT)
-			log(LOG_DEBUG, "%d/%d: writable (%s)",
+			mylog(LOG_DEBUG, "%d/%d: writable (%s)",
 				conn->seq, conn->socket, STATE(st));
 			if (state_tbl[st].send != NULL)
 			{
@@ -825,14 +873,14 @@
 			if (conn->host == NULL)
 			{
 				if (cnf.debug & DEBUG_EVENT)
-				log(LOG_DEBUG, "%d/%d: state %s -> NULL",
+				mylog(LOG_DEBUG, "%d/%d: state %s -> NULL",
 					conn->seq, conn->socket, STATE(st));
 			}
 			else if (st != conn->host->state)
 			{
 				conn->host->time = Now;
 				if (cnf.debug & DEBUG_EVENT)
-				log(LOG_DEBUG, "%d/%d: state %s -> %s",
+				mylog(LOG_DEBUG, "%d/%d: state %s -> %s",
 					conn->seq, conn->socket, STATE(st),
 					STATE(conn->host->state));
 			}
@@ -841,7 +889,7 @@
 		if (FD_ISSET(conn->socket, r_fds))
 		{
 			if (cnf.debug & DEBUG_EVENT)
-			log(LOG_DEBUG, "%d/%d: readable (%s)",
+			mylog(LOG_DEBUG, "%d/%d: readable (%s)",
 				conn->seq, conn->socket, STATE(st));
 			if (state_tbl[st].recv != NULL)
 			{
@@ -852,14 +900,14 @@
 			if (conn->host == NULL)
 			{
 				if (cnf.debug & DEBUG_EVENT)
-				log(LOG_DEBUG, "%d/%d: state %s -> NULL",
+				mylog(LOG_DEBUG, "%d/%d: state %s -> NULL",
 					conn->seq, conn->socket, STATE(st));
 			}
 			else if (st != conn->host->state)
 			{
 				conn->host->time = Now;
 				if (cnf.debug & DEBUG_EVENT)
-				log(LOG_DEBUG, "%d/%d: state %s -> %s",
+				mylog(LOG_DEBUG, "%d/%d: state %s -> %s",
 					conn->seq, conn->socket, STATE(st),
 					STATE(conn->host->state));
 			}
@@ -1041,7 +1089,7 @@
 		{
 			/* buffer may be full */
 			strcat(addrbuf+addrlen, ",(more...)");
-			log(LOG_INFO, "(%d+%d+%d+%d/%d) relay=%s to=%s proto=%s delay=%d code=%d (%s)",
+			mylog(LOG_INFO, "(%d+%d+%d+%d/%d) relay=%s to=%s proto=%s delay=%d code=%d (%s)",
 				sti.nsent, sti.ndeferred, sti.nnsfailed,
 				sti.nsmtpfailed, sti.nrcpt, hostname,
 				addrbuf, proto, delay, rcode,
@@ -1066,7 +1114,7 @@
 			{
 				rcptp->stat = RCPT_RETRY;
 				if (cnf.debug & DEBUG_TRANS)
-				log(LOG_DEBUG, "tempfail; next avail: %s",
+				mylog(LOG_DEBUG, "tempfail; next avail: %s",
 					rcptp->address);
 			}
 			else
@@ -1074,7 +1122,7 @@
 				sti.ndeferred++;
 				rcptp->stat = RCPT_DONE;
 				if (cnf.debug & DEBUG_TRANS)
-				log(LOG_DEBUG, "tempfail; done: %s",
+				mylog(LOG_DEBUG, "tempfail; done: %s",
 					rcptp->address);
 			}
 		}
@@ -1103,7 +1151,7 @@
 	}
 	if (addrlen > 0)
 	{
-		log(LOG_INFO, "(%d+%d+%d+%d/%d) relay=%s to=%s proto=%s delay=%d code=%d (%s)",
+		mylog(LOG_INFO, "(%d+%d+%d+%d/%d) relay=%s to=%s proto=%s delay=%d code=%d (%s)",
 			sti.nsent, sti.ndeferred, sti.nnsfailed,
 			sti.nsmtpfailed, sti.nrcpt, hostname,
 			addrbuf, proto, delay, rcode,
@@ -1143,7 +1191,7 @@
 
 #if 1
 	if (cnf.debug & DEBUG_TRANS)
-	log(LOG_DEBUG, "num_trans=%d, num_sock=%d, max_sock=%d, min_sock=%d",
+	mylog(LOG_DEBUG, "num_trans=%d, num_sock=%d, max_sock=%d, min_sock=%d",
 		num_trans, num_sock, max_sock, sti.minsock);
 #endif
 	if (num_trans > (max_sock - sti.minsock))
@@ -1158,7 +1206,7 @@
 
 #if 1
 	if (cnf.debug & DEBUG_TRANS)
-	log(LOG_DEBUG, "open transaction for %s", rcptp->address);
+	mylog(LOG_DEBUG, "open transaction for %s", rcptp->address);
 #endif
 
 	if (rcptp->domain->curmx->host->state == STAT_SENT)
@@ -1170,7 +1218,7 @@
 				break;
 		}
 		if (cnf.debug & DEBUG_TRANS)
-		log(LOG_DEBUG, "reusing: slot=%d", i);
+		mylog(LOG_DEBUG, "reusing: slot=%d", i);
 	}
 	else
 	{
@@ -1190,7 +1238,7 @@
 	{
 #if 0
 		if (cnf.debug & DEBUG_TRANS)
-		log(LOG_DEBUG, "no free slot");
+		mylog(LOG_DEBUG, "no free slot");
 #endif
 		/* sleep (1); */
 		return NULL;	/* XXX socket slot is full */
@@ -1199,7 +1247,7 @@
 	sti.ntrans++;
 
 	if (cnf.debug & DEBUG_TRANS)
-	log(LOG_DEBUG, "%d/-: open transaction for %s, slot=%d",
+	mylog(LOG_DEBUG, "%d/-: open transaction for %s, slot=%d",
 		sti.ntrans, rcptp->address, i);
 
 	/* initialize transaction */
@@ -1230,7 +1278,7 @@
 		domp = mxp->domain;
 		if (domp == NULL)
 		{
-			log(LOG_NOTICE, "Oops, mxp->domain for %s is NULL",
+			mylog(LOG_NOTICE, "Oops, mxp->domain for %s is NULL",
 				mxp->name);
 			goto next_domain;
 		}
@@ -1253,7 +1301,7 @@
 				if (rcpts + 1 > cnf.rcpts_trans)
 #else
 				if (cnf.debug & DEBUG_TRANS)
-				log(LOG_DEBUG, "check count of rcpts (domain:%s, max rcpts:%d, count:%d)",
+				mylog(LOG_DEBUG, "check count of rcpts (domain:%s, max rcpts:%d, count:%d)",
 					rcptp2->domain->name,
 					rcptp2->domain->rcpts,
 					rcpts);
@@ -1266,7 +1314,7 @@
 				}
 				rcpts++;
 				if (cnf.debug & DEBUG_TRANS)
-				log(LOG_DEBUG, "%d/-: with %s",
+				mylog(LOG_DEBUG, "%d/-: with %s",
 					sti.ntrans, rcptp2->address);
 				rcptp2->stat = RCPT_WORK;
 				rcptp2->chain = NULL;
@@ -1306,7 +1354,7 @@
 #endif
 
 	if (cnf.debug & DEBUG_TRANS)
-	log(LOG_DEBUG, "%d/%d: close transaction", conn->seq, conn->socket);
+	mylog(LOG_DEBUG, "%d/%d: close transaction", conn->seq, conn->socket);
 
 	NewTransCheck = 1;		/* do not skip new_transaction() */
 	env.work_dom_ptr = NULL;	/* retry from the top of list */
@@ -1369,7 +1417,7 @@
 			if (domp->curmx != NULL)
 			{
 				if (cnf.debug & DEBUG_TRANS)
-				log(LOG_DEBUG, "%d/-: switching to next MX: %s",
+				mylog(LOG_DEBUG, "%d/-: switching to next MX: %s",
 					conn->seq, domp->curmx->name);
 			}
 		}
@@ -1410,7 +1458,7 @@
 	num_trans--;
 }
 
-void
+static void
 trim_rcpts(domp)
 struct domain *domp;
 {
@@ -1427,7 +1475,7 @@
 		{
 			/* remove recipient from working chain */
 			if (cnf.debug & DEBUG_TRANS)
-			log(LOG_DEBUG, "removing recipient: %s",
+			mylog(LOG_DEBUG, "removing recipient: %s",
 				rcptp->address);
 			if (rcptp == domp->rcpt_top)
 			{
@@ -1449,7 +1497,7 @@
 		NeedTrimDomain = 1;
 }
 
-int
+static int
 trim_domain()
 {
 	struct domain *domp, *domtmp;
@@ -1463,7 +1511,7 @@
 		{
 			/* remove from working domain chain */
 			if (cnf.debug & DEBUG_TRANS)
-			log(LOG_DEBUG, "removing domain: %s",
+			mylog(LOG_DEBUG, "removing domain: %s",
 				domp->name);
 			if (domp == env.work_domain)
 			{
@@ -1490,7 +1538,7 @@
 	return 0;
 }
 
-void
+static void
 forced_terminate()
 {
 	struct recipient *rcptp;
@@ -1518,7 +1566,7 @@
 
 	if (conn->host == NULL)
 	{
-		log(LOG_NOTICE, "smtp_connect called with NULL host");
+		mylog(LOG_NOTICE, "smtp_connect called with NULL host");
 		return -1;
 	}
 
@@ -1532,7 +1580,7 @@
 	}
 
 	if (cnf.debug & DEBUG_CONNECT)
-	log(LOG_DEBUG, "%d/-: connecting to %s",
+	mylog(LOG_DEBUG, "%d/-: connecting to %s",
 		conn->seq, conn->host->name);
 
 	bzero((char *)&rsin, sizeof(rsin));
@@ -1569,7 +1617,7 @@
 			socksize = sizeof(struct sockaddr_in);
 
 			if (cnf.debug & DEBUG_CONNECT)
-			log(LOG_DEBUG, "%d/-: destination=%s/%d", conn->seq,
+			mylog(LOG_DEBUG, "%d/-: destination=%s/%d", conn->seq,
 				inet_ntoa(rsin.in.sin_addr), cnf.dst_port);
 			found = 1;
 			break;
@@ -1599,7 +1647,7 @@
 
 				inet_ntop(AF_INET6, &rsin.in6.sin6_addr,
 					buf, sizeof(buf));
-				log(LOG_DEBUG, "%d/-: destination=%s/%d",
+				mylog(LOG_DEBUG, "%d/-: destination=%s/%d",
 					conn->seq, buf, cnf.dst_port);
 			}
 			found = 1;
@@ -1637,7 +1685,7 @@
 
 	if (sd > MAX_SOCK)
 	{
-		log(LOG_NOTICE, "%d/%d: can not manage such a big file descriptor number with select()",
+		mylog(LOG_NOTICE, "%d/%d: can not manage such a big file descriptor number with select()",
 			conn->seq, sd);
 		close(sd);
 		if (max_sock > MAX_SOCK)
@@ -1650,7 +1698,7 @@
 
 	if (sd < 0){
 		/* no more socket resource */
-		log(LOG_NOTICE, "socket allocation failed for %s: %s (may be max=%d, current=%d/%d/%d)",
+		mylog(LOG_NOTICE, "socket allocation failed for %s: %s (may be max=%d, current=%d/%d/%d)",
 			conn->host->name, smtpstrerror(errno), sti.maxsock,
 			max_sock, num_sock, sti.minsock);
 		if (max_sock > NOFILE)
@@ -1669,14 +1717,14 @@
 	}
 
 	if (cnf.debug & DEBUG_CONNECT)
-	log(LOG_DEBUG, "%d/%d: socket allocated", conn->seq, sd);
+	mylog(LOG_DEBUG, "%d/%d: socket allocated", conn->seq, sd);
 
 #ifdef SO_SNDBUF
 	if (cnf.sendbufsize > 0)
 	{
 		if (setsockopt(sd, SOL_SOCKET, SO_SNDBUF,
 		    (char *)&cnf.sendbufsize, sizeof(cnf.sendbufsize)) < 0)
-			log(LOG_NOTICE, "%d/%d: setsockopt(SO_SNDBUF) failed for %s: %s",
+			mylog(LOG_NOTICE, "%d/%d: setsockopt(SO_SNDBUF) failed for %s: %s",
 				conn->seq, sd, conn->host->name,
 				smtpstrerror(errno));
 		/* ignore error */
@@ -1741,7 +1789,7 @@
 				    case AF_INET:
 					bcopy(addrp->address,
 						&lsin.in.sin_addr, addrp->len);
-					log(LOG_INFO,
+					mylog(LOG_INFO,
 						"using %s as source IP address",
 						inet_ntoa(lsin.in.sin_addr));
 					break;
@@ -1753,7 +1801,7 @@
 
 					inet_ntop(AF_INET6, &lsin.in6.sin6_addr,
 						buf, sizeof(buf));
-					log(LOG_INFO, "using %s as source IP address", buf);
+					mylog(LOG_INFO, "using %s as source IP address", buf);
 					break;
 #endif
 				}
@@ -1771,7 +1819,7 @@
 				p = NULL;
 		}
 		if (!found)
-			log(LOG_INFO, "sourceIP (%s) ignored", cnf.sourceIP);
+			mylog(LOG_INFO, "sourceIP (%s) ignored", cnf.sourceIP);
 	}
 	if (!found)
 	{
@@ -1820,7 +1868,7 @@
 	{
 		if (bind(sd, (struct sockaddr *)&lsin, socksize) < 0)
 		{
-			log(LOG_NOTICE, "%d/%d: bind failed for %s: %s", 
+			mylog(LOG_NOTICE, "%d/%d: bind failed for %s: %s", 
 				conn->seq, sd, conn->host->name,
 				smtpstrerror(errno));
 			conn->host->state = STAT_FAIL;
@@ -1837,7 +1885,7 @@
 
 	if (ioctl (sd, FIONBIO, &res) < 0)
 	{
-		log(LOG_NOTICE, "%d/%d: FIONBIO failed for %s: %s",
+		mylog(LOG_NOTICE, "%d/%d: FIONBIO failed for %s: %s",
 			conn->seq, sd, conn->host->name, smtpstrerror(errno));
 		conn->host->state = STAT_FAIL;
 		close (sd);
@@ -1848,7 +1896,7 @@
 #else
 	if ((res = fcntl(sd, F_GETFL, 0)) == -1)
 	{
-		log(LOG_NOTICE, "%d/%d: F_GETFL failed for %s: %s",
+		mylog(LOG_NOTICE, "%d/%d: F_GETFL failed for %s: %s",
 			conn->seq, sd, conn->host->name, smtpstrerror(errno));
 		conn->host->state = STAT_FAIL;
 		close (sd);
@@ -1863,7 +1911,7 @@
 # endif
 	if (fcntl(sd, F_SETFL, res) == -1)
 	{
-		log(LOG_NOTICE, "%d/%d: F_SETFL failed for %s: %s",
+		mylog(LOG_NOTICE, "%d/%d: F_SETFL failed for %s: %s",
 			conn->seq, sd, conn->host->name, smtpstrerror(errno));
 		conn->host->state = STAT_FAIL;
 		close (sd);
@@ -1879,7 +1927,7 @@
 	 && errno != EINPROGRESS && errno != EINTR)	/* XXX */
 	{
 		alarm(0);
-		log(LOG_DEBUG, "%d/%d: connect failed for %s: %s",
+		mylog(LOG_DEBUG, "%d/%d: connect failed for %s: %s",
 			conn->seq, sd, conn->host->name, smtpstrerror(errno));
 		conn->host->current->stat = EX_TEMPFAIL;
 		close (sd);
@@ -1911,7 +1959,7 @@
 		}
 		sti.minsock = sd;
 		if (cnf.debug & DEBUG_CONNECT)
-		log(LOG_DEBUG, "minsock=%d", sti.minsock);
+		mylog(LOG_DEBUG, "minsock=%d", sti.minsock);
 	}
 	num_sock++;
 	return 0;
@@ -1931,11 +1979,11 @@
 {
 	SockAddr cin;
 	int len = sizeof(SockAddr);
-	const char *errmsg;
+	char *errmsg;
 
 	if (getpeername(conn->socket, (struct sockaddr *)&cin, &len) < 0)
 	{
-		log(LOG_INFO, "%d/%d: getpeername failed for %s: %s",
+		mylog(LOG_INFO, "%d/%d: getpeername failed for %s: %s",
 			conn->seq, conn->socket, conn->host->name,
 			smtpstrerror(errno));
 		if (conn->host->current != NULL) /* XXX for safe access */
@@ -1984,7 +2032,7 @@
 	conn->outlen = 0;
 	if (conn->inbuf == NULL || conn->outbuf == NULL)
 	{
-		log(LOG_NOTICE, "out of memory (SMTP buffer allocation)");
+		mylog(LOG_NOTICE, "out of memory (SMTP buffer allocation)");
 		if (conn->host->current != NULL) /* XXX for safe access */
 		{
 			conn->host->current->stat = EX_TEMPFAIL;
@@ -2028,7 +2076,7 @@
 			if (n == 0)
 			{
 				if (cnf.debug & DEBUG_CONNECT)
-				log(LOG_DEBUG, "%d/%d: closed by foreign host",
+				mylog(LOG_DEBUG, "%d/%d: closed by foreign host",
 					conn->seq, conn->socket);
 				errno = E_SF_IO;
 				return -1;
@@ -2046,7 +2094,7 @@
 #endif
 				return 0;
 			  default:
-				log(LOG_DEBUG, "%d/%d: read failed for %s: ret=%d, errno=%d",
+				mylog(LOG_DEBUG, "%d/%d: read failed for %s: ret=%d, errno=%d",
 					conn->seq, conn->socket,
 					conn->host->name, n, errno);
 				return n;
@@ -2112,7 +2160,7 @@
 			if (n == 0)
 			{
 				if (cnf.debug & DEBUG_CONNECT)
-				log(LOG_DEBUG,
+				mylog(LOG_DEBUG,
 					"%d/%d: closed by foreign host (%s)",
 					conn->seq, conn->socket,
 					conn->host->name);
@@ -2132,7 +2180,7 @@
 #endif
 				return 0;
 			  default:
-				log(LOG_DEBUG,
+				mylog(LOG_DEBUG,
 					"%d/%d: write failed for %s: ret=%d, errno=%d",
 					conn->seq, conn->socket,
 					conn->host->name, n, errno);
@@ -2167,7 +2215,7 @@
 			if (n == 0)
 			{
 				if (cnf.debug & DEBUG_CONNECT)
-				log(LOG_DEBUG,
+				mylog(LOG_DEBUG,
 					"%d/%d: closed by foreign host (%s)",
 					conn->seq, conn->socket,
 					conn->host->name);
@@ -2185,7 +2233,7 @@
 #endif
 				return size;
 			  default:
-				log(LOG_DEBUG,
+				mylog(LOG_DEBUG,
 					"%d/%d: write failed for %s: ret=%d, errno=%d",
 					conn->seq, conn->socket,
 					conn->host->name, n, errno);
@@ -2236,7 +2284,7 @@
 static int
 smtp_get_reply(conn, func, firstline, size, rest)
 struct connection *conn;
-void (*func)();
+void (*func) P((struct connection *, char *));
 char firstline[];
 int size;
 int *rest;
@@ -2281,7 +2329,7 @@
 			cbuf[--len] = '\0';
 		}
 		if (cnf.debug & DEBUG_SMTP)
-		log(LOG_DEBUG, "%d/%d: >>> %s", conn->seq, conn->socket, cbuf);
+		mylog(LOG_DEBUG, "%d/%d: >>> %s", conn->seq, conn->socket, cbuf);
 		if (func != NULL)
 			(*func)(conn, cbuf);
 		if (!isdigit(cbuf[0]) || !isdigit(cbuf[1]) || !isdigit(cbuf[2])
@@ -2338,7 +2386,7 @@
 	int len = strlen(buf);
 
 	if (cnf.debug & DEBUG_SMTP)
-	log(LOG_DEBUG, "%d/%d: <<< %s", conn->seq, conn->socket, buf);
+	mylog(LOG_DEBUG, "%d/%d: <<< %s", conn->seq, conn->socket, buf);
 	if (len + 2 < size)
 	{
 		strcat(buf, CRLF);
@@ -2412,7 +2460,7 @@
 {
 	char buf[MAXLINE];
 	int rcode, savestate;
-	const char *errmsg;
+	char *errmsg;
 
 	errno = 0;
 	savestate = conn->host->state;
@@ -2453,7 +2501,7 @@
 			errmsg = "Unexpected Error";
 			break;
 		}
-		log(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
+		mylog(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
 			conn->seq, conn->socket, conn->host->name,
 			smtpstrerror(errno), STATE(savestate));
 		if (conn->host->current != NULL) /* XXX for safe access */
@@ -2600,7 +2648,7 @@
 	{
 		if (errno > 0)
 		{
-			log(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
+			mylog(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
 				conn->seq, conn->socket, smtpstrerror(errno),
 				conn->host->name, STATE(savestate));
 		}
@@ -2854,7 +2902,7 @@
 	{
 		if (errno > 0)
 		{
-			log(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
+			mylog(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
 				conn->seq, conn->socket, conn->host->name,
 				smtpstrerror(errno), STATE(savestate));
 		}
@@ -3032,7 +3080,7 @@
 	{
 		if (errno > 0)
 		{
-			log(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
+			mylog(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
 				conn->seq, conn->socket, conn->host->name,
 				smtpstrerror(errno), STATE(savestate));
 		}
@@ -3149,7 +3197,7 @@
 	{
 		if (errno > 0)
 		{
-			log(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
+			mylog(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
 				conn->seq, conn->socket, conn->host->name,
 				smtpstrerror(errno), STATE(savestate));
 		}
@@ -3229,7 +3277,7 @@
 		len = strlen(altbuf);
 		rcode = smtp_write(conn, altbuf, len, 0);
 		if (rcode != len)	/* XXX */
-			log(LOG_NOTICE,
+			mylog(LOG_NOTICE,
 			    "Header of sent message will be corrupted: %s",
 			    altbuf);
 	}
@@ -3301,7 +3349,7 @@
 		return 0;
 
 	if (cnf.debug & DEBUG_CONNECT)
-	log(LOG_DEBUG, "reusability check: %s", conn->host->name);
+	mylog(LOG_DEBUG, "reusability check: %s", conn->host->name);
 
 	/* check possibility of reuse connection */
 	for (rmxp = conn->host->mx_ref; rmxp != NULL; rmxp = rmxp->mx_ref)
@@ -3323,7 +3371,7 @@
 			}
 		}
 		if (cnf.debug & DEBUG_CONNECT)
-		log(LOG_DEBUG, "on domain: %s = %d", domp->name, reused);
+		mylog(LOG_DEBUG, "on domain: %s = %d", domp->name, reused);
 
 		if (reused == 0)
 			continue;
@@ -3335,7 +3383,7 @@
 			if (mxp == rmxp)
 			{
 				if (cnf.debug & DEBUG_CONNECT)
-				log(LOG_DEBUG, "%d/%d: may be reused: %s",
+				mylog(LOG_DEBUG, "%d/%d: may be reused: %s",
 					conn->seq, conn->socket,
 					conn->host->name);
 				return 1;
@@ -3361,7 +3409,7 @@
 	{
 		if (errno > 0)
 		{
-			log(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
+			mylog(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
 				conn->seq, conn->socket, conn->host->name,
 				smtpstrerror(errno), STATE(savestate));
 		}
@@ -3453,7 +3501,7 @@
 	{
 		if (errno > 0)
 		{
-			log(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
+			mylog(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
 				conn->seq, conn->socket, conn->host->name,
 				smtpstrerror(errno), STATE(savestate));
 		}
@@ -3528,7 +3576,7 @@
 	{
 		if (errno > 0)
 		{
-			log(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
+			mylog(LOG_INFO, "%d/%d: failed for %s: %s (%s)",
 				conn->seq, conn->socket, conn->host->name,
 				smtpstrerror(errno), STATE(savestate));
 		}
@@ -3588,7 +3636,7 @@
 			markstatus(conn->rcpt, SMTP_TEMPFAIL(52),
 				newstr(buf), 1);
 		else
-			log(LOG_INFO, "Trying next address of %s",
+			mylog(LOG_INFO, "Trying next address of %s",
 			    conn->host->name);
 		if (conn->host->current != NULL) /* XXX for safe access */
 			conn->host->current = conn->host->current->next;
@@ -3614,7 +3662,7 @@
 		{
 			conn->host->state = STAT_CLOSED;
 			conn->host->current->stat = EX_TEMPFAIL;
-			log(LOG_INFO, "Trying next address of %s",
+			mylog(LOG_INFO, "Trying next address of %s",
 			    conn->host->name);
 		}
 		else
@@ -3641,17 +3689,17 @@
 	struct recipient *rcptp;
 	int i;
 
-	log(LOG_INFO, "=== dumping internal information ===");
+	mylog(LOG_INFO, "=== dumping internal information ===");
 
 	for (rcptp = env.rcpt_list; rcptp != NULL; rcptp = rcptp->next)
 	{
 		switch (rcptp->stat)
 		{
 		    case RCPT_NOOP:
-			log(LOG_INFO, "rcpt=%s stat=noop", rcptp->address);
+			mylog(LOG_INFO, "rcpt=%s stat=noop", rcptp->address);
 			break;
 		    case RCPT_WORK:
-			log(LOG_INFO, "rcpt=%s stat=working mx=%s st=%s",
+			mylog(LOG_INFO, "rcpt=%s stat=working mx=%s st=%s",
 				rcptp->address,
 				(rcptp->domain->curmx == NULL)?"none":
 				rcptp->domain->curmx->name,
@@ -3660,18 +3708,18 @@
 			break;
 		    case RCPT_RETRY:
 			if (rcptp->domain->curmx != NULL)
-				log(LOG_INFO,
+				mylog(LOG_INFO,
 				    "rcpt=%s stat=retry code=%d mx=%s st=%s",
 				    rcptp->address, rcptp->result,
 				    rcptp->domain->curmx->name,
 				    STATE(rcptp->domain->curmx->host->state));
 			else
-				log(LOG_INFO,
+				mylog(LOG_INFO,
 					"rcpt=%s stat=retry code=%d mx=none",
 					rcptp->address, rcptp->result);
 			break;
 		    case RCPT_DONE:
-			log(LOG_INFO, "rcpt=%s stat=done code=%d",
+			mylog(LOG_INFO, "rcpt=%s stat=done code=%d",
 				rcptp->address, rcptp->result);
 			break;
 		}
@@ -3681,12 +3729,12 @@
 	{
 		if (connwork[i].host == NULL)
 			continue;
-		log(LOG_INFO, "slot=%d host=%s stat=%s", i,
+		mylog(LOG_INFO, "slot=%d host=%s stat=%s", i,
 			connwork[i].host->name,
 			STATE(connwork[i].host->state));
 	}
 
-	log(LOG_INFO, "=== end of internal information ===");
+	mylog(LOG_INFO, "=== end of internal information ===");
 }
 
 static char *
$NetBSD$

--- util.c.orig	2002-01-20 23:19:44.000000000 +0900
+++ util.c
@@ -41,6 +41,11 @@
 # include "common.h"
 # include "extern.h"
 
+static void tv_sub P((struct timeval *, struct timeval *, struct timeval *));
+static int hash_func P((char *));
+struct dns_stat *hash_query_lookup P((char *, struct dns_stat ***));
+static void hash_map_enter P((char *, struct host_map *));
+
 char *
 newstr(str)
 char *str;
@@ -49,7 +54,7 @@
 
 	ptr = (char *)MALLOC(strlen(str) + 1);
 	if (ptr == NULL) {
-		log(LOG_NOTICE, "out of memory (newstr)");
+		mylog(LOG_NOTICE, "out of memory (newstr)");
 		return NULL;
 	}
 	strcpy(ptr, str);
@@ -109,7 +114,7 @@
 	tv_sub(&ct, &pt, &dt);
 	d.ru_maxrss = c.ru_maxrss - p.ru_maxrss;
 	d.ru_nivcsw = c.ru_nivcsw - p.ru_nivcsw;
-	log(LOG_INFO, "time=%d.%03d+%d.%03d/%d.%03d rss=%ld nivcsw=%ld (%s)",
+	mylog(LOG_INFO, "time=%d.%03d+%d.%03d/%d.%03d rss=%ld nivcsw=%ld (%s)",
 		d.ru_utime.tv_sec, d.ru_utime.tv_usec/1000,
 		d.ru_stime.tv_sec, d.ru_stime.tv_usec/1000,
 		dt.tv_sec, dt.tv_usec/1000,
@@ -139,7 +144,7 @@
 	}
 
 	if (cnf.debug & DEBUG_HASH)
-	log(LOG_DEBUG, "hash_func(%s) = %d", name, val);
+	mylog(LOG_DEBUG, "hash_func(%s) = %d", name, val);
 
 	return val;
 }
@@ -165,7 +170,7 @@
                 if (strcasecmp(qp->name, name) == 0)
 		{
 			if (cnf.debug & DEBUG_HASH)
-			log(LOG_DEBUG, "query %s found in hash table", name);
+			mylog(LOG_DEBUG, "query %s found in hash table", name);
                         return qp;
 		}
                 qp = qp->next;
@@ -194,7 +199,7 @@
                 if (strcasecmp(domp->name, name) == 0)
 		{
 			if (cnf.debug & DEBUG_HASH)
-			log(LOG_DEBUG, "domain %s found in hash table", name);
+			mylog(LOG_DEBUG, "domain %s found in hash table", name);
                         return domp;
 		}
                 domp = domp->hash;
@@ -211,7 +216,7 @@
 	int idx = hash_func(name);
 
 	if (cnf.debug & DEBUG_HASH)
-	log(LOG_DEBUG, "enter domain %s into hash table", name);
+	mylog(LOG_DEBUG, "enter domain %s into hash table", name);
 
 	newdomp->hash = hash_domain[idx];
 	hash_domain[idx] = newdomp;
@@ -228,21 +233,21 @@
 	int idx = hash_func(name);
 
 	if (cnf.debug & DEBUG_HASH)
-	log(LOG_DEBUG, "look up domain(%s) index(%d)", name, idx);
+	mylog(LOG_DEBUG, "look up domain(%s) index(%d)", name, idx);
 	dom_r_p = hash_domain_rcpts[idx];
 	while (dom_r_p != NULL)
 	{
 		if (strcasecmp(dom_r_p->name, name) == 0)
 		{
 			if (cnf.debug & DEBUG_HASH)
-			log(LOG_DEBUG, "hit domain(%s) rcpts(%d) in hash table",
+			mylog(LOG_DEBUG, "hit domain(%s) rcpts(%d) in hash table",
 				name, dom_r_p->rcpts);
 			return dom_r_p->rcpts;
 		}
 		dom_r_p = dom_r_p->hash;
 	}
 	if (cnf.debug & DEBUG_HASH)
-	log(LOG_DEBUG, "domain(%s) not found in hash table, return %d",
+	mylog(LOG_DEBUG, "domain(%s) not found in hash table, return %d",
 		name, cnf.rcpts_trans);
 	return cnf.rcpts_trans;
 }
@@ -255,7 +260,7 @@
 	int idx = hash_func(name);
 
 	if (cnf.debug & DEBUG_HASH)
-	log(LOG_DEBUG, "enter domain(%s) index(%d) rcpts(%d) into hash table",
+	mylog(LOG_DEBUG, "enter domain(%s) index(%d) rcpts(%d) into hash table",
 		name, idx, newdom_r_p->rcpts);
 
 	newdom_r_p->hash = hash_domain_rcpts[idx];
@@ -290,7 +295,7 @@
 	fp = fopen(cnf.rcpts_def, "r");
 	if (fp == NULL)
 	{
-		log(LOG_NOTICE, "file %s not found", cnf.rcpts_def);
+		mylog(LOG_NOTICE, "file %s not found", cnf.rcpts_def);
 		return -1;
 	}
 	/* read cnf.rcpts_def */
@@ -337,7 +342,7 @@
 			dom_r_p = (struct domain_rcpts*) MALLOC(sizeof(struct domain_rcpts));
 			if (dom_r_p == NULL)
 			{
-				log(LOG_NOTICE, "out of memory (domain_rcpts)");
+				mylog(LOG_NOTICE, "out of memory (domain_rcpts)");
 				fclose(fp);
 				return -1;
 			}
@@ -345,7 +350,7 @@
 			dom_r_p->name  = newstr(strp);
 			if(dom_r_p->name == NULL)
 			{
-				log(LOG_NOTICE, "out of memory (dom_r_p->name)");
+				mylog(LOG_NOTICE, "out of memory (dom_r_p->name)");
 				fclose(fp);
 				return -1;
 			}
@@ -356,7 +361,7 @@
 	fclose(fp);
 	cnf.rcpts_trans = hash_domain_rcpts_lookup(DEFAULTRCPTS);
 	if (cnf.debug & DEBUG_TRANS)
-	log(LOG_DEBUG, "set cnf.rcpts_trans = %d", cnf.rcpts_trans);
+	mylog(LOG_DEBUG, "set cnf.rcpts_trans = %d", cnf.rcpts_trans);
 	return 0;
 }
 
@@ -381,7 +386,7 @@
                 if (strcasecmp(hostp->name, name) == 0)
 		{
 			if (cnf.debug & DEBUG_HASH)
-			log(LOG_DEBUG, "host %s found in hash table", name);
+			mylog(LOG_DEBUG, "host %s found in hash table", name);
                         return hostp;
 		}
                 hostp = hostp->hash;
@@ -398,7 +403,7 @@
 	int idx = hash_func(name);
 
 	if (cnf.debug & DEBUG_HASH)
-	log(LOG_DEBUG, "enter host %s into hash table", name);
+	mylog(LOG_DEBUG, "enter host %s into hash table", name);
 
 	newhostp->hash = hash_host[idx];
 	hash_host[idx] = newhostp;
@@ -426,7 +431,7 @@
                 if (strcasecmp(mapp->name, name) == 0)
 		{
 			if (cnf.debug & DEBUG_HASH)
-			log(LOG_DEBUG, "map %s found in hash table", name);
+			mylog(LOG_DEBUG, "map %s found in hash table", name);
                         return mapp;
 		}
                 mapp = mapp->hash;
@@ -434,7 +439,7 @@
 	return NULL;
 }
 
-void
+static void
 hash_map_enter(name, newmapp)
 char *name;
 struct host_map *newmapp;
@@ -442,7 +447,7 @@
 	int idx = hash_func(name);
 
 	if (cnf.debug & DEBUG_HASH)
-	log(LOG_DEBUG, "enter map %s into hash table", name);
+	mylog(LOG_DEBUG, "enter map %s into hash table", name);
 
 	newmapp->hash = hash_map[idx];
 	hash_map[idx] = newmapp;
@@ -462,7 +467,7 @@
 	fp = fopen(cnf.map, "r");
 	if (fp == NULL)
 	{
-		log(LOG_NOTICE, "map %s not found", cnf.map);
+		mylog(LOG_NOTICE, "map %s not found", cnf.map);
 		return -1;	/* should be TEMPFAIL */
 	}
 	while (fgets(buf, sizeof(buf), fp) != NULL)
@@ -580,7 +585,7 @@
 				}
 				argp++;
 			}
-			log(LOG_DEBUG, "reading map: domain = %s, map = %s",
+			mylog(LOG_DEBUG, "reading map: domain = %s, map = %s",
 				mapp->name, tmpbuf);
 		}
 	}
@@ -604,7 +609,7 @@
 	while (p != NULL)
 	{
 		if (cnf.debug & DEBUG_MAP)
-		log(LOG_DEBUG, "searching host map for %s: %s", domain, p);
+		mylog(LOG_DEBUG, "searching host map for %s: %s", domain, p);
 
 		if ((mapp = hash_map_lookup(p, NULL)) != NULL)
 		{