aboutsummaryrefslogtreecommitdiff
path: root/hosts_cache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'hosts_cache.cpp')
-rw-r--r--hosts_cache.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/hosts_cache.cpp b/hosts_cache.cpp
index 9c0f0a0c..5a759698 100644
--- a/hosts_cache.cpp
+++ b/hosts_cache.cpp
@@ -122,7 +122,7 @@ static int cmp_hcent_name(const void *a, const void *b)
return hstrcmp(na, nb);
}
-static struct hcent *_hcfindname(const char *name)
+static struct hcent *_hcfindname_exact(const char *name)
{
size_t first, last, mid;
struct hcent *cur = NULL;
@@ -163,6 +163,33 @@ found:
return cur;
}
+static struct hcent *_hcfindname(const char *name)
+{
+ struct hcent *ent;
+ char namebuf[MAX_HOSTLEN];
+ char *p;
+ char *dot;
+
+ ent = _hcfindname_exact(name);
+ if (!ent && strlen(name) < sizeof(namebuf)) {
+ strlcpy(namebuf, name, sizeof(namebuf));
+ p = namebuf;
+ do {
+ dot = strchr(p, '.');
+ if (!dot)
+ break;
+ if (dot > p) {
+ *(dot - 1) = '*';
+ ent = _hcfindname_exact(dot - 1);
+ }
+ p = dot + 1;
+ }
+ while (!ent);
+ }
+
+ return ent;
+}
+
/*
* Find next name on line, if any.
*