added some functions usually served by libc
[my-code/arm.git] / betty / functions.c
1 /*
2  * * functions.c - severla functions usually served by libc
3  *
4  * author: hackbard@hackdaworld.org
5  *
6  */
7
8 #include "functions.h"
9
10 /*
11  * functions
12  */
13
14 int strlen(char *string) {
15
16         int cnt;
17
18         cnt=0;
19
20         while(string[cnt])
21                 cnt++;
22
23         return cnt;
24 }
25
26 int strncmp(char *a,char *b,int n) {
27
28         if(!n)
29                 return 0;
30
31         while(n--) {
32                 if(*a!=*b)
33                         return (*(u8 *)a-*(u8 *)b++);
34                 if(!*a++)
35                         break;
36         }
37
38         return 0;
39 }
40
41 int strncpy(char *d,char *s,int n) {
42
43         while(n) {
44                 n--;
45                 d[n]=s[n];
46         }
47         
48         return 0;
49 }
50
51 int mset(u8 *s,u8 v,int n) {
52
53         while(n)
54                 s[--n]=v;
55
56         return 0;
57 }
58