示例#1
0
static
void KNSManagerHttpProxyInit ( KNSManager * self )
{
    const KConfigNode * proxy;
    rc_t rc = KConfigOpenNodeRead ( self -> kfg, & proxy, "http/proxy" );
    if ( rc == 0 )
    {
        const KConfigNode * proxy_path;
        rc = KConfigNodeOpenNodeRead ( proxy, & proxy_path, "path" );
        if ( rc == 0 )
        {
            String * path;
            rc = KConfigNodeReadString ( proxy_path, & path );
            if ( rc == 0 )
            {
                rc = KNSManagerSetHTTPProxyPath ( self, "%S", path );
                if ( rc == 0 )
                {
                    const KConfigNode * proxy_enabled;
                    rc = KConfigNodeOpenNodeRead ( proxy, & proxy_enabled, "enabled" );
                    if ( rc == 0 )
                    {
                        rc = KConfigNodeReadBool ( proxy_enabled, & self -> http_proxy_enabled );
                        KConfigNodeRelease ( proxy_enabled );
                    }
                    else if ( GetRCState ( rc ) == rcNotFound )
                    {
                        rc = 0;
                    }

                    if ( rc != 0 )
                    {
                        KNSManagerSetHTTPProxyPath ( self, NULL );
                        assert ( self -> http_proxy_enabled == false );
                    }
                }

                StringWhack ( path );
            }

            KConfigNodeRelease ( proxy_path );
        }

        KConfigNodeRelease ( proxy );
    }
}
示例#2
0
/* CacheEnabled
 *  discover whether the repository supports caching
 */
LIB_EXPORT bool CC KRepositoryCacheEnabled ( const KRepository *self )
{
    if ( self != NULL )
    {
        const KConfigNode *node;
        rc_t rc = KConfigNodeOpenNodeRead ( self -> node, & node, "cache-enabled" );
        if ( rc == 0 )
        {
            bool enabled = false;
            rc = KConfigNodeReadBool ( node, & enabled );
            KConfigNodeRelease ( node );
            if ( rc == 0 )
                return enabled;
        }
    }

    return false;
}