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 const char * u_usrClockConfigElementDataString ( const cf_element element, const char *defaultValue) { c_iter children; const char *data = defaultValue; c_value dataValue; c_ulong i; cf_node node; assert(element != NULL); children = cf_elementGetChilds (element); if (children) { for (i = 0; i < c_iterLength (children); i++) { node = c_iterObject (children, i); if (cf_nodeKind (node) == CF_DATA) { dataValue = cf_dataValue (cf_data(node)); if (dataValue.kind == V_STRING) { data = dataValue.is.String; } } } c_iterFree(children); } return data; }
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; }