Add console subsystem dummy
authorDavid Herrmann <dh.herrmann@googlemail.com>
Sat, 19 Nov 2011 23:41:15 +0000 (00:41 +0100)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Sat, 19 Nov 2011 23:41:15 +0000 (00:41 +0100)
Add dummy files for the console subsystem. This subsystem will be used to draw a
console to a framebuffer. It uses pango and cairo for text-rendering and will
provide all required modification functions that the terminal emulation will
require.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
src/console.c [new file with mode: 0644]
src/console.h [new file with mode: 0644]

diff --git a/src/console.c b/src/console.c
new file mode 100644 (file)
index 0000000..1273bdd
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * kmscon - Console Management
+ * Written 2011 by David Herrmann <dh.herrmann@googlemail.com>
+ */
+
+/*
+ * Console Management
+ * This provides the console drawing and manipulation functions. It does not
+ * provide the terminal emulation. It is just an abstraction layer to draw text
+ * to a framebuffer as used by terminals and consoles.
+ */
+
+/*
+ * TODO: Avoid using this hack and instead retrieve GL extension
+ * pointers dynamically on initialization.
+ */
+#define GL_GLEXT_PROTOTYPES
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <GL/gl.h>
+#include <GL/glext.h>
+
+#include "console.h"
+
+struct kmscon_console {
+       size_t ref;
+};
+
+int kmscon_console_new(struct kmscon_console **out)
+{
+       struct kmscon_console *con;
+
+       if (!out)
+               return -EINVAL;
+
+       con = malloc(sizeof(*con));
+       if (!con)
+               return -ENOMEM;
+
+       memset(con, 0, sizeof(*con));
+       con->ref = 1;
+
+       *out = con;
+       return 0;
+}
+
+void kmscon_console_ref(struct kmscon_console *con)
+{
+       if (!con)
+               return;
+
+       ++con->ref;
+}
+
+void kmscon_con_unref(struct kmscon_console *con)
+{
+       if (!con || !con->ref)
+               return;
+
+       if (--con->ref)
+               return;
+
+       free(con);
+}
diff --git a/src/console.h b/src/console.h
new file mode 100644 (file)
index 0000000..5e06700
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * kmscon - Console Management
+ * Written 2011 by David Herrmann <dh.herrmann@googlemail.com>
+ */
+
+/*
+ * Console Management
+ * The console management uses OpenGL, cairo and pango to draw a console to a
+ * framebuffer. It is independent of the other subsystems and can also be used
+ * in other applications.
+ *
+ * This console does not emulate any terminal at all. This subsystem just
+ * provides functions to draw a console to a framebuffer and modifying the state
+ * of it.
+ */
+
+#include <stdlib.h>
+
+struct kmscon_console;
+
+/* console objects */
+
+int kmscon_console_new(struct kmscon_console **out);
+void kmscon_console_ref(struct kmscon_console *con);
+void kmscon_console_unref(struct kmscon_console *con);