24 typedef struct subst_s {
29 static const subst_t substitutions[] = {
32 {
"Assignment Scores",
34 {
"Assignment Scores and Utilization Information",
38 {
"Current cluster status",
40 {
"Executing Cluster Transition",
42 {
"Failed Resource Actions",
46 {
"Full List of Resources",
48 {
"Inactive Resources",
50 {
"Migration Summary",
52 {
"Negative Location Constraints",
60 {
"Resource Operations",
62 {
"Revised Cluster Status",
66 {
"Transition Summary",
68 {
"Utilization Information",
80 typedef struct private_data_s {
98 return priv != NULL && priv->root != NULL;
107 if (has_root_node(out)) {
113 if (priv->legacy_xml) {
120 pcmk__s(out->
request,
"libpacemaker"));
123 priv->parent_q = g_queue_new();
124 g_queue_push_tail(priv->parent_q, priv->root);
131 if (out == NULL || out->
priv == NULL) {
137 if (has_root_node(out)) {
143 g_queue_free(priv->parent_q);
146 g_slist_free_full(priv->errors, free);
158 if (out->
priv != NULL) {
162 if (out->
priv == NULL) {
175 add_error_node(gpointer
data, gpointer user_data) {
176 const char *str = (
const char *)
data;
177 xmlNodePtr node = (xmlNodePtr) user_data;
197 if (priv->legacy_xml) {
198 GSList *node = priv->errors;
204 while (node != NULL) {
205 fprintf(stderr,
"%s\n", (
char *) node->data);
209 char *rc_as_str = pcmk__itoa(exit_status);
217 if (g_slist_length(priv->errors) > 0) {
219 g_slist_foreach(priv->errors, add_error_node, (gpointer) errors_node);
229 if (copy_dest != NULL) {
238 out->
dest = freopen(NULL,
"w", out->
dest);
247 const char *proc_stdout,
const char *proc_stderr) {
248 xmlNodePtr node, child_node;
249 char *rc_as_str = NULL;
253 rc_as_str = pcmk__itoa(exit_status);
259 if (proc_stdout != NULL) {
265 if (proc_stderr != NULL) {
276 const char *author =
"Andrew Beekhof and the Pacemaker project " 302 va_start(ap, format);
303 len = vasprintf(&buf, format, ap);
307 priv->errors = g_slist_append(priv->errors, buf);
319 xmlNodePtr cdata_node = NULL;
328 xmlAddChild(
parent, cdata_node);
333 xml_begin_list(
pcmk__output_t *out, const
char *singular_noun, const
char *plural_noun,
334 const
char *format, ...) {
344 va_start(ap, format);
345 len = vasprintf(&buf, format, ap);
349 for (
const subst_t *s = substitutions; s->from != NULL; s++) {
350 if (strcmp(s->from, buf) == 0) {
351 name = g_strdup(s->to);
357 name = g_ascii_strdown(buf, -1);
360 if (priv->list_element) {
375 xmlNodePtr item_node = NULL;
382 va_start(ap, format);
383 len = vasprintf(&buf, format, ap);
408 if (priv->list_element) {
413 node = g_queue_pop_tail(priv->parent_q);
419 g_queue_pop_tail(priv->parent_q);
442 if (retval == NULL) {
449 retval->
init = xml_init;
451 retval->
finish = xml_finish;
452 retval->
reset = xml_reset;
459 retval->
info = xml_info;
461 retval->
err = xml_err;
470 retval->
spacer = xml_spacer;
480 xmlNodePtr node = NULL;
487 va_start(args,
name);
507 parent = g_queue_peek_tail(priv->parent_q);
517 xmlNodePtr node = NULL;
529 va_start(args,
name);
538 xmlNodePtr node = NULL;
560 g_queue_push_tail(priv->parent_q,
parent);
574 CRM_ASSERT(g_queue_get_length(priv->parent_q) > 0);
576 g_queue_pop_tail(priv->parent_q);
591 return g_queue_peek_tail(priv->parent_q);
608 return priv->legacy_xml;
625 priv->legacy_xml =
true;
642 priv->list_element =
true;
void(* end_list)(pcmk__output_t *out)
#define PCMK_XE_FENCE_HISTORY
#define CRM_CHECK(expr, failure_action)
xmlNode * pcmk__xml_copy(xmlNode *parent, xmlNode *src)
xmlNodePtr pcmk__output_create_xml_node(pcmk__output_t *out, const char *name,...)
#define PCMK_XE_PACEMAKER_RESULT
#define PCMK_XE_NODE_HISTORY
Control output from tools.
#define PCMK_XE_UTILIZATIONS
void void void void void pcmk__text_prompt(const char *prompt, bool echo, char **dest)
int(* message)(pcmk__output_t *out, const char *message_id,...)
void pcmk__output_enable_list_element(pcmk__output_t *out)
const char * fmt_name
The name of this output formatter.
bool(* is_quiet)(pcmk__output_t *out)
#define PCMK_XE_CLUSTER_STATUS
#define PCMK__API_VERSION
void(* spacer)(pcmk__output_t *out)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
void pcmk__register_message(pcmk__output_t *out, const char *message_id, pcmk__message_fn_t fn)
xmlNodePtr pcmk__output_xml_peek_parent(pcmk__output_t *out)
xmlNodePtr pcmk__output_create_xml_text_node(pcmk__output_t *out, const char *name, const char *content)
enum crm_exit_e crm_exit_t
void pcmk__xe_set_propv(xmlNodePtr node, va_list pairs)
int(* info)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
void pcmk__output_xml_add_node_copy(pcmk__output_t *out, xmlNodePtr node)
void pcmk__output_xml_pop_parent(pcmk__output_t *out)
#define PACEMAKER_VERSION
int pcmk__call_message(pcmk__output_t *out, const char *message_id,...)
void pcmk__xe_set_content(xmlNode *node, const char *format,...) G_GNUC_PRINTF(2
void(* prompt)(const char *prompt, bool echo, char **dest)
void pcmk__output_xml_push_parent(pcmk__output_t *out, xmlNodePtr parent)
void * priv
Implementation-specific private data.
const char * crm_exit_str(crm_exit_t exit_code)
void(* register_message)(pcmk__output_t *out, const char *message_id, pcmk__message_fn_t fn)
struct private_data_s private_data_t
void(* free_priv)(pcmk__output_t *out)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
bool(* init)(pcmk__output_t *out)
int(*) int(*) void(*) void(* output_xml)(pcmk__output_t *out, const char *name, const char *buf)
int(*) int(*) void(* err)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
Wrappers for and extensions to libxml2.
void(* finish)(pcmk__output_t *out, crm_exit_t exit_status, bool print, void **copy_dest)
#define PCMK_XE_ALLOCATIONS
int(*) int(* transient)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
#define PCMK_XE_OPERATIONS
void free_xml(xmlNode *child)
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
#define PCMK_XE_TRANSITION
void pcmk__xe_set_props(xmlNodePtr node,...) G_GNUC_NULL_TERMINATED
FILE * dest
Where output should be written.
const xmlChar * pcmkXmlStr
bool pcmk__output_get_legacy_xml(pcmk__output_t *out)
void(*) void(* list_item)(pcmk__output_t *out, const char *name, const char *format,...) G_GNUC_PRINTF(3
gchar * request
A copy of the request that generated this output.
This structure contains everything that makes up a single output formatter.
struct private_data_s private_data_t
void(* version)(pcmk__output_t *out, bool extended)
void(* begin_list)(pcmk__output_t *out, const char *singular_noun, const char *plural_noun, const char *format,...) G_GNUC_PRINTF(4
void(* reset)(pcmk__output_t *out)
void(* progress)(pcmk__output_t *out, bool end)
#define PCMK_XE_REVISED_CLUSTER_STATUS
#define PCMK_XA_API_VERSION
pcmk__output_t * pcmk__mk_xml_output(char **argv)
void pcmk__output_set_legacy_xml(pcmk__output_t *out)
int pcmk__xml2fd(int fd, xmlNode *cur)
#define PCMK_XE_NODE_ATTRIBUTES
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)
gchar * pcmk__quote_cmdline(gchar **argv)
#define PCMK_XE_RESOURCES
void(*) void(*) void(* increment_list)(pcmk__output_t *out)
#define PCMK_XE_ALLOCATIONS_UTILIZATIONS
xmlNodePtr pcmk__output_xml_create_parent(pcmk__output_t *out, const char *name,...)
#define PCMK_XE_RESOURCE_CONFIG
void(* subprocess_output)(pcmk__output_t *out, int exit_status, const char *proc_stdout, const char *proc_stderr)