]> jfr.im git - solanum.git/commitdiff
no need for inetntop* now - removed
authorValery Yatsko <redacted>
Sun, 20 Apr 2008 04:57:25 +0000 (08:57 +0400)
committerValery Yatsko <redacted>
Sun, 20 Apr 2008 04:57:25 +0000 (08:57 +0400)
src/irc_string.c

index 6062e3a4cb80727c301e5c35db0b30a05ff5b521..d47147d297bf78cf6050f9e72a76183321b587ec 100644 (file)
@@ -197,146 +197,6 @@ strtoken(char **save, char *str, const char *fs)
 
 #define SPRINTF(x) ((size_t)rb_sprintf x)
 
-/*
- * WARNING: Don't even consider trying to compile this on a system where
- * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
- */
-
-static const char *inet_ntop4(const u_char * src, char *dst, unsigned int size);
-#ifdef RB_IPV6
-static const char *inet_ntop6(const u_char * src, char *dst, unsigned int size);
-#endif
-
-/* const char *
- * inet_ntop4(src, dst, size)
- *     format an IPv4 address
- * return:
- *     `dst' (as a const)
- * notes:
- *     (1) uses no statics
- *     (2) takes a u_char* not an in_addr as input
- * author:
- *     Paul Vixie, 1996.
- */
-static const char *
-inet_ntop4(const unsigned char *src, char *dst, unsigned int size)
-{
-       if(size < 16)
-               return NULL;
-       return strcpy(dst, inetntoa((const char *) src));
-}
-
-/* const char *
- * inet_ntop6(src, dst, size)
- *     convert IPv6 binary address into presentation (printable) format
- * author:
- *     Paul Vixie, 1996.
- */
-#ifdef RB_IPV6
-static const char *
-inet_ntop6(const unsigned char *src, char *dst, unsigned int size)
-{
-       /*
-        * Note that int32_t and int16_t need only be "at least" large enough
-        * to contain a value of the specified size.  On some systems, like
-        * Crays, there is no such thing as an integer variable with 16 bits.
-        * Keep this in mind if you think this function should have been coded
-        * to use pointer overlays.  All the world's not a VAX.
-        */
-       char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
-       struct
-       {
-               int base, len;
-       }
-       best, cur;
-       u_int words[IN6ADDRSZ / INT16SZ];
-       int i;
-
-       /*
-        * Preprocess:
-        *      Copy the input (bytewise) array into a wordwise array.
-        *      Find the longest run of 0x00's in src[] for :: shorthanding.
-        */
-       memset(words, '\0', sizeof words);
-       for(i = 0; i < IN6ADDRSZ; i += 2)
-               words[i / 2] = (src[i] << 8) | src[i + 1];
-       best.base = -1;
-       cur.base = -1;
-       for(i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
-       {
-               if(words[i] == 0)
-               {
-                       if(cur.base == -1)
-                               cur.base = i, cur.len = 1;
-                       else
-                               cur.len++;
-               }
-               else
-               {
-                       if(cur.base != -1)
-                       {
-                               if(best.base == -1 || cur.len > best.len)
-                                       best = cur;
-                               cur.base = -1;
-                       }
-               }
-       }
-       if(cur.base != -1)
-       {
-               if(best.base == -1 || cur.len > best.len)
-                       best = cur;
-       }
-       if(best.base != -1 && best.len < 2)
-               best.base = -1;
-
-       /*
-        * Format the result.
-        */
-       tp = tmp;
-       for(i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
-       {
-               /* Are we inside the best run of 0x00's? */
-               if(best.base != -1 && i >= best.base && i < (best.base + best.len))
-               {
-                       if(i == best.base)
-                       {
-                               if(i == 0)
-                                       *tp++ = '0';
-                               *tp++ = ':';
-                       }
-                       continue;
-               }
-               /* Are we following an initial run of 0x00s or any real hex? */
-               if(i != 0)
-                       *tp++ = ':';
-               /* Is this address an encapsulated IPv4? */
-               if(i == 6 && best.base == 0 &&
-                  (best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
-               {
-                       if(!inet_ntop4(src + 12, tp, sizeof tmp - (tp - tmp)))
-                               return (NULL);
-                       tp += strlen(tp);
-                       break;
-               }
-               tp += SPRINTF((tp, "%x", words[i]));
-       }
-       /* Was it a trailing run of 0x00's? */
-       if(best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
-               *tp++ = ':';
-       *tp++ = '\0';
-
-       /*
-        * Check for overflow, copy, and we're done.
-        */
-
-       if((unsigned int) (tp - tmp) > size)
-       {
-               return (NULL);
-       }
-       return strcpy(dst, tmp);
-}
-#endif
-
 char *
 strip_colour(char *string)
 {