Exemplo n.º 1
0
static
bool map_typename ( const ctx_t *ctx, const char *sub_node, const char *in, char *out, char *schema_src, size_t size )
{
    FUNC_ENTRY ( ctx );

    rc_t rc;
    const KConfigNode *n;
    size_t num_read, remaining;

    typename_to_config_path ( in, out );

    rc = KConfigOpenNodeRead ( ctx -> caps -> cfg, & n, "sra-sort/%s/%s", sub_node, out );
    if ( rc != 0 )
        return map_typename_builtin ( ctx, sub_node, in, out, schema_src, size );

    rc = KConfigNodeRead ( n, 0, out, size - 1, & num_read, & remaining );
    if ( rc != 0 )
        ERROR ( rc, "KConfigNodeRead failed" );
    else if ( remaining != 0 )
    {
        rc = RC ( rcExe, rcNode, rcReading, rcBuffer, rcInsufficient );
        ERROR ( rc, "type map of '%s' is too long", in );
    }
    else
    {
        out [ num_read ] = 0;
        typename_to_config_path ( out, schema_src );

        KConfigNodeRelease ( n );
        rc = KConfigOpenNodeRead ( ctx -> caps -> cfg, & n, "sra-sort/schema-src/%s", schema_src );
        if ( rc != 0 )
            ERROR ( rc, "KConfigOpenNodeRead - failed to find entry 'sra-sort/schema-src/%s'", schema_src );
        else
        {
            rc = KConfigNodeRead ( n, 0, schema_src, size - 1, & num_read, & remaining );
            if ( rc != 0 )
                ERROR ( rc, "KConfigNodeRead failed" );
            else if ( remaining != 0 )
            {
                rc = RC ( rcExe, rcNode, rcReading, rcBuffer, rcInsufficient );
                ERROR ( rc, "type map of '%s' is too long", in );
            }
            else
            {
                schema_src [ num_read ] = 0;
            }
        }
    }

    KConfigNodeRelease ( n );
    return true;
}
Exemplo n.º 2
0
/* RemoteRepositories
 *  retrieve all remote repositories in a Vector
 */
LIB_EXPORT rc_t CC KRepositoryMgrRemoteRepositories ( const KRepositoryMgr *self,
    KRepositoryVector *remote_repositories )
{
    rc_t rc;

    if ( remote_repositories == NULL )
        rc = RC ( rcKFG, rcMgr, rcAccessing, rcParam, rcNull );
    else
    {
        VectorInit ( remote_repositories, 0, 8 );

        if ( self == NULL )
            rc = RC ( rcKFG, rcMgr, rcAccessing, rcSelf, rcNull );
        else
        {
            const KConfig *kfg = KRepositoryMgrGetROKConfig ( self );

            const KConfigNode *remote;
            rc = KConfigOpenNodeRead ( kfg, & remote, "/repository/remote" );
            if ( rc == 0 )
            {
                rc = KRepositoryMgrCategoryRepositories ( remote, krepRemoteCategory, remote_repositories );
                KConfigNodeRelease ( remote );
                if ( rc == 0 )
                    VectorReorder ( remote_repositories, KRepositorySort, NULL );
            }

            if ( rc != 0 )
                KRepositoryVectorWhack ( remote_repositories );
        }
    }

    return rc;
}
Exemplo n.º 3
0
/* Config
 *  configure an existing path manager
 */
static
rc_t SRAPathConfigValue ( const KConfig *kfg, const char *node_path,
    char *value, size_t value_size, const char *dflt )
{
    const KConfigNode *node;
    rc_t rc = KConfigOpenNodeRead ( kfg, & node, node_path );
    if ( rc == 0 )
    {
        size_t num_read, remaining;
        rc = KConfigNodeRead ( node, 0, value, value_size - 1, & num_read,  & remaining );
        if ( rc == 0 )
        {
            if ( remaining != 0 )
                rc = RC ( rcSRA, rcMgr, rcConstructing, rcString, rcExcessive );
            else
                value [ num_read ] = 0;
        }

        KConfigNodeRelease ( node );
    }

    if ( rc != 0 )
    {
        if ( dflt != NULL && dflt [ 0 ] != 0 )
        {
            size_t num_read = string_copy_measure ( value, value_size, dflt );
            rc = 0;
            if ( num_read == value_size )
                rc = RC ( rcSRA, rcMgr, rcConstructing, rcString, rcExcessive );
        }
        else
	    	value[0] = 0;     
    }
    return rc;
}
Exemplo n.º 4
0
/* UserRepositories
 *  retrieve all user repositories in a Vector
 */
LIB_EXPORT rc_t CC KRepositoryMgrUserRepositories ( const KRepositoryMgr *self,
    KRepositoryVector *user_repositories )
{
    rc_t rc;

    if ( user_repositories == NULL )
        rc = RC ( rcKFG, rcMgr, rcAccessing, rcParam, rcNull );
    else
    {
        VectorInit ( user_repositories, 0, 8 );

        if ( self == NULL )
            rc = RC ( rcKFG, rcMgr, rcAccessing, rcSelf, rcNull );
        else
        {
            const KConfig *kfg = KRepositoryMgrGetROKConfig ( self );

            const KConfigNode *user;
            rc = KConfigOpenNodeRead ( kfg, & user, "/repository/user" );
            if ( rc == 0 )
            {
                rc = KRepositoryMgrCategoryRepositories ( user, krepUserCategory, user_repositories );
                KConfigNodeRelease ( user );
                if ( rc == 0 )
                    VectorReorder ( user_repositories, KRepositorySort, NULL );
            }

            if ( rc != 0 )
                KRepositoryVectorWhack ( user_repositories );
        }
    }

    return rc;
}
Exemplo n.º 5
0
static bool KNSProxiesHttpProxyInitFromKfg ( KNSProxies * self,
                                             const KConfig * kfg )
{
    bool fromKfg = false;

    const KConfigNode * proxy;
    rc_t rc = KConfigOpenNodeRead ( 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 ) {
                DBGMSG ( DBG_KNS, DBG_FLAG ( DBG_KNS_PROXY ),
                    ( "Loading proxy '%S' from configuration\n", path ) );
                rc = KNSProxiesAddHTTPProxyPath ( self, "%S", path );
                if ( rc == 0 )
                    fromKfg = true;

                StringWhack ( path );
            }

            KConfigNodeRelease ( proxy_path );
        }

        KConfigNodeRelease ( proxy );
    }

    return fromKfg;
}
Exemplo n.º 6
0
static
rc_t ConfigRepoSet(DLList* repos, KConfig * kfg, const char* kfgPath, const char *dflt, uint8_t type)
{
    const KConfigNode *node;

    rc_t rc = KConfigOpenNodeRead ( kfg, & node, kfgPath );
    if ( rc == 0 )
    {
        KNamelist* children;
        rc = KConfigNodeListChild ( node, &children );
        if ( rc == 0 )
        {
            uint32_t count;
            rc = KNamelistCount ( children, &count );
            if ( rc == 0 )
            {
                uint32_t i;
                for (i = 0; i < count; ++i)
                {
                    const char* name;
                    rc = KNamelistGet ( children, i, &name );
                    if ( rc == 0 )
                    {
                        #define BufSize 4096
                        char buf[ BufSize ];
                        size_t bSize = string_size(kfgPath);
                        string_copy(buf, BufSize, kfgPath, bSize);
                        if (bSize + string_size(name) < sizeof(buf))
                        {
                            NCBIRepository* repo;
                            string_copy(buf + bSize, sizeof(buf) - bSize, name, string_size(name) + 1);
                            rc = ConfigRepo( kfg, dflt, buf, buf, type, &repo );
                            DLListPushTail( repos, (DLNode*) repo );
                        }
                        #undef BufSize
                    }
                    else
                    {
                        rc = RC ( rcSRA, rcMgr, rcConstructing, rcString, rcExcessive );
                    }
                    if ( rc != 0 )
                    {
                        break;
                    }
                }
            }
            KNamelistRelease ( children );
        }

        KConfigNodeRelease ( node );
    }
    if (GetRCState(rc) == rcNotFound)
    {
        return 0;
    }
    return rc;
}
Exemplo n.º 7
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 );
    }
}
Exemplo n.º 8
0
static
uint64_t KConfigGetNodeU64 ( const ctx_t *ctx, const char *path, bool *found )
{
    rc_t rc;
    uint64_t val = 0;
    const KConfigNode *n;

    bool dummy;
    if ( found == NULL )
        found = & dummy;

    rc = KConfigOpenNodeRead ( ctx -> caps -> cfg, & n, "sra-sort/map_file_bsize" );
    if ( rc == 0 )
    {
        char buff [ 256 ];
        size_t num_read, remaining;

        rc = KConfigNodeRead ( n, 0, buff, sizeof buff - 1, & num_read, & remaining );
        if ( rc != 0 )
            ERROR ( rc, "failed to read KConfig node '%s'", path );
        else if ( remaining != 0 )
        {
            rc = RC ( rcExe, rcNode, rcReading, rcBuffer, rcInsufficient );
            ERROR ( rc, "failed to read KConfig node '%s'", path );
        }
        else
        {
            char *end;
            buff [ num_read ] = 0;
            val = strtou64 ( buff, & end, 0 );
            if ( end [ 0 ] != 0 )
            {
                rc = RC ( rcExe, rcNode, rcReading, rcNumeral, rcIncorrect );
                ERROR ( rc, "bad '%s' config value: '%s'", path, buff );
            }
        }

        KConfigNodeRelease ( n );
    }

    return val;
}
Exemplo n.º 9
0
static rc_t check_if_schema_exists( KDirectory * dir, const char * schema_name )
{
    KConfig * cfg;
    rc_t rc = KConfigMake ( &cfg, NULL );
    if ( rc != 0 )
    {
        LOGERR( klogErr, rc, "check_if_schema_exists:KConfigMake() failed" );
    }
    else
    {
        const KConfigNode *node;
        rc = KConfigOpenNodeRead ( cfg, &node, "vdb/schema/paths" );
        if ( rc !=  0 )
        {
            LOGERR( klogErr, rc, "check_if_schema_exists:KConfigOpenNodeRead( 'vdb/schema/paths' ) failed" );
        }
        else
        {
            char buffer[ 1024 ];
            size_t num_read;
            rc = KConfigNodeRead ( node, 0, buffer, sizeof buffer, &num_read, NULL );
            if ( rc != 0 )
            {
                LOGERR( klogErr, rc, "check_if_schema_exists:KConfigNodeRead() failed" );
            }
            else
            {
                uint32_t path_type;
                buffer[ num_read ] = 0;
                path_type = KDirectoryPathType ( dir, "%s/%s", buffer, schema_name );
                if ( ( path_type & kptFile ) == 0 )
                {
                    rc = RC( rcExe, rcFile, rcConstructing, rcParam, rcInvalid );
                }
            }
            KConfigNodeRelease ( node );
        }
        KConfigRelease ( cfg );
    }
    return rc;
}
Exemplo n.º 10
0
static
rc_t RefSeqMgr_ConfigValue ( const KConfig *kfg, const char *node_path, char *value, size_t value_size )
{
    const KConfigNode *node;
    rc_t rc = KConfigOpenNodeRead ( kfg, & node, "%s", node_path );
    if ( rc == 0 )
    {
        size_t num_read, remaining;
        rc = KConfigNodeRead ( node, 0, value, value_size - 1, & num_read,  & remaining );
        if ( rc == 0 )
        {
            if ( remaining != 0 )
                rc = RC ( rcSRA, rcMgr, rcConstructing, rcString, rcExcessive );
            else
                value [ num_read ] = 0;
        }
        
        KConfigNodeRelease ( node );
    }
    return rc;
}
Exemplo n.º 11
0
static
void check_env ( const KConfig *self, char *path, size_t path_size )
{
    size_t num_read;
    const char *home;
    
    const KConfigNode *home_node;
    
    /* Check to see if home node exists */
    rc_t rc = KConfigOpenNodeRead ( self, &home_node, "HOME" );
    if ( home_node == NULL )
    {
        /* just grab the HOME env variable */
        home = getenv ( "HOME" );
        if ( home != NULL )
        {
            num_read = string_copy_measure ( path, path_size, home );
            if ( num_read >= path_size )
                path [ 0 ] = 0;
        }
    }
    else
    {
        /* if it exists check for a path */
        rc = KConfigNodeRead ( home_node, 0, path, path_size, &num_read, NULL );
        if ( rc != 0 )
        {
            home = getenv ( "HOME" );
            if ( home != NULL )
            {
                num_read = string_copy_measure ( path, path_size, home );
                if ( num_read >= path_size )
                    path [ 0 ] = 0;
            }

        }
        
        rc = KConfigNodeRelease ( home_node );
    }
}
Exemplo n.º 12
0
static
rc_t RefSeqMgr_KfgReadStr(const KConfig* kfg, const char* path, char* value, size_t value_sz)
{
    rc_t rc = 0;
    const KConfigNode *node;
    
    if ( (rc = KConfigOpenNodeRead(kfg, &node, "%s", path)) == 0 ) {
        size_t num_read, remaining;
        if( (rc = KConfigNodeRead(node, 0, value, value_sz - 1, &num_read, &remaining)) == 0 ) {
            if( remaining != 0 ) {
                rc = RC(rcAlign, rcIndex, rcConstructing, rcString, rcTooLong);
            } else {
                value[num_read] = '\0';
            }
        }
        KConfigNodeRelease(node);
    } else if( GetRCState(rc) == rcNotFound ) {
        rc = 0;
        value[0] = '\0';
    }
    return rc;
}
Exemplo n.º 13
0
static rc_t ShowConfig(const KConfig* cfg, Params* prm) {
    rc_t rc = 0;
    bool hasAny = false;
    bool hasQuery = false;
    bool xml = true;
    assert(cfg && prm);
    xml = prm->xml;
    while (rc == 0) {
        KNamelist* names = NULL;
        const KConfigNode* node = NULL;
        uint32_t count = 0;
        uint32_t i = 0;
        int indent = 0;
        const char* root = NULL;
        const char* nodeName = NULL;
        size_t nodeNameL = 1;
        rc = ParamsGetNextParam(prm, &root);
        if (rc == 0) {
            if (root == NULL) {
                if (hasQuery)
                {   break; }
                else
                {   root = "/"; }
            }
            else { hasQuery = true; }
            assert(root);
        }
        if (rc == 0) {
            int64_t len = strlen(root);
            assert(len > 0);
            while (len > 0) {
                if (root[len - 1] == '/')
                {   --len; }
                else { break; }
            }
            assert(len >= 0);
            if (len == 0) {
                root += strlen(root) - 1;
                nodeName = root;
            }
            else {
                char *c = memrchr(root, '/', len);
                if (c != NULL) {
                    nodeName = c + 1;
                }
                else {
                    nodeName = root;
                }
            }
            assert(nodeName && nodeName[0]);
            nodeNameL = strlen(nodeName);
            while (nodeNameL > 1 && nodeName[nodeNameL - 1] == '/')
            {   --nodeNameL; }
        }

        if (rc == 0) {
            rc = KConfigOpenNodeRead(cfg, &node, root);
            DISP_RC(rc, root);
        }
        if (rc == 0) {
            rc = KConfigNodeListChild(node, &names);
        }
        if (rc == 0) {
            rc = KNamelistCount(names, &count);
        }
        if (rc == 0 && count == 0) {
            char buf[512] = "";
            size_t num_read = 0;
            rc = KConfigNodeReadData(node, buf, sizeof buf, &num_read);
            if (rc == 0 && num_read > 0) {
                if (prm->showMultiple)
                {   OUTMSG(("<!-- Configuration node %s -->\n", root)); }
                if (xml) {
                    VDB_CONGIG_OUTMSG(("<%.*s>", nodeNameL, nodeName));
                    VDB_CONGIG_OUTMSG(("%.*s", (int)num_read, buf));
                    VDB_CONGIG_OUTMSG(("</%.*s>\n", nodeNameL, nodeName));
                }
                else {
                    OUTMSG(("%.*s = \"%.*s\"\n",
                        nodeNameL, nodeName, (int)num_read, buf));
                }
                hasAny = true;
            }
        }
        else {
            if (rc == 0) {
                if (nodeName[0] != '/') {
                    if (prm->showMultiple)
                    {   OUTMSG(("<!-- Configuration node %s -->\n", root)); }
                    VDB_CONGIG_OUTMSG(("<%.*s>\n", nodeNameL, nodeName));
                } else {
                    if (prm->showMultiple)
                    {   OUTMSG(("<!-- Current configuration -->\n")); }
                    VDB_CONGIG_OUTMSG(("<Config>\n"));
                }
                hasAny = true;
                ++indent;
            }
            for (i = 0; i < count && rc == 0; ++i) {
                const char* name = NULL;
                if (rc == 0)
                {   rc = KNamelistGet(names, i, &name); }
                if (rc == 0) {
                    char* fullname = NULL;
                    if (strcmp(root, "/") == 0) {
                        fullname = malloc(strlen(name) + 2);
                        if (fullname == NULL) {
                            rc = RC(rcExe,
                                rcStorage, rcAllocating, rcMemory, rcExhausted);
                        }
                        sprintf(fullname, "/%s", name);
                    }
                    else {
                        fullname = strdup(root);
                        if (fullname == NULL) {
                            rc = RC(rcExe,
                                rcStorage, rcAllocating, rcMemory, rcExhausted);
                        }
                    }
                    if (rc == 0) {
                        rc = KConfigNodePrintChildNames
                            (xml, node, name, indent, fullname);
                        hasAny = true;
                    }
                    free(fullname);
                    fullname = NULL;
                }
            }
            if (rc == 0) {
                if (nodeName[0] != '/') {
                    VDB_CONGIG_OUTMSG(("</%.*s>\n", nodeNameL, nodeName));
                }
                else {
                    VDB_CONGIG_OUTMSG(("</Config>\n"));
                }
            }
        }

        RELEASE(KConfigNode, node);
        RELEASE(KNamelist, names);

        if (rc == 0) {
            if (hasAny) {
                OUTMSG(("\n"));
            }
            else if (nodeNameL > 0 && nodeName != NULL) {
                VDB_CONGIG_OUTMSG(("<%.*s/>\n", nodeNameL, nodeName));
            }
        }

        if (!hasQuery)
        {   break; }
    }

    return rc;
}
Exemplo n.º 14
0
static rc_t ShowModules(const KConfig* cfg, const Params* prm) {
    rc_t rc = 0;
#ifdef _STATIC
    OUTMSG(("<!-- Modules are not used in static build -->\n"));
#else
    const VDBManager* mgr = NULL;
    KNamelist* list = NULL;
    OUTMSG(("<!-- Modules -->\n"));
    rc = VDBManagerMakeRead(&mgr, NULL);
    DISP_RC(rc, "while calling VDBManagerMakeRead");
    if (rc == 0) {
        rc = VDBManagerListExternalSchemaModules(mgr, &list);
        DISP_RC(rc, "while calling VDBManagerListExternalSchemaModules");
    }
    if (rc == 0) {
        uint32_t count = 0;
        rc = KNamelistCount(list, &count);
        DISP_RC(rc, "while calling KNamelistCount "
            "on VDBManagerListExternalSchemaModules result");
        if (rc == 0) {
            int64_t i = 0;
            for (i = 0; i < count && rc == 0; ++i) {
                const char* name = NULL;
                rc = KNamelistGet(list, i, &name);
                DISP_RC(rc, "while calling KNamelistGet "
                    "on VDBManagerListExternalSchemaModules result");
                if (rc == 0) {
                    OUTMSG(("%s\n", name));
                }
            }
        }
    }
    OUTMSG(("\n"));
    RELEASE(KNamelist, list);
    RELEASE(VDBManager, mgr);
#endif
#if 0
    KDirectory* dir = NULL;
    const char* paths[] = { "vdb/module/paths", "vdb/wmodule/paths" };
    int i = 0;
    assert(cfg);
    for (i = 0; i < sizeof paths / sizeof paths[0] && rc == 0; ++i) {
        const KConfigNode* node = NULL;
        if (rc == 0) {
            const char* path = paths[i];
            rc = KConfigOpenNodeRead(cfg, &node, path);
            if (rc != 0) {
                if (GetRCState(rc) == rcNotFound) {
                    rc = 0;
                    continue;
                }
                else {  DISP_RC(rc, path); }
            }
            else {
                char buf[PATH_MAX + 1];
                size_t num_read = 0;
                size_t remaining = 0;
                rc = KConfigNodeRead(node, 0,
                    buf, sizeof buf, &num_read, &remaining);
                assert(remaining == 0);
                assert(num_read <= sizeof buf);
                DISP_RC(rc, path);
                if (rc == 0) {
                    if (num_read < sizeof buf) {
                        buf[num_read] = '\0';
                        if (dir == NULL)
                        {   rc = KDirectoryNativeDir(&dir); }
                        if (rc == 0) {
                            OUTMSG(("%s = %s\n", path, buf));
                            rc = ShowModDir(dir, buf);
                            if (rc == 0)
                            {   OUTMSG(("\n")); }
                        }
                    }
                }
            }
            RELEASE(KConfigNode, node);
        }
    }
    RELEASE(KDirectory, dir);
#endif
    return rc;
}
Exemplo n.º 15
0
static
rc_t RefSeqMgr_KfgReadRepositories(const KConfig* kfg, char* paths, size_t paths_sz)
{
    /* servers are children of refseq/repository, e.g.:             /refseq/repository/main="..." */
    /* volumes are in refseq/repository/<serverName>/volumes, e.g.: /refseq/repository/main/volumes="..." */
    /* all server/volume combinations are returned in paths separated by ':' */
    
    rc_t rc = 0;
    const KConfigNode *node;
#define KFG_PATH "/refseq/repository/"
    paths[0] = 0;
    
    rc = KConfigOpenNodeRead ( kfg, & node, KFG_PATH );
    if ( rc == 0 )
    {
        KNamelist* children;
        rc = KConfigNodeListChild ( node, &children );
        if ( rc == 0 )
        {
            uint32_t count;
            rc = KNamelistCount ( children, &count );
            if ( rc == 0 )
            {
                uint32_t i;
                for (i = 0; i < count; ++i) /* for all servers */
                {
                    const char* name;
                    rc = KNamelistGet ( children, i, &name );
                    if ( rc == 0 )
                    {
#define BufSize 4096
                        char server[ BufSize ];
                        char buf[ BufSize ];
                        size_t num_writ;
                        
                        rc = string_printf(buf, BufSize, &num_writ, KFG_PATH "%s", name);
                        if (rc == 0)
                        {
                            rc = RefSeqMgr_ConfigValue ( kfg, buf, server, sizeof(server) );
                            if (rc == 0)
                            {
                                rc = string_printf(buf, BufSize, &num_writ, KFG_PATH "%s/volumes", name);
                                if (rc == 0)
                                {
                                    char volumes[ BufSize ];
                                    rc = RefSeqMgr_ConfigValue ( kfg, buf, volumes, sizeof(volumes) );
                                    if (rc == 0)
                                    {   /* create a server/volume pair for every combination, append to paths, ':' - separate */
                                        char *vol_rem = volumes;
                                        char *vol_sep;
                                        
                                        do {
                                            char const *volume = vol_rem;
                                            vol_sep = string_chr(volume, string_size(volume), ':');
                                            if(vol_sep) {
                                                vol_rem = vol_sep + 1;
                                                *vol_sep = 0;
                                            }
                                            string_copy(paths + string_size(paths), paths_sz - string_size(paths), server, string_size(server));
                                            if (paths[string_size(paths)-1] != '/')
                                            {
                                                string_copy(paths + string_size(paths), paths_sz - string_size(paths), "/", 1);
                                            }
                                            string_copy(paths + string_size(paths), paths_sz - string_size(paths), volume, string_size(volume));
                                            string_copy(paths + string_size(paths), paths_sz - string_size(paths), ":", 1);
                                        } while(vol_sep);
                                    }
                                }
                            }
                        }
#undef BufSize
                    }
                    if ( rc != 0 )
                    {
                        break;
                    }
                }
            }
            KNamelistRelease ( children );
        }
        
        KConfigNodeRelease ( node );
    }
    if (GetRCState(rc) == rcNotFound)
    {
        paths[0] = '\0';
        return 0;
    }
    return 0;
}
Exemplo n.º 16
0
static
void KNSManagerLoadAWS ( struct KNSManager *self )
{
    rc_t rc;

    const KConfigNode *aws_node;
    const KConfig *kfg = self -> kfg;

    if ( self == NULL )
        return;

    rc = KConfigOpenNodeRead ( kfg, &aws_node, "AWS" );
    if ( rc == 0 )
    {
        do
        {
            String *access_key_id = NULL, *secret_access_key = NULL, *region = NULL, *output = NULL;
            const KConfigNode *access_key_id_node, *secret_access_key_node, *region_node, *output_node;

            rc = KConfigNodeOpenNodeRead ( aws_node, &access_key_id_node, "aws_access_key_id" );
            if ( rc == 0 )
            {
                rc = KConfigNodeReadString ( access_key_id_node, &access_key_id );

                KConfigNodeRelease ( access_key_id_node );

                if( rc != 0 )
                    break;
            }


            rc = KConfigNodeOpenNodeRead ( aws_node, &secret_access_key_node, "aws_secret_access_key" );
            if ( rc == 0 )
            {
                rc = KConfigNodeReadString ( secret_access_key_node, &secret_access_key );

                KConfigNodeRelease ( secret_access_key_node );

                if ( rc != 0 )
                    break;
            }
        
            rc = KConfigNodeOpenNodeRead ( aws_node, &region_node, "region" );
            if ( rc == 0 )
            {
                rc = KConfigNodeReadString ( region_node, &region );

                KConfigNodeRelease ( region_node );

                if ( rc != 0 )
                    break;
            }

            rc = KConfigNodeOpenNodeRead ( aws_node, &output_node, "output" );
            if ( rc == 0 )
            {
                rc = KConfigNodeReadString ( output_node, &output );

                KConfigNodeRelease ( output_node );
                
                if ( rc != 0 )
                    break;
            }

            self -> aws_access_key_id = access_key_id;
            self -> aws_secret_access_key = secret_access_key;
            self -> aws_region = region;
            self -> aws_output = output;

        } while ( 0 );

        KConfigNodeRelease ( aws_node );
    }
}