feature/delete-host: Delete a hosts from the hosts file. #4
16
main.c
16
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")) {
|
||||
|
Loading…
Reference in New Issue
Block a user