Changeset 5855
- Timestamp:
- May 19, 2008, 6:16:58 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/daemon/remote.c
r5846 r5855 133 133 while((( opt = getopt_long( argc, argv, optstr, longopts, NULL ))) != -1 ) 134 134 { 135 char * req = NULL;136 135 char buf[MAX_PATH_LENGTH]; 136 tr_benc top, *args; 137 tr_bencInitDict( &top, 3 ); 138 args = tr_bencDictAddDict( &top, "args", 0 ); 137 139 138 140 switch( opt ) … … 140 142 case 'g': debug = 1; break; 141 143 case 'h': showUsage( ); break; 142 case 'a': req = tr_strdup_printf( "method=torrent-add&filename=%s", optarg ); break; 143 case 'c': req = tr_strdup_printf( "method=session-set&encryption=%s", optarg ); break; 144 case 'd': req = tr_strdup_printf( "method=session-set&speed-limit-down=%d&speed-limit-down-enabled=1", numarg(optarg) ); break; 145 case 'D': req = tr_strdup( "method=session-set&speed-limit-down-enabled=0" ); break; 146 case 'u': req = tr_strdup_printf( "method=session-set&speed-limit-up=%d&speed-limit-up-enabled:1", numarg(optarg) ); break; 147 case 'U': req = tr_strdup( "method=session-set&speed-limit-up-enabled=0" ); break; 148 case 'e': req = tr_strdup( "method=session-set&pex-allowed=1" ); break; 149 case 'E': req = tr_strdup( "method=session-set&pex-allowed=0" ); break; 150 case 'f': req = tr_strdup_printf( "method=session-set&download-dir=%s", absolutify(buf,sizeof(buf),optarg)); break; 151 case 'l': req = tr_strdup_printf( "method=torrent-list&tag=%d", TAG_LIST ); break; 152 case 'm': req = tr_strdup( "method=session-set&port-forwarding-enabled=1" ); break; 153 case 'M': req = tr_strdup( "method=session-set&port-forwarding-enabled=0" ); break; 154 case 'p': req = tr_strdup_printf( "method=session-set&port=%d", numarg( optarg ) ); break; 155 case 'r': req = strcmp( optarg, "all" ) 156 ? tr_strdup_printf( "method=torrent-remove&ids=%s", optarg ) 157 : tr_strdup ( "method=torrent-remove" ); break; 158 case 's': req = strcmp( optarg, "all" ) 159 ? tr_strdup_printf( "method=torrent-start&ids=%s", optarg ) 160 : tr_strdup ( "method=torrent-start" ); break; 161 case 'S': req = strcmp( optarg, "all" ) 162 ? tr_strdup_printf( "method=torrent-stop&ids=%s", optarg ) 163 : tr_strdup ( "method=torrent-stop" ); break; 164 case 'v': req = strcmp( optarg, "all" ) 165 ? tr_strdup_printf( "method=torrent-verify&ids=%s", optarg ) 166 : tr_strdup ( "method=torrent-verify" ); break; 144 case 'a': tr_bencDictAddStr( &top, "method", "torrent-add" ); 145 tr_bencDictAddStr( args, "filename", optarg ); 146 break; 147 case 'c': tr_bencDictAddStr( &top, "method", "session-set" ); 148 tr_bencDictAddStr( args, "encryption", optarg ); 149 break; 150 case 'd': tr_bencDictAddStr( &top, "method", "session-set" ); 151 tr_bencDictAddInt( args, "speed-limit-down", numarg( optarg ) ); 152 tr_bencDictAddInt( args, "speed-limit-down-enabled", 1 ); 153 break; 154 case 'D': tr_bencDictAddStr( &top, "method", "session-set" ); 155 tr_bencDictAddInt( args, "speed-limit-down-enabled", 0 ); 156 break; 157 case 'u': tr_bencDictAddStr( &top, "method", "session-set" ); 158 tr_bencDictAddInt( args, "speed-limit-up", numarg( optarg ) ); 159 tr_bencDictAddInt( args, "speed-limit-up-enabled", 1 ); 160 break; 161 case 'U': tr_bencDictAddStr( &top, "method", "session-set" ); 162 tr_bencDictAddInt( args, "speed-limit-up-enabled", 0 ); 163 break; 164 case 'e': tr_bencDictAddStr( &top, "method", "session-set" ); 165 tr_bencDictAddInt( args, "pex-allowed", 1 ); 166 break; 167 case 'E': tr_bencDictAddStr( &top, "method", "session-set" ); 168 tr_bencDictAddInt( args, "pex-allowed", 0 ); 169 break; 170 case 'f': tr_bencDictAddStr( &top, "method", "session-set" ); 171 tr_bencDictAddStr( args, "download-dir", absolutify(buf,sizeof(buf),optarg) ); 172 break; 173 case 'l': tr_bencDictAddStr( &top, "method", "torrent-list" ); 174 tr_bencDictAddInt( &top, "tag", TAG_LIST ); 175 break; 176 case 'm': tr_bencDictAddStr( &top, "method", "session-set" ); 177 tr_bencDictAddInt( args, "port-forwarding-enabled", 1 ); 178 break; 179 case 'M': tr_bencDictAddStr( &top, "method", "session-set" ); 180 tr_bencDictAddInt( args, "port-forwarding-enabled", 0 ); 181 break; 182 case 'p': tr_bencDictAddStr( &top, "method", "session-set" ); 183 tr_bencDictAddInt( args, "port", numarg( optarg ) ); 184 break; 185 case 'r': tr_bencDictAddStr( &top, "method", "torrent-remove" ); 186 if( strcmp( optarg, "all" ) ) 187 tr_bencDictAddStr( args, "ids", optarg ); 188 break; 189 case 's': tr_bencDictAddStr( &top, "method", "torrent-start" ); 190 if( strcmp( optarg, "all" ) ) 191 tr_bencDictAddStr( args, "ids", optarg ); 192 break; 193 case 'S': tr_bencDictAddStr( &top, "method", "torrent-stop" ); 194 if( strcmp( optarg, "all" ) ) 195 tr_bencDictAddStr( args, "ids", optarg ); 196 break; 197 case 'v': tr_bencDictAddStr( &top, "method", "torrent-verify" ); 198 if( strcmp( optarg, "all" ) ) 199 tr_bencDictAddStr( args, "ids", optarg ); 200 break; 201 default: 202 showUsage( ); 203 break; 167 204 } 168 205 169 if( req )170 reqs[reqCount++] = req;206 reqs[reqCount++] = tr_bencSaveAsJSON( &top, NULL ); 207 tr_bencFree( &top ); 171 208 } 172 209 } … … 277 314 CURL * curl; 278 315 struct evbuffer * buf = evbuffer_new( ); 316 char * url = tr_strdup_printf( "http://%s:%d/transmission", host, port ); 279 317 280 318 curl = curl_easy_init( ); … … 283 321 curl_easy_setopt( curl, CURLOPT_WRITEFUNCTION, writeFunc ); 284 322 curl_easy_setopt( curl, CURLOPT_WRITEDATA, buf ); 323 curl_easy_setopt( curl, CURLOPT_POST, 1 ); 324 curl_easy_setopt( curl, CURLOPT_URL, url ); 285 325 286 326 for( i=0; i<reqCount; ++i ) 287 327 { 288 328 CURLcode res; 289 char * url = tr_strdup_printf( "http://%s:%d/transmission?%s", 290 host, port, reqs[i] ); 291 curl_easy_setopt( curl, CURLOPT_URL, url ); 329 curl_easy_setopt( curl, CURLOPT_POSTFIELDS, reqs[i] ); 292 330 if(( res = curl_easy_perform( curl ))) 293 331 tr_nerr( MY_NAME, "%s\n", curl_easy_strerror( res ) ); … … 296 334 297 335 evbuffer_drain( buf, EVBUFFER_LENGTH( buf ) ); 298 tr_free( url );299 336 } 300 337 301 338 /* cleanup */ 339 tr_free( url ); 302 340 evbuffer_free( buf ); 303 341 curl_easy_cleanup( curl ); … … 327 365 tr_free( reqs[i] ); 328 366 367 tr_free( host ); 329 368 return 0; 330 369 } -
trunk/daemon/transmission-remote.1
r5843 r5855 193 193 .Pp 194 194 .Dl transmission-remote -x -i ssh jade transmission-proxy 195 195 196 .Sh AUTHORS 196 197 .An -nosplit 197 The198 .Nm199 program was written by200 198 .An Charles Kerr , 201 199 .An Josh Elsasser , … … 203 201 and 204 202 .An Mitchell Livingston . 203 205 204 .Sh SEE ALSO 206 205 .Xr transmissioncli 1 , 207 206 .Xr transmission-daemon 1 , 208 207 .Xr transmission 1 208 209 209 .Pp 210 210 http://www.transmissionbt.com/ -
trunk/libtransmission/rpc-server.c
r5847 r5855 57 57 evbuffer_add( s->in, arg->in.buf, arg->in.len ); 58 58 arg->in.num_bytes = arg->in.len; 59 60 if( ! ( arg->flags & SHTTPD_MORE_POST_DATA ) ) 59 if( arg->flags & SHTTPD_MORE_POST_DATA ) 61 60 return; 62 response = tr_rpc_request_exec_ uri( s->session,63 EVBUFFER_DATA( s->in ),64 EVBUFFER_LENGTH( s->in ),65 &len );61 response = tr_rpc_request_exec_json( s->session, 62 EVBUFFER_DATA( s->in ), 63 EVBUFFER_LENGTH( s->in ), 64 &len ); 66 65 evbuffer_drain( s->in, EVBUFFER_LENGTH( s->in ) ); 67 66 } … … 207 206 evbuffer_free( s->in ); 208 207 evbuffer_free( s->out ); 208 tr_free( s->acl ); 209 209 tr_free( s ); 210 210 } -
trunk/libtransmission/session.c
r5843 r5855 475 475 tr_free( h->resumeDir ); 476 476 tr_free( h->torrentDir ); 477 tr_free( h->downloadDir ); 477 478 free( h ); 478 479 } -
trunk/libtransmission/utils.h
r5843 r5855 56 56 #else 57 57 #define TR_GNUC_PRINTF( fmt, args ) 58 #endif59 #endif60 61 #ifndef TR_GNUC_NULL_TERMINATED62 #if __GNUC__ >= 463 #define TR_GNUC_NULL_TERMINATED __attribute__((__sentinel__))64 #else65 #define TR_GNUC_NULL_TERMINATED66 58 #endif 67 59 #endif
Note: See TracChangeset
for help on using the changeset viewer.