summaryrefslogtreecommitdiffstats
path: root/lib/output.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/output.c')
-rw-r--r--lib/output.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/output.c b/lib/output.c
index 62a00fed..4c5041c8 100644
--- a/lib/output.c
+++ b/lib/output.c
@@ -23,7 +23,7 @@ static inline char *fmt_subcheck_perfdata(mp_subcheck check) {
23 int added = 0; 23 int added = 0;
24 24
25 if (check.perfdata != NULL) { 25 if (check.perfdata != NULL) {
26 added = xasprintf(&result, "%s", pd_list_to_string(*check.perfdata)); 26 added = asprintf(&result, "%s", pd_list_to_string(*check.perfdata));
27 } 27 }
28 28
29 if (check.subchecks == NULL) { 29 if (check.subchecks == NULL) {
@@ -35,10 +35,10 @@ static inline char *fmt_subcheck_perfdata(mp_subcheck check) {
35 35
36 while (subchecks != NULL) { 36 while (subchecks != NULL) {
37 if (added > 0) { 37 if (added > 0) {
38 added = xasprintf(&result, "%s%s", result, fmt_subcheck_perfdata(subchecks->subcheck)); 38 added = asprintf(&result, "%s%s", result, fmt_subcheck_perfdata(subchecks->subcheck));
39 } else { 39 } else {
40 // TODO free previous result here? 40 // TODO free previous result here?
41 added = xasprintf(&result, "%s", result, fmt_subcheck_perfdata(subchecks->subcheck)); 41 added = asprintf(&result, "%s", fmt_subcheck_perfdata(subchecks->subcheck));
42 } 42 }
43 43
44 subchecks = subchecks->next; 44 subchecks = subchecks->next;
@@ -185,7 +185,7 @@ char *get_subcheck_summary(mp_check check) {
185 subchecks = subchecks->next; 185 subchecks = subchecks->next;
186 } 186 }
187 char *result = NULL; 187 char *result = NULL;
188 xasprintf(&result, "ok=%d, warning=%d, critical=%d, unknown=%d", ok, warning, critical, unknown); 188 asprintf(&result, "ok=%d, warning=%d, critical=%d, unknown=%d", ok, warning, critical, unknown);
189 return result; 189 return result;
190} 190}
191 191
@@ -238,7 +238,7 @@ char *mp_fmt_output(mp_check check) {
238 check.summary = get_subcheck_summary(check); 238 check.summary = get_subcheck_summary(check);
239 } 239 }
240 240
241 xasprintf(&result, "%s: %s", state_text(mp_compute_check_state(check)), check.summary); 241 asprintf(&result, "%s: %s", state_text(mp_compute_check_state(check)), check.summary);
242 return result; 242 return result;
243 243
244 case MP_FORMAT_ONE_LINE: { 244 case MP_FORMAT_ONE_LINE: {
@@ -251,12 +251,12 @@ char *mp_fmt_output(mp_check check) {
251 check.summary = get_subcheck_summary(check); 251 check.summary = get_subcheck_summary(check);
252 } 252 }
253 253
254 xasprintf(&result, "%s: %s", state_text(mp_compute_check_state(check)), check.summary); 254 asprintf(&result, "%s: %s", state_text(mp_compute_check_state(check)), check.summary);
255 255
256 mp_subcheck_list *subchecks = check.subchecks; 256 mp_subcheck_list *subchecks = check.subchecks;
257 257
258 while (subchecks != NULL) { 258 while (subchecks != NULL) {
259 xasprintf(&result, "%s - %s", result, fmt_subcheck_output(MP_FORMAT_ONE_LINE, subchecks->subcheck, 1)); 259 asprintf(&result, "%s - %s", result, fmt_subcheck_output(MP_FORMAT_ONE_LINE, subchecks->subcheck, 1));
260 subchecks = subchecks->next; 260 subchecks = subchecks->next;
261 } 261 }
262 262
@@ -267,12 +267,12 @@ char *mp_fmt_output(mp_check check) {
267 check.summary = get_subcheck_summary(check); 267 check.summary = get_subcheck_summary(check);
268 } 268 }
269 269
270 xasprintf(&result, "[%s] - %s", state_text(mp_compute_check_state(check)), check.summary); 270 asprintf(&result, "[%s] - %s", state_text(mp_compute_check_state(check)), check.summary);
271 271
272 mp_subcheck_list *subchecks = check.subchecks; 272 mp_subcheck_list *subchecks = check.subchecks;
273 273
274 while (subchecks != NULL) { 274 while (subchecks != NULL) {
275 xasprintf(&result, "%s\n%s", result, fmt_subcheck_output(MP_FORMAT_ICINGA_WEB_2, subchecks->subcheck, 1)); 275 asprintf(&result, "%s\n%s", result, fmt_subcheck_output(MP_FORMAT_ICINGA_WEB_2, subchecks->subcheck, 1));
276 subchecks = subchecks->next; 276 subchecks = subchecks->next;
277 } 277 }
278 278
@@ -281,16 +281,16 @@ char *mp_fmt_output(mp_check check) {
281 281
282 while (subchecks != NULL) { 282 while (subchecks != NULL) {
283 if (pd_string == NULL) { 283 if (pd_string == NULL) {
284 xasprintf(&pd_string, "%s", fmt_subcheck_perfdata(subchecks->subcheck)); 284 asprintf(&pd_string, "%s", fmt_subcheck_perfdata(subchecks->subcheck));
285 } else { 285 } else {
286 xasprintf(&pd_string, "%s %s", pd_string, fmt_subcheck_perfdata(subchecks->subcheck)); 286 asprintf(&pd_string, "%s %s", pd_string, fmt_subcheck_perfdata(subchecks->subcheck));
287 } 287 }
288 288
289 subchecks = subchecks->next; 289 subchecks = subchecks->next;
290 } 290 }
291 291
292 if (pd_string != NULL && strlen(pd_string) > 0) { 292 if (pd_string != NULL && strlen(pd_string) > 0) {
293 xasprintf(&result, "%s|%s", result, pd_string); 293 asprintf(&result, "%s|%s", result, pd_string);
294 } 294 }
295 295
296 break; 296 break;
@@ -358,23 +358,23 @@ static inline char *fmt_subcheck_output(mp_output_format output_format, mp_subch
358 358
359 switch (output_format) { 359 switch (output_format) {
360 case MP_FORMAT_ICINGA_WEB_2: 360 case MP_FORMAT_ICINGA_WEB_2:
361 xasprintf(&result, "%s\\_[%s] - %s", generate_indentation_string(indentation), state_text(mp_compute_subcheck_state(check)), 361 asprintf(&result, "%s\\_[%s] - %s", generate_indentation_string(indentation), state_text(mp_compute_subcheck_state(check)),
362 check.output); 362 check.output);
363 363
364 subchecks = check.subchecks; 364 subchecks = check.subchecks;
365 365
366 while (subchecks != NULL) { 366 while (subchecks != NULL) {
367 xasprintf(&result, "%s\n%s", result, fmt_subcheck_output(output_format, subchecks->subcheck, indentation + 1)); 367 asprintf(&result, "%s\n%s", result, fmt_subcheck_output(output_format, subchecks->subcheck, indentation + 1));
368 subchecks = subchecks->next; 368 subchecks = subchecks->next;
369 } 369 }
370 return result; 370 return result;
371 case MP_FORMAT_ONE_LINE: 371 case MP_FORMAT_ONE_LINE:
372 xasprintf(&result, "[%s] - %s", state_text(mp_compute_subcheck_state(check)), check.output); 372 asprintf(&result, "[%s] - %s", state_text(mp_compute_subcheck_state(check)), check.output);
373 373
374 subchecks = check.subchecks; 374 subchecks = check.subchecks;
375 375
376 while (subchecks != NULL) { 376 while (subchecks != NULL) {
377 xasprintf(&result, " - %s\n%s", result, fmt_subcheck_output(output_format, subchecks->subcheck, indentation + 1)); 377 asprintf(&result, " - %s\n%s", result, fmt_subcheck_output(output_format, subchecks->subcheck, indentation + 1));
378 subchecks = subchecks->next; 378 subchecks = subchecks->next;
379 } 379 }
380 return result; 380 return result;