summaryrefslogtreecommitdiff
path: root/usr.sbin/hoststated/hoststated.c
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2006-12-16 18:50:34 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2006-12-16 18:50:34 +0000
commit19d82ea2d7751a0b7ec8fa66d2a2053a369f0403 (patch)
treed91fc3a03e096ac77beaf625f8687d85b92e7b05 /usr.sbin/hoststated/hoststated.c
parenteb9e468ffdd8750ab38d6914ccb20acb388e2102 (diff)
- allow to use host/service/table names instead of Ids in hostatectl.
- minor change of the "hostatectl show" command output - increase the max service and tag names (max pf tag name size is 64 now!) thanks to pyr who found a bug in my initial diff
Diffstat (limited to 'usr.sbin/hoststated/hoststated.c')
-rw-r--r--usr.sbin/hoststated/hoststated.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/usr.sbin/hoststated/hoststated.c b/usr.sbin/hoststated/hoststated.c
index cd593ef6873..223eb1eadad 100644
--- a/usr.sbin/hoststated/hoststated.c
+++ b/usr.sbin/hoststated/hoststated.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hoststated.c,v 1.3 2006/12/16 14:07:29 reyk Exp $ */
+/* $OpenBSD: hoststated.c,v 1.4 2006/12/16 18:50:33 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -374,3 +374,38 @@ service_find(struct hostated *env, objid_t id)
return (service);
return (NULL);
}
+
+struct host *
+host_findbyname(struct hostated *env, const char *name)
+{
+ struct table *table;
+ struct host *host;
+
+ TAILQ_FOREACH(table, &env->tables, entry)
+ TAILQ_FOREACH(host, &table->hosts, entry)
+ if (strcmp(host->name, name) == 0)
+ return (host);
+ return (NULL);
+}
+
+struct table *
+table_findbyname(struct hostated *env, const char *name)
+{
+ struct table *table;
+
+ TAILQ_FOREACH(table, &env->tables, entry)
+ if (strcmp(table->name, name) == 0)
+ return (table);
+ return (NULL);
+}
+
+struct service *
+service_findbyname(struct hostated *env, const char *name)
+{
+ struct service *service;
+
+ TAILQ_FOREACH(service, &env->services, entry)
+ if (strcmp(service->name, name) == 0)
+ return (service);
+ return (NULL);
+}