| 675 | } |
| 676 | |
| 677 | void |
| 678 | unpack_instance_attributes(xmlNode * top, xmlNode * xml_obj, const char *set_name, |
| 679 | GHashTable * node_hash, GHashTable * hash, const char *always_first, |
| 680 | gboolean overwrite, crm_time_t * now) |
| 681 | { |
| 682 | GListPtr sorted = NULL; |
| 683 | GListPtr unsorted = NULL; |
| 684 | const char *score = NULL; |
| 685 | sorted_set_t *pair = NULL; |
| 686 | struct unpack_data_s data; |
| 687 | xmlNode *attr_set = NULL; |
| 688 | |
| 689 | if (xml_obj == NULL) { |
| 690 | crm_trace("No instance attributes"); |
| 691 | return; |
| 692 | } |
| 693 | |
| 694 | crm_trace("Checking for attributes"); |
| 695 | for (attr_set = __xml_first_child(xml_obj); attr_set != NULL; attr_set = __xml_next(attr_set)) { |
| 696 | /* Uncertain if set_name == NULL check is strictly necessary here */ |
| 697 | if (set_name == NULL || crm_str_eq((const char *)attr_set->name, set_name, TRUE)) { |
| 698 | pair = NULL; |
| 699 | attr_set = expand_idref(attr_set, top); |
| 700 | if (attr_set == NULL) { |
| 701 | continue; |
| 702 | } |
| 703 | |
| 704 | pair = calloc(1, sizeof(sorted_set_t)); |
| 705 | pair->name = ID(attr_set); |
| 706 | pair->special_name = always_first; |
| 707 | pair->attr_set = attr_set; |
| 708 | |
| 709 | score = crm_element_value(attr_set, XML_RULE_ATTR_SCORE); |
| 710 | pair->score = char2score(score); |
| 711 | |
| 712 | unsorted = g_list_prepend(unsorted, pair); |
| 713 | } |
| 714 | } |
| 715 | |
| 716 | if (pair != NULL) { |
| 717 | data.hash = hash; |
| 718 | data.node_hash = node_hash; |
| 719 | data.now = now; |
| 720 | data.overwrite = overwrite; |
| 721 | } |
| 722 | |
| 723 | sorted = g_list_sort(unsorted, sort_pairs); |
| 724 | g_list_foreach(sorted, unpack_attr_set, &data); |
| 725 | g_list_free_full(sorted, free); |
| 726 | } |
no test coverage detected