Ignore:
Timestamp:
Aug 10, 2009, 8:04:08 PM (12 years ago)
Author:
charles
Message:

(trunk) remove trailing spaces

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/net.c

    r8791 r8889  
    5757#endif
    5858
    59 const tr_address tr_in6addr_any = { TR_AF_INET6, { IN6ADDR_ANY_INIT } }; 
    60 const tr_address tr_inaddr_any = { TR_AF_INET, { { { { INADDR_ANY, 0x00, 0x00, 0x00 } } } } }; 
     59const tr_address tr_in6addr_any = { TR_AF_INET6, { IN6ADDR_ANY_INIT } };
     60const tr_address tr_inaddr_any = { TR_AF_INET, { { { { INADDR_ANY, 0x00, 0x00, 0x00 } } } } };
    6161
    6262#ifdef WIN32
     
    130130}
    131131
    132 const char * 
    133 tr_ntop( const tr_address * src, char * dst, int size ) 
     132const char *
     133tr_ntop( const tr_address * src, char * dst, int size )
    134134{
    135135    assert( tr_isAddress( src ) );
    136136
    137     if( src->type == TR_AF_INET ) 
    138         return inet_ntop( AF_INET, &src->addr, dst, size ); 
    139     else 
    140         return inet_ntop( AF_INET6, &src->addr, dst, size ); 
    141 } 
    142 
    143 /* 
    144  * Non-threadsafe version of tr_ntop, which uses a static memory area for a buffer. 
    145  * This function is suitable to be called from libTransmission's networking code, 
    146  * which is single-threaded. 
    147  */ 
    148 const char * 
    149 tr_ntop_non_ts( const tr_address * src ) 
    150 { 
    151     static char buf[INET6_ADDRSTRLEN]; 
    152     return tr_ntop( src, buf, sizeof( buf ) ); 
    153 } 
    154 
    155 tr_address * 
    156 tr_pton( const char * src, tr_address * dst ) 
    157 { 
    158     int retval = inet_pton( AF_INET, src, &dst->addr ); 
     137    if( src->type == TR_AF_INET )
     138        return inet_ntop( AF_INET, &src->addr, dst, size );
     139    else
     140        return inet_ntop( AF_INET6, &src->addr, dst, size );
     141}
     142
     143/*
     144 * Non-threadsafe version of tr_ntop, which uses a static memory area for a buffer.
     145 * This function is suitable to be called from libTransmission's networking code,
     146 * which is single-threaded.
     147 */
     148const char *
     149tr_ntop_non_ts( const tr_address * src )
     150{
     151    static char buf[INET6_ADDRSTRLEN];
     152    return tr_ntop( src, buf, sizeof( buf ) );
     153}
     154
     155tr_address *
     156tr_pton( const char * src, tr_address * dst )
     157{
     158    int retval = inet_pton( AF_INET, src, &dst->addr );
    159159    assert( dst );
    160     if( retval < 0 ) 
    161         return NULL; 
    162     else if( retval == 0 ) 
    163         retval = inet_pton( AF_INET6, src, &dst->addr ); 
     160    if( retval < 0 )
     161        return NULL;
     162    else if( retval == 0 )
     163        retval = inet_pton( AF_INET6, src, &dst->addr );
    164164    else
    165     { 
    166         dst->type = TR_AF_INET; 
    167         return dst; 
    168     } 
    169 
    170     if( retval < 1 ) 
    171         return NULL; 
    172     dst->type = TR_AF_INET6; 
    173     return dst; 
    174 }
    175 
    176 /* 
    177  * Compare two tr_address structures. 
    178  * Returns: 
    179  * <0 if a < b 
    180  * >0 if a > b 
    181  * 0  if a == b 
    182  */ 
     165    {
     166        dst->type = TR_AF_INET;
     167        return dst;
     168    }
     169
     170    if( retval < 1 )
     171        return NULL;
     172    dst->type = TR_AF_INET6;
     173    return dst;
     174}
     175
     176/*
     177 * Compare two tr_address structures.
     178 * Returns:
     179 * <0 if a < b
     180 * >0 if a > b
     181 * 0  if a == b
     182 */
    183183int
    184184tr_compareAddresses( const tr_address * a, const tr_address * b)
     
    189189    assert( tr_isAddress( b ) );
    190190
    191     /* IPv6 addresses are always "greater than" IPv4 */ 
     191    /* IPv6 addresses are always "greater than" IPv4 */
    192192    if( a->type != b->type )
    193193        return a->type == TR_AF_INET ? 1 : -1;
    194194
    195195    return memcmp( &a->addr, &b->addr, sizes[a->type] );
    196 } 
     196}
    197197
    198198/***********************************************************************
     
    314314
    315315    addrlen = setup_sockaddr( addr, port, &sock );
    316    
     316
    317317    /* set source address */
    318318    source_addr = tr_sessionGetPublicAddress( session, addr->type );
Note: See TracChangeset for help on using the changeset viewer.