From f460facdca9995e32d1c69f84945a306c6063a40 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Wed, 19 Jun 2013 12:24:40 +0200 Subject: utils: Add helper function to check a string for a given prefix --- src/libstrongswan/utils/utils.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/libstrongswan/utils/utils.h b/src/libstrongswan/utils/utils.h index 081852cd9..0e103de9c 100644 --- a/src/libstrongswan/utils/utils.h +++ b/src/libstrongswan/utils/utils.h @@ -88,6 +88,14 @@ static inline bool strneq(const char *x, const char *y, size_t len) return strncmp(x, y, len) == 0; } +/** + * Helper function that checks if a string starts with a given prefix + */ +static inline bool strpfx(const char *x, const char *prefix) +{ + return strneq(x, prefix, strlen(prefix)); +} + /** * Helper function that compares two strings for equality ignoring case */ -- cgit v1.2.3