pacemaker  3.0.0-d8340737c4
Scalable High-Availability cluster resource manager
util.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2024 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 #include <crm/common/scores.h>
26 #include <crm/common/strings.h>
27 #include <crm/common/nvpair.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
39 /* public node attribute functions (from attrs.c) */
40 char *pcmk_promotion_score_name(const char *rsc_id);
41 
42 /* public Pacemaker Remote functions (from remote.c) */
43 int crm_default_remote_port(void);
44 
45 int compare_version(const char *version1, const char *version2);
46 
56 static inline bool
57 pcmk_any_flags_set(uint64_t flag_group, uint64_t flags_to_check)
58 {
59  return (flag_group & flags_to_check) != 0;
60 }
61 
71 static inline bool
72 pcmk_all_flags_set(uint64_t flag_group, uint64_t flags_to_check)
73 {
74  return (flag_group & flags_to_check) == flags_to_check;
75 }
76 
80 #define pcmk_is_set(g, f) pcmk_all_flags_set((g), (f))
81 
82 void pcmk_common_cleanup(void);
83 char *crm_md5sum(const char *buffer);
84 char *crm_generate_uuid(void);
85 int crm_user_lookup(const char *name, uid_t * uid, gid_t * gid);
86 int pcmk_daemon_user(uid_t *uid, gid_t *gid);
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
93 #include <crm/common/util_compat.h>
94 #endif
95 
96 #endif
API related to resource agents.
char * crm_generate_uuid(void)
Definition: utils.c:335
API for strings.
const char * name
Definition: cib.c:26
APIs related to actions.
char * pcmk_promotion_score_name(const char *rsc_id)
Return the name of the node attribute used as a promotion score.
Definition: attrs.c:88
int crm_user_lookup(const char *name, uid_t *uid, gid_t *gid)
Definition: utils.c:99
void pcmk_common_cleanup(void)
Free all memory used by libcrmcommon.
Definition: utils.c:54
int pcmk_daemon_user(uid_t *uid, gid_t *gid)
Get user and group IDs of pacemaker daemon user.
Definition: utils.c:139
Low-level API for XML Access Control Lists (ACLs)
Function and executable result codes.
Functionality for manipulating name/value pairs.
int compare_version(const char *version1, const char *version2)
Definition: utils.c:202
Pacemaker APIs related to scores.
char * crm_md5sum(const char *buffer)
Definition: digest.c:251
Deprecated Pacemaker utilities.
int crm_default_remote_port(void)
Get the default remote connection TCP port on this host.
Definition: remote.c:1008