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 strlen(const char *c)
61 void strcpy(char *a2, const char *a1)
68 void puts(const char *c)
70 putbytes(c, strlen(c));
73 static char hexarr[] = "0123456789ABCDEF";
74 void tohex(char *s, unsigned long l)
77 for (i = 0; i < 8; i++)
79 s[i] = hexarr[l >> 28];
84 void puthex(unsigned long l)
92 unsigned short htons(unsigned short in)
94 return (in >> 8) | (in << 8);
97 unsigned int htonl(unsigned int in)
99 return ((in & 0xff) << 24) |
100 ((in & 0xff00) << 8) |
101 ((in & 0xff0000UL) >> 8) |
102 ((in & 0xff000000UL) >> 24);