Ignore:
Timestamp:
Jul 16, 2008, 11:55:49 PM (14 years ago)
Author:
charles
Message:

(third-party) upgrade shttpd from 1.39 to the latest, 1.41

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/rpc-server.c

    r6343 r6349  
    329329    if( !server->ctx )
    330330    {
    331         char ports[128];
     331        int i;
     332        int argc = 0;
     333        char * argv[100];
    332334        char passwd[MAX_PATH_LENGTH];
    333335        const char * clutchDir = tr_getClutchDir( server->session );
     
    340342            edit_passwords( passwd, MY_REALM, server->username, server->password );
    341343
    342         server->ctx = shttpd_init( );
    343         tr_snprintf( ports, sizeof( ports ), "%d", server->port );
     344        argv[argc++] = tr_strdup( "appname-unused" );
     345        argv[argc++] = tr_strdup( "-ports" );
     346        argv[argc++] = tr_strdup_printf( "%d", server->port );
     347        argv[argc++] = tr_strdup( "-dir_list" );
     348        argv[argc++] = tr_strdup( "0" );
     349        argv[argc++] = tr_strdup( "-auth_realm" );
     350        argv[argc++] = tr_strdup( MY_REALM );
     351        if( server->acl )
     352        {
     353            argv[argc++] = tr_strdup( "-acl" );
     354            argv[argc++] = tr_strdup( server->acl );
     355        }
     356        if( server->isPasswordEnabled )
     357        {
     358            argv[argc++] = tr_strdup( "-protect" );
     359            argv[argc++] = tr_strdup_printf( "/transmission=%s", passwd );
     360        }
     361        if( clutchDir && *clutchDir )
     362        {
     363            tr_inf( _( "Serving the web interface files from \"%s\"" ), clutchDir );
     364            argv[argc++] = tr_strdup( "-aliases" );
     365            argv[argc++] = tr_strdup_printf( "%s=%s,%s=%s",
     366                                             "/transmission/clutch", clutchDir,
     367                                             "/transmission/web", clutchDir );
     368        }
     369
     370        server->ctx = shttpd_init( argc, argv );
    344371        shttpd_register_uri( server->ctx, "/transmission/rpc", handle_rpc, server );
    345372        shttpd_register_uri( server->ctx, "/transmission/upload", handle_upload, server );
    346373
    347         if( clutchDir && *clutchDir ) {
    348             char * clutchAlias = tr_strdup_printf( "%s=%s,%s=%s",
    349                 "/transmission/clutch", clutchDir,
    350                 "/transmission/web", clutchDir );
    351             tr_inf( _( "Serving the web interface files from \"%s\"" ), clutchDir );
    352             shttpd_set_option( server->ctx, "aliases", clutchAlias );
    353             tr_free( clutchAlias );
    354         }
    355 
    356         shttpd_set_option( server->ctx, "ports", ports );
    357         shttpd_set_option( server->ctx, "dir_list", "0" );
    358         //shttpd_set_option( server->ctx, "root", "/dev/null" );
    359         shttpd_set_option( server->ctx, "auth_realm", MY_REALM );
    360         if( server->acl ) {
    361             dbgmsg( "setting acl [%s]", server->acl );
    362             shttpd_set_option( server->ctx, "acl", server->acl );
    363         }
    364         if( server->isPasswordEnabled ) {
    365             char * buf = tr_strdup_printf( "/transmission=%s", passwd );
    366             shttpd_set_option( server->ctx, "protect", buf );
    367             tr_free( buf );
    368         }
    369 
    370374        evtimer_set( &server->timer, rpcPulse, server );
    371375        evtimer_add( &server->timer, &tv );
     376
     377        for( i=0; i<argc; ++i )
     378            tr_free( argv[i] );
    372379    }
    373380}
     
    430437
    431438/*
    432  * DELIM_CHARS, FOR_EACH_WORD_IN_LIST, isbyte, and testACL are from, or modified from,
     439 * FOR_EACH_WORD_IN_LIST, isbyte, and testACL are from, or modified from,
    433440 * shttpd, written by Sergey Lyubka under this license:
    434441 * "THE BEER-WARE LICENSE" (Revision 42):
     
    437444 * this stuff is worth it, you can buy me a beer in return.
    438445 */
    439 
    440 #define  DELIM_CHARS "," /* Separators for lists */
    441446
    442447#define FOR_EACH_WORD_IN_LIST(s,len)                                    \
Note: See TracChangeset for help on using the changeset viewer.