Example #1
0
c_iter
u_cfElementXPath(
    u_cfElement element,
    const c_char *xpathExpr)
{
    u_result      r;
    v_cfElement   ke;
    v_cfNode      vChild;
    c_iter        vChildren;
    c_iter        children;
    u_participant p;
    u_cfNode      proxy;

    children = c_iterNew(NULL);
    if ((element != NULL) && (xpathExpr != NULL)) {
        r = u_cfNodeReadClaim(u_cfNode(element), (v_cfNode*)(&ke));
        if (r == U_RESULT_OK) {
            p = u_cfNodeParticipant(u_cfNode(element));
            vChildren = v_cfElementXPath(ke, xpathExpr);
            vChild = c_iterTakeFirst(vChildren);
            while (vChild != NULL) {
                switch(v_cfNodeKind(vChild)) {
                case V_CFELEMENT:
                    proxy = u_cfNode(u_cfElementNew(p, v_cfElement(vChild)));
                break;
                case V_CFATTRIBUTE:
                    proxy = u_cfNode(u_cfAttributeNew(p, v_cfAttribute(vChild)));
                break;
                case V_CFDATA:
                    proxy = u_cfNode(u_cfDataNew(p,v_cfData(vChild)));
                break;
                default:
                    proxy = NULL;
                break;
                }
                children = c_iterInsert(children, proxy);
                vChild = c_iterTakeFirst(vChildren);
            }
            c_iterFree(vChildren);
            u_cfNodeRelease(u_cfNode(element));
        }
    }
    return children;
}
Example #2
0
c_iter
u_cfElementGetChildren(
    u_cfElement element)
{
    u_result      r;
    v_cfElement   ke;
    v_cfNode      child;
    u_cfNode      proxy;
    c_iter        kc;
    c_iter        children;
    u_participant p;

    children = c_iterNew(NULL);
    if (element != NULL) {
        r = u_cfNodeReadClaim(u_cfNode(element), (v_cfNode*)(&ke));
        if (r == U_RESULT_OK) {
            p = u_cfNodeParticipant(u_cfNode(element));
            kc = v_cfElementGetChildren(ke);
            child = c_iterTakeFirst(kc);
            while (child != NULL) {
                switch(v_cfNodeKind(child)) {
                case V_CFELEMENT:
                    proxy = u_cfNode(u_cfElementNew(p, v_cfElement(child)));
                break;
                case V_CFATTRIBUTE:
                    proxy = u_cfNode(u_cfAttributeNew(p, v_cfAttribute(child)));
                break;
                case V_CFDATA:
                    proxy = u_cfNode(u_cfDataNew(p,v_cfData(child)));
                break;
                default:
                    proxy = NULL;
                break;
                }
                c_iterInsert(children, proxy);
                child = c_iterTakeFirst(kc);
            }
            c_iterFree(kc);
            u_cfNodeRelease(u_cfNode(element));
        }
    }
    return children;
}
Example #3
0
/**************************************************************
 * constructor/destructor
 **************************************************************/
v_cfData
v_cfDataNew (
    v_configuration config,
    c_value value)
{
    v_cfData data;

    assert(C_TYPECHECK(config, v_configuration));
    assert(value.kind != V_UNDEFINED);

    data = v_cfData(v_cfNodeNew(config, V_CFDATA));
    v_cfDataInit(data, config, value);

    if (data->value.kind == V_UNDEFINED) {
        c_free(data);
        data = NULL;
    }

    return data;
}
Example #4
0
static int
lockPages(
    v_kernel k,
    const c_char *name)
{
    v_configuration cfg;
    v_cfElement root;
    v_cfElement service;
    v_cfData data;
    int lock;
    c_char *path;
    c_iter iter;
    int iterLength;
    c_value value;

    assert(k);

    lock = 0;
    cfg = v_getConfiguration(k);
    if (cfg != NULL) {
        root = v_configurationGetRoot(cfg);
        if (root != NULL) {
            path = (c_char *)os_malloc(strlen(SERVICE_PATH) + strlen(name));
            /* NULL terminator is covered by '%s' in SERVICE_PATH constant */
            os_sprintf(path, SERVICE_PATH, name);
            iter = v_cfElementXPath(root, path);
            iterLength = c_iterLength(iter);
            os_free(path);
            if (iterLength == 1) {
                service = v_cfElement(c_iterTakeFirst(iter));
                c_iterFree(iter);
                iter = v_cfElementXPath(service, "Locking/#text");
                iterLength = c_iterLength(iter);
                if (iterLength == 1) {
                    data = v_cfData(c_iterTakeFirst(iter));
                    if (u_cfValueScan(v_cfDataValue(data), V_BOOLEAN, &value)) {
                        if (value.is.Boolean) {
                            lock = 1;
                            OS_REPORT_1(OS_INFO,"lockPages", 0,
                                "service '%s': Locking enabled", name);
                        }
                    } else {
                        OS_REPORT_1(OS_WARNING,"lockPages", 0,
                            "Failed to retrieve Locking for service '%s': Locking disabled", name);
                    }
                }
            } else if (iterLength > 1) {
                OS_REPORT_2(OS_WARNING,"lockPages", 0,
                    "Multiple configuration found for service '%s' (too many: %d): Locking disabled",
                    name, iterLength);
            } else {
                OS_REPORT_1(OS_WARNING,"lockPages", 0,
                    "Could not get configuration for service '%s' (non-existent): Locking disabled",
                    name);
            }
            c_iterFree(iter);
            c_free(root);
        }
    }

    return lock;
}
Example #5
0
void
v_loadWarningLevels(
    v_kernel kernel,
    v_configuration config)
{
    c_iter iter;
    v_cfData elementData = NULL;
    c_value value;
    v_cfElement root;

    assert(kernel != NULL);
    assert(C_TYPECHECK(kernel,v_kernel));
    assert(config != NULL);
    assert(C_TYPECHECK(config,v_configuration));

    root = v_configurationGetRoot(config);
    /* load max samples warn level */
    iter = v_cfElementXPath(root, "Domain/ResourceLimits/MaxSamples/WarnAt/#text");
    while(c_iterLength(iter) > 0)
    {
        elementData = v_cfData(c_iterTakeFirst(iter));
    }
    if(iter)
    {
        c_iterFree(iter);
    }
    if(elementData)/* aka the last one from the previous while loop */
    {
        value = v_cfDataValue(elementData);
        sscanf(value.is.String, "%u", &kernel->maxSamplesWarnLevel);
        if(kernel->maxSamplesWarnLevel < V_KERNEL_MAX_SAMPLES_WARN_LEVEL_MIN)
        {
            kernel->maxSamplesWarnLevel = V_KERNEL_MAX_SAMPLES_WARN_LEVEL_MIN;
        }
    }
    elementData = NULL;
    /* load max instances warn level */
    iter = v_cfElementXPath(root, "Domain/ResourceLimits/MaxInstances/WarnAt/#text");
    while(c_iterLength(iter) > 0)
    {
        elementData = v_cfData(c_iterTakeFirst(iter));
    }
    if(iter)
    {
        c_iterFree(iter);
    }
    if(elementData)/* aka the last one from the previous while loop */
    {
        value = v_cfDataValue(elementData);
        sscanf(value.is.String, "%u", &kernel->maxInstancesWarnLevel);
        if(kernel->maxInstancesWarnLevel < V_KERNEL_MAX_INSTANCES_WARN_LEVEL_MIN)
        {
            kernel->maxInstancesWarnLevel = V_KERNEL_MAX_INSTANCES_WARN_LEVEL_MIN;
        }
    }
    elementData = NULL;
    /* load max samples per instances warn level */
    iter = v_cfElementXPath(root, "Domain/ResourceLimits/MaxSamplesPerInstance/WarnAt/#text");
    while(c_iterLength(iter) > 0)
    {
        elementData = v_cfData(c_iterTakeFirst(iter));
    }
    if(iter)
    {
        c_iterFree(iter);
    }
    if(elementData)/* aka the last one from the previous while loop */
    {
        value = v_cfDataValue(elementData);
        sscanf(value.is.String, "%u", &kernel->maxSamplesPerInstanceWarnLevel);
        if(kernel->maxSamplesPerInstanceWarnLevel < V_KERNEL_MAX_SAMPLES_PER_INSTANCES_WARN_LEVEL_MIN)
        {
            kernel->maxSamplesPerInstanceWarnLevel = V_KERNEL_MAX_SAMPLES_PER_INSTANCES_WARN_LEVEL_MIN;
        }

    }
}