#include "fd-util.h"
#include "log.h"
#include "macro.h"
+#include "pretty-print.h"
#include "process-util.h"
#include "signal-util.h"
#include "socket-util.h"
#include "pager.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pretty-print.h"
#if HAVE_SECCOMP
-#include "seccomp-util.h"
+# include "seccomp-util.h"
#endif
#include "special.h"
#include "strv.h"
#include "log.h"
#include "macro.h"
#include "main-func.h"
+#include "pretty-print.h"
#include "strv.h"
-#include "terminal-util.h"
static const char *arg_icon = NULL;
static const char *arg_id = NULL;
*replace_file = TAKE_PTR(p);
return 0;
}
-
-int conf_files_cat(const char *root, const char *name) {
- _cleanup_strv_free_ char **dirs = NULL, **files = NULL;
- _cleanup_free_ char *path = NULL;
- const char *dir;
- char **t;
- int r;
-
- NULSTR_FOREACH(dir, CONF_PATHS_NULSTR("")) {
- assert(endswith(dir, "/"));
- r = strv_extendf(&dirs, "%s%s.d", dir, name);
- if (r < 0)
- return log_error_errno(r, "Failed to build directory list: %m");
- }
-
- r = conf_files_list_strv(&files, ".conf", root, 0, (const char* const*) dirs);
- if (r < 0)
- return log_error_errno(r, "Failed to query file list: %m");
-
- path = path_join(root, "/etc", name);
- if (!path)
- return log_oom();
-
- if (DEBUG_LOGGING) {
- log_debug("Looking for configuration in:");
- log_debug(" %s", path);
- STRV_FOREACH(t, dirs)
- log_debug(" %s/*.conf", *t);
- }
-
- /* show */
- return cat_files(path, files, CAT_FLAGS_MAIN_FILE_OPTIONAL);
-}
const char *replacement,
char ***files,
char **replace_file);
-int conf_files_cat(const char *root, const char *name);
nss-util.h
ordered-set.c
ordered-set.h
- pager.c
- pager.h
parse-util.c
parse-util.h
path-util.c
#include "io-util.h"
#include "log.h"
#include "macro.h"
-#include "pager.h"
#include "parse-util.h"
#include "path-util.h"
#include "proc-cmdline.h"
return 0;
}
-
-static bool urlify_enabled(void) {
- static int cached_urlify_enabled = -1;
-
- /* Unfortunately 'less' doesn't support links like this yet 😭, hence let's disable this as long as there's a
- * pager in effect. Let's drop this check as soon as less got fixed a and enough time passed so that it's safe
- * to assume that a link-enabled 'less' version has hit most installations. */
-
- if (cached_urlify_enabled < 0) {
- int val;
-
- val = getenv_bool("SYSTEMD_URLIFY");
- if (val >= 0)
- cached_urlify_enabled = val;
- else
- cached_urlify_enabled = colors_enabled() && !pager_have();
- }
-
- return cached_urlify_enabled;
-}
-
-int terminal_urlify(const char *url, const char *text, char **ret) {
- char *n;
-
- assert(url);
-
- /* Takes an URL and a pretty string and formats it as clickable link for the terminal. See
- * https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda for details. */
-
- if (isempty(text))
- text = url;
-
- if (urlify_enabled())
- n = strjoin("\x1B]8;;", url, "\a", text, "\x1B]8;;\a");
- else
- n = strdup(text);
- if (!n)
- return -ENOMEM;
-
- *ret = n;
- return 0;
-}
-
-int terminal_urlify_path(const char *path, const char *text, char **ret) {
- _cleanup_free_ char *absolute = NULL;
- struct utsname u;
- const char *url;
- int r;
-
- assert(path);
-
- /* Much like terminal_urlify() above, but takes a file system path as input
- * and turns it into a proper file:// URL first. */
-
- if (isempty(path))
- return -EINVAL;
-
- if (isempty(text))
- text = path;
-
- if (!urlify_enabled()) {
- char *n;
-
- n = strdup(text);
- if (!n)
- return -ENOMEM;
-
- *ret = n;
- return 0;
- }
-
- if (uname(&u) < 0)
- return -errno;
-
- if (!path_is_absolute(path)) {
- r = path_make_absolute_cwd(path, &absolute);
- if (r < 0)
- return r;
-
- path = absolute;
- }
-
- /* As suggested by https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda, let's include the local
- * hostname here. Note that we don't use gethostname_malloc() or gethostname_strict() since we are interested
- * in the raw string the kernel has set, whatever it may be, under the assumption that terminals are not overly
- * careful with validating the strings either. */
-
- url = strjoina("file://", u.nodename, path);
-
- return terminal_urlify(url, text, ret);
-}
-
-int terminal_urlify_man(const char *page, const char *section, char **ret) {
- const char *url, *text;
-
- url = strjoina("man:", page, "(", section, ")");
- text = strjoina(page, "(", section, ") man page");
-
- return terminal_urlify(url, text, ret);
-}
-
-static int cat_file(const char *filename, bool newline) {
- _cleanup_fclose_ FILE *f = NULL;
- _cleanup_free_ char *urlified = NULL;
- int r;
-
- f = fopen(filename, "re");
- if (!f)
- return -errno;
-
- r = terminal_urlify_path(filename, NULL, &urlified);
- if (r < 0)
- return r;
-
- printf("%s%s# %s%s\n",
- newline ? "\n" : "",
- ansi_highlight_blue(),
- urlified,
- ansi_normal());
- fflush(stdout);
-
- for (;;) {
- _cleanup_free_ char *line = NULL;
-
- r = read_line(f, LONG_LINE_MAX, &line);
- if (r < 0)
- return log_error_errno(r, "Failed to read \"%s\": %m", filename);
- if (r == 0)
- break;
-
- puts(line);
- }
-
- return 0;
-}
-
-int cat_files(const char *file, char **dropins, CatFlags flags) {
- char **path;
- int r;
-
- if (file) {
- r = cat_file(file, false);
- if (r == -ENOENT && (flags & CAT_FLAGS_MAIN_FILE_OPTIONAL))
- printf("%s# config file %s not found%s\n",
- ansi_highlight_magenta(),
- file,
- ansi_normal());
- else if (r < 0)
- return log_warning_errno(r, "Failed to cat %s: %m", file);
- }
-
- STRV_FOREACH(path, dropins) {
- r = cat_file(*path, file || path != dropins);
- if (r < 0)
- return log_warning_errno(r, "Failed to cat %s: %m", *path);
- }
-
- return 0;
-}
-
-void print_separator(void) {
-
- /* Outputs a separator line that resolves to whitespace when copied from the terminal. We do that by outputting
- * one line filled with spaces with ANSI underline set, followed by a second (empty) line. */
-
- if (underline_enabled()) {
- size_t i, c;
-
- c = columns();
-
- flockfile(stdout);
- fputs_unlocked(ANSI_UNDERLINE, stdout);
-
- for (i = 0; i < c; i++)
- fputc_unlocked(' ', stdout);
-
- fputs_unlocked(ANSI_NORMAL "\n\n", stdout);
- funlockfile(stdout);
- } else
- fputs("\n\n", stdout);
-}
int vt_default_utf8(void);
int vt_reset_keyboard(int fd);
-
-int terminal_urlify(const char *url, const char *text, char **ret);
-int terminal_urlify_path(const char *path, const char *text, char **ret);
-int terminal_urlify_man(const char *page, const char *section, char **ret);
-
-typedef enum CatFlags {
- CAT_FLAGS_MAIN_FILE_OPTIONAL = 1 << 0,
-} CatFlags;
-
-int cat_files(const char *file, char **dropins, CatFlags flags);
-
-void print_separator(void);
#include "main-func.h"
#include "pager.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "string-util.h"
#include "strv.h"
-#include "terminal-util.h"
#include "util.h"
static bool arg_cat_config = false;
#include "main-func.h"
#include "pager.h"
#include "parse-util.h"
+#include "pretty-print.h"
#include "rm-rf.h"
#include "stat-util.h"
#include "string-util.h"
#include "pager.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "set.h"
#include "strv.h"
#include "terminal-util.h"
#include "output-mode.h"
#include "pager.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "strv.h"
-#include "terminal-util.h"
#include "unit-name.h"
#include "util.h"
#include "main-func.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "process-util.h"
#include "procfs-util.h"
#include "stdio-util.h"
#include "pager.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "proc-cmdline.h"
#include "process-util.h"
#include "raw-clone.h"
#include "pager.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "process-util.h"
#include "rlimit-util.h"
#include "sigbus.h"
#include "path-util.h"
#include "string-util.h"
#include "strv.h"
-#include "terminal-util.h"
+#include "pretty-print.h"
#include "util.h"
/* internal helper */
#include "pager.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "process-util.h"
#include "signal-util.h"
#include "stat-util.h"
#include "alloc-util.h"
#include "main-func.h"
+#include "pretty-print.h"
#include "string-table.h"
-#include "terminal-util.h"
#include "util.h"
#include "virt.h"
#include "alloc-util.h"
#include "log.h"
#include "main-func.h"
+#include "pretty-print.h"
#include "string-util.h"
#include "strv.h"
-#include "terminal-util.h"
#include "unit-name.h"
static enum {
#include "os-util.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "proc-cmdline.h"
#include "random-util.h"
#include "string-util.h"
#include "bus-util.h"
#include "hostname-util.h"
#include "main-func.h"
+#include "pretty-print.h"
#include "spawn-polkit-agent.h"
-#include "terminal-util.h"
#include "util.h"
#include "verbs.h"
#include "alloc-util.h"
#include "hwdb-util.h"
#include "main-func.h"
+#include "pretty-print.h"
#include "selinux-util.h"
-#include "terminal-util.h"
#include "util.h"
#include "verbs.h"
#include "alloc-util.h"
#include "id128-print.h"
#include "main-func.h"
-#include "terminal-util.h"
+#include "pretty-print.h"
#include "util.h"
#include "verbs.h"
#include "microhttpd-util.h"
#include "os-util.h"
#include "parse-util.h"
+#include "pretty-print.h"
#include "sigbus.h"
-#include "terminal-util.h"
#include "util.h"
#define JOURNAL_WAIT_TIMEOUT (10*USEC_PER_SEC)
#include "fileio.h"
#include "journal-remote-write.h"
#include "journal-remote.h"
+#include "pretty-print.h"
#include "process-util.h"
#include "rlimit-util.h"
#include "signal-util.h"
#include "stat-util.h"
#include "string-table.h"
#include "strv.h"
-#include "terminal-util.h"
#define PRIV_KEY_FILE CERTIFICATE_ROOT "/private/journal-remote.pem"
#define CERT_FILE CERTIFICATE_ROOT "/certs/journal-remote.pem"
#include "log.h"
#include "mkdir.h"
#include "parse-util.h"
+#include "pretty-print.h"
#include "process-util.h"
#include "rlimit-util.h"
#include "sigbus.h"
#include "signal-util.h"
#include "string-util.h"
-#include "terminal-util.h"
#include "util.h"
#define PRIV_KEY_FILE CERTIFICATE_ROOT "/private/journal-upload.pem"
#include "fd-util.h"
#include "main-func.h"
#include "parse-util.h"
+#include "pretty-print.h"
#include "string-util.h"
#include "syslog-util.h"
-#include "terminal-util.h"
#include "util.h"
static const char *arg_identifier = NULL;
#include "pager.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "rlimit-util.h"
#include "set.h"
#include "sigbus.h"
#include "locale-util.h"
#include "main-func.h"
#include "pager.h"
+#include "pretty-print.h"
#include "proc-cmdline.h"
#include "set.h"
#include "spawn-polkit-agent.h"
#include "strv.h"
-#include "terminal-util.h"
#include "util.h"
#include "verbs.h"
#include "virt.h"
#include "format-util.h"
#include "main-func.h"
#include "pager.h"
+#include "pretty-print.h"
#include "process-util.h"
#include "signal-util.h"
#include "strv.h"
-#include "terminal-util.h"
#include "user-util.h"
#include "util.h"
#include "main-func.h"
#include "pager.h"
#include "parse-util.h"
+#include "pretty-print.h"
#include "process-util.h"
#include "rlimit-util.h"
#include "sigbus.h"
#include "machine-id-setup.h"
#include "main-func.h"
#include "path-util.h"
-#include "terminal-util.h"
+#include "pretty-print.h"
#include "util.h"
static char *arg_root = NULL;
#include "pager.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "process-util.h"
#include "ptyfwd.h"
#include "rlimit-util.h"
#include "fileio.h"
#include "log.h"
#include "module-util.h"
+#include "pretty-print.h"
#include "proc-cmdline.h"
#include "string-util.h"
#include "strv.h"
-#include "terminal-util.h"
#include "util.h"
static char **arg_proc_cmdline_modules = NULL;
#include "pager.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "spawn-polkit-agent.h"
#include "stat-util.h"
#include "strv.h"
#include "netlink-util.h"
#include "pager.h"
#include "parse-util.h"
+#include "pretty-print.h"
#include "socket-util.h"
#include "sparse-endian.h"
#include "stdio-util.h"
#include "sd-daemon.h"
#include "manager.h"
+#include "pretty-print.h"
#include "signal-util.h"
#include "strv.h"
-#include "terminal-util.h"
static bool arg_quiet = false;
static usec_t arg_timeout = 120 * USEC_PER_SEC;
#include "log.h"
#include "main-func.h"
#include "parse-util.h"
+#include "pretty-print.h"
#include "string-util.h"
#include "strv.h"
-#include "terminal-util.h"
#include "user-util.h"
#include "util.h"
#include "pager.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "process-util.h"
#include "ptyfwd.h"
#include "random-util.h"
#include "mount-util.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "strv.h"
-#include "terminal-util.h"
static const char *arg_target = NULL;
static bool arg_dry_run = false;
#include "log.h"
#include "macro.h"
#include "main-func.h"
+#include "pretty-print.h"
#include "string-util.h"
-#include "terminal-util.h"
#include "util.h"
static const char *arg_suffix = NULL;
#include "pager.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "spawn-polkit-agent.h"
#include "string-util.h"
#include "strv.h"
#include "extract-word.h"
#include "fileio.h"
#include "parse-util.h"
+#include "pretty-print.h"
#include "resolvconf-compat.h"
#include "resolvectl.h"
#include "resolved-def.h"
#include "netlink-util.h"
#include "pager.h"
#include "parse-util.h"
+#include "pretty-print.h"
#include "resolvconf-compat.h"
#include "resolvectl.h"
#include "resolved-def.h"
#include "format-util.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "process-util.h"
#include "ptyfwd.h"
#include "signal-util.h"
#include "alloc-util.h"
#include "id128-print.h"
#include "log.h"
+#include "pretty-print.h"
#include "terminal-util.h"
int id128_pretty_print(sd_id128_t id, bool pretty) {
machine-image.h
machine-pool.c
machine-pool.h
+ main-func.h
module-util.h
nsflags.c
nsflags.h
os-util.h
output-mode.c
output-mode.h
+ pager.c
+ pager.h
path-lookup.c
path-lookup.h
+ pretty-print.c
+ pretty-print.h
ptyfwd.c
ptyfwd.h
reboot-util.c
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
+#include <sys/utsname.h>
+#include <errno.h>
+#include <stdio.h>
+
+#include "alloc-util.h"
+#include "conf-files.h"
+#include "def.h"
+#include "env-util.h"
+#include "fd-util.h"
+#include "fileio.h"
+#include "pager.h"
+#include "path-util.h"
+#include "pretty-print.h"
+#include "string-util.h"
+#include "strv.h"
+#include "terminal-util.h"
+#include "util.h"
+
+static bool urlify_enabled(void) {
+ static int cached_urlify_enabled = -1;
+
+ /* Unfortunately 'less' doesn't support links like this yet 😭, hence let's disable this as long as there's a
+ * pager in effect. Let's drop this check as soon as less got fixed a and enough time passed so that it's safe
+ * to assume that a link-enabled 'less' version has hit most installations. */
+
+ if (cached_urlify_enabled < 0) {
+ int val;
+
+ val = getenv_bool("SYSTEMD_URLIFY");
+ if (val >= 0)
+ cached_urlify_enabled = val;
+ else
+ cached_urlify_enabled = colors_enabled() && !pager_have();
+ }
+
+ return cached_urlify_enabled;
+}
+
+int terminal_urlify(const char *url, const char *text, char **ret) {
+ char *n;
+
+ assert(url);
+
+ /* Takes an URL and a pretty string and formats it as clickable link for the terminal. See
+ * https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda for details. */
+
+ if (isempty(text))
+ text = url;
+
+ if (urlify_enabled())
+ n = strjoin("\x1B]8;;", url, "\a", text, "\x1B]8;;\a");
+ else
+ n = strdup(text);
+ if (!n)
+ return -ENOMEM;
+
+ *ret = n;
+ return 0;
+}
+
+int terminal_urlify_path(const char *path, const char *text, char **ret) {
+ _cleanup_free_ char *absolute = NULL;
+ struct utsname u;
+ const char *url;
+ int r;
+
+ assert(path);
+
+ /* Much like terminal_urlify() above, but takes a file system path as input
+ * and turns it into a proper file:// URL first. */
+
+ if (isempty(path))
+ return -EINVAL;
+
+ if (isempty(text))
+ text = path;
+
+ if (!urlify_enabled()) {
+ char *n;
+
+ n = strdup(text);
+ if (!n)
+ return -ENOMEM;
+
+ *ret = n;
+ return 0;
+ }
+
+ if (uname(&u) < 0)
+ return -errno;
+
+ if (!path_is_absolute(path)) {
+ r = path_make_absolute_cwd(path, &absolute);
+ if (r < 0)
+ return r;
+
+ path = absolute;
+ }
+
+ /* As suggested by https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda, let's include the local
+ * hostname here. Note that we don't use gethostname_malloc() or gethostname_strict() since we are interested
+ * in the raw string the kernel has set, whatever it may be, under the assumption that terminals are not overly
+ * careful with validating the strings either. */
+
+ url = strjoina("file://", u.nodename, path);
+
+ return terminal_urlify(url, text, ret);
+}
+
+int terminal_urlify_man(const char *page, const char *section, char **ret) {
+ const char *url, *text;
+
+ url = strjoina("man:", page, "(", section, ")");
+ text = strjoina(page, "(", section, ") man page");
+
+ return terminal_urlify(url, text, ret);
+}
+
+static int cat_file(const char *filename, bool newline) {
+ _cleanup_fclose_ FILE *f = NULL;
+ _cleanup_free_ char *urlified = NULL;
+ int r;
+
+ f = fopen(filename, "re");
+ if (!f)
+ return -errno;
+
+ r = terminal_urlify_path(filename, NULL, &urlified);
+ if (r < 0)
+ return r;
+
+ printf("%s%s# %s%s\n",
+ newline ? "\n" : "",
+ ansi_highlight_blue(),
+ urlified,
+ ansi_normal());
+ fflush(stdout);
+
+ for (;;) {
+ _cleanup_free_ char *line = NULL;
+
+ r = read_line(f, LONG_LINE_MAX, &line);
+ if (r < 0)
+ return log_error_errno(r, "Failed to read \"%s\": %m", filename);
+ if (r == 0)
+ break;
+
+ puts(line);
+ }
+
+ return 0;
+}
+
+int cat_files(const char *file, char **dropins, CatFlags flags) {
+ char **path;
+ int r;
+
+ if (file) {
+ r = cat_file(file, false);
+ if (r == -ENOENT && (flags & CAT_FLAGS_MAIN_FILE_OPTIONAL))
+ printf("%s# config file %s not found%s\n",
+ ansi_highlight_magenta(),
+ file,
+ ansi_normal());
+ else if (r < 0)
+ return log_warning_errno(r, "Failed to cat %s: %m", file);
+ }
+
+ STRV_FOREACH(path, dropins) {
+ r = cat_file(*path, file || path != dropins);
+ if (r < 0)
+ return log_warning_errno(r, "Failed to cat %s: %m", *path);
+ }
+
+ return 0;
+}
+
+void print_separator(void) {
+
+ /* Outputs a separator line that resolves to whitespace when copied from the terminal. We do that by outputting
+ * one line filled with spaces with ANSI underline set, followed by a second (empty) line. */
+
+ if (underline_enabled()) {
+ size_t i, c;
+
+ c = columns();
+
+ flockfile(stdout);
+ fputs_unlocked(ANSI_UNDERLINE, stdout);
+
+ for (i = 0; i < c; i++)
+ fputc_unlocked(' ', stdout);
+
+ fputs_unlocked(ANSI_NORMAL "\n\n", stdout);
+ funlockfile(stdout);
+ } else
+ fputs("\n\n", stdout);
+}
+
+int conf_files_cat(const char *root, const char *name) {
+ _cleanup_strv_free_ char **dirs = NULL, **files = NULL;
+ _cleanup_free_ char *path = NULL;
+ const char *dir;
+ char **t;
+ int r;
+
+ NULSTR_FOREACH(dir, CONF_PATHS_NULSTR("")) {
+ assert(endswith(dir, "/"));
+ r = strv_extendf(&dirs, "%s%s.d", dir, name);
+ if (r < 0)
+ return log_error_errno(r, "Failed to build directory list: %m");
+ }
+
+ r = conf_files_list_strv(&files, ".conf", root, 0, (const char* const*) dirs);
+ if (r < 0)
+ return log_error_errno(r, "Failed to query file list: %m");
+
+ path = path_join(root, "/etc", name);
+ if (!path)
+ return log_oom();
+
+ if (DEBUG_LOGGING) {
+ log_debug("Looking for configuration in:");
+ log_debug(" %s", path);
+ STRV_FOREACH(t, dirs)
+ log_debug(" %s/*.conf", *t);
+ }
+
+ /* show */
+ return cat_files(path, files, CAT_FLAGS_MAIN_FILE_OPTIONAL);
+}
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
+
+void print_separator(void);
+
+int terminal_urlify(const char *url, const char *text, char **ret);
+int terminal_urlify_path(const char *path, const char *text, char **ret);
+int terminal_urlify_man(const char *page, const char *section, char **ret);
+
+typedef enum CatFlags {
+ CAT_FLAGS_MAIN_FILE_OPTIONAL = 1 << 0,
+} CatFlags;
+
+int cat_files(const char *file, char **dropins, CatFlags flags);
+int conf_files_cat(const char *root, const char *name);
#include "log.h"
#include "main-func.h"
#include "parse-util.h"
+#include "pretty-print.h"
#include "sleep-config.h"
#include "stdio-util.h"
#include "string-util.h"
#include "strv.h"
-#include "terminal-util.h"
#include "util.h"
static char* arg_verb = NULL;
#include "log.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "set.h"
#include "socket-util.h"
#include "string-util.h"
-#include "terminal-util.h"
#include "util.h"
#define BUFFER_SIZE (256 * 1024)
#include "main-func.h"
#include "pager.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "string-util.h"
#include "strv.h"
#include "sysctl-util.h"
-#include "terminal-util.h"
#include "util.h"
static char **arg_prefixes = NULL;
#include "parse-util.h"
#include "path-lookup.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "proc-cmdline.h"
#include "process-util.h"
#include "reboot-util.h"
#include "hashmap.h"
#include "pager.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "selinux-util.h"
#include "smack-util.h"
#include "specifier.h"
#include "string-util.h"
#include "strv.h"
-#include "terminal-util.h"
#include "uid-range.h"
#include "user-util.h"
#include "utf8.h"
[],
[]],
+ [['src/test/test-pretty-print.c'],
+ [],
+ []],
+
[['src/test/test-uid-range.c'],
[],
[]],
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
+#include <stdio.h>
+
+#include "alloc-util.h"
+#include "macro.h"
+#include "pretty-print.h"
+#include "strv.h"
+#include "tests.h"
+
+static void test_terminal_urlify(void) {
+ _cleanup_free_ char *formatted = NULL;
+
+ assert_se(terminal_urlify("https://www.freedesktop.org/wiki/Software/systemd/", "systemd homepage", &formatted) >= 0);
+ printf("Hey, considere visiting the %s right now! It is very good!\n", formatted);
+
+ formatted = mfree(formatted);
+
+ assert_se(terminal_urlify_path("/etc/fstab", "this link to your /etc/fstab", &formatted) >= 0);
+ printf("Or click on %s to have a look at it!\n", formatted);
+}
+
+static void test_cat_files(void) {
+ assert_se(cat_files("/no/such/file", NULL, 0) == -ENOENT);
+ assert_se(cat_files("/no/such/file", NULL, CAT_FLAGS_MAIN_FILE_OPTIONAL) == 0);
+
+ if (access("/etc/fstab", R_OK) >= 0)
+ assert_se(cat_files("/etc/fstab", STRV_MAKE("/etc/fstab", "/etc/fstab"), 0) == 0);
+}
+
+int main(int argc, char *argv[]) {
+ test_setup_logging(LOG_INFO);
+
+ test_terminal_urlify();
+ test_cat_files();
+
+ print_separator();
+
+ return 0;
+}
#include <stdio.h>
#include "alloc-util.h"
+#include "pretty-print.h"
#include "string-util.h"
#include "terminal-util.h"
#include "util.h"
#include "alloc-util.h"
#include "fd-util.h"
#include "fileio.h"
-#include "log.h"
+#include "tests.h"
#include "macro.h"
#include "strv.h"
#include "terminal-util.h"
unlink(name);
}
-static void test_terminal_urlify(void) {
- _cleanup_free_ char *formatted = NULL;
-
- assert_se(terminal_urlify("https://www.freedesktop.org/wiki/Software/systemd/", "systemd homepage", &formatted) >= 0);
- printf("Hey, considere visiting the %s right now! It is very good!\n", formatted);
-
- formatted = mfree(formatted);
-
- assert_se(terminal_urlify_path("/etc/fstab", "this link to your /etc/fstab", &formatted) >= 0);
- printf("Or click on %s to have a look at it!\n", formatted);
-}
-
-static void test_cat_files(void) {
- assert_se(cat_files("/no/such/file", NULL, 0) == -ENOENT);
- assert_se(cat_files("/no/such/file", NULL, CAT_FLAGS_MAIN_FILE_OPTIONAL) == 0);
-
- if (access("/etc/fstab", R_OK) >= 0)
- assert_se(cat_files("/etc/fstab", STRV_MAKE("/etc/fstab", "/etc/fstab"), 0) == 0);
-}
-
int main(int argc, char *argv[]) {
- log_parse_environment();
- log_open();
+ test_setup_logging(LOG_INFO);
test_default_term_for_tty();
test_read_one_char();
- test_terminal_urlify();
- test_cat_files();
-
- print_separator();
return 0;
}
#include "main-func.h"
#include "pager.h"
#include "parse-util.h"
+#include "pretty-print.h"
#include "spawn-polkit-agent.h"
#include "sparse-endian.h"
#include "string-table.h"
#include "parse-util.h"
#include "path-lookup.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "rm-rf.h"
#include "selinux-util.h"
#include "set.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
-#include "terminal-util.h"
#include "umask-util.h"
#include "user-util.h"
#include "util.h"
#include "main-func.h"
#include "mkdir.h"
#include "path-util.h"
+#include "pretty-print.h"
#include "process-util.h"
#include "signal-util.h"
#include "socket-util.h"
#include <stdio.h>
#include "alloc-util.h"
+#include "pretty-print.h"
#include "selinux-util.h"
#include "string-util.h"
-#include "terminal-util.h"
#include "udevadm.h"
#include "udev-util.h"
#include "verbs.h"
#include "mkdir.h"
#include "netlink-util.h"
#include "parse-util.h"
+#include "pretty-print.h"
#include "proc-cmdline.h"
#include "process-util.h"
#include "selinux-util.h"
#include "string-util.h"
#include "strxcpyx.h"
#include "syslog-util.h"
-#include "terminal-util.h"
#include "udev-builtin.h"
#include "udev-ctrl.h"
#include "udev-util.h"
#include "crypt-util.h"
#include "hexdecoct.h"
#include "log.h"
+#include "pretty-print.h"
#include "string-util.h"
#include "terminal-util.h"