From 31186418c3d5a168df0880220881e008c548aaf7 Mon Sep 17 00:00:00 2001 From: Jacob Date: Fri, 17 Jan 2020 08:21:19 -0500 Subject: [PATCH] Cleanup, implements delete functionality --- main.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/main.c b/main.c index 9afed09..ae1ab9c 100644 --- a/main.c +++ b/main.c @@ -14,13 +14,6 @@ #define ARG_IS(argname) (strcmp(argv[i], argname) == 0) -/** - * TODO: Add config file reading for daemonization. - * TODO: Allow daemonized process to call file reading/editing routines at will. - * TODO: Generalized routine for reading through a file and replacing a line. - * TODO: Generalized routine for reading a file. - */ - /** GLOBALS **/ // Our rule we use to blackhole domains const char *blockString = "0.0.0.0 "; @@ -107,8 +100,7 @@ void blockHost(char *host) fclose(hostsFile); } -void deleteHost(char *host) -{ +void deleteHost(char *host) { modifyHostsFile(host, NULL, 1); } @@ -163,7 +155,7 @@ int update_hosts_file() { return 0; } } - replacehost(ptr->data, buf); + replaceHost(ptr->data, buf); strcpy(ptr->data, buf); prev = ptr; ptr = ptr->next; @@ -258,12 +250,12 @@ int main(int argc, char **argv) } // Replaces a host else if (ARG_IS("edit")) { - replacehost(argv[i + 1], argv[i + 2], 0); + replaceHost(argv[i + 1], argv[i + 2]); i += 2; } // Deletes a host. else if (ARG_IS("delete")) { - fprintf(stdout, "Soon to be implemented!\n"); + deleteHost(argv[i+1]); } // Shows usage. else if (ARG_IS("-h")) {