#include <bwio.h> #include <tools.h> #include <types.h> // Reference: http://clc-wiki.net/wiki/C_standard_library:string.h:strlen int stringLen(const char* Str) { int i; for (i = 0; Str[i] != '\0'; i++); return i; } // Reference: http://clc-wiki.net/wiki/C_standard_library:string.h:strncpy int stringCopy(char* Dest, const char* Src, int Length) { int i = 0; for(;i<Length;i++){ if(Src[i] == 0) break; Dest[i] = Src[i]; } Dest[Length] = 0; return 0; } // Reference: http://clc-wiki.net/wiki/C_standard_library:string.h:strcmp int stringCompare(const char* Str1, const char* Str2) { //bwprintf(COM2,"StringComp: str1:%d,str2:%d\n\r",Str1,Str2); while (*Str1 && (*Str1==*Str2)) Str1++,Str2++; return *(const unsigned char*)Str1-*(const unsigned char*)Str2; } /* * Reference: https://www.geeksforgeeks.org/write-memcpy/ */ int byteCopy(void* Dest, void* Src, int DestLen, int SrcLen) { if (SrcLen > DestLen) return FAILURE; int i; char* cDest = (char*)Dest; char* cSrc = (char*)Src; for (i = 0; i < SrcLen; i++) cDest[i] = cSrc[i]; return 0; } /* * Reference https://www.geeksforgeeks.org/write-memcpy/ */ void memcpy(void* Dest, void* Src, int Size){ char* cDest = (char *)Dest; char* cSrc = (char *)Src; int i = 0; for(;i<Size;i++){ cDest[i] = cSrc[i]; } }