Esempio n. 1
0
static c_bool
getAttribute(
    c_object o,
    c_voidp arg)
{
    struct getAttributeArg *a = (struct getAttributeArg *)arg;
    c_bool result;

    assert(a != NULL);

    if (strcmp(v_cfNodeGetName(v_cfNode(o)), a->name) == 0) {
        a->attr = v_cfAttribute(o);
        result = FALSE; /* stop the walk */
    } else {
        result = TRUE;
    }

    return result;
}
Esempio n. 2
0
c_char *
u_cfNodeName(
    const u_cfNode node)
{
    v_cfNode kNode;
    const c_char *vname;
    c_char *name;
    u_result result;

    assert(node != NULL);

    name = NULL;
    result = u_cfNodeReadClaim(node, &kNode);
    if (result == U_RESULT_OK) {
        vname = v_cfNodeGetName(kNode);
        if (vname != NULL) {
            name = os_strdup(vname);
        }
        u_cfNodeRelease(node);
    }
    return name;
}
Esempio n. 3
0
static c_bool
getChildren(
    c_object o,
    c_voidp arg)
{
    struct getChildrenArg *a = (struct getChildrenArg *)arg;
    c_value value;
    c_bool isEqual;

    if (a->tagName == NULL) {
        a->children = c_iterInsert(a->children, o);
    } else {
        if (strcmp(v_cfNodeGetName(v_cfNode(o)), a->tagName) == 0) {
            if (a->attribName == NULL) {
                a->children = c_iterInsert(a->children, o);
            } else {
                value = v_cfElementAttributeValue(v_cfElement(o), a->attribName);
                if (value.kind == V_STRING) {
                    isEqual = (strcmp(a->attribValue, value.is.String) == 0);
                    if (isEqual != a->attribNegate) {
                        /* Add if isEqual && !a->attribNegate or
                               if !isEqual && a->attribNegate (XOR) */
                        a->children = c_iterInsert(a->children, o);
                    }
                } else {
                    assert(value.kind == V_UNDEFINED);
                    /* If this is a not-relationship,
                       add the element to the result */
                    if (a->attribNegate) {
                        a->children = c_iterInsert(a->children, o);
                    }
                }
            }
        }
    }
    return TRUE; /* always finish the walk */
}