Changeset e9b755e for lib


Ignore:
Timestamp:
2007-10-18T16:44:25Z (17 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
7435ccf
Parents:
c511365
Message:

Use standard functions for dealing with both IPv6 and IPv4.

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/misc.c

    rc511365 re9b755e  
    322322}
    323323
    324 #ifdef IPV6
    325 /* Wrap an IPv4 address into IPv6 space. Not thread-safe... */
    326 char *ipv6_wrap( char *src )
    327 {
    328         static char dst[64];
    329         int i;
    330        
    331         for( i = 0; src[i]; i ++ )
    332                 if( ( src[i] < '0' || src[i] > '9' ) && src[i] != '.' )
    333                         break;
    334        
    335         /* Hmm, it's not even an IP... */
    336         if( src[i] )
    337                 return src;
    338        
    339         g_snprintf( dst, sizeof( dst ), "::ffff:%s", src );
    340        
    341         return dst;
    342 }
    343 
    344 /* Unwrap an IPv4 address into IPv6 space. Thread-safe, because it's very simple. :-) */
    345 char *ipv6_unwrap( char *src )
    346 {
    347         int i;
    348        
    349         if( g_strncasecmp( src, "::ffff:", 7 ) != 0 )
    350                 return src;
    351        
    352         for( i = 7; src[i]; i ++ )
    353                 if( ( src[i] < '0' || src[i] > '9' ) && src[i] != '.' )
    354                         break;
    355        
    356         /* Hmm, it's not even an IP... */
    357         if( src[i] )
    358                 return src;
    359        
    360         return ( src + 7 );
    361 }
    362 #endif
    363 
    364324/* Convert from one charset to another.
    365325   
  • lib/misc.h

    rc511365 re9b755e  
    5252G_MODULE_EXPORT void http_encode( char *s );
    5353
    54 G_MODULE_EXPORT char *ipv6_wrap( char *src );
    55 G_MODULE_EXPORT char *ipv6_unwrap( char *src );
    56 
    5754G_MODULE_EXPORT signed int do_iconv( char *from_cs, char *to_cs, char *src, char *dst, size_t size, size_t maxbuf );
    5855
Note: See TracChangeset for help on using the changeset viewer.