10 #ifndef CRM_COMMON_UTIL__H 11 # define CRM_COMMON_UTIL__H 23 # include <sys/types.h> 31 # include <libxml/tree.h> 37 # define ONLINESTATUS "online" // Status of an online client 38 # define OFFLINESTATUS "offline" // Status of an offline client 52 long long crm_parse_ll(
const char *text,
const char *default_text);
53 int crm_parse_int(
const char *text,
const char *default_text);
62 # define crm_str_hash g_str_hash_traditional 71 crm_ftoa(
double a_float)
77 crm_ttoa(time_t epoch_time)
89 static inline GHashTable *
90 crm_str_table_new(
void)
92 return g_hash_table_new_full(
crm_str_hash, g_str_equal, free, free);
102 static inline GHashTable *
103 crm_strcase_table_new(
void)
110 # define crm_atoi(text, default_text) crm_parse_int(text, default_text) 121 gboolean
parse_op_key(
const char *key,
char **rsc_id,
char **op_type,
124 int *action_id,
int *target_rc);
126 int *transition_id,
int *action_id,
127 int *
op_status,
int *op_rc,
int *target_rc);
132 const char *task,
const char *interval_spec,
134 #define CRM_DEFAULT_OP_TIMEOUT_S "20s" 160 void crm_abort(
const char *file,
const char *
function,
int line,
161 const char *condition, gboolean do_core, gboolean do_fork);
173 pcmk_any_flags_set(uint64_t flag_group, uint64_t flags_to_check)
175 return (flag_group & flags_to_check) != 0;
188 pcmk_all_flags_set(uint64_t flag_group, uint64_t flags_to_check)
190 return (flag_group & flags_to_check) == flags_to_check;
196 #define pcmk_is_set(g, f) pcmk_all_flags_set((g), (f)) 199 crm_hash_table_size(GHashTable * hashtable)
201 if (hashtable == NULL) {
204 return g_hash_table_size(hashtable);
220 #ifdef HAVE_GNUTLS_GNUTLS_H 221 void crm_gnutls_global_init(
void);
229 #ifndef PCMK__NO_COMPAT 235 #define crm_get_interval crm_parse_interval_spec 238 static inline gboolean
239 is_not_set(
long long word,
long long bit)
241 return ((word & bit) == 0);
245 static inline gboolean
246 is_set(
long long word,
long long bit)
248 return ((word & bit) == bit);
252 static inline gboolean
253 is_set_any(
long long word,
long long bit)
255 return ((word & bit) != 0);
262 gboolean
crm_str_eq(
const char *a,
const char *b, gboolean use_case);
268 #define safe_str_eq(a, b) crm_str_eq(a, b, FALSE) 270 #endif // PCMK__NO_COMPAT 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 string represents a client name used by cluster daemons.
gboolean safe_str_neq(const char *a, const char *b)
char * crm_generate_uuid(void)
guint g_str_hash_traditional(gconstpointer v)
char int pcmk_numeric_strcasecmp(const char *s1, const char *s2)
Sort strings, with numeric portions sorted numerically.
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)
Parse a time+units string and return milliseconds equivalent.
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)
Parse milliseconds from a Pacemaker interval specification.
int pcmk_daemon_user(uid_t *uid, gid_t *gid)
Get user and group IDs of pacemaker daemon user.
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 * pcmk_format_nvpair(const char *name, const char *value, const char *units)
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.
char * pcmk_format_named_time(const char *name, time_t epoch_time)
Low-level API for XML Access Control Lists (ACLs)
guint crm_strcase_hash(gconstpointer v)
uint32_t pcmk_get_ra_caps(const char *standard)
Get capabilities of a resource agent standard.
bool pcmk_str_is_infinity(const char *s)
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)
bool pcmk_str_is_minus_infinity(const char *s)
gboolean decode_transition_key(const char *key, char **uuid, int *transition_id, int *action_id, int *target_rc)
Parse a transition key into its constituent parts.
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_ais_msg_types type
gboolean crm_strcase_equal(gconstpointer a, gconstpointer b)
char * score2char(int score)