Index: uspace/lib/c/generic/adt/char_map.c
===================================================================
--- uspace/lib/c/generic/adt/char_map.c	(revision 0402bda5d398fe22b00721b43066b197408016dd)
+++ uspace/lib/c/generic/adt/char_map.c	(revision 3c213f6e05d62f758d8643c6407493d1071d6526)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup net
+/** @addtogroup libc 
  *  @{
  */
@@ -35,4 +35,6 @@
  *  @see char_map.h
  */
+
+#include <adt/char_map.h>
 
 #include <errno.h>
@@ -41,108 +43,142 @@
 #include <unistd.h>
 
-#include <adt/char_map.h>
-
-/** Internal magic value for a&nbsp;consistency check.
- */
+/** Internal magic value for a consistency check. */
 #define CHAR_MAP_MAGIC_VALUE	0x12345611
 
 /** Adds the value with the key to the map.
- *  Creates new nodes to map the key.
- *  @param[in,out] map The character string to integer map.
- *  @param[in] identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found.
- *  @param[in] length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found.
- *  @param[in] value The integral value to be stored for the key character string.
- *  @returns EOK on success.
- *  @returns ENOMEM if there is not enough memory left.
- *  @returns EEXIST if the key character string is already used.
- */
-int char_map_add_item(char_map_ref map, const char * identifier, size_t length, const int value);
-
-/** Returns the node assigned to the key from the map.
- *  @param[in] map The character string to integer map.
- *  @param[in] identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found.
- *  @param[in] length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found.
- *  @returns The node holding the integral value assigned to the key character string.
- *  @returns NULL if the key is not assigned a&nbsp;node.
- */
-char_map_ref char_map_find_node(const char_map_ref map, const char * identifier, const size_t length);
-
-/** Returns the value assigned to the map.
- *  @param[in] map The character string to integer map.
- *  @returns The integral value assigned to the map.
- *  @returns CHAR_MAP_NULL if the map is not assigned a&nbsp;value.
- */
-int char_map_get_value(const char_map_ref map);
+ *
+ * Creates new nodes to map the key.
+ *
+ * @param[in,out] map	The character string to integer map.
+ * @param[in] identifier The key zero ('\0') terminated character string.
+ *			The key character string is processed until the first
+ *			terminating zero ('\0') character after the given
+ *			length is found.
+ * @param[in] length	The key character string length. The parameter may be
+ *			zero (0) which means that the string is processed until
+ *			the terminating zero ('\0') character is found.
+ * @param[in] value	The integral value to be stored for the key character
+ *			string.
+ * @returns		EOK on success.
+ * @returns		ENOMEM if there is not enough memory left.
+ * @returns		EEXIST if the key character string is already used.
+ */
+static int
+char_map_add_item(char_map_ref map, const char *identifier, size_t length,
+    const int value)
+{
+	if (map->next == (map->size - 1)) {
+		char_map_ref *tmp;
+
+		tmp = (char_map_ref *) realloc(map->items,
+		    sizeof(char_map_ref) * 2 * map->size);
+		if (!tmp)
+			return ENOMEM;
+
+		map->size *= 2;
+		map->items = tmp;
+	}
+
+	map->items[map->next] = (char_map_ref) malloc(sizeof(char_map_t));
+	if (!map->items[map->next])
+		return ENOMEM;
+
+	if (char_map_initialize(map->items[map->next]) != EOK) {
+		free(map->items[map->next]);
+		map->items[map->next] = NULL;
+		return ENOMEM;
+	}
+
+	map->items[map->next]->c = * identifier;
+	++ identifier;
+	++ map->next;
+	if ((length > 1) || ((length == 0) && (*identifier))) {
+		map->items[map->next - 1]->value = CHAR_MAP_NULL;
+		return char_map_add_item(map->items[map->next - 1], identifier,
+		    length ? length - 1 : 0, value);
+	} else {
+		map->items[map->next - 1]->value = value;
+	}
+
+	return EOK;
+}
 
 /** Checks if the map is valid.
- *  @param[in] map The character string to integer map.
- *  @returns TRUE if the map is valid.
- *  @returns FALSE otherwise.
- */
-int char_map_is_valid(const char_map_ref map);
-
-int char_map_add(char_map_ref map, const char * identifier, size_t length, const int value){
-	if(char_map_is_valid(map) && (identifier) && ((length) || (*identifier))){
+ *
+ * @param[in] map	The character string to integer map.
+ * @returns		TRUE if the map is valid.
+ * @returns		FALSE otherwise.
+ */
+static int char_map_is_valid(const char_map_ref map)
+{
+	return map && (map->magic == CHAR_MAP_MAGIC_VALUE);
+}
+
+/** Adds the value with the key to the map.
+ *
+ * @param[in,out] map	The character string to integer map.
+ * @param[in] identifier The key zero ('\0') terminated character string. The
+ *			key character string is processed until the first
+ *			terminating zero ('\0') character after the given
+ *			length is found.
+ * @param[in] length	The key character string length. The parameter may be
+ *			zero (0) which means that the string is processed until
+ *			the terminating zero ('\\0') character is found.
+ * @param[in] value	The integral value to be stored for the key character
+ *			string.
+ * @returns		EOK on success.
+ * @returns		EINVAL if the map is not valid.
+ * @returns		EINVAL if the identifier parameter is NULL.
+ * @returns		EINVAL if the length parameter zero (0) and the
+ *			identifier parameter is an empty character string (the
+ *			first character is the terminating zero ('\0')
+ *			character.
+ * @returns		EEXIST if the key character string is already used.
+ * @returns		Other error codes as defined for the
+ *			char_map_add_item() function.
+ */
+int
+char_map_add(char_map_ref map, const char *identifier, size_t length,
+    const int value)
+{
+	if (char_map_is_valid(map) && (identifier) &&
+	    ((length) || (*identifier))) {
 		int index;
 
-		for(index = 0; index < map->next; ++ index){
-			if(map->items[index]->c == * identifier){
-				++ identifier;
-				if((length > 1) || ((length == 0) && (*identifier))){
-					return char_map_add(map->items[index], identifier, length ? length - 1 : 0, value);
-				}else{
-					if(map->items[index]->value != CHAR_MAP_NULL){
-						return EEXISTS;
-					}
-					map->items[index]->value = value;
-					return EOK;
-				}
+		for (index = 0; index < map->next; ++ index) {
+			if (map->items[index]->c != *identifier)
+				continue;
+				
+			++ identifier;
+			if((length > 1) || ((length == 0) && (*identifier))) {
+				return char_map_add(map->items[index],
+				    identifier, length ? length - 1 : 0, value);
+			} else {
+				if (map->items[index]->value != CHAR_MAP_NULL)
+					return EEXISTS;
+
+				map->items[index]->value = value;
+				return EOK;
 			}
 		}
 		return char_map_add_item(map, identifier, length, value);
 	}
+
 	return EINVAL;
 }
 
-int char_map_add_item(char_map_ref map, const char * identifier, size_t length, const int value){
-	if(map->next == (map->size - 1)){
-		char_map_ref *tmp;
-
-		tmp = (char_map_ref *) realloc(map->items, sizeof(char_map_ref) * 2 * map->size);
-		if(! tmp){
-			return ENOMEM;
-		}
-		map->size *= 2;
-		map->items = tmp;
-	}
-	map->items[map->next] = (char_map_ref) malloc(sizeof(char_map_t));
-	if(! map->items[map->next]){
-		return ENOMEM;
-	}
-	if(char_map_initialize(map->items[map->next]) != EOK){
-		free(map->items[map->next]);
-		map->items[map->next] = NULL;
-		return ENOMEM;
-	}
-	map->items[map->next]->c = * identifier;
-	++ identifier;
-	++ map->next;
-	if((length > 1) || ((length == 0) && (*identifier))){
-		map->items[map->next - 1]->value = CHAR_MAP_NULL;
-		return char_map_add_item(map->items[map->next - 1], identifier, length ? length - 1 : 0, value);
-	}else{
-		map->items[map->next - 1]->value = value;
-	}
-	return EOK;
-}
-
-void char_map_destroy(char_map_ref map){
-	if(char_map_is_valid(map)){
+/** Clears and destroys the map.
+ *
+ * @param[in,out] map	The character string to integer map.
+ */
+void char_map_destroy(char_map_ref map)
+{
+	if (char_map_is_valid(map)) {
 		int index;
 
 		map->magic = 0;
-		for(index = 0; index < map->next; ++ index){
+		for (index = 0; index < map->next; ++index)
 			char_map_destroy(map->items[index]);
-		}
+
 		free(map->items);
 		map->items = NULL;
@@ -150,9 +186,66 @@
 }
 
-int char_map_exclude(char_map_ref map, const char * identifier, size_t length){
+/** Returns the node assigned to the key from the map.
+ *
+ * @param[in] map	The character string to integer map.
+ * @param[in] identifier The key zero ('\0') terminated character string. The
+ *			key character string is processed until the first
+ *			terminating zero ('\0') character after the given length
+ *			is found.
+ * @param[in] length	The key character string length. The parameter may be
+ *			zero (0) which means that the string is processed until
+ *			the terminating zero ('\0') character is found.
+ * @returns		The node holding the integral value assigned to the key
+ *			character string.
+ * @returns		NULL if the key is not assigned a node.
+ */
+static char_map_ref
+char_map_find_node(const char_map_ref map, const char *identifier,
+    size_t length)
+{
+	if (!char_map_is_valid(map))
+		return NULL;
+
+	if (length || (*identifier)) {
+		int index;
+
+		for (index = 0; index < map->next; ++index) {
+			if (map->items[index]->c == *identifier) {
+				++identifier;
+				if (length == 1)
+					return map->items[index];
+
+				return char_map_find_node(map->items[index],
+				    identifier, length ? length - 1 : 0);
+			}
+		}
+
+		return NULL;
+	}
+
+	return map;
+}
+
+/** Excludes the value assigned to the key from the map.
+ *
+ * The entry is cleared from the map.
+ *
+ * @param[in,out] map	The character string to integer map.
+ * @param[in] identifier The key zero ('\0') terminated character string. The
+ *			key character string is processed until the first
+ *			terminating zero ('\0') character after the given length
+ *			is found.
+ * @param[in] length	The key character string length. The parameter may be
+ *			zero (0) which means that the string is processed until
+ *			the terminating zero ('\0') character is found.
+ * @returns		The integral value assigned to the key character string.
+ * @returns		CHAR_MAP_NULL if the key is not assigned a value.
+ */
+int char_map_exclude(char_map_ref map, const char *identifier, size_t length)
+{
 	char_map_ref node;
 
 	node = char_map_find_node(map, identifier, length);
-	if(node){
+	if (node) {
 		int value;
 
@@ -164,5 +257,19 @@
 }
 
-int char_map_find(const char_map_ref map, const char * identifier, size_t length){
+/** Returns the value assigned to the key from the map.
+ *
+ *  @param[in] map	The character string to integer map.
+ *  @param[in] identifier The key zero ('\0') terminated character string. The
+ *			key character string is processed until the first
+ *			terminating zero ('\0') character after the given length
+ *			is found.
+ *  @param[in] length	The key character string length. The parameter may be
+ *			zero (0) which means that the string is processed until
+ *			the terminating zero ('\0') character is found.
+ *  @returns		The integral value assigned to the key character string.
+ *  @returns		CHAR_MAP_NULL if the key is not assigned a value.
+ */
+int char_map_find(const char_map_ref map, const char *identifier, size_t length)
+{
 	char_map_ref node;
 
@@ -171,62 +278,68 @@
 }
 
-char_map_ref char_map_find_node(const char_map_ref map, const char * identifier, size_t length){
-	if(! char_map_is_valid(map)){
-		return NULL;
-	}
-	if(length || (*identifier)){
-		int index;
-
-		for(index = 0; index < map->next; ++ index){
-			if(map->items[index]->c == * identifier){
-				++ identifier;
-				if(length == 1){
-					return map->items[index];
-				}
-				return char_map_find_node(map->items[index], identifier, length ? length - 1 : 0);
-			}
-		}
-		return NULL;
-	}
-	return map;
-}
-
-int char_map_get_value(const char_map_ref map){
-	return char_map_is_valid(map) ? map->value : CHAR_MAP_NULL;
-}
-
-int char_map_initialize(char_map_ref map){
-	if(! map){
+/** Initializes the map.
+ *
+ *  @param[in,out] map	The character string to integer map.
+ *  @returns		EOK on success.
+ *  @returns		EINVAL if the map parameter is NULL.
+ *  @returns		ENOMEM if there is not enough memory left.
+ */
+int char_map_initialize(char_map_ref map)
+{
+	if (!map)
 		return EINVAL;
-	}
+
 	map->c = '\0';
 	map->value = CHAR_MAP_NULL;
 	map->size = 2;
 	map->next = 0;
+
 	map->items = malloc(sizeof(char_map_ref) * map->size);
-	if(! map->items){
+	if (!map->items) {
 		map->magic = 0;
 		return ENOMEM;
 	}
+
 	map->items[map->next] = NULL;
 	map->magic = CHAR_MAP_MAGIC_VALUE;
+
 	return EOK;
 }
 
-int char_map_is_valid(const char_map_ref map){
-	return map && (map->magic == CHAR_MAP_MAGIC_VALUE);
-}
-
-int char_map_update(char_map_ref map, const char * identifier, const size_t length, const int value){
+/** Adds or updates the value with the key to the map.
+ *
+ *  @param[in,out] map	The character string to integer map.
+ *  @param[in] identifier The key zero ('\0') terminated character string. The
+ *			key character string is processed until the first
+ *			terminating zero ('\0') character after the given length
+ *			is found.
+ *  @param[in] length	The key character string length. The parameter may be
+ *			zero (0) which means that the string is processed until
+ *			the terminating zero ('\0') character is found.
+ *  @param[in] value	The integral value to be stored for the key character
+ *			string.
+ *  @returns		EOK on success.
+ *  @returns		EINVAL if the map is not valid.
+ *  @returns		EINVAL if the identifier parameter is NULL.
+ *  @returns		EINVAL if the length parameter zero (0) and the
+ *			identifier parameter is an empty character string (the
+ *			first character is the terminating zero ('\0) character.
+ *  @returns		EEXIST if the key character string is already used.
+ *  @returns		Other error codes as defined for the char_map_add_item()
+ *			function.
+ */
+int
+char_map_update(char_map_ref map, const char *identifier, const size_t length,
+    const int value)
+{
 	char_map_ref node;
 
-//	if(! char_map_is_valid(map)) return EINVAL;
 	node = char_map_find_node(map, identifier, length);
-	if(node){
+	if (node) {
 		node->value = value;
 		return EOK;
-	}else{
-		return char_map_add(map, identifier, length, value);
-	}
+	}
+	
+	return char_map_add(map, identifier, length, value);
 }
 
Index: uspace/lib/c/include/adt/char_map.h
===================================================================
--- uspace/lib/c/include/adt/char_map.h	(revision 0402bda5d398fe22b00721b43066b197408016dd)
+++ uspace/lib/c/include/adt/char_map.h	(revision 3c213f6e05d62f758d8643c6407493d1071d6526)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup net
+/** @addtogroup libc 
  *  @{
  */
@@ -38,6 +38,7 @@
 #define __CHAR_MAP_H__
 
-/** Invalid assigned value used also if an&nbsp;entry does not exist.
- */
+#include <libarch/types.h>
+
+/** Invalid assigned value used also if an&nbsp;entry does not exist. */
 #define CHAR_MAP_NULL	(-1)
 
@@ -50,90 +51,33 @@
  *  @see char_map
  */
-typedef char_map_t *	char_map_ref;
+typedef char_map_t *char_map_ref;
 
 /** Character string to integer map item.
- *  This structure recursivelly contains itself as a&nbsp;character by character tree.
- *  The actually mapped character string consists o fall the parent characters and the actual one.
+ *
+ * This structure recursivelly contains itself as a character by character tree.
+ * The actually mapped character string consists of all the parent characters
+ * and the actual one.
  */
-struct	char_map{
-	/** Actually mapped character.
-	 */
+struct char_map {
+	/** Actually mapped character. */
 	char c;
-	/** Stored integral value.
-	 */
+	/** Stored integral value. */
 	int value;
-	/** Next character array size.
-	 */
+	/** Next character array size. */
 	int size;
-	/** First free position in the next character array.
-	 */
+	/** First free position in the next character array. */
 	int next;
-	/** Next character array.
-	 */
-	char_map_ref * items;
-	/** Consistency check magic value.
-	 */
+	/** Next character array. */
+	char_map_ref *items;
+	/** Consistency check magic value. */
 	int magic;
 };
 
-/** Adds the value with the key to the map.
- *  @param[in,out] map The character string to integer map.
- *  @param[in] identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found.
- *  @param[in] length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found.
- *  @param[in] value The integral value to be stored for the key character string.
- *  @returns EOK on success.
- *  @returns EINVAL if the map is not valid.
- *  @returns EINVAL if the identifier parameter is NULL.
- *  @returns EINVAL if the length parameter zero (0) and the identifier parameter is an empty character string (the first character is the terminating zero ('\\0') character.
- *  @returns EEXIST if the key character string is already used.
- *  @returns Other error codes as defined for the char_map_add_item() function.
- */
-extern int char_map_add(char_map_ref map, const char * identifier, size_t length, const int value);
-
-/** Clears and destroys the map.
- *  @param[in,out] map The character string to integer map.
- */
-extern void char_map_destroy(char_map_ref map);
-
-/** Excludes the value assigned to the key from the map.
- *  The entry is cleared from the map.
- *  @param[in,out] map The character string to integer map.
- *  @param[in] identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found.
- *  @param[in] length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found.
- *  @returns The integral value assigned to the key character string.
- *  @returns CHAR_MAP_NULL if the key is not assigned a&nbsp;value.
- */
-extern int char_map_exclude(char_map_ref map, const char * identifier, size_t length);
-
-/** Returns the value assigned to the key from the map.
- *  @param[in] map The character string to integer map.
- *  @param[in] identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found.
- *  @param[in] length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found.
- *  @returns The integral value assigned to the key character string.
- *  @returns CHAR_MAP_NULL if the key is not assigned a&nbsp;value.
- */
-extern int char_map_find(const char_map_ref map, const char * identifier, size_t length);
-
-/** Initializes the map.
- *  @param[in,out] map The character string to integer map.
- *  @returns EOK on success.
- *  @returns EINVAL if the map parameter is NULL.
- *  @returns ENOMEM if there is not enough memory left.
- */
-extern int char_map_initialize(char_map_ref map);
-
-/** Adds or updates the value with the key to the map.
- *  @param[in,out] map The character string to integer map.
- *  @param[in] identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found.
- *  @param[in] length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found.
- *  @param[in] value The integral value to be stored for the key character string.
- *  @returns EOK on success.
- *  @returns EINVAL if the map is not valid.
- *  @returns EINVAL if the identifier parameter is NULL.
- *  @returns EINVAL if the length parameter zero (0) and the identifier parameter is an empty character string (the first character is the terminating zero ('\\0) character.
- *  @returns EEXIST if the key character string is already used.
- *  @returns Other error codes as defined for the char_map_add_item() function.
- */
-extern int char_map_update(char_map_ref map, const char * identifier, size_t length, const int value);
+extern int char_map_initialize(char_map_ref);
+extern void char_map_destroy(char_map_ref);
+extern int char_map_exclude(char_map_ref, const char *, size_t);
+extern int char_map_add(char_map_ref, const char *, size_t, const int);
+extern int char_map_find(const char_map_ref, const char *, size_t);
+extern int char_map_update(char_map_ref, const char *, size_t, const int);
 
 #endif
