pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
results_internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2020-2022 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__COMMON_RESULTS_INTERNAL__H
11 #define PCMK__COMMON_RESULTS_INTERNAL__H
12 
13 #include <glib.h> // GQuark
14 
15 // Generic result code type
16 
17 int pcmk__result_bounds(enum pcmk_result_type, int *lower, int *upper);
18 
19 // Standard Pacemaker API return codes
20 
21 extern const size_t pcmk__n_rc;
22 
23 /* Error domains for use with g_set_error */
24 
25 GQuark pcmk__rc_error_quark(void);
26 GQuark pcmk__exitc_error_quark(void);
27 
28 #define PCMK__RC_ERROR pcmk__rc_error_quark()
29 #define PCMK__EXITC_ERROR pcmk__exitc_error_quark()
30 
31 /* Action results */
32 
33 typedef struct {
34  int exit_status; // Child exit status
35  enum pcmk_exec_status execution_status; // Execution status
36  char *exit_reason; // Brief, human-friendly explanation
37  char *action_stdout; // Action output
38  char *action_stderr; // Action error output
40 
48 #define PCMK__UNKNOWN_RESULT { \
49  .exit_status = CRM_EX_OK, \
50  .execution_status = PCMK_EXEC_UNKNOWN, \
51  .exit_reason = NULL, \
52  .action_stdout = NULL, \
53  .action_stderr = NULL, \
54  }
55 
56 void pcmk__set_result(pcmk__action_result_t *result, int exit_status,
57  enum pcmk_exec_status exec_status,
58  const char *exit_reason);
59 
60 void pcmk__format_result(pcmk__action_result_t *result, int exit_status,
61  enum pcmk_exec_status exec_status,
62  const char *format, ...) G_GNUC_PRINTF(4, 5);
63 
65  char *out, char *err);
66 
68 
71 
72 int pcmk__gaierror2rc(int gai);
73 int pcmk__bzlib2rc(int bz2);
74 
84 static inline bool
85 pcmk__result_ok(const pcmk__action_result_t *result)
86 {
87  return (result != NULL) && (result->exit_status == CRM_EX_OK)
89 }
90 
91 #endif // PCMK__COMMON_RESULTS_INTERNAL__H
void pcmk__format_result(pcmk__action_result_t *result, int exit_status, enum pcmk_exec_status exec_status, const char *format,...) G_GNUC_PRINTF(4
const size_t pcmk__n_rc
Definition: results.c:331
void void pcmk__set_result_output(pcmk__action_result_t *result, char *out, char *err)
Definition: results.c:1045
enum pcmk_exec_status execution_status
int pcmk__result_bounds(enum pcmk_result_type, int *lower, int *upper)
Definition: results.c:94
void pcmk__copy_result(const pcmk__action_result_t *src, pcmk__action_result_t *dst)
Definition: results.c:1089
Action completed, result is known.
Definition: results.h:318
Success.
Definition: results.h:240
int pcmk__bzlib2rc(int bz2)
Map a bz2 return code to the most similar Pacemaker return code.
Definition: results.c:906
pcmk__action_result_t result
Definition: pcmk_fence.c:35
int pcmk__gaierror2rc(int gai)
Map a getaddrinfo() return code to the most similar Pacemaker return code.
Definition: results.c:865
GQuark pcmk__rc_error_quark(void)
void pcmk__set_result(pcmk__action_result_t *result, int exit_status, enum pcmk_exec_status exec_status, const char *exit_reason)
Definition: results.c:976
pcmk_exec_status
Execution status.
Definition: results.h:315
GQuark pcmk__exitc_error_quark(void)
void pcmk__reset_result(pcmk__action_result_t *result)
Definition: results.c:1065
pcmk_result_type
Types of Pacemaker result codes.
Definition: results.h:349