[SeaBIOS] [PATCH 3/9] Add strchr() function.

Gleb Natapov gleb at redhat.com
Thu Dec 23 10:29:37 CET 2010


Signed-off-by: Gleb Natapov <gleb at redhat.com>
---
 src/util.c |   11 +++++++++++
 src/util.h |    1 +
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/util.c b/src/util.c
index f9a7533..3892c3c 100644
--- a/src/util.c
+++ b/src/util.c
@@ -262,6 +262,17 @@ strtcpy(char *dest, const char *src, size_t len)
     return dest;
 }
 
+// locate first occurance of character c in the string s
+char *
+strchr(const char *s, int c)
+{
+    int i = 0;
+
+    while(s[i] && s[i] != c)
+        i++;
+
+    return s[i] ? (char*)&s[i] : NULL;
+}
 
 /****************************************************************
  * Keyboard calls
diff --git a/src/util.h b/src/util.h
index fa7b20f..f5b9446 100644
--- a/src/util.h
+++ b/src/util.h
@@ -209,6 +209,7 @@ void *memcpy(void *d1, const void *s1, size_t len);
 void iomemcpy(void *d, const void *s, u32 len);
 void *memmove(void *d, const void *s, size_t len);
 char *strtcpy(char *dest, const char *src, size_t len);
+char *strchr(const char *s, int c);
 int get_keystroke(int msec);
 
 // stacks.c
-- 
1.7.2.3




More information about the SeaBIOS mailing list