title: Querying domain field from /etc/resolv.conf using Linux API (resolv.h)
body: <p>I'm trying to extract <strong>domain</strong> entry from <em>/etc/resolv.conf</em>. </p>
  
  <p>For instance, from the following file, I want to get <em>my.domain.com</em> using standard Linux API, but I couldn't find any corresponding entries from <em>struct __res_state</em> defined from <em>/usr/include/resolv.h</em>.</p>
  
  <pre><code># Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
  #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN   
  nameserver 127.0.1.1 
  domain my.domain.com 
  search localdomain
  </code></pre>
  
  <p>Easy way is to parse the file and extract any string literal that follows domain keyword, but I expect to find a somewhat standard way to get it. </p>
  
  <p>Thanks a lot for your help in advance! </p>