root/include/crm/common/xml_element.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. crm_copy_xml_element

   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 
  22 /**
  23  * \file
  24  * \brief Wrappers for and extensions to libxml2 for XML elements
  25  * \ingroup core
  26  */
  27 
  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 
  45 /*!
  46  * \brief Copy an element from one XML object to another
  47  *
  48  * \param[in]     obj1     Source XML
  49  * \param[in,out] obj2     Destination XML
  50  * \param[in]     element  Name of element to copy
  51  *
  52  * \return Pointer to copied value (from source)
  53  */
  54 static inline const char *
  55 crm_copy_xml_element(const xmlNode *obj1, xmlNode *obj2, const char *element)
     /* [previous][next][first][last][top][bottom][index][help] */
  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)
  68 #include <crm/common/xml_element_compat.h>
  69 #endif
  70 
  71 #endif // PCMK__CRM_COMMON_XML_ELEMENT__H

/* [previous][next][first][last][top][bottom][index][help] */