| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
#include "sd-json.h" |
| 4 |
|
| 5 |
#include "output-mode.h" |
| 6 |
#include "string-table.h" |
| 7 |
|
| 8 |
sd_json_format_flags_t output_mode_to_json_format_flags(OutputMode m) { |
| 9 |
|
| 10 |
switch (m) { |
| 11 |
|
| 12 |
case OUTPUT_JSON_SSE: |
| 13 |
return SD_JSON_FORMAT_SSE; |
| 14 |
|
| 15 |
case OUTPUT_JSON_SEQ: |
| 16 |
return SD_JSON_FORMAT_SEQ; |
| 17 |
|
| 18 |
case OUTPUT_JSON_PRETTY: |
| 19 |
return SD_JSON_FORMAT_PRETTY; |
| 20 |
|
| 21 |
default: |
| 22 |
return SD_JSON_FORMAT_NEWLINE; |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
static const char *const output_mode_table[_OUTPUT_MODE_MAX] = { |
| 27 |
[OUTPUT_SHORT] = "short", |
| 28 |
[OUTPUT_SHORT_FULL] = "short-full", |
| 29 |
[OUTPUT_SHORT_ISO] = "short-iso", |
| 30 |
[OUTPUT_SHORT_ISO_PRECISE] = "short-iso-precise", |
| 31 |
[OUTPUT_SHORT_PRECISE] = "short-precise", |
| 32 |
[OUTPUT_SHORT_MONOTONIC] = "short-monotonic", |
| 33 |
[OUTPUT_SHORT_DELTA] = "short-delta", |
| 34 |
[OUTPUT_SHORT_UNIX] = "short-unix", |
| 35 |
[OUTPUT_VERBOSE] = "verbose", |
| 36 |
[OUTPUT_EXPORT] = "export", |
| 37 |
[OUTPUT_JSON] = "json", |
| 38 |
[OUTPUT_JSON_PRETTY] = "json-pretty", |
| 39 |
[OUTPUT_JSON_SSE] = "json-sse", |
| 40 |
[OUTPUT_JSON_SEQ] = "json-seq", |
| 41 |
[OUTPUT_CAT] = "cat", |
| 42 |
[OUTPUT_WITH_UNIT] = "with-unit", |
| 43 |
}; |
| 44 |
|
| 45 |
DEFINE_STRING_TABLE_LOOKUP(output_mode, OutputMode); |