]> err.no Git - systemd/commitdiff
util: split out tty_is_vc_resolve() from default_term_for_tty()
authorLennart Poettering <lennart@poettering.net>
Fri, 13 Jan 2012 20:56:28 +0000 (21:56 +0100)
committerLennart Poettering <lennart@poettering.net>
Sat, 14 Jan 2012 00:54:33 +0000 (01:54 +0100)
src/util.c
src/util.h

index a6cdfd5b5ade9bf23a6a5082cf15392ded1d0150..7450565567bf8036affcfe11efea7235d59b12a1 100644 (file)
@@ -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) {
index a52ac64ee3c4a04f1a2a8dd96945311ae4d57e72..e6ffad6c2e89554b732ce83d3a870cef3740e78a 100644 (file)
@@ -411,6 +411,7 @@ char *fstab_node_to_udev_node(const char *p);
 void filter_environ(const char *prefix);
 
 bool tty_is_vc(const char *tty);
+bool tty_is_vc_resolve(const char *tty);
 int vtnr_from_tty(const char *tty);
 const char *default_term_for_tty(const char *tty);