summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2010-12-24 10:39:32 -0500
committerKevin O'Connor <kevin@koconnor.net>2010-12-24 10:39:32 -0500
commit2e109a692553f4c198f3bf755391ccdc3bc1e68a (patch)
tree7a48586b1240eec1c498c9f50b4f4be279d67809
parent1703ea21a4c774bd1888133f77e68f26dc9f941c (diff)
Add strchr() function.
-rw-r--r--src/util.c9
-rw-r--r--src/util.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index f9a7533..579a044 100644
--- a/src/util.c
+++ b/src/util.c
@@ -262,6 +262,15 @@ 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)
+{
+ for (; *s; s++)
+ if (*s == c)
+ return (char*)s;
+ return 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