X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/9ab7a6c75566a2d06e56a8a97173c6382a3c5b3d..dc873169cfaa03aaec2637c0cc8f4a70907d856d:/armsrc/string.c diff --git a/armsrc/string.c b/armsrc/string.c index a3d3c049..acb5a460 100644 --- a/armsrc/string.c +++ b/armsrc/string.c @@ -1,8 +1,15 @@ -/* Implementations of the common string.h functions */ +//----------------------------------------------------------------------------- +// Jonathan Westhues, Sept 2005 +// +// This code is licensed to you under the terms of the GNU GPL, version 2 or, +// at your option, any later version. See the LICENSE.txt file for the text of +// the license. +//----------------------------------------------------------------------------- +// Common string.h functions +//----------------------------------------------------------------------------- #include "string.h" -#include -void *memcpy(void *dest, const void *src, int len) +RAMFUNC void *memcpy(void *dest, const void *src, int len) { uint8_t *d = dest; const uint8_t *s = src; @@ -24,7 +31,7 @@ void *memset(void *dest, int c, int len) return dest; } -int memcmp(const void *av, const void *bv, int len) +RAMFUNC int memcmp(const void *av, const void *bv, int len) { const uint8_t *a = av; const uint8_t *b = bv; @@ -39,6 +46,11 @@ int memcmp(const void *av, const void *bv, int len) return 0; } +void memxor(uint8_t * dest, uint8_t * src, size_t len) { + for( ; len > 0; len--,dest++,src++) + *dest ^= *src; +} + int strlen(const char *str) { int l = 0; @@ -60,3 +72,47 @@ char* strncat(char *dest, const char *src, unsigned int n) return dest; } + +char* strcat(char *dest, const char *src) +{ + unsigned int dest_len = strlen(dest); + unsigned int i; + + for (i = 0 ; src[i] != '\0' ; i++) + dest[dest_len + i] = src[i]; + dest[dest_len + i] = '\0'; + + return dest; +} +////////////////////////////////////////// code to do 'itoa' + +/* reverse: reverse string s in place */ +void strreverse(char s[]) +{ + int c, i, j; + + for (i = 0, j = strlen(s)-1; i 0); /* delete it */ + if (sign < 0) + s[i++] = '-'; + s[i] = '\0'; + strreverse(s); +} + +//////////////////////////////////////// END 'itoa' CODE