return strstr(haystack, needle);
}
-static inline const char* strempty(const char *s) {
- return s ?: "";
-}
-
static inline const char* strnull(const char *s) {
return s ?: "(null)";
}
bool string_is_safe(const char *p) _pure_;
-static inline size_t strlen_ptr(const char *s) {
- if (!s)
- return 0;
-
- return strlen(s);
-}
-
DISABLE_WARNING_STRINGOP_TRUNCATION;
static inline void strncpy_exact(char *buf, const char *src, size_t buf_len) {
strncpy(buf, src, buf_len);
bool strv_overlap(char * const *a, char * const *b) _pure_;
-#define _STRV_FOREACH(s, l, i) \
- for (typeof(*(l)) *s, *i = (l); (s = i) && *i; i++)
-
-#define STRV_FOREACH(s, l) \
- _STRV_FOREACH(s, l, UNIQ_T(i, UNIQ))
-
#define _STRV_FOREACH_BACKWARDS(s, l, h, i) \
for (typeof(*(l)) *s, *h = (l), *i = ({ \
size_t _len = strv_length(h); \
return strcasecmp_ptr(a, b) == 0;
}
+static inline size_t strlen_ptr(const sd_char *s) {
+ if (!s)
+ return 0;
+
+ return strlen(s);
+}
+
sd_char *startswith(const sd_char *s, const sd_char *prefix) _pure_;
#ifndef SD_BOOT
sd_char *startswith_no_case(const sd_char *s, const sd_char *prefix) _pure_;
return !a || a[0] == '\0';
}
+static inline const sd_char *strempty(const sd_char *s) {
+ return s ?: STR_C("");
+}
+
static inline const sd_char *yes_no(sd_bool b) {
return b ? STR_C("yes") : STR_C("no");
}
return (uint8_t*) p + n;
}
+
+#define _STRV_FOREACH(s, l, i) \
+ for (typeof(*(l)) *s, *i = (l); (s = i) && *i; i++)
+
+#define STRV_FOREACH(s, l) \
+ _STRV_FOREACH(s, l, UNIQ_T(i, UNIQ))