Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 9f1362d4e7eaaca0f48042dc579d07341d14e38a)
+++ uspace/lib/c/Makefile	(revision 369a5f8a1a86047b7259dfe2c89e8b6f05751cbb)
@@ -79,4 +79,5 @@
 	generic/io/printf_core.c \
 	generic/io/console.c \
+	generic/io/screenbuffer.c \
 	generic/malloc.c \
 	generic/sysinfo.c \
Index: uspace/lib/c/generic/io/asprintf.c
===================================================================
--- uspace/lib/c/generic/io/asprintf.c	(revision 9f1362d4e7eaaca0f48042dc579d07341d14e38a)
+++ uspace/lib/c/generic/io/asprintf.c	(revision 369a5f8a1a86047b7259dfe2c89e8b6f05751cbb)
@@ -61,5 +61,5 @@
 int asprintf(char **strp, const char *fmt, ...)
 {
-	struct printf_spec ps = {
+	printf_spec_t ps = {
 		asprintf_str_write,
 		asprintf_wstr_write,
Index: uspace/lib/c/generic/io/screenbuffer.c
===================================================================
--- uspace/lib/c/generic/io/screenbuffer.c	(revision 369a5f8a1a86047b7259dfe2c89e8b6f05751cbb)
+++ uspace/lib/c/generic/io/screenbuffer.c	(revision 369a5f8a1a86047b7259dfe2c89e8b6f05751cbb)
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2006 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup console
+ * @{
+ */
+/** @file
+ */
+
+#include <io/style.h>
+#include <io/screenbuffer.h>
+#include <malloc.h>
+#include <unistd.h>
+
+/** Store one character to screenbuffer.
+ *
+ * Its position is determined by scr->position_x
+ * and scr->position_y.
+ *
+ * @param scr Screenbuffer
+ * @param c   Stored character
+ *
+ */
+void screenbuffer_putchar(screenbuffer_t *scr, wchar_t ch)
+{
+	keyfield_t *field =
+	    get_field_at(scr, scr->position_x, scr->position_y);
+	
+	field->character = ch;
+	field->attrs = scr->attrs;
+}
+
+/** Initilize screenbuffer.
+ *
+ * Allocate space for screen content in accordance to given size.
+ *
+ * @param scr    Initialized screenbuffer
+ * @param size_x Width in characters
+ * @param size_y Height in characters
+ *
+ * @return Pointer to screenbuffer (same as scr parameter) or NULL
+ *
+ */
+screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, ipcarg_t size_x,
+    ipcarg_t size_y)
+{
+	scr->buffer = (keyfield_t *) malloc(sizeof(keyfield_t) * size_x * size_y);
+	if (!scr->buffer)
+		return NULL;
+	
+	scr->size_x = size_x;
+	scr->size_y = size_y;
+	scr->attrs.t = at_style;
+	scr->attrs.a.s.style = STYLE_NORMAL;
+	scr->is_cursor_visible = 1;
+	
+	screenbuffer_clear(scr);
+	
+	return scr;
+}
+
+/** Clear screenbuffer.
+ *
+ * @param scr Screenbuffer
+ *
+ */
+void screenbuffer_clear(screenbuffer_t *scr)
+{
+	size_t i;
+	
+	for (i = 0; i < (scr->size_x * scr->size_y); i++) {
+		scr->buffer[i].character = ' ';
+		scr->buffer[i].attrs = scr->attrs;
+	}
+	
+	scr->top_line = 0;
+	scr->position_x = 0;
+	scr->position_y = 0;
+}
+
+/** Clear one buffer line.
+ *
+ * @param scr
+ * @param line One buffer line (not a screen line!)
+ *
+ */
+void screenbuffer_clear_line(screenbuffer_t *scr, ipcarg_t line)
+{
+	ipcarg_t x;
+	
+	for (x = 0; x < scr->size_x; x++) {
+		scr->buffer[x + line * scr->size_x].character = ' ';
+		scr->buffer[x + line * scr->size_x].attrs = scr->attrs;
+	}
+}
+
+/** Copy content buffer from screenbuffer to given memory.
+ *
+ * @param scr  Source screenbuffer
+ * @param dest Destination
+ *
+ */
+void screenbuffer_copy_buffer(screenbuffer_t *scr, keyfield_t *dest)
+{
+	size_t i;
+	
+	for (i = 0; i < (scr->size_x * scr->size_y); i++)
+		dest[i] = scr->buffer[i];
+}
+
+/** Set new cursor position in screenbuffer.
+ *
+ * @param scr
+ * @param x
+ * @param y
+ *
+ */
+void screenbuffer_goto(screenbuffer_t *scr, ipcarg_t x, ipcarg_t y)
+{
+	scr->position_x = x % scr->size_x;
+	scr->position_y = y % scr->size_y;
+}
+
+/** Set new style.
+ *
+ * @param scr
+ * @param fg_color
+ * @param bg_color
+ *
+ */
+void screenbuffer_set_style(screenbuffer_t *scr, uint8_t style)
+{
+	scr->attrs.t = at_style;
+	scr->attrs.a.s.style = style;
+}
+
+/** Set new color.
+ *
+ * @param scr
+ * @param fg_color
+ * @param bg_color
+ *
+ */
+void screenbuffer_set_color(screenbuffer_t *scr, uint8_t fg_color,
+    uint8_t bg_color, uint8_t flags)
+{
+	scr->attrs.t = at_idx;
+	scr->attrs.a.i.fg_color = fg_color;
+	scr->attrs.a.i.bg_color = bg_color;
+	scr->attrs.a.i.flags = flags;
+}
+
+/** Set new RGB color.
+ *
+ * @param scr
+ * @param fg_color
+ * @param bg_color
+ *
+ */
+void screenbuffer_set_rgb_color(screenbuffer_t *scr, uint32_t fg_color,
+    uint32_t bg_color)
+{
+	scr->attrs.t = at_rgb;
+	scr->attrs.a.r.fg_color = fg_color;
+	scr->attrs.a.r.bg_color = bg_color;
+}
+
+/** @}
+ */
Index: uspace/lib/c/generic/io/vprintf.c
===================================================================
--- uspace/lib/c/generic/io/vprintf.c	(revision 9f1362d4e7eaaca0f48042dc579d07341d14e38a)
+++ uspace/lib/c/generic/io/vprintf.c	(revision 369a5f8a1a86047b7259dfe2c89e8b6f05751cbb)
@@ -76,5 +76,5 @@
 int vfprintf(FILE *stream, const char *fmt, va_list ap)
 {
-	struct printf_spec ps = {
+	printf_spec_t ps = {
 		vprintf_str_write,
 		vprintf_wstr_write,
Index: uspace/lib/c/include/io/color.h
===================================================================
--- uspace/lib/c/include/io/color.h	(revision 9f1362d4e7eaaca0f48042dc579d07341d14e38a)
+++ uspace/lib/c/include/io/color.h	(revision 369a5f8a1a86047b7259dfe2c89e8b6f05751cbb)
@@ -36,5 +36,5 @@
 #define LIBC_IO_COLOR_H_
 
-enum console_color {
+typedef enum {
 	COLOR_BLACK   = 0,
 	COLOR_BLUE    = 1,
@@ -48,5 +48,5 @@
 	CATTR_BRIGHT  = 8,
 	CATTR_BLINK   = 8
-};
+} console_color_t;
 
 #endif
Index: uspace/lib/c/include/io/console.h
===================================================================
--- uspace/lib/c/include/io/console.h	(revision 9f1362d4e7eaaca0f48042dc579d07341d14e38a)
+++ uspace/lib/c/include/io/console.h	(revision 369a5f8a1a86047b7259dfe2c89e8b6f05751cbb)
@@ -44,10 +44,10 @@
 } console_ev_type_t;
 
-enum {
+typedef enum {
 	CONSOLE_CCAP_NONE = 0,
 	CONSOLE_CCAP_STYLE,
 	CONSOLE_CCAP_INDEXED,
 	CONSOLE_CCAP_RGB
-};
+} console_caps_t;
 
 /** Console event structure. */
Index: uspace/lib/c/include/io/keycode.h
===================================================================
--- uspace/lib/c/include/io/keycode.h	(revision 9f1362d4e7eaaca0f48042dc579d07341d14e38a)
+++ uspace/lib/c/include/io/keycode.h	(revision 369a5f8a1a86047b7259dfe2c89e8b6f05751cbb)
@@ -51,5 +51,5 @@
  * they really are organized here by position, rather than by label.
  */
-enum keycode {
+typedef enum {
 
 	/* Main block row 1 */
@@ -199,5 +199,5 @@
 } keycode_t;
 
-enum keymod {
+typedef enum {
 	KM_LSHIFT      = 0x001,
 	KM_RSHIFT      = 0x002,
Index: uspace/lib/c/include/io/klog.h
===================================================================
--- uspace/lib/c/include/io/klog.h	(revision 9f1362d4e7eaaca0f48042dc579d07341d14e38a)
+++ uspace/lib/c/include/io/klog.h	(revision 369a5f8a1a86047b7259dfe2c89e8b6f05751cbb)
@@ -33,10 +33,10 @@
  */
 
-#ifndef LIBC_STREAM_H_
-#define LIBC_STREAM_H_
+#ifndef LIBC_IO_KLOG_H_
+#define LIBC_IO_KLOG_H_
 
 #include <sys/types.h>
 
-extern size_t klog_write(const void *buf, size_t size);
+extern size_t klog_write(const void *, size_t);
 extern void klog_update(void);
 
Index: uspace/lib/c/include/io/printf_core.h
===================================================================
--- uspace/lib/c/include/io/printf_core.h	(revision 9f1362d4e7eaaca0f48042dc579d07341d14e38a)
+++ uspace/lib/c/include/io/printf_core.h	(revision 369a5f8a1a86047b7259dfe2c89e8b6f05751cbb)
@@ -40,5 +40,5 @@
 
 /** Structure for specifying output methods for different printf clones. */
-typedef struct printf_spec {
+typedef struct {
 	/* String output function, returns number of printed characters or EOF */
 	int (*str_write)(const char *, size_t, void *);
@@ -51,5 +51,5 @@
 } printf_spec_t;
 
-int printf_core(const char *fmt, printf_spec_t *ps, va_list ap);
+extern int printf_core(const char *, printf_spec_t *, va_list);
 
 #endif
Index: uspace/lib/c/include/io/screenbuffer.h
===================================================================
--- uspace/lib/c/include/io/screenbuffer.h	(revision 369a5f8a1a86047b7259dfe2c89e8b6f05751cbb)
+++ uspace/lib/c/include/io/screenbuffer.h	(revision 369a5f8a1a86047b7259dfe2c89e8b6f05751cbb)
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2006 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup console
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_SCREENBUFFER_H__
+#define LIBC_SCREENBUFFER_H__
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <ipc/ipc.h>
+#include <bool.h>
+
+typedef enum {
+	at_style,
+	at_idx,
+	at_rgb
+} attr_type_t;
+
+typedef struct {
+	uint8_t style;
+} attr_style_t;
+
+typedef struct {
+	uint8_t fg_color;
+	uint8_t bg_color;
+	uint8_t flags;
+} attr_idx_t;
+
+typedef struct {
+	uint32_t bg_color;  /**< background color */
+	uint32_t fg_color;  /**< foreground color */
+} attr_rgb_t;
+
+typedef union {
+	attr_style_t s;
+	attr_idx_t i;
+	attr_rgb_t r;
+} attr_val_t;
+
+typedef struct {
+	attr_type_t t;
+	attr_val_t a;
+} attrs_t;
+
+/** One field on screen. It contain one character and its attributes. */
+typedef struct {
+	wchar_t character;  /**< Character itself */
+	attrs_t attrs;      /**< Character attributes */
+} keyfield_t;
+
+/** Structure for buffering state of one virtual console.
+ */
+typedef struct {
+	keyfield_t *buffer;      /**< Screen content - characters and
+	                              their attributes (used as a circular buffer) */
+	ipcarg_t size_x;         /**< Number of columns  */
+	ipcarg_t size_y;         /**< Number of rows */
+	
+	/** Coordinates of last printed character for determining cursor position */
+	ipcarg_t position_x;
+	ipcarg_t position_y;
+	
+	attrs_t attrs;           /**< Current attributes. */
+	size_t top_line;         /**< Points to buffer[][] line that will
+	                              be printed at screen as the first line */
+	bool is_cursor_visible;  /**< Cursor state - default is visible */
+} screenbuffer_t;
+
+/** Returns keyfield for position on screen
+ *
+ * Screenbuffer->buffer is cyclic buffer so we
+ * must couted in index of the topmost line.
+ *
+ * @param scr Screenbuffer
+ * @param x   Position on screen
+ * @param y   Position on screen
+ *
+ * @return Keyfield structure with character and its attributes on x, y
+ *
+ */
+static inline keyfield_t *get_field_at(screenbuffer_t *scr, ipcarg_t x, ipcarg_t y)
+{
+	return scr->buffer + x + ((y + scr->top_line) % scr->size_y) * scr->size_x;
+}
+
+/** Compares two sets of attributes.
+ *
+ * @param s1 First style
+ * @param s2 Second style
+ *
+ * @return Nonzero on equality
+ *
+ */
+static inline bool attrs_same(attrs_t a1, attrs_t a2)
+{
+	if (a1.t != a2.t)
+		return false;
+	
+	switch (a1.t) {
+	case at_style:
+		return (a1.a.s.style == a2.a.s.style);
+	case at_idx:
+		return (a1.a.i.fg_color == a2.a.i.fg_color)
+		    && (a1.a.i.bg_color == a2.a.i.bg_color)
+		    && (a1.a.i.flags == a2.a.i.flags);
+	case at_rgb:
+		return (a1.a.r.fg_color == a2.a.r.fg_color)
+		    && (a1.a.r.bg_color == a2.a.r.bg_color);
+	}
+	
+	return false;
+}
+
+extern void screenbuffer_putchar(screenbuffer_t *, wchar_t);
+extern screenbuffer_t *screenbuffer_init(screenbuffer_t *, ipcarg_t, ipcarg_t);
+
+extern void screenbuffer_clear(screenbuffer_t *);
+extern void screenbuffer_clear_line(screenbuffer_t *, ipcarg_t);
+extern void screenbuffer_copy_buffer(screenbuffer_t *, keyfield_t *);
+extern void screenbuffer_goto(screenbuffer_t *, ipcarg_t, ipcarg_t);
+extern void screenbuffer_set_style(screenbuffer_t *, uint8_t);
+extern void screenbuffer_set_color(screenbuffer_t *, uint8_t, uint8_t, uint8_t);
+extern void screenbuffer_set_rgb_color(screenbuffer_t *, uint32_t, uint32_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/io/style.h
===================================================================
--- uspace/lib/c/include/io/style.h	(revision 9f1362d4e7eaaca0f48042dc579d07341d14e38a)
+++ uspace/lib/c/include/io/style.h	(revision 369a5f8a1a86047b7259dfe2c89e8b6f05751cbb)
@@ -36,10 +36,10 @@
 #define LIBC_IO_STYLE_H_
 
-enum console_style {
+typedef enum {
 	STYLE_NORMAL   = 0,
 	STYLE_EMPHASIS = 1,
 	STYLE_INVERTED = 2,
 	STYLE_SELECTED = 3
-};
+} console_style_t;
 
 #endif
