]> Joshua Wise's Git repositories - netwatch.git/blame_incremental - lib/minilib.c
Add cut 1 at a TODO list
[netwatch.git] / lib / minilib.c
... / ...
CommitLineData
1#include "console.h"
2
3void memcpy(unsigned char *a2, unsigned char *a1, int bytes)
4{
5 while (bytes--)
6 *(a2++) = *(a1++);
7}
8
9void memmove(unsigned char *dest, unsigned char *src, int bytes)
10{
11 if ((dest > src) && (dest <= (src + bytes)))
12 {
13 /* do it backwards! */
14 dest += bytes;
15 src += bytes;
16 while (bytes--)
17 *(--dest) = *(--src);
18 } else
19 while (bytes--)
20 *(dest++) = *(src++);
21}
22
23int memcmp (unsigned char *a2, unsigned char *a1, int bytes) {
24 while (bytes--)
25 {
26 if (*(a2++) != *(a1++))
27 return 1;
28 }
29 return 0;
30}
31
32int strcmp (unsigned char *a2, unsigned char *a1) {
33 while (1) {
34 if (*a2 != *a1) return 1;
35 if (*a2 == 0) return 0;
36 a1++;
37 a2++;
38 }
39}
40
41int strlen(char *c)
42{
43 int l = 0;
44 while (*(c++))
45 l++;
46 return l;
47}
48
49void strcpy(unsigned char *a2, unsigned char *a1)
50{
51 do {
52 *(a2++) = *a1;
53 } while (*(a1++));
54}
55
56void puts(char *c)
57{
58 putbytes(c, strlen(c));
59}
60
61static char hexarr[] = "0123456789ABCDEF";
62void tohex(unsigned char *s, unsigned long l)
63{
64 int i;
65 for (i = 0; i < 8; i++)
66 {
67 s[i] = hexarr[l >> 28];
68 l <<= 4;
69 }
70}
71
72void puthex(unsigned long l)
73{
74 unsigned char d[9];
75 d[8] = 0;
76 tohex(d, l);
77 puts(d);
78}
79
80
This page took 0.026797 seconds and 4 git commands to generate.