pacemaker 2.1.7-2.1.7
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
1/*
2 * Copyright 2004-2023 the Pacemaker project contributors
3 *
4 * The version control history for this file may have further details.
5 *
6 * This source code is licensed under the GNU Lesser General Public License
7 * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8 */
9
10#ifndef PCMK__CRM_COMMON_UTIL__H
11# define PCMK__CRM_COMMON_UTIL__H
12
13# include <sys/types.h> // gid_t, mode_t, size_t, time_t, uid_t
14# include <stdlib.h>
15# include <stdbool.h>
16# include <stdint.h> // uint32_t
17# include <limits.h>
18# include <signal.h>
19# include <glib.h>
20
21# include <crm/common/acl.h>
22# include <crm/common/actions.h>
23# include <crm/common/agents.h>
24# include <crm/common/results.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
37# define ONLINESTATUS "online" // Status of an online client
38# define OFFLINESTATUS "offline" // Status of an offline client
39
40/* public node attribute functions (from attrd_client.c) */
41char *pcmk_promotion_score_name(const char *rsc_id);
42
43/* public Pacemaker Remote functions (from remote.c) */
45
46/* public score-related functions (from scores.c) */
47const char *pcmk_readable_score(int score);
48int char2score(const char *score);
49int pcmk__add_scores(int score1, int score2);
50
51/* public string functions (from strings.c) */
52gboolean crm_is_true(const char *s);
53int crm_str_to_boolean(const char *s, int *ret);
54long long crm_get_msec(const char *input);
55char * crm_strip_trailing_newline(char *str);
56char *crm_strdup_printf(char const *format, ...) G_GNUC_PRINTF(1, 2);
57
58guint crm_parse_interval_spec(const char *input);
59
60int compare_version(const char *version1, const char *version2);
61
62/* coverity[+kill] */
63void crm_abort(const char *file, const char *function, int line,
64 const char *condition, gboolean do_core, gboolean do_fork);
65
75static inline bool
76pcmk_any_flags_set(uint64_t flag_group, uint64_t flags_to_check)
77{
78 return (flag_group & flags_to_check) != 0;
79}
80
90static inline bool
91pcmk_all_flags_set(uint64_t flag_group, uint64_t flags_to_check)
92{
93 return (flag_group & flags_to_check) == flags_to_check;
94}
95
99#define pcmk_is_set(g, f) pcmk_all_flags_set((g), (f))
100
101char *crm_meta_name(const char *field);
102const char *crm_meta_value(GHashTable * hash, const char *field);
103
104char *crm_md5sum(const char *buffer);
105
106char *crm_generate_uuid(void);
107
108// This belongs in ipc.h but is here for backward compatibility
109bool crm_is_daemon_name(const char *name);
110
111int crm_user_lookup(const char *name, uid_t * uid, gid_t * gid);
112int pcmk_daemon_user(uid_t *uid, gid_t *gid);
113
114#ifdef HAVE_GNUTLS_GNUTLS_H
115void crm_gnutls_global_init(void);
116#endif
117
118char *pcmk_hostname(void);
119
120bool pcmk_str_is_infinity(const char *s);
121bool pcmk_str_is_minus_infinity(const char *s);
122
123#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
125#endif
126
127#ifdef __cplusplus
128}
129#endif
130
131#endif
Low-level API for XML Access Control Lists (ACLs)
APIs related to actions.
API related to resource agents.
const char * name
Definition cib.c:26
const char * crm_meta_value(GHashTable *hash, const char *field)
Definition utils.c:490
bool pcmk_str_is_infinity(const char *s)
Definition utils.c:543
char * crm_md5sum(const char *buffer)
Definition digest.c:253
char guint crm_parse_interval_spec(const char *input)
Parse milliseconds from a Pacemaker interval specification.
Definition utils.c:271
int pcmk__add_scores(int score1, int score2)
Definition scores.c:116
int pcmk_daemon_user(uid_t *uid, gid_t *gid)
Get user and group IDs of pacemaker daemon user.
Definition utils.c:126
const char * pcmk_readable_score(int score)
Return a displayable static string for a score value.
Definition scores.c:86
char * crm_generate_uuid(void)
Definition utils.c:509
char * crm_meta_name(const char *field)
Definition utils.c:468
int crm_default_remote_port(void)
Get the default remote connection TCP port on this host.
Definition remote.c:1258
long long crm_get_msec(const char *input)
Parse a time+units string and return milliseconds equivalent.
Definition strings.c:364
void crm_abort(const char *file, const char *function, int line, const char *condition, gboolean do_core, gboolean do_fork)
Definition utils.c:397
int char2score(const char *score)
Get the integer value of a score string.
Definition scores.c:36
int crm_user_lookup(const char *name, uid_t *uid, gid_t *gid)
Definition utils.c:86
char * pcmk_promotion_score_name(const char *rsc_id)
Return the name of the node attribute used as a promotion score.
Definition attrs.c:80
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
char * crm_strip_trailing_newline(char *str)
Definition strings.c:1351
int compare_version(const char *version1, const char *version2)
Definition utils.c:189
char * pcmk_hostname(void)
Get the local hostname.
Definition utils.c:535
bool crm_is_daemon_name(const char *name)
Check whether string represents a client name used by cluster daemons.
Definition ipc_server.c:999
gboolean crm_is_true(const char *s)
Definition strings.c:416
int crm_str_to_boolean(const char *s, int *ret)
Definition strings.c:424
bool pcmk_str_is_minus_infinity(const char *s)
Definition utils.c:548
Deprecated Pacemaker utilities.
xmlNode * input
Function and executable result codes.