]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
Move vt code into it's own module
authorRobert Ancell <robert.ancell@canonical.com>
Mon, 4 Jul 2011 03:08:39 +0000 (13:08 +1000)
committerRobert Ancell <robert.ancell@canonical.com>
Mon, 4 Jul 2011 03:08:39 +0000 (13:08 +1000)
src/Makefile.am
src/display-manager.c
src/vt.c [new file with mode: 0644]
src/vt.h [new file with mode: 0644]

index 57906c0ed7d02d8d95ac6ebb94e15b0902221549..a8af67fac28feed0e18ff5e97f2666fc4907f256 100644 (file)
@@ -33,6 +33,8 @@ lightdm_SOURCES = \
        theme.h \
        user.c \
        user.h \
+       vt.c \
+       vt.h \
        xauth.c \
        xauth.h \
        xdmcp-protocol.c \
index 60ec273abe4d62c70a004f02b3af0609f6014c6a..ddb2c1bfc024c877f6a63f56aba10fe1407b6577 100644 (file)
 
 #include <stdlib.h>
 #include <string.h>
-#include <errno.h>
-#include <sys/stat.h>
 #include <xcb/xcb.h>
 #include <fcntl.h>
-#include <glib/gstdio.h>
-#include <sys/ioctl.h>
-#ifdef __linux__
-#include <linux/vt.h>
-#endif
 
 #include "display-manager.h"
 #include "configuration.h"
 #include "user.h"
 #include "xdmcp-server.h"
 #include "xserver.h"
+#include "vt.h"
 #include "theme.h"
 
 enum {
@@ -258,56 +252,6 @@ string_to_xdm_auth_key (const gchar *key, guchar *data)
     }
 }
 
-static gint
-vt_get_active ()
-{
-#ifdef __linux__
-    gint console_fd;
-    struct vt_stat console_state = { 0 };    
-
-    console_fd = g_open ("/dev/console", O_RDONLY | O_NOCTTY);
-    if (console_fd < 0)
-    {
-        g_warning ("Error opening /dev/console: %s", strerror (errno));
-        return -1;
-    }
-
-    if (ioctl (console_fd, VT_GETSTATE, &console_state) < 0)
-        g_warning ("Error using VT_GETSTATE on /dev/console: %s", strerror (errno));
-
-    close (console_fd);
-
-    return console_state.v_active;
-#else
-    return -1;
-#endif    
-}
-
-static gint
-vt_get_unused ()
-{
-#ifdef __linux__
-    gint console_fd;
-    int number;
-
-    console_fd = g_open ("/dev/console", O_RDONLY | O_NOCTTY);
-    if (console_fd < 0)
-    {
-        g_warning ("Error opening /dev/console: %s", strerror (errno));
-        return -1;
-    }
-
-    if (ioctl (console_fd, VT_OPENQRY, &number) < 0)
-        g_warning ("Error using VT_OPENQRY on /dev/console: %s", strerror (errno));
-
-    close (console_fd);
-  
-    return number;
-#else
-    return -1;
-#endif    
-}
-
 static XServer *
 make_xserver (DisplayManager *manager, gchar *config_section)
 {
diff --git a/src/vt.c b/src/vt.c
new file mode 100644 (file)
index 0000000..fb570d1
--- /dev/null
+++ b/src/vt.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2010-2011 Robert Ancell.
+ * Author: Robert Ancell <robert.ancell@canonical.com>
+ * 
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <glib/gstdio.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#ifdef __linux__
+#include <linux/vt.h>
+#endif
+
+#include "vt.h"
+
+gint
+vt_get_active (void)
+{
+#ifdef __linux__
+    gint console_fd;
+    struct vt_stat console_state = { 0 };    
+
+    console_fd = g_open ("/dev/console", O_RDONLY | O_NOCTTY);
+    if (console_fd < 0)
+    {
+        g_warning ("Error opening /dev/console: %s", strerror (errno));
+        return -1;
+    }
+
+    if (ioctl (console_fd, VT_GETSTATE, &console_state) < 0)
+        g_warning ("Error using VT_GETSTATE on /dev/console: %s", strerror (errno));
+
+    close (console_fd);
+
+    return console_state.v_active;
+#else
+    return -1;
+#endif    
+}
+
+gint
+vt_get_unused (void)
+{
+#ifdef __linux__
+    gint console_fd;
+    int number;
+
+    console_fd = g_open ("/dev/console", O_RDONLY | O_NOCTTY);
+    if (console_fd < 0)
+    {
+        g_warning ("Error opening /dev/console: %s", strerror (errno));
+        return -1;
+    }
+
+    if (ioctl (console_fd, VT_OPENQRY, &number) < 0)
+        g_warning ("Error using VT_OPENQRY on /dev/console: %s", strerror (errno));
+
+    close (console_fd);
+  
+    return number;
+#else
+    return -1;
+#endif    
+}
+
+void
+vt_release (gint number)
+{
+}
diff --git a/src/vt.h b/src/vt.h
new file mode 100644 (file)
index 0000000..e615917
--- /dev/null
+++ b/src/vt.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2010-2011 Robert Ancell.
+ * Author: Robert Ancell <robert.ancell@canonical.com>
+ * 
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef _VT_H_
+#define _VT_H_
+
+#include <glib.h>
+
+gint vt_get_active (void);
+
+gint vt_get_unused (void);
+
+void vt_release (gint number);
+
+#endif /* _VT_H_ */