summaryrefslogtreecommitdiff
path: root/src/library/std/string.c
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2010-04-07 11:37:21 +0200
committerAlexis211 <alexis211@gmail.com>2010-04-07 11:37:21 +0200
commitee348973b0cb0f6481e4fd6e7494c63167c9759c (patch)
treea9f1cd82703aaeeefbf4cf449203881cfcafc0a5 /src/library/std/string.c
parentca4f5906f284e60a7a59ca7450e3e09c4f9356e5 (diff)
downloadTCE-ee348973b0cb0f6481e4fd6e7494c63167c9759c.tar.gz
TCE-ee348973b0cb0f6481e4fd6e7494c63167c9759c.zip
More work on manager
Diffstat (limited to 'src/library/std/string.c')
-rw-r--r--src/library/std/string.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/library/std/string.c b/src/library/std/string.c
index 869256a..4c374ad 100644
--- a/src/library/std/string.c
+++ b/src/library/std/string.c
@@ -6,6 +6,46 @@ int strlen(const char *str) {
return i;
}
+char *strchr(const char *str, char c) {
+ while (*str) {
+ if (*str == c) return (char*)str;
+ str++;
+ }
+ return NULL;
+}
+
+char *strcpy(char *dest, const char *src) {
+ memcpy(dest, src, strlen(src) + 1);
+ return (char*)src;
+}
+
+char *strdup(const char *src) {
+ char* ret = malloc(strlen(src) + 1);
+ if (ret == NULL) return ret;
+ strcpy(ret, src);
+ return ret;
+}
+
+char *strcat(char *dest, const char *src) {
+ char *dest2 = dest;
+ dest2 += strlen(dest) - 1;
+ while (*src) {
+ *dest2 = *src;
+ src++;
+ dest2++;
+ }
+ *dest2 = 0;
+ return dest;
+}
+
+int strcmp(const char *s1, const char *s2) {
+ while ((*s1) && (*s1 == *s2)) {
+ s1++;
+ s2++;
+ }
+ return (* (unsigned char*)s1 - *(unsigned char*)s2);
+}
+
void *memcpy(void *vd, const void *vs, int count) {
uint8_t *dest = (uint8_t*)vd, *src = (uint8_t*)vs;
uint32_t f = count % 4, n = count / 4, i;