]> hackdaworld.org Git - my-code/arm.git/commitdiff
added some functions usually served by libc
authorhackbard <hackbard@staubsauger.localdomain>
Sun, 9 Sep 2007 19:52:47 +0000 (21:52 +0200)
committerhackbard <hackbard@staubsauger.localdomain>
Sun, 9 Sep 2007 19:52:47 +0000 (21:52 +0200)
betty/functions.c [new file with mode: 0644]
betty/functions.h [new file with mode: 0644]

diff --git a/betty/functions.c b/betty/functions.c
new file mode 100644 (file)
index 0000000..43dfebc
--- /dev/null
@@ -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;
+}
+
diff --git a/betty/functions.h b/betty/functions.h
new file mode 100644 (file)
index 0000000..db55296
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * * functions.h - functions header file
+ *
+ * author: hackbard@hackdaworld.org
+ *
+ */
+
+#ifndef FUNCTIONS_H
+#define FUNCTIONS_H
+
+#include "lpc2xxx.h"
+#include "types.h"
+
+/*
+ * function prototypes
+ */
+
+int strlen(char *string);
+int strncmp(char *a,char *b,int n);
+int strncpy(char *d,char *s,int n);
+int mset(u8 *s,u8 v,int n);
+
+#endif