diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-01-13 21:56:28 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-01-14 01:54:33 +0100 |
commit | 3043935f02da2e680b37cf282587106ad05440ee (patch) | |
tree | 9a26ea56e312b80a2805c9f03ad993819f247756 /src/util.c | |
parent | c1072ea0dade39a4188de5e511adfffd4ba8e42c (diff) |
util: split out tty_is_vc_resolve() from default_term_for_tty()
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/util.c b/src/util.c index a6cdfd5b5a..7450565567 100644 --- a/src/util.c +++ b/src/util.c @@ -4402,31 +4402,37 @@ int vtnr_from_tty(const char *tty) { return i; } -const char *default_term_for_tty(const char *tty) { +bool tty_is_vc_resolve(const char *tty) { char *active = NULL; - const char *term; + bool b; assert(tty); if (startswith(tty, "/dev/")) tty += 5; - /* Resolve where /dev/console is pointing when determining - * TERM */ + /* Resolve where /dev/console is pointing to */ if (streq(tty, "console")) if (read_one_line_file("/sys/class/tty/console/active", &active) >= 0) { /* If multiple log outputs are configured the * last one is what /dev/console points to */ - if ((tty = strrchr(active, ' '))) + tty = strrchr(active, ' '); + if (tty) tty++; else tty = active; } - term = tty_is_vc(tty) ? "TERM=linux" : "TERM=vt100"; + b = tty_is_vc(tty); free(active); - return term; + return b; +} + +const char *default_term_for_tty(const char *tty) { + assert(tty); + + return tty_is_vc_resolve(tty) ? "TERM=linux" : "TERM=vt100"; } bool dirent_is_file(const struct dirent *de) { |