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 strcat(char *dest, char *src)
87 void puts(const char *c)
89 putbytes(c, strlen(c));
92 static char hexarr[] = "0123456789ABCDEF";
93 void tohex(char *s, unsigned long l)
96 for (i = 0; i < 8; i++)
98 s[i] = hexarr[l >> 28];
103 void puthex(unsigned long l)
111 unsigned short htons(unsigned short in)
113 return (in >> 8) | (in << 8);
116 unsigned int htonl(unsigned int in)
118 return ((in & 0xff) << 24) |
119 ((in & 0xff00) << 8) |
120 ((in & 0xff0000UL) >> 8) |
121 ((in & 0xff000000UL) >> 24);