aboutsummaryrefslogtreecommitdiff
path: root/check_user_name.h
blob: 77051ce6a611dd84a41aeb1b2406f55e1a0546b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
 * Localchat
 * Ben Burwell
 *
 * Checks whether a username is in use
 */

int check_user_name(const char * username) {

	int i;

	pthread_mutex_lock(&peer_table_lock);

	for (i = 0; i < num_peers_in_table; i++) {
		if (strcmp(peers[i].username, username) == 0) {

			pthread_mutex_unlock(&peer_table_lock);
			return 1;
			
		}
	}

	pthread_mutex_unlock(&peer_table_lock);

	return 0;

}