diff --git a/liblist.a b/liblist.a new file mode 100644 index 0000000..927feaf Binary files /dev/null and b/liblist.a differ diff --git a/list.h b/list.h new file mode 100644 index 0000000..dd2bef3 --- /dev/null +++ b/list.h @@ -0,0 +1,168 @@ +/* + Dane MacFadden + dgm288 + 11283087 + + James Hom + jhh318 + 11287431 +*/ + +#ifndef __LIST_H__ +#define __LIST_H__ + + +typedef struct node { + void *data; + struct node *next; + struct node *previous; +} NODE; + +typedef struct list { + + int size; + NODE *current; + NODE *head; + NODE *tail; + +} LIST; + +/* + Create empty list + Returns: Pointer to new empty list if successful, NULL pointer otherwise + */ +LIST *ListCreate(); + + +/* Returns the number of items contained by the list */ +int ListCount(LIST *list); + + +/* + Returns pointer to first item in the list and makes it the current item + list: Pointer to a list + Returns: Pointer to first item in the list +*/ +void *ListFirst(LIST *list); + + +/* + Return pointer to last item in list + list: Pointer to a list + Returns: Pointer to last item in list +*/ +void *ListLast(LIST *list); + + +/* + Return next item in the list + list: Pointer to a list + Returns: Pointer to next item in list +*/ + +void *ListNext(LIST *list); + + +/* + Return previous item in list + list: Pointer to a list + Returns: Pointer to last item +*/ +void *ListPrev(LIST *list); + + +/* Get current item in list + list: Pointer to list + Returns: Pointer to last item +*/ +void *ListCurr(LIST *list); + + +/* + Add item to list after current item, + switch current item to the item we just added. + If current item is at the end, item is added at the end. + list: List pointer + item: Pointer to an item to add to the list + Returns: 0 if successful, -1 otherwise +*/ +int ListAdd(LIST *list, void *item); + + +/* + Insert an item right before the current item. + If current is the start of the list, add to the start. + list: Pointer to list + item: Pointer to item to add + Returns: 0 if successful, -1 otherwise + */ +int ListInsert(LIST *list, void *item); + + +/* + Add an item to the end of the list + list: Pointer to list + item: Pointer to item to add + Returns: 0 if successful, -1 otherwise +*/ +int ListAppend(LIST *list, void *item); + + +/* + Add item to the front of the list + list: Pointer to list + item: Pointer to item to add + Returns: 0 if successful, -1 otherwise +*/ +int ListPrepend(LIST *list, void *item); + +/* + Delete current item from list and make next item current + list: Pointer to list + Returns: Deleted item +*/ +void *ListRemove(LIST *list); + + +/* + Adds list2 to the end of list1 + Current pointer set to current pointer of list1 + List2 ceases to exist + list1: Pointer to list1 + list2: Pointer to list2 +*/ +void ListConcat(LIST *list1, LIST *list2); + +/* + Deletes list + list: Pointer to list + itemFree: routine that frees an item +*/ +void ListFree(LIST *list, void (*itemFree)(void *)); + + +/* + Returns last item and takes it out of the list + list: Pointer to list + Returns: Pointer to last item that was just deleted from list +*/ +void *ListTrim(LIST *list); + + +/* + Search list starting at current item. + Finishes at end of list or when a match is found + list: Pointer to list + comparator: Routine that returns 0 + if the item and comparisonArg don't match, + or 1 if they do. If a match is found the current pointer + is left at the matched item + If no match is found, + current pointer is left at the end + Returns: Pointer to matching item if found, otherwise NULL pointer +*/ +void *ListSearch(LIST *list, int (*comparator)(void *, void *), void *comparisonArg); + +#endif + + diff --git a/main.c b/main.c index 26dfbc9..8a76e91 100644 --- a/main.c +++ b/main.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #define MAXBUFSIZE 30 #define BACKLOG 10 @@ -31,7 +31,12 @@ void *input(void *arg) { } void *sender(void *arg) { - return 0; + + return 0; +} + +void *receiver(void *arg) { + return 0; } void *get_in_addr(struct sockaddr *sa) { @@ -126,8 +131,6 @@ int main(int argc, char* argv[]) { s, sizeof s); printf("Getting chatty with %s\n", s); - len = strlen("test"); - send(confd, "test", len, 0); } else { /* You're the client */ @@ -169,14 +172,15 @@ int main(int argc, char* argv[]) { servinfo = q; } printf("Connected!\n"); - recv(socketfd, &buf, 20, 0); - printf("%s\n", buf); } /* pthread_create(&input_thread, NULL, input, (void*) msg); pthread_join(input_thread, NULL); -*/ +*/ + + close(socketfd); + close(confd); return 0; }