diff options
Diffstat (limited to 'lib/output.c')
| -rw-r--r-- | lib/output.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/output.c b/lib/output.c index 62e1366d..bfd43195 100644 --- a/lib/output.c +++ b/lib/output.c | |||
| @@ -165,7 +165,7 @@ int mp_add_subcheck_to_subcheck(mp_subcheck check[static 1], mp_subcheck subchec | |||
| 165 | void mp_add_summary(mp_check check[static 1], char *summary) { check->summary = summary; } | 165 | void mp_add_summary(mp_check check[static 1], char *summary) { check->summary = summary; } |
| 166 | 166 | ||
| 167 | /* | 167 | /* |
| 168 | * Generate the summary string of a mp_check object based on it's subchecks | 168 | * Generate the summary string of a mp_check object based on its subchecks |
| 169 | */ | 169 | */ |
| 170 | char *get_subcheck_summary(mp_check check) { | 170 | char *get_subcheck_summary(mp_check check) { |
| 171 | mp_subcheck_list *subchecks = check.subchecks; | 171 | mp_subcheck_list *subchecks = check.subchecks; |
| @@ -175,7 +175,7 @@ char *get_subcheck_summary(mp_check check) { | |||
| 175 | unsigned int critical = 0; | 175 | unsigned int critical = 0; |
| 176 | unsigned int unknown = 0; | 176 | unsigned int unknown = 0; |
| 177 | while (subchecks != NULL) { | 177 | while (subchecks != NULL) { |
| 178 | switch (subchecks->subcheck.state) { | 178 | switch (mp_compute_subcheck_state(subchecks->subcheck)) { |
| 179 | case STATE_OK: | 179 | case STATE_OK: |
| 180 | ok++; | 180 | ok++; |
| 181 | break; | 181 | break; |
| @@ -243,7 +243,7 @@ mp_state_enum mp_compute_check_state(const mp_check check) { | |||
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | /* | 245 | /* |
| 246 | * Generate the result state of a mp_check object based on it's own state and it's subchecks states | 246 | * Generate the result state of a mp_check object based on its own state and its subchecks states |
| 247 | */ | 247 | */ |
| 248 | mp_state_enum mp_eval_check_default(const mp_check check) { | 248 | mp_state_enum mp_eval_check_default(const mp_check check) { |
| 249 | assert(check.subchecks != NULL); // a mp_check without subchecks is invalid, die here | 249 | assert(check.subchecks != NULL); // a mp_check without subchecks is invalid, die here |
| @@ -259,6 +259,21 @@ mp_state_enum mp_eval_check_default(const mp_check check) { | |||
| 259 | return result; | 259 | return result; |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | // Remove troublesome symbols from plugin output | ||
| 263 | char *sanitize_output_insitu(char *input) { | ||
| 264 | if (input == NULL) { | ||
| 265 | return input; | ||
| 266 | } | ||
| 267 | |||
| 268 | for (char *walker = input; *walker != '\0'; walker++) { | ||
| 269 | if (*walker == '|') { | ||
| 270 | *walker = ' '; | ||
| 271 | } | ||
| 272 | } | ||
| 273 | |||
| 274 | return input; | ||
| 275 | } | ||
| 276 | |||
| 262 | /* | 277 | /* |
| 263 | * Generate output string for a mp_check object | 278 | * Generate output string for a mp_check object |
| 264 | * Non static to be available for testing functions | 279 | * Non static to be available for testing functions |
| @@ -299,6 +314,8 @@ char *mp_fmt_output(mp_check check) { | |||
| 299 | subchecks = subchecks->next; | 314 | subchecks = subchecks->next; |
| 300 | } | 315 | } |
| 301 | 316 | ||
| 317 | result = sanitize_output_insitu(result); | ||
| 318 | |||
| 302 | if (pd_string != NULL && strlen(pd_string) > 0) { | 319 | if (pd_string != NULL && strlen(pd_string) > 0) { |
| 303 | asprintf(&result, "%s|%s", result, pd_string); | 320 | asprintf(&result, "%s|%s", result, pd_string); |
| 304 | } | 321 | } |
