aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2024-11-29 15:36:40 +0100
committerFlorian Weimer <fweimer@redhat.com>2024-12-20 16:15:53 +0100
commita20bc2f6233a726c7df8eaa332b6e498bd59321f (patch)
treee5cea43924a1c3b798ec83fe87b5d70f2e065286
parent4a50fdf8b2c1106b50cd9056b4c6f3a72cdeed5f (diff)
downloadglibc-a20bc2f6233a726c7df8eaa332b6e498bd59321f.zip
glibc-a20bc2f6233a726c7df8eaa332b6e498bd59321f.tar.gz
glibc-a20bc2f6233a726c7df8eaa332b6e498bd59321f.tar.bz2
elf: Add the endswith function to <endswith.h>
And include <stdbool.h> for a definition of bool. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
-rw-r--r--elf/endswith.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/elf/endswith.h b/elf/endswith.h
index c6430c4..3954e57 100644
--- a/elf/endswith.h
+++ b/elf/endswith.h
@@ -17,6 +17,7 @@
#ifndef _ENDSWITH_H
#define _ENDSWITH_H
+#include <stdbool.h>
#include <string.h>
/* Return true if the N bytes at NAME end with with the characters in
@@ -30,4 +31,11 @@ endswithn (const char *name, size_t n, const char *suffix)
strlen (suffix)) == 0);
}
+/* Same as endswithn, but uses the entire SUBJECT for matching. */
+static inline bool
+endswith (const char *subject, const char *suffix)
+{
+ return endswithn (subject, strlen (subject), suffix);
+}
+
#endif /* _ENDSWITH_H */