943,880 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 776
  • C RSS
Dec 2nd, 2008
0

/etc/resolv.conf

Expand Post »
Hi All,
Can anyone tell me about a library that helps me to read contents from /etc/resolv.conf file and also update the same file with new entries. Does this possible with Resolver library routines? Any useful links or sample programs regarding this? Thanks in advance.
Renjith
Similar Threads
Reputation Points: 12
Solved Threads: 7
Light Poster
RenjithVR is offline Offline
41 posts
since Mar 2008
Dec 2nd, 2008
0

Re: /etc/resolv.conf

The conf file is just a textfile, so you can use standard c++ file-acces:

  1. #include <fstream>
  2.  
  3. [....]
  4.  
  5. std::ifstream in_file("/etc/resolv.conf");
  6. if (!in_file.is_open())
  7. std::cout << "error opening file";
  8. else
  9. // do stuff
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006
Dec 2nd, 2008
0

Re: /etc/resolv.conf

Thanks for your reply. I have to use libraries to open this file.
With the help of the library routines I can add name server,
read the contents etc. Does this possible with Resolver library(http://swoolley.org/man.cgi/resolver)? Please let me know,
if need more info.
Last edited by RenjithVR; Dec 2nd, 2008 at 9:34 am.
Reputation Points: 12
Solved Threads: 7
Light Poster
RenjithVR is offline Offline
41 posts
since Mar 2008
Dec 2nd, 2008
0

Re: /etc/resolv.con

Click to Expand / Collapse  Quote originally posted by RenjithVR ...
Hi,
Hi All,
Can anyone tell me about a library that helps me to read contents from /etc/resolv.conf file and also update the same file with new entries. Does this possible with Resolver library routines? Any useful links or sample programs regarding this? Thanks in advance.
Renjith
resolv.conf stores the DNS Servers your system should use, in plain text. Why would you want a special library to read it ???
Last edited by stephen84s; Dec 2nd, 2008 at 10:29 am.
Featured Poster
Reputation Points: 653
Solved Threads: 151
Nearly a Posting Virtuoso
stephen84s is offline Offline
1,316 posts
since Jul 2007
Dec 3rd, 2008
0

Re: /etc/resolv.conf

If you look at the man resolv.conf, you can see different configuration options. I have to use some of those options. Is it possible to do with the 'resolver', a set of routines in the C library. Can I use those set of routines in my program to access/update resolv.conf file? or any other library available to do this?
Reputation Points: 12
Solved Threads: 7
Light Poster
RenjithVR is offline Offline
41 posts
since Mar 2008
Dec 3rd, 2008
0

Re: /etc/resolv.conf

Although I have never tried it, I have read the manual pages of both resolv.conf and resolver, and I found the following line which would interest you :-
This is from the resolv.conf manual page.
Quote ...
The resolver is a set of routines in the C library that provide access to the Internet Domain Name System (DNS). The resolver configuration file contains information that is read by the resolver routines the first time they are invoked by a process.
And this is from the resolver manual page:-
Quote ...
The res_init() function reads the configuration files (see resolv.conf(5)) to get the default domain name, search order and name server address(es). If no server is given, the local host is tried. If no domain is given, that associated with the local host is used. It can be overridden with the environment variable LOCALDOMAIN. res_init() is normally executed by the first call to one of the other functions.
So I guess you can read the resolv.conf file using resolver but I could not find any method that would actually write back to it.
Featured Poster
Reputation Points: 653
Solved Threads: 151
Nearly a Posting Virtuoso
stephen84s is offline Offline
1,316 posts
since Jul 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Warning: Comparison between pointer and integer (mingw 5.1.4)
Next Thread in C Forum Timeline: Optimizing OpenGL (SwapBuffer being slow)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC