Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/25447
Change subject: include/string: Add strrchr
......................................................................
include/string: Add strrchr
Copy strrchr from libpayload.
To be used by Cavium's BDK or FDT parsers.
Change-Id: Iab7981c25113ed16f1b8130de4935d30c29d2fa5
Signed-off-by: Patrick Rudolph <patrick.rudolph(a)9elements.com>
---
M src/include/string.h
1 file changed, 20 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/47/25447/1
diff --git a/src/include/string.h b/src/include/string.h
index 7597323..d2d7bb8 100644
--- a/src/include/string.h
+++ b/src/include/string.h
@@ -66,6 +66,26 @@
}
#endif
+/**
+ * Find a character in a string.
+ *
+ * @param s The string.
+ * @param c The character.
+ * @return A pointer to the last occurrence of the character in the
+ * string, or NULL if the character was not encountered within the string.
+ */
+static inline char *strrchr(const char *s, int c)
+{
+ char *p = (char *)s + strlen(s);
+
+ for (; p >= s; p--) {
+ if (*p == c)
+ return p;
+ }
+
+ return NULL;
+}
+
static inline char *strncpy(char *to, const char *from, int count)
{
register char *ret = to;
--
To view, visit https://review.coreboot.org/25447
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iab7981c25113ed16f1b8130de4935d30c29d2fa5
Gerrit-Change-Number: 25447
Gerrit-PatchSet: 1
Gerrit-Owner: Patrick Rudolph <patrick.rudolph(a)9elements.com>