pacemaker  3.0.0-d8340737c4
Scalable High-Availability cluster resource manager
Macros | Functions
xml_element.c File Reference
#include <crm_internal.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <libxml/tree.h>
#include <libxml/valid.h>
#include <crm/crm.h>
#include <crm/common/nvpair.h>
#include <crm/common/results.h>
#include <crm/common/xml.h>
#include "crmcommon_private.h"
#include <glib.h>
#include <crm/common/nvpair_compat.h>
#include <crm/common/xml_compat.h>
#include <crm/common/xml_element_compat.h>
Include dependency graph for xml_element.c:

Go to the source code of this file.

Macros

#define LLSTRSIZE   21
 

Functions

xmlNode * pcmk__xe_first_child (const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
 
xmlNode * pcmk__xe_next (const xmlNode *xml, const char *element_name)
 
int pcmk__xe_get_score (const xmlNode *xml, const char *name, int *score, int default_score)
 
int pcmk__xe_set_score (xmlNode *target, const char *name, const char *value)
 
int pcmk__xe_copy_attrs (xmlNode *target, const xmlNode *src, uint32_t flags)
 
void pcmk__xe_sort_attrs (xmlNode *xml)
 
void pcmk__xe_remove_attr (xmlNode *element, const char *name)
 
bool pcmk__xe_remove_attr_cb (xmlNode *xml, void *user_data)
 
void pcmk__xe_remove_matching_attrs (xmlNode *element, bool(*match)(xmlAttrPtr, void *), void *user_data)
 
xmlNode * pcmk__xe_create (xmlNode *parent, const char *name)
 
void pcmk__xe_set_content (xmlNode *node, const char *format,...)
 
void pcmk__xe_set_id (xmlNode *node, const char *format,...)
 
const char * pcmk__xe_add_last_written (xmlNode *xe)
 
int pcmk__xe_delete_match (xmlNode *xml, xmlNode *search)
 
int pcmk__xe_replace_match (xmlNode *xml, xmlNode *replace)
 
int pcmk__xe_update_match (xmlNode *xml, xmlNode *update, uint32_t flags)
 
void pcmk__xe_set_propv (xmlNodePtr node, va_list pairs)
 
void pcmk__xe_set_props (xmlNodePtr node,...)
 
int pcmk__xe_foreach_child (xmlNode *xml, const char *child_element_name, int(*handler)(xmlNode *xml, void *userdata), void *userdata)
 
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_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 pcmk__xe_get_flags (const xmlNode *xml, const char *name, uint32_t *dest, uint32_t default_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. 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...
 
int pcmk__xe_get_datetime (const xmlNode *xml, const char *attr, crm_time_t **t)
 
char * crm_element_value_copy (const xmlNode *data, const char *name)
 Retrieve a copy of the value of an XML attribute. More...
 
void pcmk__xe_set_bool_attr (xmlNodePtr node, const char *name, bool value)
 
int pcmk__xe_get_bool_attr (const xmlNode *node, const char *name, bool *value)
 
bool pcmk__xe_attr_is_true (const xmlNode *node, const char *name)
 
xmlNode * expand_idref (xmlNode *input, xmlNode *top)
 
void crm_xml_set_id (xmlNode *xml, const char *format,...)
 
xmlNode * sorted_xml (xmlNode *input, xmlNode *parent, gboolean recursive)
 

Macro Definition Documentation

◆ LLSTRSIZE

#define LLSTRSIZE   21

Definition at line 1103 of file xml_element.c.

Function Documentation

◆ crm_element_value()

const char* crm_element_value ( const xmlNode *  data,
const char *  name 
)

Retrieve the value of an XML attribute.

Parameters
[in]dataXML node to check
[in]nameAttribute name to check
Returns
Value of specified attribute (may be NULL)

Definition at line 1168 of file xml_element.c.

◆ crm_element_value_copy()

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.

Parameters
[in]dataXML node to check
[in]nameAttribute name to check
Returns
Value of specified attribute (may be NULL)
Note
The caller is responsible for freeing the result.

Definition at line 1466 of file xml_element.c.

◆ crm_element_value_epoch()

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.

Parameters
[in]xmlXML node to check
[in]nameAttribute name to check
[out]destWhere to store attribute value
Returns
pcmk_ok on success, -1 otherwise

Definition at line 1359 of file xml_element.c.

◆ crm_element_value_int()

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.

Parameters
[in]dataXML node to check
[in]nameAttribute name to check
[out]destWhere to store element value
Returns
0 on success, -1 otherwise

Definition at line 1201 of file xml_element.c.

◆ crm_element_value_ll()

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.

Parameters
[in]dataXML node to check
[in]nameAttribute name to check
[out]destWhere to store element value
Returns
0 on success, -1 otherwise

Definition at line 1291 of file xml_element.c.

◆ crm_element_value_ms()

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.

Parameters
[in]dataXML node to check
[in]nameAttribute name to check
[out]destWhere to store attribute value
Returns
pcmk_ok on success, -1 otherwise

Definition at line 1322 of file xml_element.c.

◆ crm_element_value_timeval()

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.

Parameters
[in]xmlXML to parse
[in]name_secName of XML attribute for seconds
[in]name_usecName of XML attribute for microseconds
[out]destWhere to store result
Returns
pcmk_ok on success, -errno on error
Note
Values default to 0 if XML or XML attribute does not exist

Definition at line 1388 of file xml_element.c.

◆ crm_xml_add()

const char* crm_xml_add ( xmlNode *  node,
const char *  name,
const char *  value 
)

Create an XML attribute with specified name and value.

Parameters
[in,out]nodeXML node to modify
[in]nameAttribute name to set
[in]valueAttribute value to set
Returns
New value on success, NULL otherwise
Note
This does nothing if node, name, or value are NULL or empty.

Definition at line 1015 of file xml_element.c.

◆ crm_xml_add_int()

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.

Parameters
[in,out]nodeXML node to modify
[in]nameAttribute name to set
[in]valueAttribute value to set
Returns
New value as string on success, NULL otherwise
Note
This does nothing if node or name are NULL or empty.

Definition at line 1070 of file xml_element.c.

◆ crm_xml_add_ll()

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.

Parameters
[in,out]xmlXML node to modify
[in]nameAttribute name to set
[in]valueAttribute value to set
Returns
New value as string on success, NULL otherwise
Note
This does nothing if xml or name are NULL or empty. This does not support greater than 64-bit values.

Definition at line 1120 of file xml_element.c.

◆ crm_xml_add_ms()

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.

Parameters
[in,out]nodeXML node to modify
[in]nameAttribute name to set
[in]msAttribute value to set
Returns
New value as string on success, NULL otherwise
Note
This does nothing if node or name are NULL or empty.

Definition at line 1092 of file xml_element.c.

◆ crm_xml_add_timeval()

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.

Parameters
[in,out]xmlXML node to modify
[in]name_secName of XML attribute for seconds
[in]name_usecName of XML attribute for microseconds (or NULL)
[in]valueTime value to set
Returns
New seconds value as string on success, NULL otherwise
Note
This does nothing if xml, name_sec, or value is NULL.

Definition at line 1144 of file xml_element.c.

◆ crm_xml_set_id()

void crm_xml_set_id ( xmlNode *  xml,
const char *  format,
  ... 
)

Definition at line 1563 of file xml_element.c.

◆ expand_idref()

xmlNode* expand_idref ( xmlNode *  input,
xmlNode *  top 
)
Deprecated:
Do not use Pacemaker for general-purpose XML manipulation

Definition at line 1557 of file xml_element.c.

◆ pcmk__xe_add_last_written()

const char* pcmk__xe_add_last_written ( xmlNode *  xe)

Definition at line 526 of file xml_element.c.

◆ pcmk__xe_attr_is_true()

bool pcmk__xe_attr_is_true ( const xmlNode *  node,
const char *  name 
)

Definition at line 1538 of file xml_element.c.

◆ pcmk__xe_copy_attrs()

int pcmk__xe_copy_attrs ( xmlNode *  target,
const xmlNode *  src,
uint32_t  flags 
)

Definition at line 252 of file xml_element.c.

◆ pcmk__xe_create()

xmlNode* pcmk__xe_create ( xmlNode *  parent,
const char *  name 
)

Definition at line 407 of file xml_element.c.

◆ pcmk__xe_delete_match()

int pcmk__xe_delete_match ( xmlNode *  xml,
xmlNode *  search 
)

Definition at line 717 of file xml_element.c.

◆ pcmk__xe_first_child()

xmlNode* pcmk__xe_first_child ( const xmlNode *  parent,
const char *  node_name,
const char *  attr_n,
const char *  attr_v 
)

Definition at line 42 of file xml_element.c.

◆ pcmk__xe_foreach_child()

int pcmk__xe_foreach_child ( xmlNode *  xml,
const char *  child_element_name,
int(*)(xmlNode *xml, void *userdata)  handler,
void *  userdata 
)

Definition at line 979 of file xml_element.c.

◆ pcmk__xe_get_bool_attr()

int pcmk__xe_get_bool_attr ( const xmlNode *  node,
const char *  name,
bool *  value 
)

Definition at line 1501 of file xml_element.c.

◆ pcmk__xe_get_datetime()

int pcmk__xe_get_datetime ( const xmlNode *  xml,
const char *  attr,
crm_time_t **  t 
)

Definition at line 1436 of file xml_element.c.

◆ pcmk__xe_get_flags()

int pcmk__xe_get_flags ( const xmlNode *  xml,
const char *  name,
uint32_t *  dest,
uint32_t  default_value 
)

Definition at line 1243 of file xml_element.c.

◆ pcmk__xe_get_score()

int pcmk__xe_get_score ( const xmlNode *  xml,
const char *  name,
int *  score,
int  default_score 
)

Definition at line 132 of file xml_element.c.

◆ pcmk__xe_next()

xmlNode* pcmk__xe_next ( const xmlNode *  xml,
const char *  element_name 
)

Definition at line 106 of file xml_element.c.

◆ pcmk__xe_remove_attr()

void pcmk__xe_remove_attr ( xmlNode *  element,
const char *  name 
)

Definition at line 339 of file xml_element.c.

◆ pcmk__xe_remove_attr_cb()

bool pcmk__xe_remove_attr_cb ( xmlNode *  xml,
void *  user_data 
)

Definition at line 361 of file xml_element.c.

◆ pcmk__xe_remove_matching_attrs()

void pcmk__xe_remove_matching_attrs ( xmlNode *  element,
bool(*)(xmlAttrPtr, void *)  match,
void *  user_data 
)

Definition at line 379 of file xml_element.c.

◆ pcmk__xe_replace_match()

int pcmk__xe_replace_match ( xmlNode *  xml,
xmlNode *  replace 
)

Definition at line 832 of file xml_element.c.

◆ pcmk__xe_set_bool_attr()

void pcmk__xe_set_bool_attr ( xmlNodePtr  node,
const char *  name,
bool  value 
)

Definition at line 1480 of file xml_element.c.

◆ pcmk__xe_set_content()

void pcmk__xe_set_content ( xmlNode *  node,
const char *  format,
  ... 
)

Definition at line 443 of file xml_element.c.

◆ pcmk__xe_set_id()

void pcmk__xe_set_id ( xmlNode *  node,
const char *  format,
  ... 
)

Definition at line 495 of file xml_element.c.

◆ pcmk__xe_set_props()

void pcmk__xe_set_props ( xmlNodePtr  node,
  ... 
)

Definition at line 970 of file xml_element.c.

◆ pcmk__xe_set_propv()

void pcmk__xe_set_propv ( xmlNodePtr  node,
va_list  pairs 
)

Definition at line 952 of file xml_element.c.

◆ pcmk__xe_set_score()

int pcmk__xe_set_score ( xmlNode *  target,
const char *  name,
const char *  value 
)

Definition at line 174 of file xml_element.c.

◆ pcmk__xe_sort_attrs()

void pcmk__xe_sort_attrs ( xmlNode *  xml)

Definition at line 312 of file xml_element.c.

◆ pcmk__xe_update_match()

int pcmk__xe_update_match ( xmlNode *  xml,
xmlNode *  update,
uint32_t  flags 
)

Definition at line 926 of file xml_element.c.

◆ sorted_xml()

xmlNode* sorted_xml ( xmlNode *  input,
xmlNode *  parent,
gboolean  recursive 
)
Deprecated:
Do not use

Definition at line 1581 of file xml_element.c.