X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Farm.git;a=blobdiff_plain;f=betty%2Ffunctions.c;fp=betty%2Ffunctions.c;h=43dfebc16b2856d2e81cd143520946720867e10c;hp=0000000000000000000000000000000000000000;hb=62c9b5c57e036a7a2cae5670349b86b060775706;hpb=e9e1115af8d1609165b3e5baf0aef838f29e91a1 diff --git a/betty/functions.c b/betty/functions.c new file mode 100644 index 0000000..43dfebc --- /dev/null +++ b/betty/functions.c @@ -0,0 +1,58 @@ +/* + * * functions.c - severla functions usually served by libc + * + * author: hackbard@hackdaworld.org + * + */ + +#include "functions.h" + +/* + * functions + */ + +int strlen(char *string) { + + int cnt; + + cnt=0; + + while(string[cnt]) + cnt++; + + return cnt; +} + +int strncmp(char *a,char *b,int n) { + + if(!n) + return 0; + + while(n--) { + if(*a!=*b) + return (*(u8 *)a-*(u8 *)b++); + if(!*a++) + break; + } + + return 0; +} + +int strncpy(char *d,char *s,int n) { + + while(n) { + n--; + d[n]=s[n]; + } + + return 0; +} + +int mset(u8 *s,u8 v,int n) { + + while(n) + s[--n]=v; + + return 0; +} +