10 #ifndef CRM_COMMON_UTIL__H
11 # define CRM_COMMON_UTIL__H
23 # include <sys/types.h>
31 # include <libxml/tree.h>
36 # define ONLINESTATUS "online" // Status of an online client
37 # define OFFLINESTATUS "offline" // Status of an offline client
49 long long crm_parse_ll(
const char *text,
const char *default_text);
50 int crm_parse_int(
const char *text,
const char *default_text);
52 gboolean
crm_str_eq(
const char *a,
const char *b, gboolean use_case);
59 # define safe_str_eq(a, b) crm_str_eq(a, b, FALSE)
60 # define crm_str_hash g_str_hash_traditional
75 static inline GHashTable *
78 return g_hash_table_new_full(
crm_str_hash, g_str_equal, free, free);
88 static inline GHashTable *
89 crm_strcase_table_new()
96 # define crm_atoi(text, default_text) crm_parse_int(text, default_text)
108 #define crm_get_interval crm_parse_interval_spec
111 gboolean
parse_op_key(
const char *key,
char **rsc_id,
char **op_type,
114 int *transition_id,
int *target_rc);
116 int *transition_id,
int *action_id,
117 int *
op_status,
int *op_rc,
int *target_rc);
122 const char *task,
const char *interval_spec,
123 const char *timeout);
124 #define CRM_DEFAULT_OP_TIMEOUT_S "20s"
149 void crm_abort(
const char *file,
const char *
function,
int line,
150 const char *condition, gboolean do_core, gboolean do_fork);
152 static inline gboolean
153 is_not_set(
long long word,
long long bit)
155 return ((word & bit) == 0);
158 static inline gboolean
159 is_set(
long long word,
long long bit)
161 return ((word & bit) == bit);
164 static inline gboolean
165 is_set_any(
long long word,
long long bit)
167 return ((word & bit) != 0);
171 crm_hash_table_size(GHashTable * hashtable)
173 if (hashtable == NULL) {
176 return g_hash_table_size(hashtable);
189 #ifdef HAVE_GNUTLS_GNUTLS_H
190 void crm_gnutls_global_init(
void);
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, guint *interval_ms)
xmlNode * crm_create_op_xml(xmlNode *parent, const char *prefix, const char *task, const char *interval_spec, const char *timeout)
Create a CIB XML element for an operation.
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.
char * crm_generate_ra_key(const char *standard, const char *provider, const char *type)
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)
Parse an integer value from a string.
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)
guint crm_parse_interval_spec(const char *input)
int pcmk_scan_nvpair(const char *input, char **name, char **value)
Extract the name and value from an input string formatted as "name=value". If unable to extract them...
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)
Parse a transition key into its constituent parts.
bool pcmk_acl_required(const char *user)
guint crm_strcase_hash(gconstpointer v)
uint32_t pcmk_get_ra_caps(const char *standard)
Get capabilities of a resource agent standard.
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)
Function and executable result codes.
int crm_str_to_boolean(const char *s, int *ret)
long long crm_parse_ll(const char *text, const char *default_text)
Parse a long long integer value from a string.
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)
Parse a transition magic string into its constituent parts.
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 * pcmk_hostname(void)
Get the local hostname.
char * crm_strip_trailing_newline(char *str)
void crm_abort(const char *file, const char *function, int line, const char *condition, gboolean do_core, gboolean do_fork)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
int crm_default_remote_port(void)
Get the default remote connection TCP port on this host.
enum crm_proc_flag __attribute__
enum crm_ais_msg_types type
gboolean crm_strcase_equal(gconstpointer a, gconstpointer b)
char * score2char(int score)