pacemaker  2.1.8-3980678f03
Scalable High-Availability cluster resource manager
history_internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2024 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU Lesser General Public License
7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8  */
9 
10 #ifndef PCMK__CRM_COMMON_HISTORY_INTERNAL__H
11 #define PCMK__CRM_COMMON_HISTORY_INTERNAL__H
12 
13 #include <stdio.h> // NULL
14 #include <libxml/tree.h> // xmlNode
15 
16 #include <crm/common/xml.h> // crm_element_value()
17 #include <crm/common/internal.h> // pcmk__str_empty()
18 #include <crm/common/xml_names_internal.h> // PCMK__XA_OPERATION_KEY
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
32 static inline const char *
33 pcmk__xe_history_key(const xmlNode *xml)
34 {
35  if (xml == NULL) {
36  return NULL;
37  } else {
38  /* @COMPAT Pacemaker <= 1.1.5 did not add the key, and used the ID
39  * instead. Checking for that allows us to process old saved CIBs,
40  * including some regression tests.
41  */
42  const char *key = crm_element_value(xml, PCMK__XA_OPERATION_KEY);
43 
44  return pcmk__str_empty(key)? pcmk__xe_id(xml) : key;
45  }
46 }
47 
48 #ifdef __cplusplus
49 }
50 #endif
51 
52 #endif // PCMK__CRM_COMMON_HISTORY_INTERNAL__H
#define PCMK__XA_OPERATION_KEY
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
Definition: nvpair.c:446
Wrappers for and extensions to libxml2.