4 void memcpy(void *dest, const void *src, int bytes)
7 const char *csrc = src;
9 *(cdest++) = *(csrc++);
12 void memset(void *dest, int data, int bytes)
14 unsigned char *cdest = dest;
16 *(cdest++) = (unsigned char)data;
19 void memmove(void *dest, void *src, int bytes)
23 if ((cdest > csrc) && (cdest <= (csrc + bytes)))
25 /* do it backwards! */
29 *(--cdest) = *(--csrc);
32 *(cdest++) = *(csrc++);
35 int memcmp (const char *a2, const char *a1, int bytes) {
38 if (*(a2++) != *(a1++))
44 int strcmp (const char *a2, const char *a1) {
46 if (*a2 != *a1) return 1;
47 if (*a2 == 0) return 0;
53 int strncmp (const char *a2, const char *a1, int n) {
55 if (*a2 != *a1) return 1;
56 if (*a2 == 0) return 0;
63 int strlen(const char *c)
71 void strcpy(char *a2, const char *a1)
78 void puts(const char *c)
80 putbytes(c, strlen(c));
83 static char hexarr[] = "0123456789ABCDEF";
84 void tohex(char *s, unsigned long l)
87 for (i = 0; i < 8; i++)
89 s[i] = hexarr[l >> 28];
94 void puthex(unsigned long l)
102 unsigned short htons(unsigned short in)
104 return (in >> 8) | (in << 8);
107 unsigned int htonl(unsigned int in)
109 return ((in & 0xff) << 24) |
110 ((in & 0xff00) << 8) |
111 ((in & 0xff0000UL) >> 8) |
112 ((in & 0xff000000UL) >> 24);