pacemaker
2.1.4-dc6eb4362
Scalable High-Availability cluster resource manager
|
#include <crm_internal.h>
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include <ctype.h>
#include <glib.h>
#include <libxml/tree.h>
#include <crm/crm.h>
#include <crm/msg_xml.h>
#include <crm/common/xml.h>
#include <crm/common/xml_internal.h>
#include "crmcommon_private.h"
#include <crm/common/util_compat.h>
Go to the source code of this file.
Macros | |
#define | LLSTRSIZE 21 |
Functions | |
GSList * | pcmk_prepend_nvpair (GSList *nvpairs, const char *name, const char *value) |
Prepend a name/value pair to a list. More... | |
void | pcmk_free_nvpairs (GSList *nvpairs) |
Free a list of name/value pairs. More... | |
GSList * | pcmk_sort_nvpairs (GSList *list) |
Sort a list of name/value pairs. More... | |
GSList * | pcmk_xml_attrs2nvpairs (xmlNode *xml) |
Create a list of name/value pairs from an XML node's attributes. More... | |
void | pcmk_nvpairs2xml_attrs (GSList *list, xmlNode *xml) |
Add XML attributes based on a list of name/value pairs. More... | |
int | pcmk__scan_nvpair (const char *input, char **name, char **value) |
char * | pcmk__format_nvpair (const char *name, const char *value, const char *units) |
char * | pcmk__format_named_time (const char *name, time_t epoch_time) |
const char * | crm_xml_add (xmlNode *node, const char *name, const char *value) |
Create an XML attribute with specified name and value. More... | |
const char * | crm_xml_replace (xmlNode *node, const char *name, const char *value) |
Replace an XML attribute with specified name and (possibly NULL) value. More... | |
const char * | crm_xml_add_int (xmlNode *node, const char *name, int value) |
Create an XML attribute with specified name and integer value. More... | |
const char * | crm_xml_add_ms (xmlNode *node, const char *name, guint ms) |
Create an XML attribute with specified name and unsigned value. More... | |
const char * | crm_xml_add_ll (xmlNode *xml, const char *name, long long value) |
Create an XML attribute with specified name and long long int value. More... | |
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. More... | |
const char * | crm_element_value (const xmlNode *data, const char *name) |
Retrieve the value of an XML attribute. More... | |
int | crm_element_value_int (const xmlNode *data, const char *name, int *dest) |
Retrieve the integer value of an XML attribute. More... | |
int | crm_element_value_ll (const xmlNode *data, const char *name, long long *dest) |
Retrieve the long long integer value of an XML attribute. More... | |
int | crm_element_value_ms (const xmlNode *data, const char *name, guint *dest) |
Retrieve the millisecond value of an XML attribute. More... | |
int | crm_element_value_epoch (const xmlNode *xml, const char *name, time_t *dest) |
Retrieve the seconds-since-epoch value of an XML attribute. More... | |
int | crm_element_value_timeval (const xmlNode *xml, const char *name_sec, const char *name_usec, struct timeval *dest) |
Retrieve the value of XML second/microsecond attributes as time. More... | |
char * | crm_element_value_copy (const xmlNode *data, const char *name) |
Retrieve a copy of the value of an XML attribute. More... | |
void | hash2smartfield (gpointer key, gpointer value, gpointer user_data) |
Add hash table entry to XML as (possibly legacy) name/value. More... | |
void | hash2field (gpointer key, gpointer value, gpointer user_data) |
Set XML attribute based on hash table entry. More... | |
void | hash2metafield (gpointer key, gpointer value, gpointer user_data) |
Set XML attribute based on hash table entry, as meta-attribute name. More... | |
xmlNode * | crm_create_nvpair_xml (xmlNode *parent, const char *id, const char *name, const char *value) |
Create an XML name/value pair. More... | |
void | hash2nvpair (gpointer key, gpointer value, gpointer user_data) |
Add XML nvpair element based on hash table entry. More... | |
GHashTable * | xml2list (xmlNode *parent) |
Retrieve XML attributes as a hash table. More... | |
void | pcmk__xe_set_bool_attr (xmlNodePtr node, const char *name, bool value) |
int | pcmk__xe_get_bool_attr (xmlNodePtr node, const char *name, bool *value) |
bool | pcmk__xe_attr_is_true (xmlNodePtr node, const char *name) |
int | pcmk_scan_nvpair (const char *input, char **name, char **value) |
char * | pcmk_format_nvpair (const char *name, const char *value, const char *units) |
char * | pcmk_format_named_time (const char *name, time_t epoch_time) |
xmlNode* crm_create_nvpair_xml | ( | xmlNode * | parent, |
const char * | id, | ||
const char * | name, | ||
const char * | value | ||
) |
const char* crm_element_value | ( | const xmlNode * | data, |
const char * | name | ||
) |
char* crm_element_value_copy | ( | const xmlNode * | data, |
const char * | name | ||
) |
Retrieve a copy of the value of an XML attribute.
This is like crm_element_value()
but allocating new memory for the result.
[in] | data | XML node to check |
[in] | name | Attribute name to check |
NULL
) int crm_element_value_epoch | ( | const xmlNode * | xml, |
const char * | name, | ||
time_t * | dest | ||
) |
Retrieve the seconds-since-epoch value of an XML attribute.
This is like crm_element_value()
but returning the value as a time_t.
[in] | xml | XML node to check |
[in] | name | Attribute name to check |
[out] | dest | Where to store attribute value |
pcmk_ok
on success, -1 otherwise int crm_element_value_int | ( | const xmlNode * | data, |
const char * | name, | ||
int * | dest | ||
) |
Retrieve the integer value of an XML attribute.
This is like crm_element_value()
but getting the value as an integer.
[in] | data | XML node to check |
[in] | name | Attribute name to check |
[in] | dest | Where to store element value |
int crm_element_value_ll | ( | const xmlNode * | data, |
const char * | name, | ||
long long * | dest | ||
) |
Retrieve the long long integer value of an XML attribute.
This is like crm_element_value()
but getting the value as a long long int.
[in] | data | XML node to check |
[in] | name | Attribute name to check |
[in] | dest | Where to store element value |
int crm_element_value_ms | ( | const xmlNode * | data, |
const char * | name, | ||
guint * | dest | ||
) |
Retrieve the millisecond value of an XML attribute.
This is like crm_element_value()
but returning the value as a guint.
[in] | data | XML node to check |
[in] | name | Attribute name to check |
[out] | dest | Where to store attribute value |
pcmk_ok
on success, -1 otherwise int crm_element_value_timeval | ( | const xmlNode * | xml, |
const char * | name_sec, | ||
const char * | name_usec, | ||
struct timeval * | dest | ||
) |
Retrieve the value of XML second/microsecond attributes as time.
This is like crm_element_value()
but returning value as a struct timeval.
[in] | xml | XML to parse |
[in] | name_sec | Name of XML attribute for seconds |
[in] | name_usec | Name of XML attribute for microseconds |
[out] | dest | Where to store result |
pcmk_ok
on success, -errno on error const char* crm_xml_add | ( | xmlNode * | node, |
const char * | name, | ||
const char * | value | ||
) |
Create an XML attribute with specified name and value.
[in,out] | node | XML node to modify |
[in] | name | Attribute name to set |
[in] | value | Attribute value to set |
NULL
otherwise NULL
or empty. const char* crm_xml_add_int | ( | xmlNode * | node, |
const char * | name, | ||
int | value | ||
) |
Create an XML attribute with specified name and integer value.
This is like crm_xml_add()
but taking an integer value.
[in,out] | node | XML node to modify |
[in] | name | Attribute name to set |
[in] | value | Attribute value to set |
NULL
otherwise NULL
or empty. const char* crm_xml_add_ll | ( | xmlNode * | xml, |
const char * | name, | ||
long long | value | ||
) |
Create an XML attribute with specified name and long long int value.
This is like crm_xml_add()
but taking a long long int value. It is a useful equivalent for defined types like time_t, etc.
[in,out] | xml | XML node to modify |
[in] | name | Attribute name to set |
[in] | value | Attribute value to set |
NULL
otherwise NULL
or empty. This does not support greater than 64-bit values. const char* crm_xml_add_ms | ( | xmlNode * | node, |
const char * | name, | ||
guint | ms | ||
) |
Create an XML attribute with specified name and unsigned value.
This is like crm_xml_add()
but taking a guint value.
[in,out] | node | XML node to modify |
[in] | name | Attribute name to set |
[in] | ms | Attribute value to set |
NULL
otherwise NULL
or empty. 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.
This is like crm_xml_add()
but taking a struct timeval.
[in,out] | xml | XML node to modify |
[in] | name_sec | Name of XML attribute for seconds |
[in] | name_usec | Name of XML attribute for microseconds (or NULL) |
[in] | value | Time value to set |
NULL
otherwise NULL
. const char* crm_xml_replace | ( | xmlNode * | node, |
const char * | name, | ||
const char * | value | ||
) |
Replace an XML attribute with specified name and (possibly NULL) value.
[in,out] | node | XML node to modify |
[in] | name | Attribute name to set |
[in] | value | Attribute value to set |
NULL
otherwise NULL
or empty. void hash2field | ( | gpointer | key, |
gpointer | value, | ||
gpointer | user_data | ||
) |
Set XML attribute based on hash table entry.
Suitable for g_hash_table_foreach()
, this function takes a hash table key and value, with an XML node passed as user data, and adds an XML attribute with the specified name and value if it does not already exist.
[in] | key | Key of hash table entry |
[in] | value | Value of hash table entry |
[in] | user_data | XML node |
void hash2metafield | ( | gpointer | key, |
gpointer | value, | ||
gpointer | user_data | ||
) |
Set XML attribute based on hash table entry, as meta-attribute name.
Suitable for g_hash_table_foreach()
, this function takes a hash table key and value, with an XML node passed as user data, and adds an XML attribute with the meta-attribute version of the specified name and value if it does not already exist and if the name does not appear to be cluster-internal.
[in] | key | Key of hash table entry |
[in] | value | Value of hash table entry |
[in] | user_data | XML node |
void hash2nvpair | ( | gpointer | key, |
gpointer | value, | ||
gpointer | user_data | ||
) |
Add XML nvpair element based on hash table entry.
Suitable for g_hash_table_foreach()
, this function takes a hash table key and value, with an XML node passed as the user data, and adds an nvpair
XML element with the specified name and value.
[in] | key | Key of hash table entry |
[in] | value | Value of hash table entry |
[in] | user_data | XML node |
void hash2smartfield | ( | gpointer | key, |
gpointer | value, | ||
gpointer | user_data | ||
) |
Add hash table entry to XML as (possibly legacy) name/value.
Suitable for g_hash_table_foreach()
, this function takes a hash table key and value, with an XML node passed as user data, and adds an XML attribute with the specified name and value if it does not already exist. If the key name starts with a digit, this will instead add a <param name=NAME value=VALUE/> child to the XML (for legacy compatibility with heartbeat).
[in] | key | Key of hash table entry |
[in] | value | Value of hash table entry |
[in] | user_data | XML node |
char* pcmk__format_named_time | ( | const char * | name, |
time_t | epoch_time | ||
) |
char* pcmk__format_nvpair | ( | const char * | name, |
const char * | value, | ||
const char * | units | ||
) |
int pcmk__scan_nvpair | ( | const char * | input, |
char ** | name, | ||
char ** | value | ||
) |
bool pcmk__xe_attr_is_true | ( | xmlNodePtr | node, |
const char * | name | ||
) |
int pcmk__xe_get_bool_attr | ( | xmlNodePtr | node, |
const char * | name, | ||
bool * | value | ||
) |
void pcmk__xe_set_bool_attr | ( | xmlNodePtr | node, |
const char * | name, | ||
bool | value | ||
) |
char* pcmk_format_named_time | ( | const char * | name, |
time_t | epoch_time | ||
) |
char* pcmk_format_nvpair | ( | const char * | name, |
const char * | value, | ||
const char * | units | ||
) |
void pcmk_free_nvpairs | ( | GSList * | nvpairs | ) |
void pcmk_nvpairs2xml_attrs | ( | GSList * | list, |
xmlNode * | xml | ||
) |
GSList* pcmk_prepend_nvpair | ( | GSList * | nvpairs, |
const char * | name, | ||
const char * | value | ||
) |
Prepend a name/value pair to a list.
[in,out] | nvpairs | List to modify |
[in] | name | New entry's name |
[in] | value | New entry's value |
pcmk_free_nvpairs()
. int pcmk_scan_nvpair | ( | const char * | input, |
char ** | name, | ||
char ** | value | ||
) |
GSList* pcmk_sort_nvpairs | ( | GSList * | list | ) |
GSList* pcmk_xml_attrs2nvpairs | ( | xmlNode * | xml | ) |
Create a list of name/value pairs from an XML node's attributes.
[in] | XML | to parse |
pcmk_free_nvpairs()
. GHashTable* xml2list | ( | xmlNode * | parent | ) |
Retrieve XML attributes as a hash table.
Given an XML element, this will look for any <attributes> element child, creating a hash table of (newly allocated string) name/value pairs taken first from the attributes element's NAME=VALUE XML attributes, and then from any <param name=NAME value=VALUE> children of attributes.
[in] | XML | node to parse |
g_hash_table_destroy()
.