Changeset 2428


Ignore:
Timestamp:
Jul 19, 2007, 10:49:44 AM (15 years ago)
Author:
charles
Message:

remove the TR_HTONL macro

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/internal.h

    r2427 r2428  
    8686#endif
    8787
    88 /* Convenient macros to perform uint32_t endian conversions with
    89    char pointers */
    90 #define TR_HTONL(a,p) tr_htonl((a), ( uint8_t * )(p))
    91 static inline uint32_t tr_ntohl( uint8_t * p )
    92 {
    93         uint32_t u;
    94         memcpy( &u, p, sizeof( uint32_t ) );
    95         return ntohl( u );
    96 }
    97 static inline void tr_htonl( uint32_t a, uint8_t * p )
    98 {
    99         uint32_t u;
    100         u = htonl( a );
    101         memcpy ( p, &u, sizeof( uint32_t ) );
    102 }
    103 
    10488/* Sometimes the system defines MAX/MIN, sometimes not. In the latter
    10589   case, define those here since we will use them */
  • trunk/libtransmission/peer.c

    r2374 r2428  
    227227}
    228228
     229/* utilities for endian conversions with char pointers */
     230
     231static uint32_t tr_ntohl( const void * p )
     232{
     233    uint32_t u;
     234    memcpy( &u, p, sizeof( uint32_t ) );
     235    return ntohl( u );
     236}
     237static void tr_htonl( uint32_t a, void * p )
     238{
     239    const uint32_t u = htonl( a );
     240    memcpy ( p, &u, sizeof( uint32_t ) );
     241}
     242
    229243#include "peerext.h"
    230244#include "peeraz.h"
  • trunk/libtransmission/peeraz.h

    r2427 r2428  
    115115
    116116    /* set length to zero for now, we won't know it until after bencoding */
    117     TR_HTONL( 0, buf );
     117    tr_htonl( 0, buf );
    118118    /* set name length, name, and version */
    119     TR_HTONL( azmsgLen( idx ), buf + 4 );
     119    tr_htonl( azmsgLen( idx ), buf + 4 );
    120120    memcpy( buf + 8, azmsgStr( idx ), azmsgLen( idx ) );
    121121    buf[8 + azmsgLen( idx )] = AZ_EXT_VERSION;
     
    188188    tr_bencFree( &val );
    189189    /* we know the length now, fill it in */
    190     TR_HTONL( len - 4, buf );
     190    tr_htonl( len - 4, buf );
    191191
    192192    /* XXX is there a way to tell azureus that the public port has changed? */
  • trunk/libtransmission/peermessages.h

    r2339 r2428  
    8282    int index;
    8383
    84     TR_HTONL( size - 4, buf );
     84    tr_htonl( size - 4, buf );
    8585    buf += 4;
    8686    if( peer->azproto )
     
    8888        index = azmsgIdIndex( id );
    8989        assert( 0 <= index );
    90         TR_HTONL( azmsgLen( index ), buf );
     90        tr_htonl( azmsgLen( index ), buf );
    9191        buf += 4;
    9292        memcpy( buf, azmsgStr( index ), azmsgLen( index ) );
     
    139139        buf = fillHeader( peer, hdrlen, PEER_MSG_PIECE, peer->outBlock );
    140140
    141         TR_HTONL( r->index, buf );
     141        tr_htonl( r->index, buf );
    142142        buf += 4;
    143         TR_HTONL( r->begin, buf );
     143        tr_htonl( r->begin, buf );
    144144        buf += 4;
    145145
     
    262262    p = getMessagePointer( peer, 4, PEER_MSG_HAVE );
    263263
    264     TR_HTONL( piece, p );
     264    tr_htonl( piece, p );
    265265
    266266    peer_dbg( "SEND have %d", piece );
     
    311311    p = getMessagePointer( peer, 12, PEER_MSG_REQUEST );
    312312
    313     TR_HTONL( r->index,  p     );
    314     TR_HTONL( r->begin,  p + 4 );
    315     TR_HTONL( r->length, p + 8 );
     313    tr_htonl( r->index,  p     );
     314    tr_htonl( r->begin,  p + 4 );
     315    tr_htonl( r->length, p + 8 );
    316316
    317317    tr_cpDownloaderAdd( tor->completion, block );
     
    332332    p = getMessagePointer( peer, 12, PEER_MSG_CANCEL );
    333333
    334     TR_HTONL( index,  p     );
    335     TR_HTONL( begin,  p + 4 );
    336     TR_HTONL( length, p + 8 );
     334    tr_htonl( index,  p     );
     335    tr_htonl( begin,  p + 4 );
     336    tr_htonl( length, p + 8 );
    337337
    338338    peer_dbg( "SEND cancel %d/%d (%d bytes)", index, begin, length );
Note: See TracChangeset for help on using the changeset viewer.