This source file includes following definitions.
- crm_strcase_equal
- crm_str_table_new
- crm_strcase_table_new
- is_not_set
- is_set
- is_set_any
- crm_hash_table_size
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #ifndef CRM_COMMON_UTIL__H
19 # define CRM_COMMON_UTIL__H
20
21
22
23
24
25
26
27 # include <sys/types.h>
28 # include <stdlib.h>
29 # include <stdbool.h>
30 # include <limits.h>
31 # include <signal.h>
32 # include <sysexits.h>
33 # include <glib.h>
34
35 # include <libxml/tree.h>
36
37 # include <crm/lrmd.h>
38
39 # if SUPPORT_HEARTBEAT
40 # include <heartbeat.h>
41 # else
42 # define NORMALNODE "normal"
43 # define ACTIVESTATUS "active"
44 # define DEADSTATUS "dead"
45
46 # define PINGSTATUS "ping"
47
48 # define JOINSTATUS "join"
49
50 # define LEAVESTATUS "leave"
51
52 # define ONLINESTATUS "online"
53 # define OFFLINESTATUS "offline"
54
55 # endif
56
57
58 int crm_default_remote_port(void);
59
60
61 char *crm_itoa_stack(int an_int, char *buf, size_t len);
62 char *crm_itoa(int an_int);
63 gboolean crm_is_true(const char *s);
64 int crm_str_to_boolean(const char *s, int *ret);
65 int crm_parse_int(const char *text, const char *default_text);
66 char * crm_strip_trailing_newline(char *str);
67 gboolean crm_str_eq(const char *a, const char *b, gboolean use_case);
68 gboolean safe_str_neq(const char *a, const char *b);
69 guint crm_strcase_hash(gconstpointer v);
70 guint g_str_hash_traditional(gconstpointer v);
71
72 # define safe_str_eq(a, b) crm_str_eq(a, b, FALSE)
73 # define crm_str_hash g_str_hash_traditional
74
75
76 static inline gboolean
77 crm_strcase_equal(gconstpointer a, gconstpointer b)
78 {
79 return crm_str_eq((const char *) a, (const char *) b, FALSE);
80 }
81
82
83
84
85
86
87
88
89 static inline GHashTable *
90 crm_str_table_new()
91 {
92 return g_hash_table_new_full(crm_str_hash, g_str_equal, free, free);
93 }
94
95
96
97
98
99
100
101
102 static inline GHashTable *
103 crm_strcase_table_new()
104 {
105 return g_hash_table_new_full(crm_strcase_hash, crm_strcase_equal, free, free);
106 }
107
108 GHashTable *crm_str_table_dup(GHashTable *old_table);
109
110 # define crm_atoi(text, default_text) crm_parse_int(text, default_text)
111
112
113 void crm_build_path(const char *path_c, mode_t mode);
114
115 long long crm_get_msec(const char *input);
116 unsigned long long crm_get_interval(const char *input);
117 int char2score(const char *score);
118 char *score2char(int score);
119 char *score2char_stack(int score, char *buf, size_t len);
120
121
122 gboolean parse_op_key(const char *key, char **rsc_id, char **op_type,
123 int *interval);
124 gboolean decode_transition_key(const char *key, char **uuid, int *action,
125 int *transition_id, int *target_rc);
126 gboolean decode_transition_magic(const char *magic, char **uuid,
127 int *transition_id, int *action_id,
128 int *op_status, int *op_rc, int *target_rc);
129 int rsc_op_expected_rc(lrmd_event_data_t *event);
130 gboolean did_rsc_op_fail(lrmd_event_data_t *event, int target_rc);
131 bool crm_op_needs_metadata(const char *rsc_class, const char *op);
132 xmlNode *crm_create_op_xml(xmlNode *parent, const char *prefix,
133 const char *task, const char *interval,
134 const char *timeout);
135 #define CRM_DEFAULT_OP_TIMEOUT_S "20s"
136
137 int compare_version(const char *version1, const char *version2);
138
139
140 void crm_abort(const char *file, const char *function, int line,
141 const char *condition, gboolean do_core, gboolean do_fork);
142
143 static inline gboolean
144 is_not_set(long long word, long long bit)
145 {
146 return ((word & bit) == 0);
147 }
148
149 static inline gboolean
150 is_set(long long word, long long bit)
151 {
152 return ((word & bit) == bit);
153 }
154
155 static inline gboolean
156 is_set_any(long long word, long long bit)
157 {
158 return ((word & bit) != 0);
159 }
160
161 static inline guint
162 crm_hash_table_size(GHashTable * hashtable)
163 {
164 if (hashtable == NULL) {
165 return 0;
166 }
167 return g_hash_table_size(hashtable);
168 }
169
170 char *crm_meta_name(const char *field);
171 const char *crm_meta_value(GHashTable * hash, const char *field);
172
173 char *crm_md5sum(const char *buffer);
174
175 char *crm_generate_uuid(void);
176 bool crm_is_daemon_name(const char *name);
177
178 int crm_user_lookup(const char *name, uid_t * uid, gid_t * gid);
179
180 #ifdef HAVE_GNUTLS_GNUTLS_H
181 void crm_gnutls_global_init(void);
182 #endif
183
184 int crm_exit(int rc);
185 bool pcmk_acl_required(const char *user);
186
187 char *crm_generate_ra_key(const char *class, const char *provider, const char *type);
188 bool crm_provider_required(const char *standard);
189 int crm_parse_agent_spec(const char *spec, char **standard, char **provider,
190 char **type);
191
192 #endif