@@ -161,49 +161,6 @@ pcmk__xpath_match_element(xmlNode *match)
161161 }
162162}
163163
164- xmlNode *
165- getXpathResult (xmlXPathObjectPtr xpathObj , int index )
166- {
167- xmlNode * match = NULL ;
168- int max = pcmk__xpath_num_results (xpathObj );
169-
170- CRM_CHECK (index >= 0 , return NULL );
171- CRM_CHECK (xpathObj != NULL , return NULL );
172-
173- if (index >= max ) {
174- crm_err ("Requested index %d of only %d items" , index , max );
175- return NULL ;
176-
177- } else if (xpathObj -> nodesetval -> nodeTab [index ] == NULL ) {
178- /* Previously requested */
179- return NULL ;
180- }
181-
182- match = xpathObj -> nodesetval -> nodeTab [index ];
183- CRM_CHECK (match != NULL , return NULL );
184-
185- if (xpathObj -> nodesetval -> nodeTab [index ]-> type != XML_NAMESPACE_DECL ) {
186- // See the comment for pcmk__xpath_result()
187- xpathObj -> nodesetval -> nodeTab [index ] = NULL ;
188- }
189-
190- switch (match -> type ) {
191- case XML_ELEMENT_NODE :
192- return match ;
193-
194- case XML_DOCUMENT_NODE : // Searched for '/'
195- return match -> children ;
196-
197- default :
198- if ((match -> parent != NULL )
199- && (match -> parent -> type == XML_ELEMENT_NODE )) {
200- return match -> parent ;
201- }
202- crm_warn ("Unsupported XPath match type %d (bug?)" , match -> type );
203- return NULL ;
204- }
205- }
206-
207164void
208165dedupXpathResults (xmlXPathObjectPtr xpathObj )
209166{
@@ -506,5 +463,48 @@ xpath_search(const xmlNode *xml_top, const char *path)
506463 return pcmk__xpath_search (xml_top -> doc , path );
507464}
508465
466+ xmlNode *
467+ getXpathResult (xmlXPathObjectPtr xpathObj , int index )
468+ {
469+ xmlNode * match = NULL ;
470+ int max = pcmk__xpath_num_results (xpathObj );
471+
472+ CRM_CHECK (index >= 0 , return NULL );
473+ CRM_CHECK (xpathObj != NULL , return NULL );
474+
475+ if (index >= max ) {
476+ crm_err ("Requested index %d of only %d items" , index , max );
477+ return NULL ;
478+
479+ } else if (xpathObj -> nodesetval -> nodeTab [index ] == NULL ) {
480+ /* Previously requested */
481+ return NULL ;
482+ }
483+
484+ match = xpathObj -> nodesetval -> nodeTab [index ];
485+ CRM_CHECK (match != NULL , return NULL );
486+
487+ if (xpathObj -> nodesetval -> nodeTab [index ]-> type != XML_NAMESPACE_DECL ) {
488+ // See the comment for pcmk__xpath_result()
489+ xpathObj -> nodesetval -> nodeTab [index ] = NULL ;
490+ }
491+
492+ switch (match -> type ) {
493+ case XML_ELEMENT_NODE :
494+ return match ;
495+
496+ case XML_DOCUMENT_NODE : // Searched for '/'
497+ return match -> children ;
498+
499+ default :
500+ if ((match -> parent != NULL )
501+ && (match -> parent -> type == XML_ELEMENT_NODE )) {
502+ return match -> parent ;
503+ }
504+ crm_warn ("Unsupported XPath match type %d (bug?)" , match -> type );
505+ return NULL ;
506+ }
507+ }
508+
509509// LCOV_EXCL_STOP
510510// End deprecated API
0 commit comments