Merge branch 'feature/delete-host' of jacob.windle/hb into master

This commit is contained in:
Jacob Windle 2020-01-18 13:13:14 +00:00 committed by Gitea
commit 708278be7d

4
main.c
View File

@ -43,15 +43,13 @@ FILE *fopenHostsFile(char *mode) {
* @param hostsFile * @param hostsFile
*/ */
void modifyHostsFile(char *oldhost, char *newhost, int deleteHost) { void modifyHostsFile(char *oldhost, char *newhost, int deleteHost) {
FILE *hostsFile = fopenHostsFile("r"); FILE *hostsFile = fopenHostsFile("r+");
char buf[256]; char buf[256];
char *ptr, *f; char *ptr, *f;
char newHostsFile[4096]; char newHostsFile[4096];
memset(newHostsFile, 0, 4096); memset(newHostsFile, 0, 4096);
// fseek(hostsFile, 0, SEEK_SET);
while (fgets(buf, 256, hostsFile) != NULL) while (fgets(buf, 256, hostsFile) != NULL)
{ {
f = strcasestr(buf, oldhost); f = strcasestr(buf, oldhost);