| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
#include "analyze.h" |
| 4 |
#include "analyze-cat-config.h" |
| 5 |
#include "constants.h" |
| 6 |
#include "log.h" |
| 7 |
#include "pager.h" |
| 8 |
#include "path-util.h" |
| 9 |
#include "pretty-print.h" |
| 10 |
#include "strv.h" |
| 11 |
|
| 12 |
int verb_cat_config(int argc, char *argv[], uintptr_t _data, void *userdata) { |
| 13 |
int r; |
| 14 |
|
| 15 |
pager_open(arg_pager_flags); |
| 16 |
|
| 17 |
char **list = strv_skip(argv, 1); |
| 18 |
STRV_FOREACH(arg, list) { |
| 19 |
const char *t = NULL; |
| 20 |
|
| 21 |
if (arg != list) |
| 22 |
print_separator(); |
| 23 |
|
| 24 |
if (path_is_absolute(*arg)) { |
| 25 |
FOREACH_STRING(dir, CONF_PATHS("")) { |
| 26 |
t = path_startswith(*arg, dir); |
| 27 |
if (t) |
| 28 |
break; |
| 29 |
} |
| 30 |
|
| 31 |
if (!t) |
| 32 |
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), |
| 33 |
"Path %s does not start with any known prefix.", *arg); |
| 34 |
} else |
| 35 |
t = *arg; |
| 36 |
|
| 37 |
r = conf_files_cat(arg_root, t, arg_cat_flags | CAT_FORMAT_HAS_SECTIONS); |
| 38 |
if (r < 0) |
| 39 |
return r; |
| 40 |
} |
| 41 |
|
| 42 |
return 0; |
| 43 |
} |