mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-04 17:47:03 +03:00
add first_word() call
This commit is contained in:
parent
1dccbe197c
commit
79d6d81608
19
util.c
19
util.c
@ -88,6 +88,25 @@ bool startswith(const char *s, const char *prefix) {
|
||||
return memcmp(s, prefix, pl) == 0;
|
||||
}
|
||||
|
||||
bool first_word(const char *s, const char *word) {
|
||||
size_t sl, wl;
|
||||
|
||||
assert(s);
|
||||
assert(word);
|
||||
|
||||
sl = strlen(s);
|
||||
wl = strlen(word);
|
||||
|
||||
if (sl < wl)
|
||||
return false;
|
||||
|
||||
if (memcmp(s, word, wl) != 0)
|
||||
return false;
|
||||
|
||||
return (s[wl] == 0 ||
|
||||
strchr(WHITESPACE, s[wl]));
|
||||
}
|
||||
|
||||
int close_nointr(int fd) {
|
||||
assert(fd >= 0);
|
||||
|
||||
|
2
util.h
2
util.h
@ -60,6 +60,8 @@ static inline bool is_path_absolute(const char *p) {
|
||||
bool endswith(const char *s, const char *postfix);
|
||||
bool startswith(const char *s, const char *prefix);
|
||||
|
||||
bool first_word(const char *s, const char *word);
|
||||
|
||||
int close_nointr(int fd);
|
||||
void close_nointr_nofail(int fd);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user