Changeset 6376


Ignore:
Timestamp:
Jul 21, 2008, 4:11:47 PM (13 years ago)
Author:
charles
Message:

add more rpc unit tests. man page cleanups.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/transmission-daemon.1

    r6299 r6376  
    1 .Dd May 19, 2008
     1.Dd July 21, 2008
    22.Dt TRANSMISSION-DAEMON 1
    33
     
    1111.Nm
    1212.Op Fl a Ar (+|-)x.x.x.x[/x],...
    13 .Op Fl b
    14 .Op Fl B
     13.Op Fl b | B
    1514.Op Fl f
    1615.Op Fl g Ar directory
    1716.Op Fl h
    1817.Op Fl p Ar port
    19 .Op Fl t
    20 .Op Fl T
     18.Op Fl t | T
    2119.Op Fl u Ar username
    2220.Op Fl v Ar password
     
    2725.Nm
    2826is a daemon-based Transmission session that can be controlled
    29 via RPC commands from
    30 .Xr transmission-remote 1
    31 or
    32 .Xr Clutch 1 .
    33 .Pp
    34 The options are as follows:
     27via RPC commands from transmission's web interface or
     28.Xr transmission-remote 1 .
     29
     30.Sh OPTIONS
    3531.Bl -tag -width Ds
    3632
  • trunk/daemon/transmission-remote.1

    r6324 r6376  
    1 .Dd May 20, 2008
     1.Dd July 21, 2008
    22.Dt TRANSMISSION-REMOTE 1
    33.Os
     
    1414.Op Fl a Ar torrent-files
    1515.Op Fl b
    16 .Op Fl d Ar number
    17 .Op Fl D
    18 .Op Fl er
    19 .Op Fl ep
    20 .Op Fl et
     16.Op Fl d Ar number | Fl D
     17.Op Fl er | ep | et
    2118.Op Fl f
    2219.Op Fl g Ar files
     
    2522.Op Fl i
    2623.Op Fl l
    27 .Op Fl m
    28 .Op Fl M
     24.Op Fl m | M
    2925.Op Fl n Ar user:pass
    3026.Op Fl p Ar port
     
    3329.Op Fl pn Ar files
    3430.Op Fl r
    35 .Op Fl s
    36 .Op Fl S
     31.Op Fl s | S
    3732.Op Fl t Ar all | Ar id | Ar hash
    38 .Op Fl u Ar number
    39 .Op Fl U
     33.Op Fl u Ar number | Fl U
    4034.Op Fl v
    4135.Op Fl w Ar download-dir
    42 .Op Fl x
    43 .Op Fl X
     36.Op Fl x | X
    4437.Ek
    4538.Sh DESCRIPTION
     
    5447connects to the transmission session at localhost:9091.
    5548Other sessions can be controlled by specifying a different host and/or port.
    56 .Pp
    57 The options are as follows:
     49
     50.Sh OPTIONS
    5851.Bl -tag -width Ds
    59 .It Fl a Fl -add Ar torrent-file
    60 Add metainfo
    61 .Ar torrent-file(s) .
     52.It Fl a Fl -add Ar torrent-file(s)
     53Add
     54.Ar torrent-file(s)
     55into transmission.
    6256
    6357.It Fl b Fl -debug
     
    8276Get a file list for the current torrent(s)
    8377
    84 .It Fl g Fl -get Ar files
     78.It Fl g Fl -get Ar all | file-index | files
    8579Mark file(s) for download.
     80.Ar all
     81marks all all of the torrent's files for downloading,
     82.Ar file-index
     83adds a single file to the download list, and
    8684.Ar files
    87 can be a file index, or a comma-separated list of file indices, or the literal
    88 .Ar all
    89 for all files in the torrent.
    90 
    91 .It Fl g Fl -no-get Ar files
    92 Mark file(s) for not downloading
     85adds multiple files to the download list,
     86such as "-g1,3-5" to add files #1, #3, #4, and #5 to the download list.
     87
     88.It Fl G Fl -no-get Ar all | file-index | files
     89Mark file(s) for not downloading.
    9390
    9491.It Fl h Fl -help
     
    118115for use when listening for incoming peer connections
    119116
    120 .It Fl ph Fl -priority-high Ar files
    121 Mark
     117.It Fl pn Fl -priority-normal Ar all | file-index | files
     118Mark file(s) as normal priority.
     119.Ar all
     120marks all of the torrent's files as normal priority,
     121.Ar file-index
     122sets a single file's priority as normal, and
    122123.Ar files
    123 as high priority.
    124 .Ar files
    125 can be a file index, or a comma-separated list of file indices, or the literal
    126 .Ar all
    127 for all files in the torrent.
    128 
    129 .It Fl pl Fl -priority-low Ar files
    130 Mark
    131 .Ar files
    132 as low priority
    133 
    134 .It Fl pn Fl -priority-normal Ar files
    135 Mark
    136 .Ar files
    137 as normal priority
     124sets multiple files' priorities as normal,
     125such as "-pn1,3-5" to normalize files #1, #3, #4, and #5.
     126
     127.It Fl ph Fl -priority-high Ar all | file-index | files
     128Mark file(s) as high priority.
     129
     130.It Fl pl Fl -priority-low Ar all | file-index | files
     131Mark file(s) as low priority.
    138132
    139133.It Fl r Fl -remove
     
    153147or
    154148.Ar hash .
    155 To set more than one current torrent, joined their ids or hashes together in a comma-delimited list,
    156 such as "-t1,2,3"
     149To set more than one current torrent, join their ids or hashes together in a list,
     150such as "-t2,4,6-8" to operate on the torrents whose IDs are 2, 4, 6, 7, and 8.
    157151
    158152.It Fl u Fl -uplimit Ar limit
     
    179173.Sh EXAMPLES
    180174
    181 List all torrents' IDs and states:
    182 .Bd -literal -offset indent
    183 $ transmission-remote -l
    184 .Ed
    185 
    186 List all torrents from a remote session that requires authentication:
    187 .Bd -literal -offset indent
    188 $ transmission-remote host:9091 --auth=username:password -l
    189 .Ed
    190 
    191 Start all torrents:
    192 .Bd -literal -offset indent
    193 $ transmission-remote -tall --start
    194 .Ed
    195 
    196 Add two torrents:
    197 .Bd -literal -offset indent
    198 $ transmission-remote -a one.torrent two.torrent
    199 .Ed
    200 
    201 Add all torrents in ~/Desktop:
    202 .Bd -literal -offset indent
    203 $ transmission-remote -a ~/Desktop/*torrent
    204 .Ed
    205 
    206 Get detailed information on the torrent whose ID is '1':
    207 .Bd -literal -offset indent
    208 $ transmission-remote -t1 -i"
    209 .Ed
    210 
    211 Download only its second and fourth files:
    212 .Bd -literal -offset indent
    213 $ transmission-remote -t1 -Gall -g2,4"
    214 .Ed
    215 
    216 Set all torrents' first two files' priorities to high:
    217 .Bd -literal -offset indent
    218 $ transmission-remote -tall -ph1,2"
    219 .Ed
    220 
    221 Set all torrents' files' priorities to normal:
    222 .Bd -literal -offset indent
    223 $ transmission-remote -tall -pnall"
    224 .Ed
    225 
    226175Set download and upload limits to 100 KiB/sec and 20 KiB/sec:
    227176.Bd -literal -offset indent
    228177$ transmission-remote -d100 -u20
    229178$ transmission-remote --downlimit=100 --uplimit=20
    230 .Bd -literal -offset indent
     179.Ed
     180
     181List all torrents' IDs and states:
     182.Bd -literal -offset indent
     183$ transmission-remote -l
     184.Ed
     185
     186List all torrents from a remote session that requires authentication:
     187.Bd -literal -offset indent
     188$ transmission-remote host:9091 --auth=username:password -l
     189.Ed
     190
     191Start all torrents:
     192.Bd -literal -offset indent
     193$ transmission-remote -tall --start
     194.Ed
     195
     196Add two torrents:
     197.Bd -literal -offset indent
     198$ transmission-remote -a one.torrent two.torrent
     199.Ed
     200
     201Add all torrents in ~/Desktop:
     202.Bd -literal -offset indent
     203$ transmission-remote -a ~/Desktop/*torrent
     204.Ed
     205
     206Get detailed information on the torrent whose ID is '1':
     207.Bd -literal -offset indent
     208$ transmission-remote -t1 -i"
     209.Ed
     210
     211Get a list of a torrent's files:
     212.Bd -literal -offset indent
     213$ transmission-remote -t1 -l"
     214.Ed
     215
     216Download only its second and fourth files:
     217.Bd -literal -offset indent
     218$ transmission-remote -t1 -Gall -g2,4"
     219.Ed
     220
     221Set all torrents' first two files' priorities to high:
     222.Bd -literal -offset indent
     223$ transmission-remote -tall -ph1,2"
     224.Ed
     225
     226Set all torrents' files' priorities to normal:
     227.Bd -literal -offset indent
     228$ transmission-remote -tall -pnall"
     229.Ed
    231230
    232231.Sh AUTHORS
  • trunk/gtk/transmission.1

    r5861 r6376  
    4141tracker to distribute file data amongst a group of peers.  For more
    4242information on the BitTorrent protocol see http://www.bittorrent.org/
    43 .Pp
    44 The options are as follows:
     43.Sh OPTIONS
    4544.Bl -tag -width Ds
    4645.It Fl ? Fl -help
  • trunk/libtransmission/rpc-test.c

    r6140 r6376  
    22#include <string.h> /* strcmp */
    33#include "transmission.h"
     4#include "bencode.h"
     5#include "rpc.h"
    46#include "utils.h"
    57
     
    3133    int ok;
    3234    char * str = cidrize( in );
    33 /* fprintf( stderr, "in [%s] out [%s] should be [%s]\n", in, str, expected ); */
     35/* fprintf( stderr, "in [%s] out [%s] expected [%s]\n", in, str, expected ); */
    3436    ok = expected ? !strcmp( expected, str ) : !str;
    3537    tr_free( str );
     
    4749    check( testWildcard( "192.64.0.*", "192.64.0.0/24" ) );
    4850    check( testWildcard( "192.64.0.1", "192.64.0.1/32" ) );
    49     check( testWildcard( "+192.*.*.*,-192.64.*.*", "+192.0.0.0/8,-192.64.0.0/16" ) );
     51    check( testWildcard( "+192.*.*.*,-192.64.*.*",
     52                         "+192.0.0.0/8,-192.64.0.0/16" ) );
    5053
    5154    err = tr_rpcTestACL( NULL, "+192.*.*.*", &errmsg );
     
    6467}
    6568
     69static int
     70test_list( void )
     71{
     72    int64_t i;
     73    const char * str;
     74    tr_benc top;
     75
     76    tr_rpc_parse_list_str( &top, "12", -1 );
     77    check( tr_bencIsInt( &top ) );
     78    check( tr_bencGetInt( &top, &i ) );
     79    check( i == 12 );
     80    tr_bencFree( &top );
     81
     82    tr_rpc_parse_list_str( &top, "12", 1 );
     83    check( tr_bencIsInt( &top ) );
     84    check( tr_bencGetInt( &top, &i ) );
     85    check( i == 1 );
     86    tr_bencFree( &top );
     87
     88    tr_rpc_parse_list_str( &top, "6,7", -1 );
     89    check( tr_bencIsList( &top ) );
     90    check( tr_bencListSize( &top ) == 2 );
     91    check( tr_bencGetInt( tr_bencListChild( &top, 0 ), &i ) );
     92    check( i == 6 );
     93    check( tr_bencGetInt( tr_bencListChild( &top, 1 ), &i ) );
     94    check( i == 7 );
     95    tr_bencFree( &top );
     96
     97    tr_rpc_parse_list_str( &top, "asdf", -1 );
     98    check( tr_bencIsString( &top ) );
     99    check( tr_bencGetStr( &top, &str ) );
     100    check( !strcmp( str, "asdf" ) );
     101    tr_bencFree( &top );
     102
     103    tr_rpc_parse_list_str( &top, "1,3-5", -1 );
     104    check( tr_bencIsList( &top ) );
     105    check( tr_bencListSize( &top ) == 4 );
     106    check( tr_bencGetInt( tr_bencListChild( &top, 0 ), &i ) );
     107    check( i == 1 );
     108    check( tr_bencGetInt( tr_bencListChild( &top, 1 ), &i ) );
     109    check( i == 3 );
     110    check( tr_bencGetInt( tr_bencListChild( &top, 2 ), &i ) );
     111    check( i == 4 );
     112    check( tr_bencGetInt( tr_bencListChild( &top, 3 ), &i ) );
     113    check( i == 5 );
     114    tr_bencFree( &top );
     115
     116    return 0;
     117}
     118
    66119int
    67120main( void )
     
    71124    if(( i = test_acl( )))
    72125        return i;
     126    if(( i = test_list( )))
     127        return i;
    73128
    74129    return 0;
  • trunk/libtransmission/rpc.c

    r6346 r6376  
    674674}
    675675
     676static void
     677addToken( tr_benc * list, const char * token, size_t len )
     678{
     679    char * p;
     680    const char * end = token + len;
     681    const long a = strtol( token, &p, 10 );
     682    if( p == end )
     683        tr_bencListAddInt( list, a );
     684    else if( *p == '-' && isdigit(p[1]) ) {
     685        const long b = strtol( p+1, &p, 10 );
     686        if( ( p == end ) && ( b > a ) ) {
     687            long i;
     688            for( i=a; i<=b; ++i )
     689                tr_bencListAddInt( list, i );
     690        }
     691    }
     692}
     693
    676694/**
    677695 * Munge the URI into a usable form.
     
    713731        walk = str;
    714732        while( *walk ) {
    715             char * p;
    716             tr_bencListAddInt( setme, strtol( walk, &p, 10 ) );
     733            const char * p = strchr( walk, ',' );
     734            if( !p )
     735                p = walk + strlen( walk );
     736            addToken( setme, walk, p-walk );
    717737            if( *p!=',' )
    718738                break;
Note: See TracChangeset for help on using the changeset viewer.