diff --git a/README.md b/README.md index 2795784..2b9e943 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,5 @@ I would like to get better with C, and will be using C much more in the near fut 1. Get delete working for my /etc/hosts editor. 2. Daemonize this program to be started up by systemd. - As part of daemonization, remember and remove added hosts on teardown. -3. Log dns requests that look at the hosts file -- To see how many go where \ No newline at end of file +3. Log dns requests that look at the hosts file -- To see how many go where +4. As part of daemonization -- only block hosts within a time limit. diff --git a/main.c b/main.c index b93ba86..e091b38 100644 --- a/main.c +++ b/main.c @@ -5,6 +5,10 @@ #include #include +/** + * TODO - daemonize, add in reading of config file, + * block sites within a certain time limit. + */ const char *blockString = "0.0.0.0 "; FILE *fopenHostsFile(int mode) @@ -59,6 +63,21 @@ void showHosts() } } +void readToHost(char *host, FILE *hostsFile) +{ + char buf[256]; + char *ptr; + + while ((fgets(buf, 256, hostsFile)) != NULL) + { + ptr = strcasestr(host, buf); + if (ptr != NULL) + break; + } + + // FILE should be read to the host itself. +} + /** * Entrypoint. */ @@ -95,4 +114,4 @@ int main(int argc, char **argv) if (hostsFile != NULL) fclose(hostsFile); -} \ No newline at end of file +}