From 4789384846e7522ec43d715b178f24ed29101b15 Mon Sep 17 00:00:00 2001 From: Justin Reichardt Date: Thu, 26 Aug 2021 14:39:50 -0500 Subject: [PATCH] Parses the static entries from hosts pulls the static entries and stores them in the tmp file --- src/rhosts.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/rhosts.c b/src/rhosts.c index 7c2ebf7..06a6da8 100644 --- a/src/rhosts.c +++ b/src/rhosts.c @@ -120,6 +120,20 @@ int preserve_static_entries(){ fclose(hostsf); return 1; } + char buff[MAXSTRSIZE]; + char c = EOF; + int rc = 0; + + do{ + c = fgetc(hostsf); + printf("%c",c); + strncat(buff, &c, 1); + if (strncmp(buff, "# rhosts begin", 14) == 0){c = EOF;} + if (c == '\n'){ + rc = fputs(buff, tmpf); + buff[0] = '\0'; + } + }while ( c != EOF);