Exemplo n.º 1
0
/********************************************************************
* FUNCTION grp_free_template
* 
* Scrub the memory in a grp_template_t by freeing all
* the sub-fields and then freeing the entire struct itself 
* The struct must be removed from any queue it is in before
* this function is called.
*
* INPUTS:
*    grp == grp_template_t data structure to free
*********************************************************************/
void 
    grp_free_template (grp_template_t *grp)
{
#ifdef DEBUG
    if (!grp) {
        SET_ERROR(ERR_INTERNAL_PTR);
        return;
    }
#endif

    if (grp->name) {
        m__free(grp->name);
    }
    if (grp->descr) {
        m__free(grp->descr);
    }
    if (grp->ref) {
        m__free(grp->ref);
    }

    typ_clean_typeQ(&grp->typedefQ);
    grp_clean_groupingQ(&grp->groupingQ);
    obj_clean_datadefQ(&grp->datadefQ);
    ncx_clean_appinfoQ(&grp->appinfoQ);
    m__free(grp);

}  /* grp_free_template */
Exemplo n.º 2
0
/********************************************************************
* FUNCTION ncx_free_feature
* 
* Free a malloced ncx_feature_t struct
*
* INPUTS:
*    feature == struct to free
*
*********************************************************************/
void 
    ncx_free_feature (ncx_feature_t *feature)
{

#ifdef DEBUG
    if (!feature) {
        SET_ERROR(ERR_INTERNAL_PTR);
        return;
    }
#endif

    if (feature->name) {
        m__free(feature->name);
    }

    if (feature->descr) {
        m__free(feature->descr);
    }

    if (feature->ref) {
        m__free(feature->ref);
    }

    ncx_clean_iffeatureQ(&feature->iffeatureQ);

    ncx_clean_appinfoQ(&feature->appinfoQ);

    m__free(feature);
    
} /* ncx_free_feature */
Exemplo n.º 3
0
/********************************************************************
* FUNCTION consume_yang_arg
* 
* Parse the next N tokens as an argument-stmt
* Fill in the arg anf argel fields in the ext_template_t struct
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* Current token is the 'argument' keyword
*
* INPUTS:
*   tkc == token chain
*   mod == module in progress
*   ext == extension template in progress
*   argdone == address of duplicate entry error flag
*
* OUTPUTS:
*   *argdone == TRUE upon exit
*
* RETURNS:
*   status of the operation
*********************************************************************/
static status_t 
    consume_yang_arg (tk_chain_t *tkc,
                      ncx_module_t  *mod,
                      ext_template_t *ext,
                      boolean *argdone)
{
    const xmlChar   *val;
    const char      *expstr;
    xmlChar         *errstr;
    dlq_hdr_t        errQ;
    tk_type_t        tktyp;
    boolean          done, yinel, save, errsave;
    status_t         res, retres;

#ifdef DEBUG
    if (!tkc || !mod) {
        return SET_ERROR(ERR_INTERNAL_PTR);
    }
#endif

    val = NULL;
    expstr = NULL;
    done = FALSE;
    yinel = FALSE;
    save = TRUE;
    res = NO_ERR;
    retres = NO_ERR;
    dlq_createSQue(&errQ);

    /* check duplicate entry error first */
    if (*argdone) {
        retres = ERR_NCX_ENTRY_EXISTS;
        ncx_print_errormsg(tkc, mod, retres);
        save = FALSE;
    } else {
        *argdone = TRUE;
    }

    /* Get the mandatory argument name */
    if (save) {
        res = yang_consume_id_string(tkc, mod, &ext->arg);
    } else {
        errstr = NULL;
        res = yang_consume_id_string(tkc, mod, &errstr);
        if (errstr) {
            m__free(errstr);
        }
    }
    CHK_EXIT(res, retres);

    /* Get the starting left brace for the sub-clauses
     * or a semi-colon to end the extension-stmt
     */
    res = TK_ADV(tkc);
    if (res != NO_ERR) {
        ncx_print_errormsg(tkc, mod, res);
        return res;
    }
    switch (TK_CUR_TYP(tkc)) {
    case TK_TT_SEMICOL:
        done = TRUE;
        break;
    case TK_TT_LBRACE:
        break;
    default:
        retres = ERR_NCX_WRONG_TKTYPE;
        expstr = "semi-colon or left brace";
        ncx_mod_exp_err(tkc, mod, retres, expstr);
        done = TRUE;
    }

    /* get the extension statements and any appinfo extensions */
    while (!done) {
        /* get the next token */
        res = TK_ADV(tkc);
        if (res != NO_ERR) {
            ncx_print_errormsg(tkc, mod, res);
            return res;
        }

        tktyp = TK_CUR_TYP(tkc);
        val = TK_CUR_VAL(tkc);

        /* check the current token type */
        switch (tktyp) {
        case TK_TT_NONE:
            res = ERR_NCX_EOF;
            ncx_print_errormsg(tkc, mod, res);
            return res;
        case TK_TT_MSTRING:
            /* vendor-specific clause found instead */
            if (save) {
                res = ncx_consume_appinfo(tkc, mod, &ext->appinfoQ);
            } else {
                res = ncx_consume_appinfo(tkc, mod, &errQ);
                ncx_clean_appinfoQ(&errQ);
            }
            CHK_EXIT(res, retres);
            continue;
        case TK_TT_RBRACE:
            done = TRUE;
            continue;
        case TK_TT_TSTRING:
            break;  /* YANG clause assumed */
        default:
            retres = ERR_NCX_WRONG_TKTYPE;
            ncx_mod_exp_err(tkc, mod, retres, expstr);
            continue;
        }

        /* Got a token string so check the value */
        if (!xml_strcmp(val, YANG_K_YIN_ELEMENT)) {
            if (save) {
                res = yang_consume_boolean(tkc, 
                                           mod, 
                                           &ext->argel,
                                           &yinel, 
                                           &ext->appinfoQ);
            } else {
                res = yang_consume_boolean(tkc, 
                                           mod, 
                                           &errsave,
                                           NULL, 
                                           NULL);
            }
        } else {
            res = ERR_NCX_WRONG_TKVAL;
            ncx_mod_exp_err(tkc, mod, res, expstr);
        }
        CHK_EXIT(res, retres);
    }

    return retres;

}  /* consume_yang_arg */