Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
c_charv_contains
Baptiste Daroussin committed 1 year ago
commit ec12d11b97efd8df5804d37bb2ef5f4802e9f485
parent 9e8c69a
2 files changed +17 -0
modified libpkg/private/utils.h
@@ -118,5 +118,6 @@ void append_random_suffix(char *buf, int buflen, int suffixlen);
char *json_escape(const char *str);
struct tempdir *open_tempdir(int rootfd, const char *path, stringlist_t *strlist);
const char *get_http_auth(void);
+
bool c_charv_contains(c_charv_t *, const char *, bool);

#endif
modified libpkg/utils.c
@@ -53,6 +53,7 @@
#include <bsd_compat.h>

#include "pkg.h"
+
#include "pkgvec.h"
#include "private/event.h"
#include "private/utils.h"
#include "private/pkg.h"
@@ -1050,3 +1051,18 @@ get_http_auth(void)
	return (str);
}

+
bool
+
c_charv_contains(c_charv_t *v, const char *el, bool casesensitive)
+
{
+
	for (size_t i = 0; i < v->len; i ++) {
+
		if (casesensitive) {
+
			if (STREQ(v->d[i], el))
+
				return (true);
+
		} else {
+
			if (STRIEQ(v->d[i], el)) {
+
				return (true);
+
			}
+
		}
+
	}
+
	return (false);
+
}