static int read_rule(xmlNode *rn, cp_rule_t **dst, cp_read_actions_func read_actions, cp_free_actions_func free_actions) { xmlNode *n; int res = RES_OK; if ((!rn) || (!dst)) return RES_INTERNAL_ERR; *dst = (cp_rule_t*)cds_malloc(sizeof(cp_rule_t)); if (!*dst) return RES_MEMORY_ERR; memset(*dst, 0, sizeof(cp_rule_t)); get_str_attr(rn, "id", &(*dst)->id); n = find_node(rn, "actions", common_policy_ns); if (n && (res == 0) && read_actions) res = read_actions(n, &(*dst)->actions); n = find_node(rn, "conditions", common_policy_ns); if (n && (res == 0)) res = read_conditions(n, &(*dst)->conditions); n = find_node(rn, "transformations", common_policy_ns); if (n && (res == 0)) res = read_transformations(n, &(*dst)->transformations); if (res != 0) { free_cp_rule(*dst, free_actions); *dst = NULL; return res; } return 0; }
int RDFParser::read_main(stringstream & stream) { int ret; ret=read_str(stream, "main"); if (ret < 0) return ret; ret=read_conditions(stream); if (ret < 0) return ret; return 0; }