From 882ed9f801f347b87e162777b296d5be79b8b7ba Mon Sep 17 00:00:00 2001 From: Mystery Man Date: Tue, 23 Jul 2002 11:21:56 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'V1_1_8_9mdk'. --- mdk-stage1/dietlibc/libcruft/inet_ntop.c | 75 -------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 mdk-stage1/dietlibc/libcruft/inet_ntop.c (limited to 'mdk-stage1/dietlibc/libcruft/inet_ntop.c') diff --git a/mdk-stage1/dietlibc/libcruft/inet_ntop.c b/mdk-stage1/dietlibc/libcruft/inet_ntop.c deleted file mode 100644 index 77c47f239..000000000 --- a/mdk-stage1/dietlibc/libcruft/inet_ntop.c +++ /dev/null @@ -1,75 +0,0 @@ -#include - -extern char *inet_ntoa_r(struct in_addr in,char* buf); - -static const unsigned char V4mappedprefix[12]={0,0,0,0,0,0,0,0,0,0,0xff,0xff}; - -static char tohex(char hexdigit) { - return hexdigit>9?hexdigit+'a'-10:hexdigit+'0'; -} - -static int fmt_xlong(char* s,unsigned int i) { - char* bak=s; - *s=tohex((i>>12)&0xf); if (s!=bak || *s!='0') ++s; - *s=tohex((i>>8)&0xf); if (s!=bak || *s!='0') ++s; - *s=tohex((i>>4)&0xf); if (s!=bak || *s!='0') ++s; - *s=tohex(i&0xf); - return s-bak+1; -} - -unsigned int fmt_ip6(char *s,const char ip[16]) -{ - unsigned int len; - unsigned int i; - unsigned int temp; - unsigned int compressing; - int j; - - len = 0; compressing = 0; - for (j=0; j<16; j+=2) { - if (j==12 && !memcmp(ip,V4mappedprefix,12)) { - inet_ntoa_r(*(struct in_addr*)(ip+12),s); - temp=strlen(s); - return len+temp; - } - temp = ((unsigned long) (unsigned char) ip[j] << 8) + - (unsigned long) (unsigned char) ip[j+1]; - if (temp == 0) { - if (!compressing) { - compressing=1; - if (j==0) { - *s++=':'; ++len; - } - } - } else { - if (compressing) { - compressing=0; - *s++=':'; ++len; - } - i = fmt_xlong(s,temp); len += i; s += i; - if (j<14) { - *s++ = ':'; - ++len; - } - } - } - *s=0; - return len; -} - -const char* inet_ntop(int AF, const void *CP, char *BUF, size_t LEN) { - char buf[100]; - int len; - if (AF==AF_INET) { - inet_ntoa_r(*(struct in_addr*)CP,buf); - len=strlen(buf); - } else if (AF==AF_INET6) { - len=fmt_ip6(buf,CP); - } else - return 0; - if (len