diff options
-rw-r--r-- | lib/output.c | 32 | ||||
-rw-r--r-- | lib/perfdata.c | 36 |
2 files changed, 34 insertions, 34 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; |
diff --git a/lib/perfdata.c b/lib/perfdata.c index f894df39..661756c5 100644 --- a/lib/perfdata.c +++ b/lib/perfdata.c | |||
@@ -14,13 +14,13 @@ char *pd_value_to_string(const mp_perfdata_value pd) { | |||
14 | 14 | ||
15 | switch (pd.type) { | 15 | switch (pd.type) { |
16 | case PD_TYPE_INT: | 16 | case PD_TYPE_INT: |
17 | xasprintf(&result, "%lli", pd.pd_int); | 17 | asprintf(&result, "%lli", pd.pd_int); |
18 | break; | 18 | break; |
19 | case PD_TYPE_UINT: | 19 | case PD_TYPE_UINT: |
20 | xasprintf(&result, "%llu", pd.pd_int); | 20 | asprintf(&result, "%llu", pd.pd_int); |
21 | break; | 21 | break; |
22 | case PD_TYPE_DOUBLE: | 22 | case PD_TYPE_DOUBLE: |
23 | xasprintf(&result, "%f", pd.pd_double); | 23 | asprintf(&result, "%f", pd.pd_double); |
24 | break; | 24 | break; |
25 | default: | 25 | default: |
26 | // die here | 26 | // die here |
@@ -33,33 +33,33 @@ char *pd_value_to_string(const mp_perfdata_value pd) { | |||
33 | char *pd_to_string(mp_perfdata pd) { | 33 | char *pd_to_string(mp_perfdata pd) { |
34 | assert(pd.label != NULL); | 34 | assert(pd.label != NULL); |
35 | char *result = NULL; | 35 | char *result = NULL; |
36 | xasprintf(&result, "%s=", pd.label); | 36 | asprintf(&result, "%s=", pd.label); |
37 | 37 | ||
38 | xasprintf(&result, "%s%s", result, pd_value_to_string(pd.value)); | 38 | asprintf(&result, "%s%s", result, pd_value_to_string(pd.value)); |
39 | 39 | ||
40 | if (pd.uom != NULL) { | 40 | if (pd.uom != NULL) { |
41 | xasprintf(&result, "%s%s", result, pd.uom); | 41 | asprintf(&result, "%s%s", result, pd.uom); |
42 | } | 42 | } |
43 | 43 | ||
44 | if (pd.warn_present) { | 44 | if (pd.warn_present) { |
45 | xasprintf(&result, "%s;%s", result, mp_range_to_string(pd.warn)); | 45 | asprintf(&result, "%s;%s", result, mp_range_to_string(pd.warn)); |
46 | } else { | 46 | } else { |
47 | xasprintf(&result, "%s;", result); | 47 | asprintf(&result, "%s;", result); |
48 | } | 48 | } |
49 | 49 | ||
50 | if (pd.crit_present) { | 50 | if (pd.crit_present) { |
51 | xasprintf(&result, "%s;%s", result, mp_range_to_string(pd.crit)); | 51 | asprintf(&result, "%s;%s", result, mp_range_to_string(pd.crit)); |
52 | } else { | 52 | } else { |
53 | xasprintf(&result, "%s;", result); | 53 | asprintf(&result, "%s;", result); |
54 | } | 54 | } |
55 | if (pd.min_present) { | 55 | if (pd.min_present) { |
56 | xasprintf(&result, "%s;%s", result, pd_value_to_string(pd.min)); | 56 | asprintf(&result, "%s;%s", result, pd_value_to_string(pd.min)); |
57 | } else { | 57 | } else { |
58 | xasprintf(&result, "%s;", result); | 58 | asprintf(&result, "%s;", result); |
59 | } | 59 | } |
60 | 60 | ||
61 | if (pd.max_present) { | 61 | if (pd.max_present) { |
62 | xasprintf(&result, "%s;%s", result, pd_value_to_string(pd.max)); | 62 | asprintf(&result, "%s;%s", result, pd_value_to_string(pd.max)); |
63 | } | 63 | } |
64 | 64 | ||
65 | /*printf("pd_to_string: %s\n", result); */ | 65 | /*printf("pd_to_string: %s\n", result); */ |
@@ -71,7 +71,7 @@ char *pd_list_to_string(const pd_list pd) { | |||
71 | char *result = pd_to_string(pd.data); | 71 | char *result = pd_to_string(pd.data); |
72 | 72 | ||
73 | for (pd_list *elem = pd.next; elem != NULL; elem = elem->next) { | 73 | for (pd_list *elem = pd.next; elem != NULL; elem = elem->next) { |
74 | xasprintf(&result, "%s %s", result, pd_to_string(elem->data)); | 74 | asprintf(&result, "%s %s", result, pd_to_string(elem->data)); |
75 | } | 75 | } |
76 | 76 | ||
77 | return result; | 77 | return result; |
@@ -234,17 +234,17 @@ int cmp_perfdata_value(const mp_perfdata_value a, const mp_perfdata_value b) { | |||
234 | char *mp_range_to_string(const mp_range input) { | 234 | char *mp_range_to_string(const mp_range input) { |
235 | char *result = ""; | 235 | char *result = ""; |
236 | if (input.alert_on_inside_range == INSIDE) { | 236 | if (input.alert_on_inside_range == INSIDE) { |
237 | xasprintf(&result, "@"); | 237 | asprintf(&result, "@"); |
238 | } | 238 | } |
239 | 239 | ||
240 | if (input.start_infinity) { | 240 | if (input.start_infinity) { |
241 | xasprintf(&result, "%s~:", result); | 241 | asprintf(&result, "%s~:", result); |
242 | } else { | 242 | } else { |
243 | xasprintf(&result, "%s%s:", result, pd_value_to_string(input.start)); | 243 | asprintf(&result, "%s%s:", result, pd_value_to_string(input.start)); |
244 | } | 244 | } |
245 | 245 | ||
246 | if (!input.end_infinity) { | 246 | if (!input.end_infinity) { |
247 | xasprintf(&result, "%s%s", result, pd_value_to_string(input.end)); | 247 | asprintf(&result, "%s%s", result, pd_value_to_string(input.end)); |
248 | } | 248 | } |
249 | return result; | 249 | return result; |
250 | } | 250 | } |