From 0b1d5fa90eabd98e3d69734ce1cdcef949d3fb30 Mon Sep 17 00:00:00 2001 From: Florian Lohoff Date: Sat, 4 Oct 2008 12:08:33 +0000 Subject: Add strcat and memmove for newer libext2fs --- arclib/string.c | 27 ++++++++++++++++++++++++++- arclib/string.h | 3 +++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/arclib/string.c b/arclib/string.c index 6ff3cfb..1c424c0 100644 --- a/arclib/string.c +++ b/arclib/string.c @@ -2,11 +2,21 @@ * Copyright 1999, 2001 Silicon Graphics, Inc. * Copyright 2001 Ralf Baechle * 2001 Guido Guenther + * 2008 Florian Lohoff */ #include "string.h" - #include "stdlib.h" +char *strcat(char *d, char *s) { + char *a; + + for(a=d;*a;a++); + for(;*s;*a++=*s++); + *a=0x0; + + return d; +} + size_t strlen(const char *s) { size_t len = 0; @@ -110,6 +120,21 @@ void *memcpy(void *s1, const void *s2, size_t n) return s1; } +void *memmove(void *s1, const void *s2, size_t n) +{ + char *c1 = (char *) s1; + const char *c2 = (const char *) s2; + + if (s1 < s2) + return memcpy(s1, s2, n); + + c1+=n; + c2+=n; + + while (n-- > 0) + *(--c1) = *(--c2); + return s1; +} void *memset(void *s, int c, size_t n) { diff --git a/arclib/string.h b/arclib/string.h index 53bf111..04cf123 100644 --- a/arclib/string.h +++ b/arclib/string.h @@ -1,6 +1,7 @@ /* * Copyright 1999 Silicon Graphics, Inc. * 2001 Guido Guenther + * 2008 Florian Lohoff */ #ifndef _STRING_H_ #define _STRING_H_ @@ -9,6 +10,7 @@ extern size_t strlen(const char *s); extern int strcmp(const char *s1,const char *s2); +extern char *strcat(char *d, char *s); extern int strncmp(const char *s1, const char *s2, size_t n); extern char *strchr(const char *s, int c); extern char *strcpy(char *s1, const char *s2); @@ -16,6 +18,7 @@ extern char *strncpy(char *s1, const char *s2, size_t n); extern char *strdup(const char *s1); extern void *memcpy(void *s1, const void *s2, size_t n); +extern void *memmove(void *s1, const void *s2, size_t n); extern void *memset(void *s, int c, size_t n); int memcmp(const void * cs,const void * ct,size_t count); extern void __bzero(char *p, int len); -- cgit v1.2.3