]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
elf: Add the endswith function to <endswith.h>
authorFlorian Weimer <fweimer@redhat.com>
Fri, 29 Nov 2024 14:36:40 +0000 (15:36 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 20 Dec 2024 15:15:53 +0000 (16:15 +0100)
And include <stdbool.h> for a definition of bool.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
elf/endswith.h

index c6430c48be0c1071dcf0f666493900d93cfd6625..3954e57f8eff0faace218da96af27d17d2a16dba 100644 (file)
@@ -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 */