-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Server displays current connected IPs
- Loading branch information
1 parent
facd663
commit b5ff12b
Showing
5 changed files
with
147 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/*#include "linkedList.h" | ||
void createLinkedList(node_t * head, char * ip) { | ||
head = malloc(sizeof(node_t)); | ||
if (head == NULL) { | ||
return; | ||
} | ||
strcpy(head->ip, ip); | ||
head->next = NULL; | ||
} | ||
void push(node_t * head, char * ip) { | ||
node_t * current = head; | ||
while (current->next != NULL) { | ||
current = current->next; | ||
} | ||
current->next = malloc(sizeof(node_t)); | ||
strcpy(current->next->ip, ip); | ||
current->next->next = NULL; | ||
} | ||
void popFirst(node_t ** head) { | ||
node_t * next_node = NULL; | ||
if (*head == NULL) { | ||
return; | ||
} | ||
next_node = (*head)->next; | ||
free(*head); | ||
*head = next_node; | ||
} | ||
void popLast(node_t * head) { | ||
node_t * current; | ||
if (head->next == NULL) { | ||
free(head); | ||
head = NULL; | ||
return; | ||
} | ||
current = head; | ||
while (current->next->next != NULL) { | ||
current = current->next; | ||
} | ||
} | ||
void popByIndex(node_t ** head, int index) { | ||
int i = 0; | ||
node_t * current = *head; | ||
node_t * temp_node = NULL; | ||
if (index == 0) { | ||
popFirst(head); | ||
return; | ||
} | ||
for (int i = 0; i < index-1; i++) { | ||
if (current->next == NULL) { | ||
return; | ||
} | ||
current = current->next; | ||
} | ||
temp_node = current->next; | ||
current->next = temp_node->next; | ||
free(temp_node); | ||
} | ||
void clearLinkedList(node_t ** head) { | ||
node_t * current = * head; | ||
node_t * previous; | ||
while (current->next != NULL) { | ||
previous = current; | ||
current = current->next; | ||
free(current); | ||
} | ||
free(current); | ||
} | ||
void printAllAddresses(node_t * head) { | ||
node_t * current = head; | ||
while(current->next != NULL) { | ||
printf("%s\n", current->ip); | ||
current = current->next; | ||
} | ||
printf("%s\n", current->ip); | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/*#ifndef LINKEDLIST_H | ||
#define LINKEDLIST_H | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
struct node { | ||
char * ip; | ||
struct node *next; | ||
}; | ||
typedef struct node node_t; | ||
void createLinkedList(node_t * head, char * ip); | ||
void push(node_t * head, char * ip); | ||
void popFirst(node_t ** head); | ||
void popLast(node_t * head); | ||
void popByIndex(node_t ** head, int index); | ||
void clearLinkedList(node_t ** head); | ||
void printAllAddresses(node_t * head); | ||
#endif //LINKEDLIST_H | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters