diff options
author | Thomas Haller <thaller@redhat.com> | 2020-05-06 08:21:49 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-05-06 08:21:56 +0200 |
commit | 4ea602a3b20750c7f4e81772faee39fb3ca88a6a (patch) | |
tree | 8fb5b2ec90ed8ac7530667d2664580f2470f448e | |
parent | 7f3e27a4a36beb722abe8ebfb631e19a7e855ebe (diff) | |
download | NetworkManager-4ea602a3b20750c7f4e81772faee39fb3ca88a6a.tar.gz |
shared: add NM_STR_HAS_PREFIX_WITH_MORE() helper
-rw-r--r-- | shared/nm-glib-aux/nm-macros-internal.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/shared/nm-glib-aux/nm-macros-internal.h b/shared/nm-glib-aux/nm-macros-internal.h index 6b7285e470..8c0aa21820 100644 --- a/shared/nm-glib-aux/nm-macros-internal.h +++ b/shared/nm-glib-aux/nm-macros-internal.h @@ -951,6 +951,16 @@ nm_streq0 (const char *s1, const char *s2) NM_STRLEN (suffix)) == 0)); \ }) +/* whether @str starts with the string literal @prefix and is followed by + * some other text. It is like NM_STR_HAS_PREFIX() && !nm_streq() together. */ +#define NM_STR_HAS_PREFIX_WITH_MORE(str, prefix) \ + ({ \ + const char *const _str_has_prefix_with_more = (str); \ + \ + NM_STR_HAS_PREFIX (_str_has_prefix_with_more, ""prefix"") \ + && _str_has_prefix_with_more[NM_STRLEN (prefix)] != '\0'; \ + }) + /*****************************************************************************/ static inline GString * |