2013-09-26 17:14:40 +02:00

213 lines
6.1 KiB
Plaintext

$NetBSD: patch-am,v 1.1 2006/07/23 15:00:41 taca Exp $
--- 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)
{