diff options
author | 2016-05-19 09:15:28 +0000 | |
---|---|---|
committer | 2016-05-19 09:15:28 +0000 | |
commit | eed8df8e882917ed3a0e6d9158e083b7e32b4e7e (patch) | |
tree | fbacbf6baa6eda1549f0d36da758a5c15df95489 | |
parent | table formats are described in table(5) not makemap(8) (diff) | |
download | wireguard-openbsd-eed8df8e882917ed3a0e6d9158e083b7e32b4e7e.tar.xz wireguard-openbsd-eed8df8e882917ed3a0e6d9158e083b7e32b4e7e.zip |
Implement OF_is_compatible(9).
-rw-r--r-- | sys/arch/sparc64/sparc64/openfirm.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/sys/arch/sparc64/sparc64/openfirm.c b/sys/arch/sparc64/sparc64/openfirm.c index 3c7561e88d8..3331354188a 100644 --- a/sys/arch/sparc64/sparc64/openfirm.c +++ b/sys/arch/sparc64/sparc64/openfirm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openfirm.c,v 1.18 2016/03/19 11:34:22 mpi Exp $ */ +/* $OpenBSD: openfirm.c,v 1.19 2016/05/19 09:15:28 kettenis Exp $ */ /* $NetBSD: openfirm.c,v 1.13 2001/06/21 00:08:02 eeh Exp $ */ /* @@ -839,3 +839,28 @@ void OF_val2sym(cells) } #endif + +int +OF_is_compatible(int handle, const char *name) +{ + char compat[256]; + char *str; + int len; + + len = OF_getprop(handle, "compatible", &compat, sizeof(compat)); + if (len <= 0) + return 0; + + /* Guarantee that the buffer is null-terminated. */ + compat[sizeof(compat) - 1] = 0; + + str = compat; + while (len > 0) { + if (strcmp(str, name) == 0) + return 1; + len -= strlen(str) + 1; + str += strlen(str) + 1; + } + + return 0; +} |