Beispiel #1
0
static void
findServiceTerminatePeriod(
    cf_element domain,
    os_time *serviceTerminatePeriod)
{
    cf_element elem;
    cf_attribute attr;
    cf_data data;
    c_value value;
    float offset, update_factor, expiry_time;

    /* Spliced uses 4 seconds by default or a value defined in the configuration file. */
    /* But the timing in ospl starts earlier. Therefore, increase the period in ospl   */
    /* with an additional 4 seconds such that it is larger than that in spliced. */

    offset = 4.0;
    (*serviceTerminatePeriod).tv_sec = offset + 4;
    (*serviceTerminatePeriod).tv_nsec = 0;

    if (domain != NULL) {
        elem = cf_element(cf_elementChild(domain, CFG_LEASE));
        if (elem) {
            elem = cf_element(cf_elementChild(elem, CFG_EXPIRYTIME));
            if (elem) {
                data = cf_data(cf_elementChild(elem, "#text"));
                if (data) {
                    value = cf_dataValue(data);
                    expiry_time = atof(value.is.String);
                }
                attr = cf_attribute(cf_elementAttribute(elem,"update_factor"));
                if (attr) {
                    value = cf_attributeValue(attr);
                    update_factor = atof(value.is.String);
                    offset += (expiry_time * update_factor);
                }
            }
        }
        elem = cf_element(cf_elementChild(domain, CFG_TERMPERIOD));
        if (elem) {
            data = cf_data(cf_elementChild(elem, "#text"));
            if (data) {
                value = cf_dataValue(data);
                /* dds2164: if '0' is defined, override any wait times, including
                 * the 4 second offset defined above.
                 */
                if(0 == atof(value.is.String))
                {
                    (*serviceTerminatePeriod).tv_sec = 0;
                    (*serviceTerminatePeriod).tv_nsec = 0;
                } else
                {
                    *serviceTerminatePeriod = os_realToTime(offset + atof(value.is.String));
                }
            }
        }
    }
}
Beispiel #2
0
/**************************************************************
 * constructor/destructor
 **************************************************************/
cf_attribute
cf_attributeNew (
    const c_char *name,
    c_value value)
{
    cf_attribute attr;

    assert(name != NULL);

    attr = cf_attribute(os_malloc((os_uint32)C_SIZEOF(cf_attribute)));
    cf_attributeInit(attr, name, value);

    return attr;
}
Beispiel #3
0
/**************************************************************
 * Public functions
 **************************************************************/
cf_attribute
cf_elementAddAttribute (
    cf_element element,
    cf_attribute attribute)
{
    cf_attribute attr;

    assert(element != NULL);
    assert(attribute != NULL);

    attr = cf_attribute(cf_nodeListInsert(element->attributes, 
                                          cf_node(attribute)));

    return attr;
}
Beispiel #4
0
cf_attribute
cf_elementAttribute(
    cf_element element,
    const c_char *attributeName)
{
    struct getNodeArg arg;

    assert(element != NULL);
    assert(attributeName != NULL);

    arg.name = attributeName;
    arg.node = NULL;
    cf_nodeListWalk(element->attributes, getNode, &arg);

    return cf_attribute(arg.node);
}
Beispiel #5
0
void
cf_nodeFree (
    cf_node node)
{
    assert(node != NULL);

    if (node != NULL) {
        switch (node->kind) {
        case CF_ELEMENT: cf_elementDeinit(cf_element(node)); break;
        case CF_DATA: cf_dataDeinit(cf_data(node)); break;
        case CF_ATTRIBUTE: cf_attributeDeinit(cf_attribute(node)); break;
        case CF_NODE: /* abstract */
        default:
            assert (FALSE); /* catch undefined behaviour */
            break;
        }
        os_free(node);
    }
}