summaryrefslogtreecommitdiff
path: root/src/basic/string-util.h
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-02-04 03:21:08 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-02-09 14:22:54 +0900
commite5bc5f1f5ac3595bfbe77d4896d6b7b22a0310a8 (patch)
treeebf3a88d73ad0a49008c9a441a58ad387702e900 /src/basic/string-util.h
parent5f33b2300b1ce7749a686dd1699ea0818b45857c (diff)
downloadsystemd-e5bc5f1f5ac3595bfbe77d4896d6b7b22a0310a8.tar.gz
fundamental: move several macros and functions into src/fundamental/
sd-boot has a copy of a subset of codes from libbasic. This makes sd-boot share the code with libbasic, and dedup the code. Note, startswith_no_case() is dropped from sd-boot, as - it is not used, - the previous implementation is not correct, - gnu-efi does not have StrniCmp() or so.
Diffstat (limited to 'src/basic/string-util.h')
-rw-r--r--src/basic/string-util.h48
1 files changed, 1 insertions, 47 deletions
diff --git a/src/basic/string-util.h b/src/basic/string-util.h
index 3ff21e42a4..cb2881b64d 100644
--- a/src/basic/string-util.h
+++ b/src/basic/string-util.h
@@ -7,6 +7,7 @@
#include "alloc-util.h"
#include "macro.h"
+#include "string-util-fundamental.h"
/* What is interpreted as whitespace? */
#define WHITESPACE " \t\n\r"
@@ -21,22 +22,6 @@
#define ALPHANUMERICAL LETTERS DIGITS
#define HEXDIGITS DIGITS "abcdefABCDEF"
-#define streq(a,b) (strcmp((a),(b)) == 0)
-#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)
-#define strcaseeq(a,b) (strcasecmp((a),(b)) == 0)
-#define strncaseeq(a, b, n) (strncasecmp((a), (b), (n)) == 0)
-
-int strcmp_ptr(const char *a, const char *b) _pure_;
-int strcasecmp_ptr(const char *a, const char *b) _pure_;
-
-static inline bool streq_ptr(const char *a, const char *b) {
- return strcmp_ptr(a, b) == 0;
-}
-
-static inline bool strcaseeq_ptr(const char *a, const char *b) {
- return strcasecmp_ptr(a, b) == 0;
-}
-
static inline char* strstr_ptr(const char *haystack, const char *needle) {
if (!haystack || !needle)
return NULL;
@@ -55,10 +40,6 @@ static inline const char *strna(const char *s) {
return s ?: "n/a";
}
-static inline const char* yes_no(bool b) {
- return b ? "yes" : "no";
-}
-
static inline const char* true_false(bool b) {
return b ? "true" : "false";
}
@@ -75,10 +56,6 @@ static inline const char* enable_disable(bool b) {
return b ? "enable" : "disable";
}
-static inline bool isempty(const char *p) {
- return !p || !p[0];
-}
-
static inline const char *empty_to_null(const char *p) {
return isempty(p) ? NULL : p;
}
@@ -97,29 +74,6 @@ static inline const char *empty_or_dash_to_null(const char *p) {
return empty_or_dash(p) ? NULL : p;
}
-static inline char *startswith(const char *s, const char *prefix) {
- size_t l;
-
- l = strlen(prefix);
- if (strncmp(s, prefix, l) == 0)
- return (char*) s + l;
-
- return NULL;
-}
-
-static inline char *startswith_no_case(const char *s, const char *prefix) {
- size_t l;
-
- l = strlen(prefix);
- if (strncasecmp(s, prefix, l) == 0)
- return (char*) s + l;
-
- return NULL;
-}
-
-char *endswith(const char *s, const char *postfix) _pure_;
-char *endswith_no_case(const char *s, const char *postfix) _pure_;
-
char *first_word(const char *s, const char *word) _pure_;
char *strnappend(const char *s, const char *suffix, size_t length);