pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
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_element_internal.h> // pcmk__xe_id()
19#include <crm/common/xml_names_internal.h> // PCMK__XA_OPERATION_KEY
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
33static inline const char *
34pcmk__xe_history_key(const xmlNode *xml)
35{
36 if (xml == NULL) {
37 return NULL;
38 } else {
39 /* @COMPAT Pacemaker <= 1.1.5 did not add the key, and used the ID
40 * instead. Checking for that allows us to process old saved CIBs,
41 * including some regression tests.
42 */
43 const char *key = crm_element_value(xml, PCMK__XA_OPERATION_KEY);
44
45 return pcmk__str_empty(key)? pcmk__xe_id(xml) : key;
46 }
47}
48
49#ifdef __cplusplus
50}
51#endif
52
53#endif // PCMK__CRM_COMMON_HISTORY_INTERNAL__H
Wrappers for and extensions to libxml2.
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define PCMK__XA_OPERATION_KEY