static c_iter getKnownServices(cf_element root) { c_iter services; cf_element domain; cf_element el; cf_element cmd; cf_data data; c_iter children; cf_attribute attr; struct serviceInfo *si; assert(root); services = NULL; if (root && (domain = (cf_element)cf_elementChild(root, "Domain")) ) { children = cf_elementGetChilds(domain); while ( (el = c_iterTakeFirst(children)) != NULL) { if ( strcmp(cf_nodeGetName(cf_node(el)), "Service") == 0 && (cmd = (cf_element)cf_elementChild(el, "Command")) && (data = cf_data(cf_elementChild(cmd, "#text"))) && (si = os_malloc(sizeof(struct serviceInfo)))) { si->command = cf_dataValue(data).is.String; attr = cf_elementAttribute(el, "name"); if (attr) { si->name = cf_attributeValue(attr).is.String; } else { si->name = si->command; } if (!si->name || !si->command) { /* detected an invalid service configuration, report and skip */ fprintf(stderr, "Warning: detected invalid 'Service'" " element (name = %s; command = %s) -> skip\n", (si->name?si->name:"<null>"), (si->command?si->command:"<null>")); os_free(si); si = NULL; } else { services = c_iterInsert(services, si); } } } c_iterFree(children); } return services; }
static os_boolean u_usrClockConfigElementAttributeStringToBoolean ( const cf_element element, const char *attribName, os_boolean defaultValue) { os_boolean value = defaultValue; const char *data = NULL; cf_attribute attrib; c_value attribValue; assert(element != NULL); attrib = cf_elementAttribute (element, attribName); if (attrib) { attribValue = cf_attributeValue (attrib); if (attribValue.kind == V_STRING) { data = attribValue.is.String; if (strcmp(data, "true") == 0) { value = OS_TRUE; } else if (strcmp(data, "false") == 0) { value = OS_FALSE; } } } return value; }
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)); } } } } }
static c_iter getKnownApplications(cf_element root) { c_iter apps; cf_element domain; cf_element el; cf_element cmd; cf_element lib; cf_data data; c_iter children; cf_attribute attr; struct applicationInfo *ai; assert(root); apps = NULL; if (root && (domain = (cf_element)cf_elementChild(root, "Domain")) ) { children = cf_elementGetChilds(domain); while ( (el = c_iterTakeFirst(children)) != NULL) { if ( strcmp(cf_nodeGetName(cf_node(el)), "Application") == 0 && (cmd = (cf_element)cf_elementChild(el, "Command")) && (data = cf_data(cf_elementChild(cmd, "#text"))) && (ai = os_malloc(sizeof(struct applicationInfo)))) { ai->command = cf_dataValue(data).is.String; attr = cf_elementAttribute(el, "name"); if (attr) { ai->name = cf_attributeValue(attr).is.String; } else { ai->name = ai->command; } if ( (lib = (cf_element)cf_elementChild(el, "Library")) && (data = cf_data(cf_elementChild(lib, "#text"))) ) { ai->libname = cf_dataValue(data).is.String; } else { ai->libname = ai->command; } if (!ai->name || !ai->command) { /* detected an invalid application configuration, report and skip */ fprintf(stderr, "Warning: detected invalid 'Application'" " element (name = %s; command = %s) -> skip\n", (ai->name?ai->name:"<null>"), (ai->command?ai->command:"<null>")); os_free(ai); ai = NULL; } else { apps = c_iterInsert(apps, ai); } } } c_iterFree(children); } return apps; }
static qp_result processAttribute( cf_attribute attribute, qp_parseContext ctx) { qp_result result = QP_RESULT_OK; const c_char *name = cf_nodeGetName((cf_node)attribute); c_value value = cf_attributeValue(attribute); assert(value.kind == V_STRING); switch (ctx->scope) { case QP_SCOPE_PROFILE: if (strcmp(name, "name") == 0) { ctx->name = value.is.String; } else if (strcmp(name, "base_name") == 0){ /* TODO: process base_name */ OS_REPORT_1( OS_INFO, "qp_qosProvider::processAttribute", 0, "Attribute (\"%s\") not yet supported for a <qos_profile> element...", name); } else if (strcmp(name, "topic_filter") != 0){ /* topic_filter has no meaning here */ result = QP_RESULT_UNKNOWN_ARGUMENT; OS_REPORT_1( OS_API_INFO, "qp_qosProvider::processAttribute", 0, "Unknown attribute (\"%s\") for a <qos_profile> element...", name); } break; case QP_SCOPE_QOSPOLICY: if (strcmp(name, "name") == 0) { ctx->name = value.is.String; } else if (strcmp(name, "base_name") == 0){ /* TODO: process base_name */ OS_REPORT_1( OS_INFO, "qp_qosProvider::processAttribute", 0, "Attribute (\"%s\") not yet supported for a qos element...", name); } else { result = QP_RESULT_UNKNOWN_ARGUMENT; OS_REPORT_1( OS_API_INFO, "qp_qosProvider::processAttribute", 0, "Unknown attribute (\"%s\") for a <(" DPQOS_TAG "|" TQOS_TAG "|" PUBQOS_TAG "|" SUBQOS_TAG "|" DWQOS_TAG "|" DRQOS_TAG ")_qos> element...", name); } break; default: result = QP_RESULT_UNKNOWN_ARGUMENT; OS_REPORT_1( OS_API_INFO, "qp_qosProvider::processAttribute", 0, "Element specifies an unknown attribute (\"%s\")...", name); } return result; }