Ignore:
Timestamp:
Dec 5, 2012, 5:29:46 PM (8 years ago)
Author:
jordan
Message:

Follow more common whitespace style conventions in the C code (libtransmission, daemon, utils, cli, gtk).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/tr-utp.c

    r13329 r13625  
    3131#include "net.h"
    3232#include "session.h"
    33 #include "crypto.h" /* tr_cryptoWeakRandInt() */
     33#include "crypto.h" /* tr_cryptoWeakRandInt () */
    3434#include "peer-mgr.h"
    3535#include "tr-utp.h"
     
    3838#define MY_NAME "UTP"
    3939
    40 #define dbgmsg( ... ) \
     40#define dbgmsg(...) \
    4141    do { \
    42         if( tr_deepLoggingIsActive( ) ) \
    43             tr_deepLog( __FILE__, __LINE__, MY_NAME, __VA_ARGS__ ); \
    44     } while( 0 )
     42        if (tr_deepLoggingIsActive ()) \
     43            tr_deepLog (__FILE__, __LINE__, MY_NAME, __VA_ARGS__); \
     44    } while (0)
    4545
    4646#ifndef WITH_UTP
    4747
    4848void
    49 UTP_Close(struct UTPSocket * socket)
     49UTP_Close (struct UTPSocket * socket)
    5050{
    51     tr_nerr( MY_NAME, "UTP_Close(%p) was called.", socket );
    52     dbgmsg( "UTP_Close(%p) was called.", socket );
    53     assert( 0 ); /* FIXME: this is too much for the long term, but probably needed in the short term */
     51    tr_nerr (MY_NAME, "UTP_Close (%p) was called.", socket);
     52    dbgmsg ("UTP_Close (%p) was called.", socket);
     53    assert (0); /* FIXME: this is too much for the long term, but probably needed in the short term */
    5454}
    5555
    5656void
    57 UTP_RBDrained(struct UTPSocket *socket)
     57UTP_RBDrained (struct UTPSocket *socket)
    5858{
    59     tr_nerr( MY_NAME, "UTP_RBDrained(%p) was called.", socket );
    60     dbgmsg( "UTP_RBDrained(%p) was called.", socket );
    61     assert( 0 ); /* FIXME: this is too much for the long term, but probably needed in the short term */
     59    tr_nerr (MY_NAME, "UTP_RBDrained (%p) was called.", socket);
     60    dbgmsg ("UTP_RBDrained (%p) was called.", socket);
     61    assert (0); /* FIXME: this is too much for the long term, but probably needed in the short term */
    6262}
    6363
    6464bool
    65 UTP_Write(struct UTPSocket *socket, size_t count)
     65UTP_Write (struct UTPSocket *socket, size_t count)
    6666{
    67     tr_nerr( MY_NAME, "UTP_RBDrained(%p, %zu) was called.", socket, count );
    68     dbgmsg( "UTP_RBDrained(%p, %zu) was called.", socket, count );
    69     assert( 0 ); /* FIXME: this is too much for the long term, but probably needed in the short term */
     67    tr_nerr (MY_NAME, "UTP_RBDrained (%p, %zu) was called.", socket, count);
     68    dbgmsg ("UTP_RBDrained (%p, %zu) was called.", socket, count);
     69    assert (0); /* FIXME: this is too much for the long term, but probably needed in the short term */
    7070    return false;
    7171}
    7272
    73 int tr_utpPacket(const unsigned char *buf UNUSED, size_t buflen UNUSED,
     73int tr_utpPacket (const unsigned char *buf UNUSED, size_t buflen UNUSED,
    7474                 const struct sockaddr *from UNUSED, socklen_t fromlen UNUSED,
    7575                 tr_session *ss UNUSED) { return -1; }
    7676
    77 struct UTPSocket *UTP_Create(SendToProc *send_to_proc UNUSED,
     77struct UTPSocket *UTP_Create (SendToProc *send_to_proc UNUSED,
    7878                             void *send_to_userdata UNUSED,
    7979                             const struct sockaddr *addr UNUSED,
     
    8484}
    8585
    86 void tr_utpClose( tr_session * ss UNUSED ) { }
     86void tr_utpClose (tr_session * ss UNUSED) { }
    8787
    88 void tr_utpSendTo(void *closure UNUSED,
     88void tr_utpSendTo (void *closure UNUSED,
    8989                  const unsigned char *buf UNUSED, size_t buflen UNUSED,
    9090                  const struct sockaddr *to UNUSED, socklen_t tolen UNUSED) { }
     
    9999
    100100static void
    101 incoming(void *closure, struct UTPSocket *s)
     101incoming (void *closure, struct UTPSocket *s)
    102102{
    103103    tr_session *ss = closure;
    104104    struct sockaddr_storage from_storage;
    105105    struct sockaddr *from = (struct sockaddr*)&from_storage;
    106     socklen_t fromlen = sizeof(from_storage);
     106    socklen_t fromlen = sizeof (from_storage);
    107107    tr_address addr;
    108108    tr_port port;
    109109
    110     if( !tr_sessionIsUTPEnabled(ss) ) {
    111         UTP_Close(s);
     110    if (!tr_sessionIsUTPEnabled (ss)) {
     111        UTP_Close (s);
    112112        return;
    113113    }
    114114
    115     UTP_GetPeerName(s, from, &fromlen);
    116     if( !tr_address_from_sockaddr_storage( &addr, &port, &from_storage ) )
     115    UTP_GetPeerName (s, from, &fromlen);
     116    if (!tr_address_from_sockaddr_storage (&addr, &port, &from_storage))
    117117    {
    118         tr_nerr("UTP", "Unknown socket family");
    119         UTP_Close(s);
     118        tr_nerr ("UTP", "Unknown socket family");
     119        UTP_Close (s);
    120120        return;
    121121    }
    122122
    123     tr_peerMgrAddIncoming(ss->peerMgr, &addr, port, -1, s);
     123    tr_peerMgrAddIncoming (ss->peerMgr, &addr, port, -1, s);
    124124}
    125125
    126126void
    127 tr_utpSendTo(void *closure, const unsigned char *buf, size_t buflen,
     127tr_utpSendTo (void *closure, const unsigned char *buf, size_t buflen,
    128128             const struct sockaddr *to, socklen_t tolen)
    129129{
    130130    tr_session *ss = closure;
    131131
    132     if(to->sa_family == AF_INET && ss->udp_socket)
    133         sendto(ss->udp_socket, buf, buflen, 0, to, tolen);
    134     else if(to->sa_family == AF_INET6 && ss->udp_socket)
    135         sendto(ss->udp6_socket, buf, buflen, 0, to, tolen);
     132    if (to->sa_family == AF_INET && ss->udp_socket)
     133        sendto (ss->udp_socket, buf, buflen, 0, to, tolen);
     134    else if (to->sa_family == AF_INET6 && ss->udp_socket)
     135        sendto (ss->udp6_socket, buf, buflen, 0, to, tolen);
    136136}
    137137
    138138static void
    139 reset_timer(tr_session *ss)
     139reset_timer (tr_session *ss)
    140140{
    141141    int sec;
    142142    int usec;
    143     if( tr_sessionIsUTPEnabled( ss ) ) {
     143    if (tr_sessionIsUTPEnabled (ss)) {
    144144        sec = 0;
    145         usec = UTP_INTERVAL_US / 2 + tr_cryptoWeakRandInt(UTP_INTERVAL_US);
     145        usec = UTP_INTERVAL_US / 2 + tr_cryptoWeakRandInt (UTP_INTERVAL_US);
    146146    } else {
    147147        /* If somebody has disabled uTP, then we still want to run
     
    151151           well use a large timeout. */
    152152        sec = 2;
    153         usec = tr_cryptoWeakRandInt( 1000000 );
     153        usec = tr_cryptoWeakRandInt (1000000);
    154154    }
    155     tr_timerAdd( utp_timer, sec, usec );
     155    tr_timerAdd (utp_timer, sec, usec);
    156156}
    157157
    158158static void
    159 timer_callback(int s UNUSED, short type UNUSED, void *closure)
     159timer_callback (int s UNUSED, short type UNUSED, void *closure)
    160160{
    161161    tr_session *ss = closure;
    162     UTP_CheckTimeouts();
    163     reset_timer( ss );
     162    UTP_CheckTimeouts ();
     163    reset_timer (ss);
    164164}
    165165
    166166int
    167 tr_utpPacket(const unsigned char *buf, size_t buflen,
     167tr_utpPacket (const unsigned char *buf, size_t buflen,
    168168             const struct sockaddr *from, socklen_t fromlen,
    169169             tr_session *ss)
    170170{
    171     if( !ss->isClosed && !utp_timer )
     171    if (!ss->isClosed && !utp_timer)
    172172    {
    173         utp_timer = evtimer_new( ss->event_base, timer_callback, ss );
    174         if(utp_timer == NULL)
     173        utp_timer = evtimer_new (ss->event_base, timer_callback, ss);
     174        if (utp_timer == NULL)
    175175            return -1;
    176         reset_timer( ss );
     176        reset_timer (ss);
    177177    }
    178178
    179     return UTP_IsIncomingUTP(incoming, tr_utpSendTo, ss,
     179    return UTP_IsIncomingUTP (incoming, tr_utpSendTo, ss,
    180180                             buf, buflen, from, fromlen);
    181181}
    182182
    183183void
    184 tr_utpClose( tr_session * session UNUSED )
     184tr_utpClose (tr_session * session UNUSED)
    185185{
    186     if( utp_timer )
     186    if (utp_timer)
    187187    {
    188         evtimer_del( utp_timer );
     188        evtimer_del (utp_timer);
    189189        utp_timer = NULL;
    190190    }
Note: See TracChangeset for help on using the changeset viewer.