root/include/crm/common/util.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. pcmk_any_flags_set
  2. pcmk_all_flags_set

   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 
  33 /**
  34  * \file
  35  * \brief Utility functions
  36  * \ingroup core
  37  */
  38 
  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 
  47 /*!
  48  * \brief Check whether any of specified flags are set in a flag group
  49  *
  50  * \param[in] flag_group        The flag group being examined
  51  * \param[in] flags_to_check    Which flags in flag_group should be checked
  52  *
  53  * \return true if \p flags_to_check is nonzero and any of its flags are set in
  54  *         \p flag_group, or false otherwise
  55  */
  56 static inline bool
  57 pcmk_any_flags_set(uint64_t flag_group, uint64_t flags_to_check)
     /* [previous][next][first][last][top][bottom][index][help] */
  58 {
  59     return (flag_group & flags_to_check) != 0;
  60 }
  61 
  62 /*!
  63  * \brief Check whether all of specified flags are set in a flag group
  64  *
  65  * \param[in] flag_group        The flag group being examined
  66  * \param[in] flags_to_check    Which flags in flag_group should be checked
  67  *
  68  * \return true if \p flags_to_check is zero or all of its flags are set in
  69  *         \p flag_group, or false otherwise
  70  */
  71 static inline bool
  72 pcmk_all_flags_set(uint64_t flag_group, uint64_t flags_to_check)
     /* [previous][next][first][last][top][bottom][index][help] */
  73 {
  74     return (flag_group & flags_to_check) == flags_to_check;
  75 }
  76 
  77 /*!
  78  * \brief Convenience alias for pcmk_all_flags_set(), to check single flag
  79  */
  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

/* [previous][next][first][last][top][bottom][index][help] */