/etc/resolv.conf

Reply

Join Date: Mar 2008
Posts: 41
Reputation: RenjithVR is an unknown quantity at this point 
Solved Threads: 7
RenjithVR RenjithVR is offline Offline
Light Poster

/etc/resolv.conf

 
0
  #1
Dec 2nd, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,819
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 297
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Roasting Maven

Re: /etc/resolv.conf

 
0
  #2
Dec 2nd, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 41
Reputation: RenjithVR is an unknown quantity at this point 
Solved Threads: 7
RenjithVR RenjithVR is offline Offline
Light Poster

Re: /etc/resolv.conf

 
0
  #3
Dec 2nd, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 1,176
Reputation: stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light 
Solved Threads: 125
Featured Poster
stephen84s's Avatar
stephen84s stephen84s is offline Offline
Veteran Poster

Re: /etc/resolv.con

 
0
  #4
Dec 2nd, 2008
Originally Posted by RenjithVR View Post
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.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."

"How to ask questions the smart way ?"
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 41
Reputation: RenjithVR is an unknown quantity at this point 
Solved Threads: 7
RenjithVR RenjithVR is offline Offline
Light Poster

Re: /etc/resolv.conf

 
0
  #5
Dec 3rd, 2008
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?
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 1,176
Reputation: stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light 
Solved Threads: 125
Featured Poster
stephen84s's Avatar
stephen84s stephen84s is offline Offline
Veteran Poster

Re: /etc/resolv.conf

 
0
  #6
Dec 3rd, 2008
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.
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:-
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.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."

"How to ask questions the smart way ?"
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC