root/include/crm/common/util_compat.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. is_not_set
  2. is_set
  3. is_set_any
  4. crm_str_table_new
  5. crm_strcase_table_new
  6. crm_hash_table_size
  7. crm_itoa
  8. crm_ftoa
  9. crm_ttoa

   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_UTIL_COMPAT__H
  11 #define PCMK__CRM_COMMON_UTIL_COMPAT__H
  12 
  13 #include <glib.h>
  14 #include <libxml/tree.h>
  15 #include <crm/common/util.h>
  16 
  17 #ifdef __cplusplus
  18 extern "C" {
  19 #endif
  20 
  21 /**
  22  * \file
  23  * \brief Deprecated Pacemaker utilities
  24  * \ingroup core
  25  * \deprecated Do not include this header directly. The utilities in this
  26  *             header, and the header itself, will be removed in a future
  27  *             release.
  28  */
  29 
  30 //! \deprecated Do not use
  31 #define crm_get_interval crm_parse_interval_spec
  32 
  33 //! \deprecated Do not use
  34 #define CRM_DEFAULT_OP_TIMEOUT_S "20s"
  35 
  36 //! \deprecated Use !pcmk_is_set() or !pcmk_all_flags_set() instead
  37 static inline gboolean
  38 is_not_set(long long word, long long bit)
     /* [previous][next][first][last][top][bottom][index][help] */
  39 {
  40     return ((word & bit) == 0);
  41 }
  42 
  43 // NOTE: sbd (as of at least 1.5.2) uses this
  44 //! \deprecated Use pcmk_is_set() or pcmk_all_flags_set() instead
  45 static inline gboolean
  46 is_set(long long word, long long bit)
     /* [previous][next][first][last][top][bottom][index][help] */
  47 {
  48     return ((word & bit) == bit);
  49 }
  50 
  51 //! \deprecated Use pcmk_any_flags_set() instead
  52 static inline gboolean
  53 is_set_any(long long word, long long bit)
     /* [previous][next][first][last][top][bottom][index][help] */
  54 {
  55     return ((word & bit) != 0);
  56 }
  57 
  58 //! \deprecated Use strcmp() or strcasecmp() instead
  59 gboolean crm_str_eq(const char *a, const char *b, gboolean use_case);
  60 
  61 //! \deprecated Use strcmp() instead
  62 gboolean safe_str_neq(const char *a, const char *b);
  63 
  64 //! \deprecated Use strcasecmp() instead
  65 #define safe_str_eq(a, b) crm_str_eq(a, b, FALSE)
  66 
  67 //! \deprecated Use snprintf() instead
  68 char *crm_itoa_stack(int an_int, char *buf, size_t len);
  69 
  70 //! \deprecated Use sscanf() instead
  71 int pcmk_scan_nvpair(const char *input, char **name, char **value);
  72 
  73 //! \deprecated Use a standard printf()-style function instead
  74 char *pcmk_format_nvpair(const char *name, const char *value,
  75                          const char *units);
  76 
  77 //! \deprecated Use \c crm_xml_add() or \c xml_remove_prop() instead
  78 const char *crm_xml_replace(xmlNode *node, const char *name, const char *value);
  79 
  80 //! \deprecated Use a standard printf()-style function instead
  81 char *pcmk_format_named_time(const char *name, time_t epoch_time);
  82 
  83 //! \deprecated Use strtoll() instead
  84 long long crm_parse_ll(const char *text, const char *default_text);
  85 
  86 //! \deprecated Use strtoll() instead
  87 int crm_parse_int(const char *text, const char *default_text);
  88 
  89 //! \deprecated Use strtoll() instead
  90 #define crm_atoi(text, default_text) crm_parse_int(text, default_text)
  91 
  92 //! \deprecated Use g_str_hash() instead
  93 guint g_str_hash_traditional(gconstpointer v);
  94 
  95 //! \deprecated Use g_str_hash() instead
  96 #define crm_str_hash g_str_hash_traditional
  97 
  98 //! \deprecated Do not use Pacemaker for generic string comparison
  99 gboolean crm_strcase_equal(gconstpointer a, gconstpointer b);
 100 
 101 //! \deprecated Do not use Pacemaker for generic string manipulation
 102 guint crm_strcase_hash(gconstpointer v);
 103 
 104 //! \deprecated Use g_hash_table_new_full() instead
 105 static inline GHashTable *
 106 crm_str_table_new(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 107 {
 108     return g_hash_table_new_full(crm_str_hash, g_str_equal, free, free);
 109 }
 110 
 111 //! \deprecated Use g_hash_table_new_full() instead
 112 static inline GHashTable *
 113 crm_strcase_table_new(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 114 {
 115     return g_hash_table_new_full(crm_strcase_hash, crm_strcase_equal,
 116                                  free, free);
 117 }
 118 
 119 //! \deprecated Do not use Pacemaker for generic hash table manipulation
 120 GHashTable *crm_str_table_dup(GHashTable *old_table);
 121 
 122 //! \deprecated Use g_hash_able_size() instead
 123 static inline guint
 124 crm_hash_table_size(GHashTable *hashtable)
     /* [previous][next][first][last][top][bottom][index][help] */
 125 {
 126     if (hashtable == NULL) {
 127         return 0;
 128     }
 129     return g_hash_table_size(hashtable);
 130 }
 131 
 132 //! \deprecated Don't use Pacemaker for string manipulation
 133 char *crm_strip_trailing_newline(char *str);
 134 
 135 //! \deprecated Don't use Pacemaker for string manipulation
 136 int pcmk_numeric_strcasecmp(const char *s1, const char *s2);
 137 
 138 //! \deprecated Don't use Pacemaker for string manipulation
 139 static inline char *
 140 crm_itoa(int an_int)
     /* [previous][next][first][last][top][bottom][index][help] */
 141 {
 142     return crm_strdup_printf("%d", an_int);
 143 }
 144 
 145 //! \deprecated Don't use Pacemaker for string manipulation
 146 static inline char *
 147 crm_ftoa(double a_float)
     /* [previous][next][first][last][top][bottom][index][help] */
 148 {
 149     return crm_strdup_printf("%f", a_float);
 150 }
 151 
 152 //! \deprecated Don't use Pacemaker for string manipulation
 153 static inline char *
 154 crm_ttoa(time_t epoch_time)
     /* [previous][next][first][last][top][bottom][index][help] */
 155 {
 156     return crm_strdup_printf("%lld", (long long) epoch_time);
 157 }
 158 
 159 //! \deprecated Do not use Pacemaker libraries for generic I/O
 160 void crm_build_path(const char *path_c, mode_t mode);
 161 
 162 //! \deprecated Use \c pcmk_parse_interval_spec() instead
 163 guint crm_parse_interval_spec(const char *input);
 164 
 165 //! \deprecated Use \c PCMK_VALUE_ONLINE instead
 166 #define ONLINESTATUS PCMK_VALUE_ONLINE
 167 
 168 //! \deprecated Use \c PCMK_VALUE_OFFLINE instead
 169 #define OFFLINESTATUS PCMK_VALUE_OFFLINE
 170 
 171 //! \deprecated Use \c uname() instead
 172 char *pcmk_hostname(void);
 173 
 174 #ifdef __cplusplus
 175 }
 176 #endif
 177 
 178 #endif // PCMK__CRM_COMMON_UTIL_COMPAT__H

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