Changeset 1243

Show
Ignore:
Timestamp:
08/03/08 19:59:15 (2 years ago)
Author:
ahu
Message:

implement get-parameter as suggested by Wouter de Jong of WideXS

Location:
trunk/pdns/pdns
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/docs/pdns.sgml

    r1236 r1243  
    79477947                <para> 
    79487948                  Retrieve a statistic. For items that can be queried, see below. 
     7949                </para> 
     7950              </listitem> 
     7951            </varlistentry>        
     7952            <varlistentry> 
     7953              <term>get-parameter parameter1 parameter2 ../term> 
     7954              <listitem> 
     7955                <para> 
     7956                  Retrieve a configuration parameter. All parameters from the configuration and command line can be queried. 
    79497957                </para> 
    79507958              </listitem> 
  • trunk/pdns/pdns/rec_channel_rec.cc

    r1204 r1243  
    1111#include <boost/tuple/tuple.hpp> 
    1212#include <boost/format.hpp> 
     13#include <boost/algorithm/string.hpp> 
    1314#include <sys/types.h> 
    1415#include <sys/stat.h> 
     
    1617#include "logger.hh" 
    1718#include "dnsparser.hh" 
     19#include "arguments.hh" 
    1820#ifndef WIN32 
    1921#include <sys/resource.h> 
     
    6971  return ret; 
    7072} 
     73 
     74template<typename T> 
     75string doGetParameter(T begin, T end) 
     76{ 
     77  string ret; 
     78  string parm; 
     79  for(T i=begin; i != end; ++i) { 
     80    if(::arg().parmIsset(*i)) { 
     81      parm=::arg()[*i]; 
     82      replace_all(parm, "\\", "\\\\"); 
     83      replace_all(parm, "\"", "\\\""); 
     84      replace_all(parm, "\n", "\\n"); 
     85      ret += *i +"=\""+ parm +"\"\n"; 
     86    } 
     87    else 
     88      ret += *i +" not known\n"; 
     89  } 
     90  return ret; 
     91} 
     92 
    7193 
    7294template<typename T> 
     
    290312    return doGet(begin, end); 
    291313 
     314  if(cmd=="get-parameter")  
     315    return doGetParameter(begin, end); 
     316 
     317 
    292318  if(cmd=="quit") { 
    293319    *command=&doExit;