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-2023 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 Use crm_parse_interval_spec() instead
  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 //! \deprecated Use pcmk_is_set() or pcmk_all_flags_set() instead
  44 static inline gboolean
  45 is_set(long long word, long long bit)
     /* [previous][next][first][last][top][bottom][index][help] */
  46 {
  47     return ((word & bit) == bit);
  48 }
  49 
  50 //! \deprecated Use pcmk_any_flags_set() instead
  51 static inline gboolean
  52 is_set_any(long long word, long long bit)
     /* [previous][next][first][last][top][bottom][index][help] */
  53 {
  54     return ((word & bit) != 0);
  55 }
  56 
  57 //! \deprecated Use strcmp() or strcasecmp() instead
  58 gboolean crm_str_eq(const char *a, const char *b, gboolean use_case);
  59 
  60 //! \deprecated Use strcmp() instead
  61 gboolean safe_str_neq(const char *a, const char *b);
  62 
  63 //! \deprecated Use strcasecmp() instead
  64 #define safe_str_eq(a, b) crm_str_eq(a, b, FALSE)
  65 
  66 //! \deprecated Use snprintf() instead
  67 char *crm_itoa_stack(int an_int, char *buf, size_t len);
  68 
  69 //! \deprecated Use sscanf() instead
  70 int pcmk_scan_nvpair(const char *input, char **name, char **value);
  71 
  72 //! \deprecated Use a standard printf()-style function instead
  73 char *pcmk_format_nvpair(const char *name, const char *value,
  74                          const char *units);
  75 
  76 //! \deprecated Use \c crm_xml_add() or \c xml_remove_prop() instead
  77 const char *crm_xml_replace(xmlNode *node, const char *name, const char *value);
  78 
  79 //! \deprecated Use a standard printf()-style function instead
  80 char *pcmk_format_named_time(const char *name, time_t epoch_time);
  81 
  82 //! \deprecated Use strtoll() instead
  83 long long crm_parse_ll(const char *text, const char *default_text);
  84 
  85 //! \deprecated Use strtoll() instead
  86 int crm_parse_int(const char *text, const char *default_text);
  87 
  88 //! \deprecated Use strtoll() instead
  89 #  define crm_atoi(text, default_text) crm_parse_int(text, default_text)
  90 
  91 //! \deprecated Use g_str_hash() instead
  92 guint g_str_hash_traditional(gconstpointer v);
  93 
  94 //! \deprecated Use g_str_hash() instead
  95 #define crm_str_hash g_str_hash_traditional
  96 
  97 //! \deprecated Do not use Pacemaker for generic string comparison
  98 gboolean crm_strcase_equal(gconstpointer a, gconstpointer b);
  99 
 100 //! \deprecated Do not use Pacemaker for generic string manipulation
 101 guint crm_strcase_hash(gconstpointer v);
 102 
 103 //! \deprecated Use g_hash_table_new_full() instead
 104 static inline GHashTable *
 105 crm_str_table_new(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 106 {
 107     return g_hash_table_new_full(crm_str_hash, g_str_equal, free, free);
 108 }
 109 
 110 //! \deprecated Use g_hash_table_new_full() instead
 111 static inline GHashTable *
 112 crm_strcase_table_new(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 113 {
 114     return g_hash_table_new_full(crm_strcase_hash, crm_strcase_equal,
 115                                  free, free);
 116 }
 117 
 118 //! \deprecated Do not use Pacemaker for generic hash table manipulation
 119 GHashTable *crm_str_table_dup(GHashTable *old_table);
 120 
 121 //! \deprecated Use g_hash_able_size() instead
 122 static inline guint
 123 crm_hash_table_size(GHashTable *hashtable)
     /* [previous][next][first][last][top][bottom][index][help] */
 124 {
 125     if (hashtable == NULL) {
 126         return 0;
 127     }
 128     return g_hash_table_size(hashtable);
 129 }
 130 
 131 //! \deprecated Don't use Pacemaker for string manipulation
 132 char *crm_strip_trailing_newline(char *str);
 133 
 134 //! \deprecated Don't use Pacemaker for string manipulation
 135 int pcmk_numeric_strcasecmp(const char *s1, const char *s2);
 136 
 137 //! \deprecated Don't use Pacemaker for string manipulation
 138 static inline char *
 139 crm_itoa(int an_int)
     /* [previous][next][first][last][top][bottom][index][help] */
 140 {
 141     return crm_strdup_printf("%d", an_int);
 142 }
 143 
 144 //! \deprecated Don't use Pacemaker for string manipulation
 145 static inline char *
 146 crm_ftoa(double a_float)
     /* [previous][next][first][last][top][bottom][index][help] */
 147 {
 148     return crm_strdup_printf("%f", a_float);
 149 }
 150 
 151 //! \deprecated Don't use Pacemaker for string manipulation
 152 static inline char *
 153 crm_ttoa(time_t epoch_time)
     /* [previous][next][first][last][top][bottom][index][help] */
 154 {
 155     return crm_strdup_printf("%lld", (long long) epoch_time);
 156 }
 157 
 158 //! \deprecated Do not use Pacemaker libraries for generic I/O
 159 void crm_build_path(const char *path_c, mode_t mode);
 160 
 161 //! \deprecated Use pcmk_readable_score() instead
 162 char *score2char(int score);
 163 
 164 //! \deprecated Use pcmk_readable_score() instead
 165 char *score2char_stack(int score, char *buf, size_t len);
 166 
 167 #ifdef __cplusplus
 168 }
 169 #endif
 170 
 171 #endif // PCMK__CRM_COMMON_UTIL_COMPAT__H

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