pacemaker  3.0.0-d8340737c4
Scalable High-Availability cluster resource manager
xml_element.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_XML_ELEMENT__H
11 #define PCMK__CRM_COMMON_XML_ELEMENT__H
12 
13 #include <sys/time.h> // struct timeval
14 
15 #include <glib.h> // guint
16 #include <libxml/tree.h> // xmlNode
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
28 const char *crm_xml_add(xmlNode *node, const char *name, const char *value);
29 const char *crm_xml_add_int(xmlNode *node, const char *name, int value);
30 const char *crm_xml_add_ll(xmlNode *node, const char *name, long long value);
31 const char *crm_xml_add_ms(xmlNode *node, const char *name, guint ms);
32 const char *crm_xml_add_timeval(xmlNode *xml, const char *name_sec,
33  const char *name_usec,
34  const struct timeval *value);
35 
36 const char *crm_element_value(const xmlNode *data, const char *name);
37 int crm_element_value_int(const xmlNode *data, const char *name, int *dest);
38 int crm_element_value_ll(const xmlNode *data, const char *name, long long *dest);
39 int crm_element_value_ms(const xmlNode *data, const char *name, guint *dest);
40 int crm_element_value_epoch(const xmlNode *xml, const char *name, time_t *dest);
41 int crm_element_value_timeval(const xmlNode *data, const char *name_sec,
42  const char *name_usec, struct timeval *dest);
43 char *crm_element_value_copy(const xmlNode *data, const char *name);
44 
54 static inline const char *
55 crm_copy_xml_element(const xmlNode *obj1, xmlNode *obj2, const char *element)
56 {
57  const char *value = crm_element_value(obj1, element);
58 
59  crm_xml_add(obj2, element, value);
60  return value;
61 }
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 
67 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
69 #endif
70 
71 #endif // PCMK__CRM_COMMON_XML_ELEMENT__H
Deprecated Pacemaker XML element API.
int crm_element_value_timeval(const xmlNode *data, const char *name_sec, const char *name_usec, struct timeval *dest)
Retrieve the value of XML second/microsecond attributes as time.
Definition: xml_element.c:1388
int crm_element_value_ll(const xmlNode *data, const char *name, long long *dest)
Retrieve the long long integer value of an XML attribute.
Definition: xml_element.c:1291
char data[0]
Definition: cpg.c:58
const char * name
Definition: cib.c:26
int crm_element_value_epoch(const xmlNode *xml, const char *name, time_t *dest)
Retrieve the seconds-since-epoch value of an XML attribute.
Definition: xml_element.c:1359
const char * crm_xml_add_ll(xmlNode *node, const char *name, long long value)
Create an XML attribute with specified name and long long int value.
Definition: xml_element.c:1120
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
Definition: xml_element.c:1015
int crm_element_value_ms(const xmlNode *data, const char *name, guint *dest)
Retrieve the millisecond value of an XML attribute.
Definition: xml_element.c:1322
const char * crm_xml_add_timeval(xmlNode *xml, const char *name_sec, const char *name_usec, const struct timeval *value)
Create XML attributes for seconds and microseconds.
Definition: xml_element.c:1144
char * crm_element_value_copy(const xmlNode *data, const char *name)
Retrieve a copy of the value of an XML attribute.
Definition: xml_element.c:1466
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
Definition: xml_element.c:1168
int crm_element_value_int(const xmlNode *data, const char *name, int *dest)
Retrieve the integer value of an XML attribute.
Definition: xml_element.c:1201
const char * crm_xml_add_ms(xmlNode *node, const char *name, guint ms)
Create an XML attribute with specified name and unsigned value.
Definition: xml_element.c:1092
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Create an XML attribute with specified name and integer value.
Definition: xml_element.c:1070