diff options
Diffstat (limited to 'lib/output.c')
-rw-r--r-- | lib/output.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/output.c b/lib/output.c index 17919afc..61fbf832 100644 --- a/lib/output.c +++ b/lib/output.c | |||
@@ -11,6 +11,9 @@ | |||
11 | #include "perfdata.h" | 11 | #include "perfdata.h" |
12 | #include "states.h" | 12 | #include "states.h" |
13 | 13 | ||
14 | // == Global variables | ||
15 | static mp_output_format output_format = MP_FORMAT_DEFAULT; | ||
16 | |||
14 | // == Prototypes == | 17 | // == Prototypes == |
15 | static char *fmt_subcheck_output(mp_output_format output_format, mp_subcheck check, unsigned int indentation); | 18 | static char *fmt_subcheck_output(mp_output_format output_format, mp_subcheck check, unsigned int indentation); |
16 | static inline cJSON *json_serialize_subcheck(mp_subcheck subcheck); | 19 | static inline cJSON *json_serialize_subcheck(mp_subcheck subcheck); |
@@ -55,7 +58,6 @@ static inline char *fmt_subcheck_perfdata(mp_subcheck check) { | |||
55 | */ | 58 | */ |
56 | mp_check mp_check_init(void) { | 59 | mp_check mp_check_init(void) { |
57 | mp_check check = {0}; | 60 | mp_check check = {0}; |
58 | check.format = MP_FORMAT_DEFAULT; | ||
59 | return check; | 61 | return check; |
60 | } | 62 | } |
61 | 63 | ||
@@ -234,7 +236,7 @@ mp_state_enum mp_compute_check_state(const mp_check check) { | |||
234 | char *mp_fmt_output(mp_check check) { | 236 | char *mp_fmt_output(mp_check check) { |
235 | char *result = NULL; | 237 | char *result = NULL; |
236 | 238 | ||
237 | switch (check.format) { | 239 | switch (output_format) { |
238 | case MP_FORMAT_MULTI_LINE: { | 240 | case MP_FORMAT_MULTI_LINE: { |
239 | if (check.summary == NULL) { | 241 | if (check.summary == NULL) { |
240 | check.summary = get_subcheck_summary(check); | 242 | check.summary = get_subcheck_summary(check); |
@@ -482,7 +484,7 @@ void mp_print_output(mp_check check) { puts(mp_fmt_output(check)); } | |||
482 | */ | 484 | */ |
483 | void mp_exit(mp_check check) { | 485 | void mp_exit(mp_check check) { |
484 | mp_print_output(check); | 486 | mp_print_output(check); |
485 | if (check.format == MP_FORMAT_TEST_JSON) { | 487 | if (output_format == MP_FORMAT_TEST_JSON) { |
486 | exit(0); | 488 | exit(0); |
487 | } | 489 | } |
488 | 490 | ||
@@ -533,3 +535,7 @@ parsed_output_format mp_parse_output_format(char *format_string) { | |||
533 | 535 | ||
534 | return result; | 536 | return result; |
535 | } | 537 | } |
538 | |||
539 | void mp_set_format(mp_output_format format) { output_format = format; } | ||
540 | |||
541 | mp_output_format mp_get_format(void) { return output_format; } | ||