/* products derived from this software without specific prior written */
/* permission. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND */
-/* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE */
-/* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
-/* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS */
-/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR */
-/* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF */
-/* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS */
-/* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) */
-/* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF */
-/* THE POSSIBILITY OF SUCH DAMAGE. */
+/* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS */
+/* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
+/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
+/* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY */
+/* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL */
+/* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS */
+/* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, */
+/* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/* POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/* Copyright (c) 2006-2008 the Authors */
+/* see AUTHORS and source files for details */
/******************************************************************************/
/*
const char *p, *end;
char line[BUFSIZ];
uint32_t count = 0;
+ time_t now = time(0);
if (!file_map_open(&map, file, false)) {
return false;
--end;
}
if (end != map.end) {
- warn("file %s miss a final \\n, ignoring last line",
- file);
+ warn("%s: final \\n missing, ignoring last line", file);
}
strlist_resource_t *res = resource_get("strlist", file);
res = p_new(strlist_resource_t, 1);
resource_set("strlist", file, res, (resource_destructor_t)strlist_resource_wipe);
} else if (res->trie2 != NULL) {
- err("A file (%s) cannot be used as a rbldns zone file and a strlist file at the same time",
- file);
+ err("%s not loaded: the file is already used as a rbldns zone file", file);
resource_release("strlist", file);
file_map_close(&map);
return false;
local->reverse = reverse;
local->partial = partial;
if (res->size == map.st.st_size && res->mtime == map.st.st_mtime) {
- info("strlist %s up to date", file);
+ info("%s loaded: already up-to-date", file);
file_map_close(&map);
return true;
}
eol = end;
}
if (eol - p >= BUFSIZ) {
- err("unreasonnable long line");
+ err("%s not loaded: unreasonnable long line", file);
file_map_close(&map);
trie_delete(&res->trie1);
strlist_local_wipe(local);
}
file_map_close(&map);
trie_compile(res->trie1, lock);
- info("%s loaded, %u entries", file, count);
+ info("%s loaded: done in %us, %u entries", file, (uint32_t)(time(0) - now), count);
return true;
}
file_map_t map;
const char *p, *end;
char line[BUFSIZ];
+ time_t now = time(0);
if (!file_map_open(&map, file, false)) {
return false;
--end;
}
if (end != map.end) {
- warn("file %s miss a final \\n, ignoring last line",
- file);
+ warn("%s: final \\n missing, ignoring last line", file);
}
res = p_new(strlist_resource_t, 1);
resource_set("strlist", file, res, (resource_destructor_t)strlist_resource_wipe);
} else if (res->trie2 == NULL) {
- err("A file (%s) cannot be used as a rbldns zone file and a strlist file at the same time",
- file);
+ err("%s not loaded: the file is already used as a strlist-file parameter", file);
resource_release("strlist", file);
file_map_close(&map);
return false;
domain_count = 0;
if (map.st.st_size == res->size && map.st.st_mtime == res->mtime) {
- info("rbldns %s up to date", file);
+ info("%s loaded: already up-to-date", file);
file_map_close(&map);
return true;
}
eol = end;
}
if (eol - p >= BUFSIZ) {
- err("unreasonnable long line");
+ err("%s not loaded: unreasonnable long line", file);
file_map_close(&map);
trie_delete(&res->trie1);
trie_delete(&res->trie2);
} else {
trie_delete(&res->trie2);
}
- info("rhbl %s loaded, %u hosts, %u domains", file, host_count, domain_count);
if (res->trie1 == NULL && res->trie2 == NULL) {
+ err("%s not loaded: no data found", file);
strlist_local_wipe(hosts);
return false;
}
+ info("%s loaded: done in %us, %u hosts, %u domains", file,
+ (uint32_t)(time(0) - now), host_count, domain_count);
return true;
}
}
#define LOOKUP(Flag, Field) \
if (config->match_ ## Flag) { \
- const int len = m_strlen(query->Field); \
- strlist_copy(normal, query->Field, len, false); \
- strlist_copy(reverse, query->Field, len, true); \
+ const int len = query->Field.len; \
+ strlist_copy(normal, query->Field.str, len, false); \
+ strlist_copy(reverse, query->Field.str, len, true); \
foreach (strlist_local_t *entry, config->locals) { \
if ((!entry->partial && trie_lookup(*(entry->db), \
entry->reverse ? reverse : normal)) \
}
#define DNS(Flag, Field) \
if (config->match_ ## Flag) { \
- const int len = m_strlen(query->Field); \
- strlist_copy(normal, query->Field, len, false); \
+ const int len = query->Field.len; \
+ strlist_copy(normal, query->Field.str, len, false); \
for (uint32_t i = 0 ; len > 0 && i < config->host_offsets.len ; ++i) { \
const char *rbl = array_ptr(config->hosts, \
array_elt(config->host_offsets, i)); \