pacemaker
2.0.1-9e909a5bdd
Scalable High-Availability cluster resource manager
include
crm
common
xml_internal.h
Go to the documentation of this file.
1
/*
2
* Copyright 2017 Jan Pokorny <jpokorny@redhat.com>
3
*
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
8
*
9
* This software is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* General Public License for more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
*/
18
#ifndef CRM_COMMON_XML_INTERNAL__H
19
# define CRM_COMMON_XML_INTERNAL__H
20
21
/*
22
* Internal-only wrappers for and extensions to libxml2 (libxslt)
23
*/
24
25
# include <stdlib.h>
26
# include <stdio.h>
27
# include <string.h>
28
29
# include <
crm/crm.h
>
/* transitively imports qblog.h */
30
31
75
#define CRM_XML_LOG_BASE(priority, dechunk, postemit, prefix, fmt, ap) \
76
do { \
77
if (!(dechunk) && (prefix) == NULL) {
/* quick pass */
\
78
qb_log_from_external_source_va(__FUNCTION__, __FILE__, (fmt), \
79
(priority), __LINE__, 0, (ap)); \
80
(void) (postemit); \
81
} else { \
82
int CXLB_len = 0; \
83
char *CXLB_buf = NULL; \
84
static int CXLB_buffer_len = 0; \
85
static char *CXLB_buffer = NULL; \
86
static uint8_t CXLB_priority = 0; \
87
\
88
CXLB_len = vasprintf(&CXLB_buf, (fmt), (ap)); \
89
\
90
if (CXLB_len <= 0 || CXLB_buf[CXLB_len - 1] == '\n' || !(dechunk)) { \
91
if (CXLB_len < 0) { \
92
CXLB_buf = (char *) "LOG CORRUPTION HAZARD";
/*we don't modify*/
\
93
CXLB_priority = QB_MIN(CXLB_priority, LOG_ERR); \
94
} else if (CXLB_len > 0
/* && (dechunk) */
\
95
&& CXLB_buf[CXLB_len - 1] == '\n') { \
96
CXLB_buf[CXLB_len - 1] = '\0'; \
97
} \
98
if (CXLB_buffer) { \
99
qb_log_from_external_source(__FUNCTION__, __FILE__, "%s%s%s", \
100
CXLB_priority, __LINE__, 0, \
101
(prefix) != NULL ? (prefix) : "", \
102
CXLB_buffer, CXLB_buf); \
103
free(CXLB_buffer); \
104
} else { \
105
qb_log_from_external_source(__FUNCTION__, __FILE__, "%s%s", \
106
(priority), __LINE__, 0, \
107
(prefix) != NULL ? (prefix) : "", \
108
CXLB_buf); \
109
} \
110
if (CXLB_len < 0) { \
111
CXLB_buf = NULL;
/* restore temporary override */
\
112
} \
113
CXLB_buffer = NULL; \
114
CXLB_buffer_len = 0; \
115
(void) (postemit); \
116
\
117
} else if (CXLB_buffer == NULL) { \
118
CXLB_buffer_len = CXLB_len; \
119
CXLB_buffer = CXLB_buf; \
120
CXLB_buf = NULL; \
121
CXLB_priority = (priority);
/* remember as a running severest */
\
122
\
123
} else { \
124
CXLB_buffer = realloc(CXLB_buffer, 1 + CXLB_buffer_len + CXLB_len); \
125
memcpy(CXLB_buffer + CXLB_buffer_len, CXLB_buf, CXLB_len); \
126
CXLB_buffer_len += CXLB_len; \
127
CXLB_buffer[CXLB_buffer_len] = '\0'; \
128
CXLB_priority = QB_MIN(CXLB_priority, (priority));
/* severest? */
\
129
} \
130
free(CXLB_buf); \
131
} \
132
} while (0)
133
134
#endif
crm.h
A dumping ground.
Generated on Tue Jan 7 2020 23:41:07 for pacemaker by
1.8.13