Add console subsystem dummy

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>
This commit is contained in:
David Herrmann 2011-11-20 00:41:15 +01:00
parent 259fcfa12d
commit f85eb100f9
2 changed files with 92 additions and 0 deletions

67
src/console.c Normal file
View File

@ -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);
}

25
src/console.h Normal file
View File

@ -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);