summaryrefslogtreecommitdiff
path: root/src/shared/pretty-print.c
Commit message (Collapse)AuthorAgeFilesLines
* Rename def.h to constants.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+1
| | | | | | The name "def.h" originates from before the rule of "no needless abbreviations" was established. Let's rename the file to clarify that it contains a collection of various semi-related constants.
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+0
| | | | | util.h is now about logarithms only, so we can rename it. Many files included util.h for no apparent reason… Those includes are dropped.
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-3/+1
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* analyze: fix printing config when there is no main config fileZbigniew Jędrzejewski-Szmek2021-11-211-14/+29
| | | | | | | | | | | | | | | | | | Since 8b8024f1c231c166f5c450905c8fd91d11704ae7 and the follow-up commits, the main config file may be located in /usr or in other paths. But the code in analyze.c was still assuming that it must be in /etc. Things mostly worked for our own config files because we usually install a comments-only file in /etc, but was not correct in the general case. This fixes in particular 'systemd-analyze cat-config systemd/zram-generator.conf'. In Fedora we distribute a config file in zram-generator-defaults.rpm that is in /usr/lib, and 'cat-config' would refuse to show it because /etc/systemd/zram-generator.conf does not exist. The main config file is optional, but let's print an informative message because this is a slightly unusual case. The file paths that we printed were missing the root prefix.
* Add meson option to disable urlify.James Hilliard2021-07-191-0/+4
| | | | | Useful for systems that don't use a version of less with hyperlink support.
* shared/pretty-print: silence gcc warningZbigniew Jędrzejewski-Szmek2021-03-311-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | gcc was very unhappy for some reason: [988/1664] Compiling C object systemd-oomd.p/src_oom_oomd.c.o In file included from ../src/basic/path-util.h:10, from ../src/shared/pretty-print.c:14, from ../src/oom/oomd.c:15: ../src/shared/pretty-print.c: In function ‘conf_files_cat’: ../src/basic/strv.h:123:32: warning: ‘prefixes’ may be used uninitialized [-Wmaybe-uninitialized] 123 | for ((s) = (l); (s) && *(s); (s)++) | ^ In file included from ../src/oom/oomd.c:15: ../src/shared/pretty-print.c:283:16: note: ‘prefixes’ was declared here 283 | char **prefixes, **prefix; | ^~~~~~~~ ../src/shared/pretty-print.c:305:12: warning: ‘is_collection’ may be used uninitialized in this function [-Wmaybe-uninitialized] 305 | if (!is_collection) { | ^ ../src/shared/pretty-print.c:301:13: warning: ‘extension’ may be used uninitialized in this function [-Wmaybe-uninitialized] 301 | r = conf_files_list_strv(&files, extension, root, 0, (const char* const*) dirs); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Maybe this is caused by the statis char** variables?
* pager: stop disabling urlification under a pagerZbigniew Jędrzejewski-Szmek2020-12-021-5/+1
| | | | | | | | | | | Less 568 properly shows urlified strings. Putative NEWS entry: * Urlification is now enabled by default even when a pager is used. Previously it was disabled, because less would not show such markup properly. This has been fixed in less 568. Please either upgrade less, or use SYSTEMD_URLIFY=0 to disable the feature.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* pretty-print: don't abbreviate needlessly in user-facing stringLennart Poettering2020-10-071-1/+1
|
* analyze: fix 'cat-config systemd/zram-generator.conf'Zbigniew Jędrzejewski-Szmek2020-08-051-0/+6
| | | | Also makes this work for various systemd config files that support .d.
* pretty-print: export urlify_enabled()Lennart Poettering2020-05-291-1/+1
|
* analyze: make cat-config work with relabel-extra.dZbigniew Jędrzejewski-Szmek2019-08-191-9/+18
|
* timedated: add back support for ntp-units.d/Zbigniew Jędrzejewski-Szmek2019-07-221-0/+5
| | | | | | | | | | | | | | | | | | | | We removed support for foreign services (and ntp-units.d/) in b72ddf0f4. Support for foreign services was added back in 5d280742, but through an environment variable. The problem with the env var approach is that it only works as a mechanism to select one item, and doesn't work nicely as a mechinism to create a list of items through drop-ins (because the env var can be easily overridden, but not extended). Having a list of "ntp providers" is important to be able to reliably disable all of them when that is requested. Another problem is that nobody ever bothered to care about our new "standard". ntp-units.d/ is a nice simple format that works and is already supported by chrony and ntpd and timedatex. If we were to introduce and ask people to follow a new standard, there should be some good reason for this. The idea with env vars has lower functionality, requires systemd-specific syntax. We should just re-adopt the format that we originally introduced and that seems to work for everyone, and more on to more interesting problems.
* systemd-analyze: support cat-config kernel/install.dZbigniew Jędrzejewski-Szmek2019-03-071-0/+3
| | | | Extension of f1d9d36ac5958006bbd464944ef490a198d38189.
* analyze: generalize cat-config to apply to tmpfiles, presets, hwdb.d, etc.Zbigniew Jędrzejewski-Szmek2019-02-181-10/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #10256. What works: systemd-analyze cat-config systemd/system-preset systemd-analyze cat-config systemd/user-preset systemd-analyze cat-config tmpfiles.d systemd-analyze cat-config sysusers.d systemd-analyze cat-config systemd/sleep.conf systemd-analyze cat-config systemd/user.conf systemd-analyze cat-config systemd/system.conf systemd-analyze cat-config udev/udev.conf (and other .conf files) systemd-analyze cat-config udev/rules.d systemd-analyze cat-config environment.d systemd-analyze cat-config environment Directories may be specified with the trailing dash or not. The caveat is that for user configuration, systemd and other tools also look at ~/.config/. It would be nice to support this, but this patch doesn't. "cat-config --user" is rejected, and we may allow it in the future and then extend the search path with directories under ~/.config. What doesn't work (and probably shouldn't because those files cannot be meaningfully concatenated): systemd-analyze cat-config systemd/system (.service, .slice, .socket, ...) systemd-analyze cat-config systemd/user systemd-analyze cat-config systemd/network (.network, .link, and .dnssd) The hardcoding of information about paths in this manner is a bit ugly, but OTOH, it is not too onerous, and at least we have one place where all the schemes are "documented" through code. It'll make us think twice before adding yet another slightly different scheme.
* terminal-util: split out file:// generation from terminal_urlify_path()Lennart Poettering2018-11-301-19/+33
| | | | | This way we can use it at other places, for example when preparing URLs for format_table_set_url()
* Split out pretty-print.c and move pager.c and main-func.h to shared/Zbigniew Jędrzejewski-Szmek2018-11-201-0/+233
This is high-level functionality, and fits better in shared/ (which is for our executables), than in basic/ (which is also for libraries).