root/include/crm/common/util.h

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

INCLUDED FROM


DEFINITIONS

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

   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
  27 extern "C" {
  28 #endif
  29 
  30 /**
  31  * \file
  32  * \brief Utility functions
  33  * \ingroup core
  34  */
  35 
  36 
  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) */
  41 char *pcmk_promotion_score_name(const char *rsc_id);
  42 
  43 /* public Pacemaker Remote functions (from remote.c) */
  44 int crm_default_remote_port(void);
  45 
  46 /* public score-related functions (from scores.c) */
  47 const char *pcmk_readable_score(int score);
  48 int char2score(const char *score);
  49 int pcmk__add_scores(int score1, int score2);
  50 
  51 /* public string functions (from strings.c) */
  52 gboolean crm_is_true(const char *s);
  53 int crm_str_to_boolean(const char *s, int *ret);
  54 long long crm_get_msec(const char *input);
  55 char * crm_strip_trailing_newline(char *str);
  56 char *crm_strdup_printf(char const *format, ...) G_GNUC_PRINTF(1, 2);
     /* [previous][next][first][last][top][bottom][index][help] */
  57 
  58 guint crm_parse_interval_spec(const char *input);
  59 
  60 int compare_version(const char *version1, const char *version2);
  61 
  62 /* coverity[+kill] */
  63 void crm_abort(const char *file, const char *function, int line,
  64                const char *condition, gboolean do_core, gboolean do_fork);
  65 
  66 /*!
  67  * \brief Check whether any of specified flags are set in a flag group
  68  *
  69  * \param[in] flag_group        The flag group being examined
  70  * \param[in] flags_to_check    Which flags in flag_group should be checked
  71  *
  72  * \return true if \p flags_to_check is nonzero and any of its flags are set in
  73  *         \p flag_group, or false otherwise
  74  */
  75 static inline bool
  76 pcmk_any_flags_set(uint64_t flag_group, uint64_t flags_to_check)
  77 {
  78     return (flag_group & flags_to_check) != 0;
  79 }
  80 
  81 /*!
  82  * \brief Check whether all of specified flags are set in a flag group
  83  *
  84  * \param[in] flag_group        The flag group being examined
  85  * \param[in] flags_to_check    Which flags in flag_group should be checked
  86  *
  87  * \return true if \p flags_to_check is zero or all of its flags are set in
  88  *         \p flag_group, or false otherwise
  89  */
  90 static inline bool
  91 pcmk_all_flags_set(uint64_t flag_group, uint64_t flags_to_check)
     /* [previous][next][first][last][top][bottom][index][help] */
  92 {
  93     return (flag_group & flags_to_check) == flags_to_check;
  94 }
  95 
  96 /*!
  97  * \brief Convenience alias for pcmk_all_flags_set(), to check single flag
  98  */
  99 #define pcmk_is_set(g, f)   pcmk_all_flags_set((g), (f))
 100 
 101 char *crm_meta_name(const char *field);
 102 const char *crm_meta_value(GHashTable * hash, const char *field);
 103 
 104 char *crm_md5sum(const char *buffer);
 105 
 106 char *crm_generate_uuid(void);
 107 
 108 // This belongs in ipc.h but is here for backward compatibility
 109 bool crm_is_daemon_name(const char *name);
 110 
 111 int crm_user_lookup(const char *name, uid_t * uid, gid_t * gid);
 112 int pcmk_daemon_user(uid_t *uid, gid_t *gid);
 113 
 114 #ifdef HAVE_GNUTLS_GNUTLS_H
 115 void crm_gnutls_global_init(void);
 116 #endif
 117 
 118 char *pcmk_hostname(void);
 119 
 120 bool pcmk_str_is_infinity(const char *s);
 121 bool pcmk_str_is_minus_infinity(const char *s);
 122 
 123 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
 124 #include <crm/common/util_compat.h>
 125 #endif
 126 
 127 #ifdef __cplusplus
 128 }
 129 #endif
 130 
 131 #endif

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