[Pdns-dev] QType::chartocode w/bind zone issues

Major Sphinct msphinct at gmail.com
Thu Apr 26 16:19:05 CEST 2007

Hi, I've been playing with zone2sql a lot lately, and I'm trying
to mess with 1000s of old zonefiles and convert them from bind to

I do not have control over the older zonefiles, so everytime I was doing
some test conversions, I had to deal with all the lowercase "ns", "a",
"soa" and convert them with perl pies, and that meant copying all of them
first.  In other words, it was a hassle.

Is this something that you all can change so that it can deal with
lowercase types?  it takes a lot of the sting out of converting
zonefiles for me.  So I thought I would ask.

I added a quick patch with a tiny functor to deal with this directly in
QType::chartocode, qtype.cc  It's only a few lines, and you all might
want it in a different style, but the functionality is all I'm looking

--- qtype.orig  2007-04-26 14:08:52.000000000 -0500
+++ qtype.cc    2007-04-26 14:08:43.000000000 -0500
@@ -85,12 +85,27 @@
   return *this;

+// Functor for calling std::toupper.
+struct ToUpper {
+  int operator() ( int c )
+  {
+    return std::toupper ( c );
+  }
 int QType::chartocode(const char *p)
+  std::string codestr(p);
+  std::transform(codestr.begin(), codestr.end(), codestr.begin(),
   static QType qt;
   vector<namenum>::iterator pos;
-    if(pos->first==p)
+    if(pos->first==codestr.c_str()) // Do compare with converted string
       return pos->second;

   return 0;


I'm not sure of any ill effects this could have, but chartocode is
only called from 8 or 9 places in pdns, and it's not updating any
input, so it seems pretty safe, but you all will know better than
Also, I'm aware that you all might have built this functionality into
another part of the code, and you could add that behavior much more
elegantly, but I just wanted to submit a prototype to see if it's
something that you are all interested in or if I should just keep
it for myself own use.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.powerdns.com/pipermail/pdns-dev/attachments/20070426/90cf6776/attachment.htm

More information about the Pdns-dev mailing list