root/include/crm/common/nvpair.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-2022 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_NVPAIR__H
  11 #  define PCMK__CRM_COMMON_NVPAIR__H
  12 
  13 #  include <sys/time.h>     // struct timeval
  14 #  include <glib.h>         // gpointer, gboolean, guint
  15 #  include <libxml/tree.h>  // xmlNode
  16 #  include <crm/crm.h>
  17 
  18 
  19 #  ifdef __cplusplus
  20 extern "C" {
  21 #  endif
  22 
  23 /**
  24  * \file
  25  * \brief Functionality for manipulating name/value pairs
  26  * \ingroup core
  27  */
  28 
  29 typedef struct pcmk_nvpair_s {
  30     char *name;
  31     char *value;
  32 } pcmk_nvpair_t;
  33 
  34 GSList *pcmk_prepend_nvpair(GSList *nvpairs, const char *name, const char *value);
  35 void pcmk_free_nvpairs(GSList *nvpairs);
  36 GSList *pcmk_sort_nvpairs(GSList *list);
  37 GSList *pcmk_xml_attrs2nvpairs(const xmlNode *xml);
  38 void pcmk_nvpairs2xml_attrs(GSList *list, xmlNode *xml);
  39 
  40 xmlNode *crm_create_nvpair_xml(xmlNode *parent, const char *id,
  41                                const char *name, const char *value);
  42 void hash2nvpair(gpointer key, gpointer value, gpointer user_data);
  43 void hash2field(gpointer key, gpointer value, gpointer user_data);
  44 void hash2metafield(gpointer key, gpointer value, gpointer user_data);
  45 void hash2smartfield(gpointer key, gpointer value, gpointer user_data);
  46 GHashTable *xml2list(const xmlNode *parent);
  47 
  48 const char *crm_xml_add(xmlNode *node, const char *name, const char *value);
  49 const char *crm_xml_replace(xmlNode *node, const char *name, const char *value);
  50 const char *crm_xml_add_int(xmlNode *node, const char *name, int value);
  51 const char *crm_xml_add_ll(xmlNode *node, const char *name, long long value);
  52 const char *crm_xml_add_ms(xmlNode *node, const char *name, guint ms);
  53 const char *crm_xml_add_timeval(xmlNode *xml, const char *name_sec,
  54                                 const char *name_usec,
  55                                 const struct timeval *value);
  56 
  57 const char *crm_element_value(const xmlNode *data, const char *name);
  58 int crm_element_value_int(const xmlNode *data, const char *name, int *dest);
  59 int crm_element_value_ll(const xmlNode *data, const char *name, long long *dest);
  60 int crm_element_value_ms(const xmlNode *data, const char *name, guint *dest);
  61 int crm_element_value_epoch(const xmlNode *xml, const char *name, time_t *dest);
  62 int crm_element_value_timeval(const xmlNode *data, const char *name_sec,
  63                               const char *name_usec, struct timeval *dest);
  64 char *crm_element_value_copy(const xmlNode *data, const char *name);
  65 
  66 /*!
  67  * \brief Copy an element from one XML object to another
  68  *
  69  * \param[in]     obj1     Source XML
  70  * \param[in,out] obj2     Destination XML
  71  * \param[in]     element  Name of element to copy
  72  *
  73  * \return Pointer to copied value (from source)
  74  */
  75 static inline const char *
  76 crm_copy_xml_element(const xmlNode *obj1, xmlNode *obj2, const char *element)
     /* [previous][next][first][last][top][bottom][index][help] */
  77 {
  78     const char *value = crm_element_value(obj1, element);
  79 
  80     crm_xml_add(obj2, element, value);
  81     return value;
  82 }
  83 
  84 #  ifdef __cplusplus
  85 }
  86 #  endif
  87 
  88 #endif // PCMK__CRM_COMMON_NVPAIR__H

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