aboutsummaryrefslogtreecommitdiff
path: root/check_user_name.h
diff options
context:
space:
mode:
authorBen Burwell <bburwell1@gmail.com>2013-05-02 09:31:41 -0400
committerBen Burwell <bburwell1@gmail.com>2013-05-02 09:31:41 -0400
commit8c90613ed8765eb25a9973309c66d85767ceb838 (patch)
treef9d6d76a577495c0a872f512a1ea45064e67e7a0 /check_user_name.h
parent627c3a7cb176ffe4ffee5b9f92a9af7bb60f490a (diff)
Adds "ip" command to look up peer IPHEADmaster
Diffstat (limited to 'check_user_name.h')
-rw-r--r--check_user_name.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/check_user_name.h b/check_user_name.h
index 77051ce..1660001 100644
--- a/check_user_name.h
+++ b/check_user_name.h
@@ -24,4 +24,27 @@ int check_user_name(const char * username) {
return 0;
+}
+
+void get_ip_by_username(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) {
+
+ printf("IP: %s \n", peers[i].ip);
+ pthread_mutex_unlock(&peer_table_lock);
+ return;
+
+ }
+ }
+
+ printf("%s does not exist. \n", username);
+
+ pthread_mutex_unlock(&peer_table_lock);
+ return;
+
} \ No newline at end of file