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

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