Exemplo n.º 1
0
c_bool
u_cfElementAttributeFloatValue(
    u_cfElement element,
    const c_char *attributeName,
    c_float *f)
{
    u_result r;
    c_bool result;
    v_cfElement ke;
    c_value value;
    c_value resultValue;

    result = FALSE;
    if ((element != NULL) && (f != NULL)) {
        r = u_cfNodeReadClaim(u_cfNode(element), (v_cfNode*)(&ke));
        if (r == U_RESULT_OK) {
            value = v_cfElementAttributeValue(ke, attributeName);
            result = u_cfValueScan(value, V_FLOAT, &resultValue);

            if (result == TRUE) {
                *f = resultValue.is.Float;
            }
            u_cfNodeRelease(u_cfNode(element));
        }
    }
    return result;
}
Exemplo n.º 2
0
c_bool
u_cfElementAttributeSizeValue(
    u_cfElement element,
    const c_char *attributeName,
    c_size *size)
{
    u_result r;
    c_bool result;
    v_cfElement ke;
    c_value value;

    result = FALSE;
    if ((element != NULL) && (size != NULL)) {
        r = u_cfNodeReadClaim(u_cfNode(element), (v_cfNode*)(&ke));
        if (r == U_RESULT_OK) {
            value = v_cfElementAttributeValue(ke, attributeName);

            if(value.kind == V_STRING){
                result = u_cfDataSizeValueFromString(value.is.String,size);
            }
            else
            {
                OS_REPORT(OS_ERROR, "u_cfElementAttributeSizeValue", 0, "Value is not a string");
                assert(value.kind == V_STRING);
            }

            u_cfNodeRelease(u_cfNode(element));
        }
    }
    return result;
}
Exemplo n.º 3
0
c_bool
u_cfElementAttributeULongValue(
    u_cfElement element,
    const c_char *attributeName,
    c_ulong *ul)
{
    u_result r;
    c_bool result;
    v_cfElement ke;
    c_value value;
    c_value resultValue;

    result = FALSE;
    if ((element != NULL) && (ul != NULL)) {
        r = u_cfNodeReadClaim(u_cfNode(element), (v_cfNode*)(&ke));
        if (r == U_RESULT_OK) {
            value = v_cfElementAttributeValue(ke, attributeName);
            result = u_cfValueScan(value, V_ULONG, &resultValue);

            if (result == TRUE) {
                *ul = resultValue.is.ULong;
            }
            u_cfNodeRelease(u_cfNode(element));
        }
    }
    return result;
}
Exemplo n.º 4
0
c_bool
u_cfElementAttributeBoolValue(
    u_cfElement element,
    const c_char *attributeName,
    c_bool *b)
{
    u_result r;
    c_bool result;
    v_cfElement ke;
    c_value value;
    c_value resultValue;

    result = FALSE;
    if ((element != NULL) && (b != NULL)) {
        r = u_cfNodeReadClaim(u_cfNode(element), (v_cfNode*)(&ke));
        if (r == U_RESULT_OK) {
            value = v_cfElementAttributeValue(ke, attributeName);
            result = u_cfValueScan(value, V_BOOLEAN, &resultValue);

            if (result == TRUE) {
                *b = resultValue.is.Boolean;
            }
            u_cfNodeRelease(u_cfNode(element));
        }
    }
    return result;
}
Exemplo n.º 5
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 */
}
Exemplo n.º 6
0
/*
 * ES, dds1576: This method consults the configuration info stored in the kernel
 * to determine the access policy for this partition
 */
v_accessMode
v_kernelPartitionAccessMode(
    v_kernel _this,
    v_partitionPolicy partition)
{
    v_configuration config;
    v_cfElement root;
    v_cfElement element;
    c_iter iter;
    v_accessMode retVal = V_ACCESS_MODE_UNDEFINED;
    c_value expression;
    c_value accessMode;
    c_iter partitionsSplit;
    c_char* partitionName;

    config = v_getConfiguration(_this);
    if(config)
    {
        root = v_configurationGetRoot(config);
        /* Iterate over all partitionAccess elements */
        iter = v_cfElementXPath(root, "Domain/PartitionAccess");
        while(c_iterLength(iter) > 0)
        {
            element = v_cfElement(c_iterTakeFirst(iter));
            /* Get the partition expression value, it should be a string */
            expression = v_cfElementAttributeValue(element, "partition_expression");
            if(expression.kind == V_STRING)
            {
                /* iterate over partitions, if one matches, exit and return */
                partitionsSplit = v_partitionPolicySplit(partition);
                while(c_iterLength(partitionsSplit) > 0)
                {
                    partitionName = (c_char*)c_iterTakeFirst(partitionsSplit);
                    if(v_partitionStringMatchesExpression(partitionName, expression.is.String))
                    {
                        /* The partition matches the expression.*/
                        accessMode = v_cfElementAttributeValue(element, "access_mode");
                        if(accessMode.kind == V_STRING)
                        {
                            /* A correct solution space can be realized between multiple
                             * expressions having an AND relationship by specifying the
                             * following rules R&W=RW, R&N=N, W&N=N, RW&N=N.
                             */
                            switch(retVal)
                            {
                                case V_ACCESS_MODE_UNDEFINED: /* start state */
                                    if(strcmp(accessMode.is.String, "none") == 0)
                                    {
                                        retVal = V_ACCESS_MODE_NONE;
                                    } else if(strcmp(accessMode.is.String, "write") == 0)
                                    {
                                        retVal = V_ACCESS_MODE_WRITE;
                                    } else if(strcmp(accessMode.is.String, "read") == 0)
                                    {
                                        retVal = V_ACCESS_MODE_READ;
                                    } else if(strcmp(accessMode.is.String, "readwrite") == 0)
                                    {
                                        retVal = V_ACCESS_MODE_READ_WRITE;
                                    }
                                    break;
                                case V_ACCESS_MODE_WRITE:
                                    if(strcmp(accessMode.is.String, "read") == 0 ||
                                       strcmp(accessMode.is.String, "readwrite") == 0)
                                    {
                                        retVal = V_ACCESS_MODE_READ_WRITE;
                                    } else if(strcmp(accessMode.is.String, "none") == 0)
                                    {
                                        retVal = V_ACCESS_MODE_NONE;
                                    }
                                    break;
                                case V_ACCESS_MODE_READ:
                                    if(strcmp(accessMode.is.String, "write") == 0 ||
                                       strcmp(accessMode.is.String, "readwrite") == 0)
                                    {
                                        retVal = V_ACCESS_MODE_READ_WRITE;
                                    } else if(strcmp(accessMode.is.String, "none") == 0)
                                    {
                                        retVal = V_ACCESS_MODE_NONE;
                                    }
                                    break;
                                case V_ACCESS_MODE_READ_WRITE:
                                    if(strcmp(accessMode.is.String, "none") == 0)
                                    {
                                        retVal = V_ACCESS_MODE_NONE;
                                    }
                                    break;
                                default: /* case V_ACCESS_MODE_NONE > none always remains none */
                                    break;
                            }
                        }
                    }
                    os_free(partitionName);
                }
                c_iterFree(partitionsSplit);
            }
        }
        if(iter)
        {
            c_iterFree(iter);
        }
        if(root)
        {
            c_free(root);
        }
    }
    if(retVal == V_ACCESS_MODE_UNDEFINED)
    {
        /* No specific rights defined, fall back to default */
        retVal = V_ACCESS_MODE_READ_WRITE;
    }
    return retVal;
}