18 #ifndef CRM_COMMON_UTIL__H
19 # define CRM_COMMON_UTIL__H
27 # include <sys/types.h>
32 # include <sysexits.h>
35 # include <libxml/tree.h>
39 # if SUPPORT_HEARTBEAT
40 # include <heartbeat.h>
42 # define NORMALNODE "normal"
43 # define ACTIVESTATUS "active"
44 # define DEADSTATUS "dead"
46 # define PINGSTATUS "ping"
48 # define JOINSTATUS "join"
50 # define LEAVESTATUS "leave"
52 # define ONLINESTATUS "online"
53 # define OFFLINESTATUS "offline"
65 int crm_parse_int(
const char *text,
const char *default_text);
67 gboolean
crm_str_eq(
const char *a,
const char *b, gboolean use_case);
72 # define safe_str_eq(a, b) crm_str_eq(a, b, FALSE)
73 # define crm_str_hash g_str_hash_traditional
76 static inline gboolean
77 crm_strcase_equal(gconstpointer a, gconstpointer b)
79 return crm_str_eq((
const char *) a, (
const char *) b, FALSE);
89 static inline GHashTable *
92 return g_hash_table_new_full(
crm_str_hash, g_str_equal, free, free);
102 static inline GHashTable *
103 crm_strcase_table_new()
105 return g_hash_table_new_full(
crm_strcase_hash, crm_strcase_equal, free, free);
110 # define crm_atoi(text, default_text) crm_parse_int(text, default_text)
122 gboolean
parse_op_key(
const char *key,
char **rsc_id,
char **op_type,
125 int *transition_id,
int *target_rc);
127 int *transition_id,
int *action_id,
128 int *
op_status,
int *op_rc,
int *target_rc);
133 const char *task,
const char *interval,
134 const char *timeout);
135 #define CRM_DEFAULT_OP_TIMEOUT_S "20s"
140 void crm_abort(
const char *file,
const char *
function,
int line,
141 const char *condition, gboolean do_core, gboolean do_fork);
143 static inline gboolean
144 is_not_set(
long long word,
long long bit)
146 return ((word & bit) == 0);
149 static inline gboolean
150 is_set(
long long word,
long long bit)
152 return ((word & bit) == bit);
155 static inline gboolean
156 is_set_any(
long long word,
long long bit)
158 return ((word & bit) != 0);
162 crm_hash_table_size(GHashTable * hashtable)
164 if (hashtable == NULL) {
167 return g_hash_table_size(hashtable);
180 #ifdef HAVE_GNUTLS_GNUTLS_H
181 void crm_gnutls_global_init(
void);
bool crm_is_daemon_name(const char *name)
Check whether a string represents a cluster daemon name.
gboolean safe_str_neq(const char *a, const char *b)
char * crm_generate_uuid(void)
guint g_str_hash_traditional(gconstpointer v)
void crm_build_path(const char *path_c, mode_t mode)
Create a directory, including any parent directories needed.
int rsc_op_expected_rc(lrmd_event_data_t *event)
int char2score(const char *score)
long long crm_get_msec(const char *input)
char * score2char_stack(int score, char *buf, size_t len)
const char * crm_meta_value(GHashTable *hash, const char *field)
int crm_parse_int(const char *text, const char *default_text)
bool crm_op_needs_metadata(const char *rsc_class, const char *op)
Check whether an operation requires resource agent meta-data.
int crm_user_lookup(const char *name, uid_t *uid, gid_t *gid)
char * crm_meta_name(const char *field)
int crm_parse_agent_spec(const char *spec, char **standard, char **provider, char **type)
Parse a "standard[:provider]:type" agent specification.
gboolean decode_transition_key(const char *key, char **uuid, int *action, int *transition_id, int *target_rc)
bool pcmk_acl_required(const char *user)
unsigned long long crm_get_interval(const char *input)
guint crm_strcase_hash(gconstpointer v)
xmlNode * crm_create_op_xml(xmlNode *parent, const char *prefix, const char *task, const char *interval, const char *timeout)
Create a CIB XML element for an operation.
gboolean crm_str_eq(const char *a, const char *b, gboolean use_case)
char * crm_itoa_stack(int an_int, char *buf, size_t len)
int crm_str_to_boolean(const char *s, int *ret)
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, int *interval)
gboolean did_rsc_op_fail(lrmd_event_data_t *event, int target_rc)
GHashTable * crm_str_table_dup(GHashTable *old_table)
int compare_version(const char *version1, const char *version2)
gboolean decode_transition_magic(const char *magic, char **uuid, int *transition_id, int *action_id, int *op_status, int *op_rc, int *target_rc)
char * crm_generate_ra_key(const char *class, const char *provider, const char *type)
char * crm_md5sum(const char *buffer)
bool crm_provider_required(const char *standard)
Check whether a resource standard requires a provider to be specified.
gboolean crm_is_true(const char *s)
char * crm_strip_trailing_newline(char *str)
char * crm_itoa(int an_int)
void crm_abort(const char *file, const char *function, int line, const char *condition, gboolean do_core, gboolean do_fork)
int crm_default_remote_port(void)
Get the default remote connection TCP port on this host.
enum crm_ais_msg_types type
char * score2char(int score)