This source file includes following definitions.
- is_not_set
- is_set
- is_set_any
- crm_str_table_new
- crm_strcase_table_new
- crm_hash_table_size
- crm_itoa
- crm_ftoa
- crm_ttoa
1
2
3
4
5
6
7
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
19
20
21
22
23
24
25
26
27 #define crm_get_interval crm_parse_interval_spec
28
29
30 static inline gboolean
31 is_not_set(long long word, long long bit)
32 {
33 return ((word & bit) == 0);
34 }
35
36
37 static inline gboolean
38 is_set(long long word, long long bit)
39 {
40 return ((word & bit) == bit);
41 }
42
43
44 static inline gboolean
45 is_set_any(long long word, long long bit)
46 {
47 return ((word & bit) != 0);
48 }
49
50
51 gboolean crm_str_eq(const char *a, const char *b, gboolean use_case);
52
53
54 gboolean safe_str_neq(const char *a, const char *b);
55
56
57 #define safe_str_eq(a, b) crm_str_eq(a, b, FALSE)
58
59
60 char *crm_itoa_stack(int an_int, char *buf, size_t len);
61
62
63 int pcmk_scan_nvpair(const char *input, char **name, char **value);
64
65
66 char *pcmk_format_nvpair(const char *name, const char *value,
67 const char *units);
68
69
70 char *pcmk_format_named_time(const char *name, time_t epoch_time);
71
72
73 long long crm_parse_ll(const char *text, const char *default_text);
74
75
76 int crm_parse_int(const char *text, const char *default_text);
77
78
79 # define crm_atoi(text, default_text) crm_parse_int(text, default_text)
80
81
82 guint g_str_hash_traditional(gconstpointer v);
83
84
85 #define crm_str_hash g_str_hash_traditional
86
87
88 gboolean crm_strcase_equal(gconstpointer a, gconstpointer b);
89
90
91 guint crm_strcase_hash(gconstpointer v);
92
93
94 static inline GHashTable *
95 crm_str_table_new(void)
96 {
97 return g_hash_table_new_full(crm_str_hash, g_str_equal, free, free);
98 }
99
100
101 static inline GHashTable *
102 crm_strcase_table_new(void)
103 {
104 return g_hash_table_new_full(crm_strcase_hash, crm_strcase_equal,
105 free, free);
106 }
107
108
109 GHashTable *crm_str_table_dup(GHashTable *old_table);
110
111
112 static inline guint
113 crm_hash_table_size(GHashTable *hashtable)
114 {
115 if (hashtable == NULL) {
116 return 0;
117 }
118 return g_hash_table_size(hashtable);
119 }
120
121
122 char *crm_strip_trailing_newline(char *str);
123
124
125 int pcmk_numeric_strcasecmp(const char *s1, const char *s2);
126
127
128 static inline char *
129 crm_itoa(int an_int)
130 {
131 return crm_strdup_printf("%d", an_int);
132 }
133
134
135 static inline char *
136 crm_ftoa(double a_float)
137 {
138 return crm_strdup_printf("%f", a_float);
139 }
140
141
142 static inline char *
143 crm_ttoa(time_t epoch_time)
144 {
145 return crm_strdup_printf("%lld", (long long) epoch_time);
146 }
147
148
149 void crm_build_path(const char *path_c, mode_t mode);
150
151 #ifdef __cplusplus
152 }
153 #endif
154
155 #endif