I want to parse /etc/hosts and manipulate it by adding/removing hosts. I'm using Swift to build an OSX application, but before I build a parser for /etc/hosts, I want to make sure there's nothing out there already available so I don't have to reinvent the wheels. From my researches, I found:
1. mDNSResponder seems to parse /etc/hosts according to the hosts manpage, but I couldn't find an exposed API to manipulate the hosts file;
2. gethostent seems to be able to do that, but not sure how to use standard C code on Swift and link libc to the project.
Any help is appreciated, thanks!
1. mDNSResponder seems to parse /etc/hosts according to the hosts manpage, but I couldn't find an exposed API to manipulate the hosts file;
2. gethostent seems to be able to do that, but not sure how to use standard C code on Swift and link libc to the project.
Any help is appreciated, thanks!