Index: uspace/srv/hid/remcons/remcons.c
===================================================================
--- uspace/srv/hid/remcons/remcons.c	(revision 1870d81d749335a0da30a496317fae2274a23dae)
+++ uspace/srv/hid/remcons/remcons.c	(revision 787b65b9ec3fc7f4113c27233e6e953dd5a688be)
@@ -84,13 +84,13 @@
 	int locsrv_connection_count;
 	bool socket_closed;
-} client_t;
-
-static FIBRIL_MUTEX_INITIALIZE(clients_guard);
-static LIST_INITIALIZE(clients);
+} telnet_user_t;
+
+static FIBRIL_MUTEX_INITIALIZE(users_guard);
+static LIST_INITIALIZE(users);
 
 /** Telnet commands to force character mode
  * (redundant to be on the safe side).
  * See
- * http://stackoverflow.com/questions/273261/force-telnet-client-into-character-mode
+ * http://stackoverflow.com/questions/273261/force-telnet-user-into-character-mode
  * for discussion.
  */
@@ -103,81 +103,81 @@
     sizeof(telnet_force_character_mode_command) / sizeof(telnet_cmd_t);
 
-static client_t *client_create(int socket)
-{
-	static int client_counter = 0;
-
-	client_t *client = malloc(sizeof(client_t));
-	if (client == NULL) {
+static telnet_user_t *telnet_user_create(int socket)
+{
+	static int telnet_user_id_counter = 0;
+
+	telnet_user_t *user = malloc(sizeof(telnet_user_t));
+	if (user == NULL) {
 		return NULL;
 	}
 
-	client->id = ++client_counter;
-
-	int rc = asprintf(&client->service_name, "%s/telnet%d", NAMESPACE, client->id);
+	user->id = ++telnet_user_id_counter;
+
+	int rc = asprintf(&user->service_name, "%s/telnet%d", NAMESPACE, user->id);
 	if (rc < 0) {
-		free(client);
+		free(user);
 		return NULL;
 	}
 
-	client->socket = socket;
-	client->service_id = (service_id_t) -1;
-	prodcons_initialize(&client->in_events);
-	link_initialize(&client->link);
-	client->socket_buffer_len = 0;
-	client->socket_buffer_pos = 0;
-
-	fibril_condvar_initialize(&client->refcount_cv);
-	fibril_mutex_initialize(&client->refcount_mutex);
-	client->task_finished = false;
-	client->socket_closed = false;
-	client->locsrv_connection_count = 0;
-
-
-	fibril_mutex_lock(&clients_guard);
-	list_append(&client->link, &clients);
-	fibril_mutex_unlock(&clients_guard);
-
-	return client;
-}
-
-static void client_destroy(client_t *client)
-{
-	assert(client);
-
-	fibril_mutex_lock(&clients_guard);
-	list_remove(&client->link);
-	fibril_mutex_unlock(&clients_guard);
-
-	free(client);
-}
-
-static client_t *client_get_for_client_connection(service_id_t id)
-{
-	client_t *client = NULL;
-
-	fibril_mutex_lock(&clients_guard);
-	list_foreach(clients, link) {
-		client_t *tmp = list_get_instance(link, client_t, link);
+	user->socket = socket;
+	user->service_id = (service_id_t) -1;
+	prodcons_initialize(&user->in_events);
+	link_initialize(&user->link);
+	user->socket_buffer_len = 0;
+	user->socket_buffer_pos = 0;
+
+	fibril_condvar_initialize(&user->refcount_cv);
+	fibril_mutex_initialize(&user->refcount_mutex);
+	user->task_finished = false;
+	user->socket_closed = false;
+	user->locsrv_connection_count = 0;
+
+
+	fibril_mutex_lock(&users_guard);
+	list_append(&user->link, &users);
+	fibril_mutex_unlock(&users_guard);
+
+	return user;
+}
+
+static void telnet_user_destroy(telnet_user_t *user)
+{
+	assert(user);
+
+	fibril_mutex_lock(&users_guard);
+	list_remove(&user->link);
+	fibril_mutex_unlock(&users_guard);
+
+	free(user);
+}
+
+static telnet_user_t *telnet_user_get_for_client_connection(service_id_t id)
+{
+	telnet_user_t *user = NULL;
+
+	fibril_mutex_lock(&users_guard);
+	list_foreach(users, link) {
+		telnet_user_t *tmp = list_get_instance(link, telnet_user_t, link);
 		if (tmp->service_id == id) {
-			client = tmp;
-			break;
-		}
-	}
-	if (client == NULL) {
-		fibril_mutex_unlock(&clients_guard);
+			user = tmp;
+			break;
+		}
+	}
+	if (user == NULL) {
+		fibril_mutex_unlock(&users_guard);
 		return NULL;
 	}
 
-	client_t *tmp = client;
+	telnet_user_t *tmp = user;
 	fibril_mutex_lock(&tmp->refcount_mutex);
-	client->locsrv_connection_count++;
+	user->locsrv_connection_count++;
 
 	/*
-	 * Refuse to return client whose task already finished or when
+	 * Refuse to return user whose task already finished or when
 	 * the socket is already closed().
 	 */
-	if (client->task_finished || client->socket_closed) {
-		client = NULL;
-		client->locsrv_connection_count--;
+	if (user->task_finished || user->socket_closed) {
+		user = NULL;
+		user->locsrv_connection_count--;
 	}
 
@@ -185,7 +185,7 @@
 
 
-	fibril_mutex_unlock(&clients_guard);
-
-	return client;
+	fibril_mutex_unlock(&users_guard);
+
+	return user;
 }
 
@@ -205,5 +205,5 @@
 }
 
-static void client_connection_message_loop(client_t *client)
+static void client_connection_message_loop(telnet_user_t *user)
 {
 	while (true) {
@@ -213,7 +213,7 @@
 			callid = async_get_call_timeout(&call, 1000);
 
-			fibril_mutex_lock(&client->refcount_mutex);
-			bool bail_out = client->socket_closed || client->task_finished;
-			fibril_mutex_unlock(&client->refcount_mutex);
+			fibril_mutex_lock(&user->refcount_mutex);
+			bool bail_out = user->socket_closed || user->task_finished;
+			fibril_mutex_unlock(&user->refcount_mutex);
 
 			if (bail_out) {
@@ -238,12 +238,12 @@
 			break;
 		case CONSOLE_GET_EVENT: {
-			if (list_empty(&client->in_events.list)) {
+			if (list_empty(&user->in_events.list)) {
 				retry:
-				if (client->socket_buffer_len <= client->socket_buffer_pos) {
-					int recv_length = recv(client->socket, client->socket_buffer, BUFFER_SIZE, 0);
+				if (user->socket_buffer_len <= user->socket_buffer_pos) {
+					int recv_length = recv(user->socket, user->socket_buffer, BUFFER_SIZE, 0);
 					if ((recv_length == 0) || (recv_length == ENOTCONN)) {
-						fibril_mutex_lock(&client->refcount_mutex);
-						client->socket_closed = true;
-						fibril_mutex_unlock(&client->refcount_mutex);
+						fibril_mutex_lock(&user->refcount_mutex);
+						user->socket_closed = true;
+						fibril_mutex_unlock(&user->refcount_mutex);
 						async_answer_0(callid, ENOENT);
 						return;
@@ -253,8 +253,8 @@
 						return;
 					}
-					client->socket_buffer_len = recv_length;
-					client->socket_buffer_pos = 0;
+					user->socket_buffer_len = recv_length;
+					user->socket_buffer_pos = 0;
 				}
-				char data = client->socket_buffer[client->socket_buffer_pos++];
+				char data = user->socket_buffer[user->socket_buffer_pos++];
 				if (data == 13) {
 					data = 10;
@@ -267,10 +267,10 @@
 				assert(down);
 				assert(up);
-				prodcons_produce(&client->in_events, &down->link);
-				prodcons_produce(&client->in_events, &up->link);
+				prodcons_produce(&user->in_events, &down->link);
+				prodcons_produce(&user->in_events, &up->link);
 			}
 
 
-			link_t *link = prodcons_consume(&client->in_events);
+			link_t *link = prodcons_consume(&user->in_events);
 			kbd_event_t *event = list_get_instance(link, kbd_event_t, link);
 			async_answer_4(callid, EOK, event->type, event->key, event->mods, event->c);
@@ -306,5 +306,5 @@
 				}
 			}
-			rc = send(client->socket, buf_converted, buf_converted_size, 0);
+			rc = send(user->socket, buf_converted, buf_converted_size, 0);
 			free(buf);
 
@@ -352,12 +352,12 @@
 static void client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
 {
-	/* Find the client. */
-	client_t *client = client_get_for_client_connection(IPC_GET_ARG1(*icall));
-	if (client == NULL) {
+	/* Find the user. */
+	telnet_user_t *user = telnet_user_get_for_client_connection(IPC_GET_ARG1(*icall));
+	if (user == NULL) {
 		async_answer_0(iid, ENOENT);
 		return;
 	}
 
-	printf("New client for service %s.\n", client->service_name);
+	printf("New user for service %s.\n", user->service_name);
 
 	/* Accept the connection, increment reference. */
@@ -365,23 +365,23 @@
 
 	/* Force character mode. */
-	send(client->socket, (void *)telnet_force_character_mode_command,
+	send(user->socket, (void *)telnet_force_character_mode_command,
 	    telnet_force_character_mode_command_count, 0);
 
-	client_connection_message_loop(client);
-
-	/* Announce client disconnection. */
-	fibril_mutex_lock(&client->refcount_mutex);
-	client->locsrv_connection_count--;
-	fibril_condvar_signal(&client->refcount_cv);
-	fibril_mutex_unlock(&client->refcount_mutex);
+	client_connection_message_loop(user);
+
+	/* Announce user disconnection. */
+	fibril_mutex_lock(&user->refcount_mutex);
+	user->locsrv_connection_count--;
+	fibril_condvar_signal(&user->refcount_cv);
+	fibril_mutex_unlock(&user->refcount_mutex);
 }
 
 static int spawn_task_fibril(void *arg)
 {
-	client_t *client = arg;
+	telnet_user_t *user = arg;
 	int rc;
 
 	char term[LOC_NAME_MAXLEN];
-	snprintf(term, LOC_NAME_MAXLEN, "%s/%s", "/loc", client->service_name);
+	snprintf(term, LOC_NAME_MAXLEN, "%s/%s", "/loc", user->service_name);
 
 	task_id_t task;
@@ -390,14 +390,14 @@
 		printf("%s: Error spawning %s -w %s %s (%s)\n", NAME,
 		    APP_GETTERM, term, "/app/bdsh", str_error(rc));
-		fibril_mutex_lock(&client->refcount_mutex);
-		client->task_finished = true;
-		fibril_condvar_signal(&client->refcount_cv);
-		fibril_mutex_unlock(&client->refcount_mutex);
+		fibril_mutex_lock(&user->refcount_mutex);
+		user->task_finished = true;
+		fibril_condvar_signal(&user->refcount_cv);
+		fibril_mutex_unlock(&user->refcount_mutex);
 		return EOK;
 	}
 
-	fibril_mutex_lock(&client->refcount_mutex);
-	client->task_id = task;
-	fibril_mutex_unlock(&client->refcount_mutex);
+	fibril_mutex_lock(&user->refcount_mutex);
+	user->task_id = task;
+	fibril_mutex_unlock(&user->refcount_mutex);
 
 	task_exit_t task_exit;
@@ -407,59 +407,59 @@
 
 	/* Announce destruction. */
-	fibril_mutex_lock(&client->refcount_mutex);
-	client->task_finished = true;
-	fibril_condvar_signal(&client->refcount_cv);
-	fibril_mutex_unlock(&client->refcount_mutex);
+	fibril_mutex_lock(&user->refcount_mutex);
+	user->task_finished = true;
+	fibril_condvar_signal(&user->refcount_cv);
+	fibril_mutex_unlock(&user->refcount_mutex);
 
 	return EOK;
 }
 
-static bool client_can_be_destroyed_no_lock(client_t *client)
-{
-	return client->task_finished && client->socket_closed &&
-	    (client->locsrv_connection_count == 0);
-}
-
-static int network_client_fibril(void *arg)
+static bool user_can_be_destroyed_no_lock(telnet_user_t *user)
+{
+	return user->task_finished && user->socket_closed &&
+	    (user->locsrv_connection_count == 0);
+}
+
+static int network_user_fibril(void *arg)
 {
 	int rc;
-	client_t *client = arg;
-
-	rc = loc_service_register(client->service_name, &client->service_id);
+	telnet_user_t *user = arg;
+
+	rc = loc_service_register(user->service_name, &user->service_id);
 	if (rc != EOK) {
 		fprintf(stderr, "%s: Unable to register device %s\n", NAME,
-		    client->service_name);
+		    user->service_name);
 		return EOK;
 	}
-	printf("Service %s registered as %" PRIun "\n", client->service_name,
-	    client->service_id);
-
-	fid_t spawn_fibril = fibril_create(spawn_task_fibril, client);
+	printf("Service %s registered as %" PRIun "\n", user->service_name,
+	    user->service_id);
+
+	fid_t spawn_fibril = fibril_create(spawn_task_fibril, user);
 	assert(spawn_fibril);
 	fibril_add_ready(spawn_fibril);
 
 	/* Wait for all clients to exit. */
-	fibril_mutex_lock(&client->refcount_mutex);
-	while (!client_can_be_destroyed_no_lock(client)) {
-		if (client->task_finished) {
-			closesocket(client->socket);
-			client->socket_closed = true;
+	fibril_mutex_lock(&user->refcount_mutex);
+	while (!user_can_be_destroyed_no_lock(user)) {
+		if (user->task_finished) {
+			closesocket(user->socket);
+			user->socket_closed = true;
 			continue;
-		} else if (client->socket_closed) {
-			if (client->task_id != 0) {
-				task_kill(client->task_id);
+		} else if (user->socket_closed) {
+			if (user->task_id != 0) {
+				task_kill(user->task_id);
 			}
 		}
-		fibril_condvar_wait_timeout(&client->refcount_cv, &client->refcount_mutex, 1000);
-	}
-	fibril_mutex_unlock(&client->refcount_mutex);
-
-	rc = loc_service_unregister(client->service_id);
+		fibril_condvar_wait_timeout(&user->refcount_cv, &user->refcount_mutex, 1000);
+	}
+	fibril_mutex_unlock(&user->refcount_mutex);
+
+	rc = loc_service_unregister(user->service_id);
 	if (rc != EOK) {
-		fprintf(stderr, "Warning: failed to unregister %s: %s\n", client->service_name, str_error(rc));
-	}
-
-	printf("Destroying service %s.\n", client->service_name);
-	client_destroy(client);
+		fprintf(stderr, "Warning: failed to unregister %s: %s\n", user->service_name, str_error(rc));
+	}
+
+	printf("Destroying service %s.\n", user->service_name);
+	telnet_user_destroy(user);
 
 	return EOK;
@@ -523,8 +523,8 @@
 		}
 
-		client_t *client = client_create(conn_sd);
-		assert(client);
-
-		fid_t fid = fibril_create(network_client_fibril, client);
+		telnet_user_t *user = telnet_user_create(conn_sd);
+		assert(user);
+
+		fid_t fid = fibril_create(network_user_fibril, user);
 		assert(fid);
 		fibril_add_ready(fid);
