aboutsummaryrefslogtreecommitdiff
path: root/check_user_name.h
diff options
context:
space:
mode:
authorBen Burwell <bburwell1@gmail.com>2013-04-29 16:13:34 -0400
committerBen Burwell <bburwell1@gmail.com>2013-04-29 16:13:34 -0400
commitca9e46c937e75df43d2f80f0d957fabb07892c29 (patch)
tree0d8ae2bc1d1e3e248c746586a5daf7cb58a79463 /check_user_name.h
Init
Diffstat (limited to 'check_user_name.h')
-rw-r--r--check_user_name.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/check_user_name.h b/check_user_name.h
new file mode 100644
index 0000000..77051ce
--- /dev/null
+++ b/check_user_name.h
@@ -0,0 +1,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;
+
+} \ No newline at end of file