Delete/replace/add hosts within config reading loop.

pull/4/head
Jacob Windle 2020-01-16 14:30:30 -05:00
parent fbe5e18f9d
commit ccb0e90d3b
1 changed files with 8 additions and 1 deletions

9
main.c
View File

@ -63,6 +63,10 @@ void blockHost(char *host)
fclose(hostsFile);
}
void deleteHost(char *host)
{
}
void showHosts()
{
@ -111,16 +115,18 @@ int update_hosts_file() {
return 0;
}
}
replacehost(ptr->data, buf);
strcpy(ptr->data, buf);
prev = ptr;
ptr = ptr->next;
} else {
blockHost(buf);
linkedlist_add(&hosts, buf);
}
}
// In this case, the list got chopped off, we need to reset pointers and free the rest of our list.
if (ptr != NULL) {
if (ptr != NULL && prev != NULL) {
prev->next = NULL;
}
@ -129,6 +135,7 @@ int update_hosts_file() {
while (ptr != NULL) {
prev = ptr;
ptr = ptr->next;
deleteHost(prev->data);
free(prev->data);
free(prev);
}