Index: uspace/srv/net/modules.c
===================================================================
--- uspace/srv/net/modules.c	(revision bc9da2a77f6c4a089d8231e222d0c24ab3fc92c3)
+++ uspace/srv/net/modules.c	(revision 9f2ea2842550ba0536881449ffe27c8947d72804)
@@ -48,70 +48,27 @@
 /** The time between connect requests in microseconds.
  */
-#define MODULE_WAIT_TIME	( 10 * 1000 )
+#define MODULE_WAIT_TIME	(10 * 1000)
 
-int connect_to_service( services_t need ){
-	return connect_to_service_timeout( need, 0 );
-}
-
-int connect_to_service_timeout( services_t need, suseconds_t timeout ){
-	if (timeout <= 0)
-		return async_connect_me_to_blocking( PHONE_NS, need, 0, 0);
-	
-	while( true ){
-		int phone;
-
-		phone = async_connect_me_to( PHONE_NS, need, 0, 0);
-		if( (phone >= 0) || (phone != ENOENT) )
-			return phone;
-	
-		timeout -= MODULE_WAIT_TIME;
-		if( timeout <= 0 ) return ETIMEOUT;
-
-		usleep( MODULE_WAIT_TIME );
-	}
-}
-
-int bind_service( services_t need, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, async_client_conn_t client_receiver ){
-	return bind_service_timeout( need, arg1, arg2, arg3, client_receiver, 0 );
-}
-
-int bind_service_timeout( services_t need, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout ){
-	ERROR_DECLARE;
-
-	int			phone;
-	ipcarg_t	phonehash;
-
-	phone = connect_to_service_timeout( need, timeout );
-	if( phone >= 0 ){
-		if( ERROR_OCCURRED( ipc_connect_to_me( phone, arg1, arg2, arg3, & phonehash ))){
-			ipc_hangup( phone );
-			return ERROR_CODE;
-		}
-		async_new_connection( phonehash, 0, NULL, client_receiver );
-	}
-	return phone;
-}
-
-void answer_call( ipc_callid_t callid, int result, ipc_call_t * answer, int answer_count ){
-	if( answer || ( ! answer_count )){
-		switch( answer_count ){
+void answer_call(ipc_callid_t callid, int result, ipc_call_t * answer, int answer_count){
+	if(answer || (! answer_count)){
+		switch(answer_count){
 			case 0:
-				ipc_answer_0( callid, ( ipcarg_t ) result );
+				ipc_answer_0(callid, (ipcarg_t) result);
 				break;
 			case 1:
-				ipc_answer_1( callid, ( ipcarg_t ) result, IPC_GET_ARG1( * answer ));
+				ipc_answer_1(callid, (ipcarg_t) result, IPC_GET_ARG1(*answer));
 				break;
 			case 2:
-				ipc_answer_2( callid, ( ipcarg_t ) result, IPC_GET_ARG1( * answer ), IPC_GET_ARG2( * answer ));
+				ipc_answer_2(callid, (ipcarg_t) result, IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer));
 				break;
 			case 3:
-				ipc_answer_3( callid, ( ipcarg_t ) result, IPC_GET_ARG1( * answer ), IPC_GET_ARG2( * answer ), IPC_GET_ARG3( * answer ));
+				ipc_answer_3(callid, (ipcarg_t) result, IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer), IPC_GET_ARG3(*answer));
 				break;
 			case 4:
-				ipc_answer_4( callid, ( ipcarg_t ) result, IPC_GET_ARG1( * answer ), IPC_GET_ARG2( * answer ), IPC_GET_ARG3( * answer ), IPC_GET_ARG4( * answer ));
+				ipc_answer_4(callid, (ipcarg_t) result, IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer), IPC_GET_ARG3(*answer), IPC_GET_ARG4(*answer));
 				break;
 			case 5:
 			default:
-				ipc_answer_5( callid, ( ipcarg_t ) result, IPC_GET_ARG1( * answer ), IPC_GET_ARG2( * answer ), IPC_GET_ARG3( * answer ), IPC_GET_ARG4( * answer ), IPC_GET_ARG5( * answer ));
+				ipc_answer_5(callid, (ipcarg_t) result, IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer), IPC_GET_ARG3(*answer), IPC_GET_ARG4(*answer), IPC_GET_ARG5(*answer));
 				break;
 		}
@@ -119,31 +76,66 @@
 }
 
-void refresh_answer( ipc_call_t * answer, int * answer_count ){
-	if( answer_count ){
-		* answer_count = 0;
+int bind_service(services_t need, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, async_client_conn_t client_receiver){
+	return bind_service_timeout(need, arg1, arg2, arg3, client_receiver, 0);
+}
+
+int bind_service_timeout(services_t need, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout){
+	ERROR_DECLARE;
+
+	int phone;
+	ipcarg_t phonehash;
+
+	phone = connect_to_service_timeout(need, timeout);
+	if(phone >= 0){
+		if(ERROR_OCCURRED(ipc_connect_to_me(phone, arg1, arg2, arg3, &phonehash))){
+			ipc_hangup(phone);
+			return ERROR_CODE;
+		}
+		async_new_connection(phonehash, 0, NULL, client_receiver);
 	}
-	if( answer ){
-		IPC_SET_RETVAL( * answer, 0 );
-		// just to be precize
-		IPC_SET_METHOD( * answer, 0 );
-		IPC_SET_ARG1( * answer, 0 );
-		IPC_SET_ARG2( * answer, 0 );
-		IPC_SET_ARG3( * answer, 0 );
-		IPC_SET_ARG4( * answer, 0 );
-		IPC_SET_ARG5( * answer, 0 );
+	return phone;
+}
+
+int connect_to_service(services_t need){
+	return connect_to_service_timeout(need, 0);
+}
+
+int connect_to_service_timeout(services_t need, suseconds_t timeout){
+	if (timeout <= 0)
+		return async_connect_me_to_blocking(PHONE_NS, need, 0, 0);
+	
+	while(true){
+		int phone;
+
+		phone = async_connect_me_to(PHONE_NS, need, 0, 0);
+		if((phone >= 0) || (phone != ENOENT))
+			return phone;
+	
+		timeout -= MODULE_WAIT_TIME;
+		if(timeout <= 0){
+			return ETIMEOUT;
+		}
+
+		usleep(MODULE_WAIT_TIME);
 	}
 }
 
-int data_receive( void ** data, size_t * length ){
+int data_receive(void ** data, size_t * length){
 	ERROR_DECLARE;
 
-	ipc_callid_t	callid;
+	ipc_callid_t callid;
 
-	if( !( data && length )) return EBADMEM;
-	if( ! async_data_write_receive( & callid, length )) return EINVAL;
-	* data = malloc( * length );
-	if( !( * data )) return ENOMEM;
-	if( ERROR_OCCURRED( async_data_write_finalize( callid, * data, * length ))){
-		free( data );
+	if(!(data && length)){
+		return EBADMEM;
+	}
+	if(! async_data_write_receive(&callid, length)){
+		return EINVAL;
+	}
+	*data = malloc(*length);
+	if(!(*data)){
+		return ENOMEM;
+	}
+	if(ERROR_OCCURRED(async_data_write_finalize(callid, * data, * length))){
+		free(data);
 		return ERROR_CODE;
 	}
@@ -151,16 +143,32 @@
 }
 
-int data_reply( void * data, size_t data_length ){
-	size_t			length;
-	ipc_callid_t	callid;
+int data_reply(void * data, size_t data_length){
+	size_t length;
+	ipc_callid_t callid;
 
-	if( ! async_data_read_receive( & callid, & length )){
+	if(! async_data_read_receive(&callid, &length)){
 		return EINVAL;
 	}
-	if( length < data_length ){
-		async_data_read_finalize( callid, data, length );
+	if(length < data_length){
+		async_data_read_finalize(callid, data, length);
 		return EOVERFLOW;
 	}
-	return async_data_read_finalize( callid, data, data_length );
+	return async_data_read_finalize(callid, data, data_length);
+}
+
+void refresh_answer(ipc_call_t * answer, int * answer_count){
+	if(answer_count){
+		*answer_count = 0;
+	}
+	if(answer){
+		IPC_SET_RETVAL(*answer, 0);
+		// just to be precize
+		IPC_SET_METHOD(*answer, 0);
+		IPC_SET_ARG1(*answer, 0);
+		IPC_SET_ARG2(*answer, 0);
+		IPC_SET_ARG3(*answer, 0);
+		IPC_SET_ARG4(*answer, 0);
+		IPC_SET_ARG5(*answer, 0);
+	}
 }
 
