aboutsummaryrefslogtreecommitdiff
path: root/check_user_name.h
diff options
context:
space:
mode:
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