Index: uspace/lib/c/generic/adt/measured_strings.c
===================================================================
--- uspace/lib/c/generic/adt/measured_strings.c	(revision 739087084c1098bfdf6e5eb261aa7914baebe2b3)
+++ uspace/lib/c/generic/adt/measured_strings.c	(revision edba2b6f86f0648a6927f098d1ac63a775401c9c)
@@ -32,6 +32,6 @@
 
 /** @file
- *  Character string with measured length implementation.
- *  @see measured_strings.h
+ * Character string with measured length implementation.
+ * @see measured_strings.h
  */
 
@@ -44,17 +44,33 @@
 #include <async.h>
 
-
-measured_string_ref measured_string_create_bulk(const char * string, size_t length){
+/** Creates a new measured string bundled with a copy of the given string
+ * itself as one memory block.
+ *
+ * If the measured string is being freed, whole memory block is freed.
+ * The measured string should be used only as a constant.
+ *
+ * @param[in] string	The initial character string to be stored.
+ * @param[in] length	The length of the given string without the terminating
+ *			zero ('/0') character. If the length is zero (0), the
+ *			actual length is computed. The given length is used and
+ *			appended with the terminating zero ('\\0') character
+ *			otherwise.
+ * @returns		The new bundled character string with measured length.
+ * @returns		NULL if there is not enough memory left.
+ */
+measured_string_ref
+measured_string_create_bulk(const char * string, size_t length)
+{
 	measured_string_ref new;
 
-	if(length == 0){
-		while(string[length]){
-			++ length;
-		}
-	}
-	new = (measured_string_ref) malloc(sizeof(measured_string_t) + (sizeof(char) * (length + 1)));
-	if(! new){
+	if (length == 0) {
+		while (string[length])
+			++length;
+	}
+	new = (measured_string_ref) malloc(sizeof(measured_string_t) +
+	    (sizeof(char) * (length + 1)));
+	if (!new)
 		return NULL;
-	}
+
 	new->length = length;
 	new->value = ((char *) new) + sizeof(measured_string_t);
@@ -62,70 +78,107 @@
 	memcpy(new->value, string, new->length);
 	new->value[new->length] = '\0';
+
 	return new;
 }
 
-measured_string_ref measured_string_copy(measured_string_ref source){
+/** Copies the given measured string with separated header and data parts.
+ *
+ * @param[in] source	The source measured string to be copied.
+ * @returns		The copy of the given measured string.
+ * @returns		NULL if the source parameter is NULL.
+ * @returns		NULL if there is not enough memory left.
+ */
+measured_string_ref measured_string_copy(measured_string_ref source)
+{
 	measured_string_ref new;
 
-	if(! source){
+	if (!source)
 		return NULL;
-	}
+
 	new = (measured_string_ref) malloc(sizeof(measured_string_t));
-	if(new){
+	if (new) {
 		new->value = (char *) malloc(source->length + 1);
-		if(new->value){
+		if (new->value) {
 			new->length = source->length;
 			memcpy(new->value, source->value, new->length);
 			new->value[new->length] = '\0';
 			return new;
-		}else{
+		} else {
 			free(new);
 		}
 	}
+
 	return NULL;
 }
 
-int measured_strings_receive(measured_string_ref * strings, char ** data, size_t count){
+/** Receives a measured strings array from a calling module.
+ *
+ * Creates the array and the data memory blocks.
+ * This method should be used only while processing IPC messages as the array
+ * size has to be negotiated in advance.
+ *
+ *  @param[out] strings	The received measured strings array.
+ *  @param[out] data	The measured strings data. This memory block stores the
+ *			actual character strings.
+ *  @param[in] count	The size of the measured strings array.
+ *  @returns		EOK on success.
+ *  @returns		EINVAL if the strings or data parameter is NULL.
+ *  @returns		EINVAL if the count parameter is zero (0).
+ *  @returns		EINVAL if the sent array differs in size.
+ *  @returns		EINVAL if there is inconsistency in sent measured
+ *			strings' lengths (should not occur).
+ *  @returns		ENOMEM if there is not enough memory left.
+ *  @returns		Other error codes as defined for the
+ *			async_data_write_finalize() function.
+ */
+int
+measured_strings_receive(measured_string_ref *strings, char **data,
+    size_t count)
+{
 	ERROR_DECLARE;
 
-	size_t * lengths;
+	size_t *lengths;
 	size_t index;
 	size_t length;
-	char * next;
+	char *next;
 	ipc_callid_t callid;
 
-	if((! strings) || (! data) || (count <= 0)){
-		return EINVAL;
-	}
+	if ((!strings) || (!data) || (count <= 0))
+		return EINVAL;
+
 	lengths = (size_t *) malloc(sizeof(size_t) * (count + 1));
-	if(! lengths){
-		return ENOMEM;
-	}
-	if((! async_data_write_receive(&callid, &length))
-		|| (length != sizeof(size_t) * (count + 1))){
-		free(lengths);
-		return EINVAL;
-	}
-	if(ERROR_OCCURRED(async_data_write_finalize(callid, lengths, sizeof(size_t) * (count + 1)))){
+	if (!lengths)
+		return ENOMEM;
+
+	if ((!async_data_write_receive(&callid, &length)) ||
+	    (length != sizeof(size_t) * (count + 1))) {
+		free(lengths);
+		return EINVAL;
+	}
+	if(ERROR_OCCURRED(async_data_write_finalize(callid, lengths,
+	    sizeof(size_t) * (count + 1)))) {
 		free(lengths);
 		return ERROR_CODE;
 	}
 	*data = malloc(lengths[count]);
-	if(!(*data)){
+	if (!(*data)) {
 		return ENOMEM;
 	}
 	(*data)[lengths[count] - 1] = '\0';
-	*strings = (measured_string_ref) malloc(sizeof(measured_string_t) * count);
-	if(!(*strings)){
+
+	*strings = (measured_string_ref) malloc(sizeof(measured_string_t) *
+	    count);
+	if (!(*strings)) {
 		free(lengths);
 		free(*data);
 		return ENOMEM;
 	}
-	next = * data;
-	for(index = 0; index < count; ++ index){
+
+	next = *data;
+	for (index = 0; index < count; ++index) {
 		(*strings)[index].length = lengths[index];
-		if(lengths[index] > 0){
-			if((! async_data_write_receive(&callid, &length))
-				|| (length != lengths[index])){
+		if (lengths[index] > 0) {
+			if ((!async_data_write_receive(&callid, &length)) ||
+			    (length != lengths[index])) {
 				free(*data);
 				free(*strings);
@@ -133,149 +186,226 @@
 				return EINVAL;
 			}
-			ERROR_PROPAGATE(async_data_write_finalize(callid, next, lengths[index]));
+			ERROR_PROPAGATE(async_data_write_finalize(callid, next,
+			    lengths[index]));
+			(*strings)[index].value = next;
+			next += lengths[index];
+			*next = '\0';
+			++next;
+		} else {
+			(*strings)[index].value = NULL;
+		}
+	}
+
+	free(lengths);
+	return EOK;
+}
+
+/** Computes the lengths of the measured strings in the given array.
+ *
+ * @param[in] strings	The measured strings array to be processed.
+ * @param[in] count	The measured strings array size.
+ * @returns		The computed sizes array.
+ * @returns		NULL if there is not enough memory left.
+ */
+static size_t *prepare_lengths(const measured_string_ref strings, size_t count)
+{
+	size_t *lengths;
+	size_t index;
+	size_t length;
+
+	lengths = (size_t *) malloc(sizeof(size_t) * (count + 1));
+	if (!lengths)
+		return NULL;
+
+	length = 0;
+	for (index = 0; index < count; ++ index) {
+		lengths[index] = strings[index].length;
+		length += lengths[index] + 1;
+	}
+	lengths[count] = length;
+	return lengths;
+}
+
+/** Replies the given measured strings array to a calling module.
+ *
+ * This method should be used only while processing IPC messages as the array
+ * size has to be negotiated in advance.
+ *
+ * @param[in] strings	The measured strings array to be transferred.
+ * @param[in] count	The measured strings array size.
+ * @returns		EOK on success.
+ * @returns		EINVAL if the strings parameter is NULL.
+ * @returns		EINVAL if the count parameter is zero (0).
+ * @returns		EINVAL if the calling module does not accept the given
+ *			array size.
+ * @returns		EINVAL if there is inconsistency in sent measured
+ *			strings' lengths (should not occur).
+ * @returns		Other error codes as defined for the
+ *			async_data_read_finalize() function.
+ */
+int measured_strings_reply(const measured_string_ref strings, size_t count)
+{
+	ERROR_DECLARE;
+
+	size_t *lengths;
+	size_t index;
+	size_t length;
+	ipc_callid_t callid;
+
+	if ((!strings) || (count <= 0))
+		return EINVAL;
+
+	lengths = prepare_lengths(strings, count);
+	if (!lengths)
+		return ENOMEM;
+
+	if ((!async_data_read_receive(&callid, &length)) ||
+	    (length != sizeof(size_t) * (count + 1))) {
+		free(lengths);
+		return EINVAL;
+	}
+	if (ERROR_OCCURRED(async_data_read_finalize(callid, lengths,
+	    sizeof(size_t) * (count + 1)))) {
+		free(lengths);
+		return ERROR_CODE;
+	}
+	free(lengths);
+
+	for (index = 0; index < count; ++ index) {
+		if (strings[index].length > 0) {
+			if((!async_data_read_receive(&callid, &length))	||
+			    (length != strings[index].length)) {
+				return EINVAL;
+			}
+			ERROR_PROPAGATE(async_data_read_finalize(callid,
+			    strings[index].value, strings[index].length));
+		}
+	}
+
+	return EOK;
+}
+
+/** Receives a measured strings array from another module.
+ *
+ * Creates the array and the data memory blocks.
+ * This method should be used only following other IPC messages as the array
+ * size has to be negotiated in advance.
+ *
+ * @param[in] phone	The other module phone.
+ * @param[out] strings	The returned measured strings array.
+ * @param[out] data	The measured strings data. This memory block stores the
+ *			actual character strings.
+ * @param[in] count	The size of the measured strings array.
+ * @returns		EOK on success.
+ * @returns		EINVAL if the strings or data parameter is NULL.
+ * @returns		EINVAL if the phone or count parameter is not positive.
+ * @returns		EINVAL if the sent array differs in size.
+ * @returns		ENOMEM if there is not enough memory left.
+ * @returns		Other error codes as defined for the
+ *			async_data_read_start() function.
+ */
+int
+measured_strings_return(int phone, measured_string_ref *strings, char **data,
+    size_t count)
+{
+	ERROR_DECLARE;
+
+	size_t *lengths;
+	size_t index;
+	char *next;
+
+	if ((phone <= 0) || (!strings) || (!data) || (count <= 0))
+		return EINVAL;
+
+	lengths = (size_t *) malloc(sizeof(size_t) * (count + 1));
+	if (!lengths)
+		return ENOMEM;
+
+	if (ERROR_OCCURRED(async_data_read_start(phone, lengths,
+	    sizeof(size_t) * (count + 1)))) {
+		free(lengths);
+		return ERROR_CODE;
+	}
+
+	*data = malloc(lengths[count]);
+	if (!(*data)) {
+		return ENOMEM;
+	}
+
+	*strings = (measured_string_ref) malloc(sizeof(measured_string_t) *
+	    count);
+	if (!(*strings)) {
+		free(lengths);
+		free(*data);
+		return ENOMEM;
+	}
+
+	next = *data;
+	for (index = 0; index < count; ++ index) {
+		(*strings)[index].length = lengths[index];
+		if (lengths[index] > 0) {
+			ERROR_PROPAGATE(async_data_read_start(phone, next,
+			    lengths[index]));
 			(*strings)[index].value = next;
 			next += lengths[index];
 			*next = '\0';
 			++ next;
-		}else{
+		} else {
 			(*strings)[index].value = NULL;
 		}
 	}
+
 	free(lengths);
 	return EOK;
 }
 
-/** Computes the lengths of the measured strings in the given array.
- *  @param[in] strings The measured strings array to be processed.
- *  @param[in] count The measured strings array size.
- *  @returns The computed sizes array.
- *  @returns NULL if there is not enough memory left.
- */
-static size_t * prepare_lengths(const measured_string_ref strings, size_t count){
-	size_t * lengths;
+/** Sends the given measured strings array to another module.
+ *
+ * This method should be used only following other IPC messages as the array
+ * size has to be negotiated in advance.
+ *
+ * @param[in] phone	The other module phone.
+ * @param[in] strings	The measured strings array to be transferred.
+ * @param[in] count	The measured strings array size.
+ * @returns		EOK on success.
+ * @returns		EINVAL if the strings parameter is NULL.
+ * @returns		EINVAL if the phone or count parameter is not positive.
+ * @returns		Other error codes as defined for the
+ *			async_data_write_start() function.
+ */
+int
+measured_strings_send(int phone, const measured_string_ref strings,
+    size_t count)
+{
+	ERROR_DECLARE;
+
+	size_t *lengths;
 	size_t index;
-	size_t length;
-
-	lengths = (size_t *) malloc(sizeof(size_t) * (count + 1));
-	if(! lengths){
-		return NULL;
-	}
-	length = 0;
-	for(index = 0; index < count; ++ index){
-		lengths[index] = strings[index].length;
-		length += lengths[index] + 1;
-	}
-	lengths[count] = length;
-	return lengths;
-}
-
-int measured_strings_reply(const measured_string_ref strings, size_t count){
-	ERROR_DECLARE;
-
-	size_t * lengths;
-	size_t index;
-	size_t length;
-	ipc_callid_t callid;
-
-	if((! strings) || (count <= 0)){
-		return EINVAL;
-	}
+
+	if ((phone <= 0) || (!strings) || (count <= 0))
+		return EINVAL;
+
 	lengths = prepare_lengths(strings, count);
-	if(! lengths){
-		return ENOMEM;
-	}
-	if((! async_data_read_receive(&callid, &length))
-		|| (length != sizeof(size_t) * (count + 1))){
-		free(lengths);
-		return EINVAL;
-	}
-	if(ERROR_OCCURRED(async_data_read_finalize(callid, lengths, sizeof(size_t) * (count + 1)))){
+	if (!lengths)
+		return ENOMEM;
+
+	if (ERROR_OCCURRED(async_data_write_start(phone, lengths,
+	    sizeof(size_t) * (count + 1)))) {
 		free(lengths);
 		return ERROR_CODE;
 	}
+
 	free(lengths);
-	for(index = 0; index < count; ++ index){
-		if(strings[index].length > 0){
-			if((! async_data_read_receive(&callid, &length))
-				|| (length != strings[index].length)){
-				return EINVAL;
-			}
-			ERROR_PROPAGATE(async_data_read_finalize(callid, strings[index].value, strings[index].length));
+
+	for (index = 0; index < count; ++index) {
+		if (strings[index].length > 0) {
+			ERROR_PROPAGATE(async_data_write_start(phone,
+			    strings[index].value, strings[index].length));
 		}
 	}
+
 	return EOK;
 }
 
-int measured_strings_return(int phone, measured_string_ref * strings, char ** data, size_t count){
-	ERROR_DECLARE;
-
-	size_t * lengths;
-	size_t index;
-	char * next;
-
-	if((phone <= 0) || (! strings) || (! data) || (count <= 0)){
-		return EINVAL;
-	}
-	lengths = (size_t *) malloc(sizeof(size_t) * (count + 1));
-	if(! lengths){
-		return ENOMEM;
-	}
-	if(ERROR_OCCURRED(async_data_read_start(phone, lengths, sizeof(size_t) * (count + 1)))){
-		free(lengths);
-		return ERROR_CODE;
-	}
-	*data = malloc(lengths[count]);
-	if(!(*data)){
-		return ENOMEM;
-	}
-	*strings = (measured_string_ref) malloc(sizeof(measured_string_t) * count);
-	if(!(*strings)){
-		free(lengths);
-		free(*data);
-		return ENOMEM;
-	}
-	next = * data;
-	for(index = 0; index < count; ++ index){
-		(*strings)[index].length = lengths[index];
-		if(lengths[index] > 0){
-			ERROR_PROPAGATE(async_data_read_start(phone, next, lengths[index]));
-			(*strings)[index].value = next;
-			next += lengths[index];
-			*next = '\0';
-			++ next;
-		}else{
-			(*strings)[index].value = NULL;
-		}
-	}
-	free(lengths);
-	return EOK;
-}
-
-int measured_strings_send(int phone, const measured_string_ref strings, size_t count){
-	ERROR_DECLARE;
-
-	size_t * lengths;
-	size_t index;
-
-	if((phone <= 0) || (! strings) || (count <= 0)){
-		return EINVAL;
-	}
-	lengths = prepare_lengths(strings, count);
-	if(! lengths){
-		return ENOMEM;
-	}
-	if(ERROR_OCCURRED(async_data_write_start(phone, lengths, sizeof(size_t) * (count + 1)))){
-		free(lengths);
-		return ERROR_CODE;
-	}
-	free(lengths);
-	for(index = 0; index < count; ++ index){
-		if(strings[index].length > 0){
-			ERROR_PROPAGATE(async_data_write_start(phone, strings[index].value, strings[index].length));
-		}
-	}
-	return EOK;
-}
-
 /** @}
  */
Index: uspace/lib/c/include/adt/measured_strings.h
===================================================================
--- uspace/lib/c/include/adt/measured_strings.h	(revision 739087084c1098bfdf6e5eb261aa7914baebe2b3)
+++ uspace/lib/c/include/adt/measured_strings.h	(revision edba2b6f86f0648a6927f098d1ac63a775401c9c)
@@ -27,11 +27,12 @@
  */
 
-/** @addtogroup net
+/** @addtogroup libc 
  *  @{
  */
 
 /** @file
- *  Character string with measured length.
- *  The structure has been designed for serialization of character strings between modules.
+ * Character string with measured length.
+ * The structure has been designed for serialization of character strings
+ * between modules.
  */
 
@@ -44,97 +45,29 @@
  *  @see measured_string
  */
-typedef struct measured_string	measured_string_t;
+typedef struct measured_string measured_string_t;
 
 /** Type definition of the character string with measured length pointer.
  *  @see measured_string
  */
-typedef measured_string_t *		measured_string_ref;
+typedef measured_string_t *measured_string_ref;
 
 /** Character string with measured length.
- *  This structure has been designed for serialization of character strings between modules.
+ *
+ * This structure has been designed for serialization of character strings
+ * between modules.
  */
-struct	measured_string{
-	/** Character string data.
-	 */
+struct measured_string {
+	/** Character string data. */
 	char * value;
-	/** Character string length.
-	 */
+	/** Character string length. */
 	size_t length;
 };
 
-/** Creates a&nbsp;new measured string bundled with a&nbsp;copy of the given string itself as one memory block.
- *  If the measured string is being freed, whole memory block is freed.
- *  The measured string should be used only as a&nbsp;constant.
- *  @param[in] string The initial character string to be stored.
- *  @param[in] length The length of the given string without the terminating zero ('/0') character. If the length is zero (0), the actual length is computed. The given length is used and appended with the terminating zero ('\\0') character otherwise.
- *  @returns The new bundled character string with measured length.
- *  @returns NULL if there is not enough memory left.
- */
-extern measured_string_ref measured_string_create_bulk(const char * string, size_t length);
-
-/** Copies the given measured string with separated header and data parts.
- *  @param[in] source The source measured string to be copied.
- *  @returns The copy of the given measured string.
- *  @returns NULL if the source parameter is NULL.
- *  @returns NULL if there is not enough memory left.
- */
-extern measured_string_ref measured_string_copy(measured_string_ref source);
-
-/** Receives a&nbsp;measured strings array from a&nbsp;calling module.
- *  Creates the array and the data memory blocks.
- *  This method should be used only while processing IPC messages as the array size has to be negotiated in advance.
- *  @param[out] strings The received measured strings array.
- *  @param[out] data The measured strings data. This memory block stores the actual character strings.
- *  @param[in] count The size of the measured strings array.
- *  @returns EOK on success.
- *  @returns EINVAL if the strings or data parameter is NULL.
- *  @returns EINVAL if the count parameter is zero (0).
- *  @returns EINVAL if the sent array differs in size.
- *  @returns EINVAL if there is inconsistency in sent measured strings' lengths (should not occur).
- *  @returns ENOMEM if there is not enough memory left.
- *  @returns Other error codes as defined for the async_data_write_finalize() function.
- */
-extern int measured_strings_receive(measured_string_ref * strings, char ** data, size_t count);
-
-/** Replies the given measured strings array to a&nbsp;calling module.
- *  This method should be used only while processing IPC messages as the array size has to be negotiated in advance.
- *  @param[in] strings The measured strings array to be transferred.
- *  @param[in] count The measured strings array size.
- *  @returns EOK on success.
- *  @returns EINVAL if the strings parameter is NULL.
- *  @returns EINVAL if the count parameter is zero (0).
- *  @returns EINVAL if the calling module does not accept the given array size.
- *  @returns EINVAL if there is inconsistency in sent measured strings' lengths (should not occur).
- *  @returns Other error codes as defined for the async_data_read_finalize() function.
- */
-extern int measured_strings_reply(const measured_string_ref strings, size_t count);
-
-/** Receives a&nbsp;measured strings array from another module.
- *  Creates the array and the data memory blocks.
- *  This method should be used only following other IPC messages as the array size has to be negotiated in advance.
- *  @param[in] phone The other module phone.
- *  @param[out] strings The returned measured strings array.
- *  @param[out] data The measured strings data. This memory block stores the actual character strings.
- *  @param[in] count The size of the measured strings array.
- *  @returns EOK on success.
- *  @returns EINVAL if the strings or data parameter is NULL.
- *  @returns EINVAL if the phone or count parameter is not positive (<=0).
- *  @returns EINVAL if the sent array differs in size.
- *  @returns ENOMEM if there is not enough memory left.
- *  @returns Other error codes as defined for the async_data_read_start() function.
- */
-extern int measured_strings_return(int phone, measured_string_ref * strings, char ** data, size_t count);
-
-/** Sends the given measured strings array to another module.
- *  This method should be used only following other IPC messages as the array size has to be negotiated in advance.
- *  @param[in] phone The other module phone.
- *  @param[in] strings The measured strings array to be transferred.
- *  @param[in] count The measured strings array size.
- *  @returns EOK on success.
- *  @returns EINVAL if the strings parameter is NULL.
- *  @returns EINVAL if the phone or count parameter is not positive (<=0).
- *  @returns Other error codes as defined for the async_data_write_start() function.
- */
-extern int measured_strings_send(int phone, const measured_string_ref strings, size_t count);
+extern measured_string_ref measured_string_create_bulk(const char *, size_t);
+extern measured_string_ref measured_string_copy(measured_string_ref);
+extern int measured_strings_receive(measured_string_ref *, char **, size_t);
+extern int measured_strings_reply(const measured_string_ref, size_t);
+extern int measured_strings_return(int, measured_string_ref *, char **, size_t);
+extern int measured_strings_send(int, const measured_string_ref, size_t);
 
 #endif
@@ -142,3 +75,2 @@
 /** @}
  */
-
