diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-12-10 11:48:01 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-12-10 11:48:01 +0000 |
commit | b8d0f83e6cea9640a7ee4402c163ad812237355d (patch) | |
tree | 57a64ac8aa0e98c40db8c36e96e7379490e44dbf /src/common/shibari_util_get_prefixlen.c | |
download | shibari-b8d0f83e6cea9640a7ee4402c163ad812237355d.tar.xz |
Initial commit
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/common/shibari_util_get_prefixlen.c')
-rw-r--r-- | src/common/shibari_util_get_prefixlen.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/common/shibari_util_get_prefixlen.c b/src/common/shibari_util_get_prefixlen.c new file mode 100644 index 0000000..784a3ee --- /dev/null +++ b/src/common/shibari_util_get_prefixlen.c @@ -0,0 +1,14 @@ +/* ISC license. */ + +#include <stdint.h> +#include <string.h> + +#include <shibari/util.h> + +int shibari_util_get_prefixlen (char const *name, uint16_t namelen, char const *zone, uint16_t zonelen) +{ + return + namelen < zonelen ? -1 : + memcmp(name + namelen - zonelen, zone, zonelen) ? -1 : + namelen - zonelen ; +} |