X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Farm.git;a=blobdiff_plain;f=betty%2Ffunctions.c;h=9e12c868365a6767322b619209095cadbcae4ca9;hp=43dfebc16b2856d2e81cd143520946720867e10c;hb=6292cc9190f6e7f36a3634057740e770d58d7460;hpb=62c9b5c57e036a7a2cae5670349b86b060775706 diff --git a/betty/functions.c b/betty/functions.c index 43dfebc..9e12c86 100644 --- a/betty/functions.c +++ b/betty/functions.c @@ -11,16 +11,20 @@ * functions */ -int strlen(char *string) { +#define modulo(d,x,y) (d)=(x); \ + while((d)>=(y)) \ + (d)-=(y); - int cnt; +int strlen(char *s) { - cnt=0; + int n; - while(string[cnt]) - cnt++; + n=0; - return cnt; + while(s[n]) + n++; + + return n; } int strncmp(char *a,char *b,int n) { @@ -48,11 +52,30 @@ int strncpy(char *d,char *s,int n) { return 0; } -int mset(u8 *s,u8 v,int n) { +int memset(u8 *d,int v,int n) { while(n) - s[--n]=v; + d[--n]=v; return 0; } +int memcpy(u8 *d,u8 *s,int n) { + + while(n--) + *d++=*s++; + + return n; +} + +int counttok(u8 *s,u8 delim) { + + int n; + + n=0; + while(*s++!=delim) + n++; + + return n; +} +