ClRcT dbalGetLibName(ClCharT  *pLibName)
{
    ClParserPtrT   parent     = NULL ;   /*parent*/
    ClParserPtrT   engineType = NULL ;   /*parser ptr to Component*/
    ClParserPtrT   libName    = NULL ;   /*parser ptr to ckptName*/
    ClParserPtrT   fileName    = NULL ;   /*parser ptr to ckptName*/
    ClRcT          rc         = CL_OK;
    ClCharT       *configPath = NULL;

    configPath = getenv("ASP_CONFIG");
    if (configPath != NULL)
    {
        parent    = clParserOpenFile(configPath, "clDbalConfig.xml");
        if (parent == NULL)
        {
          CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Xml file for config is not proper rc [0x %x]\n",rc));
          return CL_ERR_NULL_POINTER;
        }
    }
    else
    {
        rc = CL_ERR_NULL_POINTER;
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("ASP_CONFIG path is not set in the environment irc[0x %x] \n",rc));
    }
    if(parent != NULL)
    {
       engineType = clParserChild(parent,"Dbal");
       libName    = clParserChild(engineType,"Engine");
       fileName   = clParserChild(libName,"FileName");
    }
    if(fileName != NULL && pLibName != NULL)
      strcpy(pLibName, fileName->txt); 
    if (parent != NULL) clParserFree(parent);
    return rc;
}
static ClRcT clParseInstance(ClParserPtrT node,
                             ClParserDataT *pData,
                             ClPtrT pCurrentBase)
{
    ClRcT rc = CL_OK;
    register ClUint32T i;

    /*
     * First pass: process tags of this instance.
     * Second pass: process children
     *
     */
    rc = clParseTags(node,pData,pCurrentBase);

    CL_PARSER_TAGS_RESULT(pData,rc,out);

    /*
     * Iterate through the children of the parent tag.
    */
    for(i = 0; i < pData->numChild; ++i)
    {
        ClParserDataT *pChild = pData->pTagChildren+i;
        ClParserPtrT child = clParserChild(node,pChild->pTag);
        ClRcT childRc = rc ;
        if(child == NULL)
        {
            /*This could be a conditional child*/
            if(pChild->dontSkip == CL_TRUE)
            {
                clLogError(PARSER_LOG_AREA_PARSER,PARSER_LOG_CTX_CHILD,"Child tag:%s not present when it "\
                                              "was supposed to be\n",
                                              pChild->pTag);
                rc = CL_PARSER_RC(CL_ERR_UNSPECIFIED);
                goto out;
            }
            /*safely skip*/
            continue;
        }
        rc = clParseChild(node,child,pChild,pCurrentBase);
        CL_PARSER_CHILD_RESULT(pChild,rc,out);
        rc = childRc;
    }
    out:
    return rc;
}
ClParserPtrT clParserOpenFileWithVer(const ClCharT *path, 
                                     const ClCharT *file, 
                                     ClVersionT *version)
{
    ClParserPtrT    top  = NULL;
    ClCharT         verStr[CL_MAX_NAME_LENGTH] = {0};
    ClParserPtrT    verTag = NULL;
    ClBoolT         found = 0;
    const ClCharT   *attrVal = NULL;
    ClUint32T       vIndex = 0;
    ClCharT         attrName[CL_MAX_NAME_LENGTH] = {0};

    if (path == NULL || file == NULL || version == NULL)
        return NULL;

    top = clParserOpenFileAllVer(path, file);
    if (top == NULL) goto done;
    
    snprintf(verStr,
             sizeof(verStr),
             "%d.%d.%d",
             version->releaseCode,
             version->majorVersion,
             version->minorVersion);
    
    /* top is pointing to <OpenClovisAsp> tag. Look for the child
     * with given version */
    verTag = clParserChild(top, "version");
    while (verTag != NULL)
    {
        vIndex = 0;
        snprintf(attrName, sizeof(attrName), "v%d",vIndex);
        attrVal = clParserAttr(verTag, attrName);
        while (attrVal != NULL)
        {
            if (!strcmp(attrVal, verStr))
            {
                found = 1;
                break;
            }
            vIndex++;
            snprintf(attrName, sizeof(attrName), "v%d",vIndex);
            attrVal = clParserAttr(verTag, attrName);
        }

        if (found == 1)
            break;

        verTag = verTag->next;
    }

    if (!found)
    {
        clLogWarning(PARSER_LOG_AREA_PARSER,PARSER_LOG_CTX_VERSION,
                     "Could not find the entry for version %s in %s",verStr,file);
        goto done;
    }

    /* Get the attributes and look for version */
    return verTag->child;
done:
    return top;
}