about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-03-09 21:23:39 +0000
committerJames Booth <boothj5@gmail.com>2012-03-09 21:23:39 +0000
commit59c02863fed3d490681dba964d7d74d4e35b11d6 (patch)
treee3bce8a3d66c995608bd8bb0c59e1b2ba8c099c3
parentf533c6c1622438f738348c22ff754d9952fb3f01 (diff)
downloadprofani-tty-59c02863fed3d490681dba964d7d74d4e35b11d6.tar.gz
Changed typenames in contact list
-rw-r--r--command.c2
-rw-r--r--contact_list.c35
-rw-r--r--contact_list.h6
-rw-r--r--test_contact_list.c34
-rw-r--r--windows.c2
-rw-r--r--windows.h2
6 files changed, 41 insertions, 40 deletions
diff --git a/command.c b/command.c
index d062138e..03d31e57 100644
--- a/command.c
+++ b/command.c
@@ -153,7 +153,7 @@ static int _cmd_who(void)
     if (conn_status != JABBER_CONNECTED) {
         cons_not_connected();
     } else {
-        struct contact_list *list = get_contact_list();
+        contact_list_t *list = get_contact_list();
         cons_show_online_contacts(list);
     }
 
diff --git a/contact_list.c b/contact_list.c
index 82bbe243..7c0ca490 100644
--- a/contact_list.c
+++ b/contact_list.c
@@ -26,19 +26,19 @@
 #include "contact_list.h"
 
 // contact list node
-struct _contact_t {
+struct _contact_node_t {
     char *contact;    
-    struct _contact_t *next;
+    struct _contact_node_t *next;
 };
 
 // the contact list
-static struct _contact_t *_contact_list = NULL;
+static struct _contact_node_t *_contact_list = NULL;
 
-static struct _contact_t * _make_contact(const char * const contact);
+static struct _contact_node_t * _make_contact_node(const char * const contact);
 
 void contact_list_clear(void)
 {
-    struct _contact_t *curr = _contact_list;
+    struct _contact_node_t *curr = _contact_list;
     
     if (curr) {
         while(curr) {
@@ -56,8 +56,8 @@ int contact_list_remove(const char * const contact)
     if (!_contact_list) {
         return 0;
     } else {
-        struct _contact_t *curr = _contact_list;
-        struct _contact_t *prev = NULL;
+        struct _contact_node_t *curr = _contact_list;
+        struct _contact_node_t *prev = NULL;
         
         while(curr) {
             if (strcmp(curr->contact, contact) == 0) {
@@ -83,12 +83,12 @@ int contact_list_remove(const char * const contact)
 int contact_list_add(const char * const contact)
 {
     if (!_contact_list) {
-        _contact_list = _make_contact(contact);
+        _contact_list = _make_contact_node(contact);
         
         return 1;
     } else {
-        struct _contact_t *curr = _contact_list;
-        struct _contact_t *prev = NULL;
+        struct _contact_node_t *curr = _contact_list;
+        struct _contact_node_t *prev = NULL;
 
         while(curr) {
             if (strcmp(curr->contact, contact) == 0)
@@ -98,7 +98,7 @@ int contact_list_add(const char * const contact)
             curr = curr->next;
         }
 
-        curr = _make_contact(contact);        
+        curr = _make_contact_node(contact);        
         
         if (prev)
             prev->next = curr;
@@ -107,14 +107,14 @@ int contact_list_add(const char * const contact)
     }
 }
 
-struct contact_list *get_contact_list(void)
+contact_list_t *get_contact_list(void)
 {
     int count = 0;
     
-    struct contact_list *list = 
-        (struct contact_list *) malloc(sizeof(struct contact_list));
+    contact_list_t *list = 
+        (contact_list_t *) malloc(sizeof(contact_list_t));
 
-    struct _contact_t *curr = _contact_list;
+    struct _contact_node_t *curr = _contact_list;
     
     if (!curr) {
         list->contacts = NULL;
@@ -135,9 +135,10 @@ struct contact_list *get_contact_list(void)
     return list;
 }
 
-static struct _contact_t * _make_contact(const char * const contact)
+struct _contact_node_t * _make_contact_node(const char * const contact)
 {
-    struct _contact_t *new = (struct _contact_t *) malloc(sizeof(struct _contact_t));
+    struct _contact_node_t *new = 
+        (struct _contact_node_t *) malloc(sizeof(struct _contact_node_t));
     new->contact = (char *) malloc((strlen(contact) + 1) * sizeof(char));
     strcpy(new->contact, contact);
     new->next = NULL;
diff --git a/contact_list.h b/contact_list.h
index f751f2ab..01fbd46f 100644
--- a/contact_list.h
+++ b/contact_list.h
@@ -23,14 +23,14 @@
 #ifndef CONTACT_LIST_H
 #define CONTACT_LIST_H
 
-struct contact_list {
+typedef struct _contact_list_t {
     char **contacts;
     int size;
-};
+} contact_list_t;
 
 void contact_list_clear(void);
 int contact_list_add(const char * const contact);
 int contact_list_remove(const char * const contact);
-struct contact_list *get_contact_list(void);
+contact_list_t *get_contact_list(void);
 
 #endif
diff --git a/test_contact_list.c b/test_contact_list.c
index 09bb66d6..794e436b 100644
--- a/test_contact_list.c
+++ b/test_contact_list.c
@@ -9,21 +9,21 @@ static void beforetest(void)
 
 static void empty_list_when_none_added(void)
 {
-    struct contact_list *list = get_contact_list();
+    contact_list_t *list = get_contact_list();
     assert_int_equals(0, list->size);
 }
 
 static void contains_one_element(void)
 {
     contact_list_add("James");
-    struct contact_list *list = get_contact_list();
+    contact_list_t *list = get_contact_list();
     assert_int_equals(1, list->size);
 }
 
 static void first_element_correct(void)
 {
     contact_list_add("James");
-    struct contact_list *list = get_contact_list();
+    contact_list_t *list = get_contact_list();
 
     assert_string_equals("James", list->contacts[0]);
 }
@@ -32,7 +32,7 @@ static void contains_two_elements(void)
 {
     contact_list_add("James");
     contact_list_add("Dave");
-    struct contact_list *list = get_contact_list();
+    contact_list_t *list = get_contact_list();
 
     assert_int_equals(2, list->size);
 }
@@ -41,7 +41,7 @@ static void first_and_second_elements_correct(void)
 {
     contact_list_add("James");
     contact_list_add("Dave");
-    struct contact_list *list = get_contact_list();
+    contact_list_t *list = get_contact_list();
     
     assert_string_equals("James", list->contacts[0]);
     assert_string_equals("Dave", list->contacts[1]);
@@ -52,7 +52,7 @@ static void contains_three_elements(void)
     contact_list_add("James");
     contact_list_add("Dave");
     contact_list_add("Bob");
-    struct contact_list *list = get_contact_list();
+    contact_list_t *list = get_contact_list();
     
     assert_int_equals(3, list->size);
 }
@@ -62,7 +62,7 @@ static void first_three_elements_correct(void)
     contact_list_add("James");
     contact_list_add("Dave");
     contact_list_add("Bob");
-    struct contact_list *list = get_contact_list();
+    contact_list_t *list = get_contact_list();
     
     assert_string_equals("James", list->contacts[0]);
     assert_string_equals("Dave", list->contacts[1]);
@@ -75,7 +75,7 @@ static void add_twice_at_beginning_adds_once(void)
     contact_list_add("James");
     contact_list_add("Dave");
     contact_list_add("Bob");
-    struct contact_list *list = get_contact_list();
+    contact_list_t *list = get_contact_list();
     
     assert_int_equals(3, list->size);    
     assert_string_equals("James", list->contacts[0]);
@@ -90,7 +90,7 @@ static void add_twice_in_middle_adds_once(void)
     contact_list_add("Dave");
     contact_list_add("James");
     contact_list_add("Bob");
-    struct contact_list *list = get_contact_list();
+    contact_list_t *list = get_contact_list();
     
     assert_int_equals(3, list->size);    
     assert_string_equals("James", list->contacts[0]);
@@ -105,7 +105,7 @@ static void add_twice_at_end_adds_once(void)
     contact_list_add("Dave");
     contact_list_add("Bob");
     contact_list_add("James");
-    struct contact_list *list = get_contact_list();
+    contact_list_t *list = get_contact_list();
     
     assert_int_equals(3, list->size);    
     assert_string_equals("James", list->contacts[0]);
@@ -117,7 +117,7 @@ static void add_twice_at_end_adds_once(void)
 static void remove_when_none_does_nothing(void)
 {
     contact_list_remove("James");
-    struct contact_list *list = get_contact_list();
+    contact_list_t *list = get_contact_list();
 
     assert_int_equals(0, list->size);
 }
@@ -126,7 +126,7 @@ static void remove_when_one_removes(void)
 {
     contact_list_add("James");
     contact_list_remove("James");
-    struct contact_list *list = get_contact_list();
+    contact_list_t *list = get_contact_list();
     
     assert_int_equals(0, list->size);
 }
@@ -137,7 +137,7 @@ static void remove_first_when_two(void)
     contact_list_add("Dave");
 
     contact_list_remove("James");
-    struct contact_list *list = get_contact_list();
+    contact_list_t *list = get_contact_list();
     
     assert_int_equals(1, list->size);
     assert_string_equals("Dave", list->contacts[0]);
@@ -149,7 +149,7 @@ static void remove_second_when_two(void)
     contact_list_add("Dave");
 
     contact_list_remove("Dave");
-    struct contact_list *list = get_contact_list();
+    contact_list_t *list = get_contact_list();
     
     assert_int_equals(1, list->size);
     assert_string_equals("James", list->contacts[0]);
@@ -162,7 +162,7 @@ static void remove_first_when_three(void)
     contact_list_add("Bob");
 
     contact_list_remove("James");
-    struct contact_list *list = get_contact_list();
+    contact_list_t *list = get_contact_list();
     
     assert_int_equals(2, list->size);
     assert_string_equals("Dave", list->contacts[0]);
@@ -176,7 +176,7 @@ static void remove_second_when_three(void)
     contact_list_add("Bob");
 
     contact_list_remove("Dave");
-    struct contact_list *list = get_contact_list();
+    contact_list_t *list = get_contact_list();
     
     assert_int_equals(2, list->size);
     assert_string_equals("James", list->contacts[0]);
@@ -190,7 +190,7 @@ static void remove_third_when_three(void)
     contact_list_add("Bob");
 
     contact_list_remove("Bob");
-    struct contact_list *list = get_contact_list();
+    contact_list_t *list = get_contact_list();
     
     assert_int_equals(2, list->size);
     assert_string_equals("James", list->contacts[0]);
diff --git a/windows.c b/windows.c
index 939e5d74..5d5161c2 100644
--- a/windows.c
+++ b/windows.c
@@ -233,7 +233,7 @@ void cons_help(void)
         dirty = TRUE;
 }
 
-void cons_show_online_contacts(const struct contact_list * const list)
+void cons_show_online_contacts(const contact_list_t * const list)
 {
     _win_show_time(_cons_win);
     wprintw(_cons_win, "Online contacts:\n");
diff --git a/windows.h b/windows.h
index b7c565fd..3c2ada95 100644
--- a/windows.h
+++ b/windows.h
@@ -75,7 +75,7 @@ void cons_bad_message(void);
 void cons_show(const char * const cmd);
 void cons_bad_show(const char * const cmd);
 void cons_highlight_show(const char * const cmd);
-void cons_show_online_contacts(const struct contact_list * const list);
+void cons_show_online_contacts(const contact_list_t * const list);
 
 // status bar actions
 void status_bar_refresh(void);