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

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