]> git.ipfire.org Git - thirdparty/pdns.git/blobdiff - pdns/qtype.cc
Merge pull request #7908 from omoerbeek/rec-4.1.14-changelog
[thirdparty/pdns.git] / pdns / qtype.cc
index 3e23f12b12135beba06ee0508cf39b3dbedb77b2..31f383124ea86a8ad11e9e57e8145f708bc8a2ea 100644 (file)
@@ -1,25 +1,24 @@
 /*
-    PowerDNS Versatile Database Driven Nameserver
-    Copyright (C) 2002 - 2007 PowerDNS.COM BV
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2
-    as published by the Free Software Foundation
-
-    Additionally, the license of this program contains a special
-    exception which allows to distribute the program in binary form when
-    it is linked against OpenSSL.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-#include "utility.hh"
+ * This file is part of PowerDNS or dnsdist.
+ * Copyright -- PowerDNS.COM B.V. and its contributors
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * In addition, for the avoidance of any doubt, permission is granted to
+ * link this program with OpenSSL and to (re)distribute the binaries
+ * produced as the result of such linking.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
 #include "dns.hh"
 #include <iostream>
 #include <string>
@@ -28,7 +27,8 @@
 #include <sstream>
 #include "qtype.hh"
 #include "misc.hh"
-#include "lock.hh"
+
+static_assert(sizeof(QType) == 2, "QType is not 2 bytes in size, something is wrong!");
 
 vector<QType::namenum> QType::names;
 // XXX FIXME we need to do something with initializer order here!
@@ -36,6 +36,7 @@ QType::init QType::initializer;
 
 QType::QType()
 {
+  code = 0;
 }
 
 bool QType::isSupportedType() {
@@ -79,19 +80,20 @@ QType &QType::operator=(uint16_t n)
 
 int QType::chartocode(const char *p)
 {
-  static QType qt;
+  string P = toUpper(p);
   vector<namenum>::iterator pos;
+
   for(pos=names.begin(); pos < names.end(); ++pos)
-    if(pos->first == p)
+    if(pos->first == P)
       return pos->second;
-  
+
   if(*p=='#') {
     return atoi(p+1);
   }
 
-  if(boost::starts_with(p, "TYPE"))
+  if(boost::starts_with(P, "TYPE"))
     return atoi(p+4);
-    
+
   return 0;
 }
 
@@ -108,8 +110,7 @@ QType &QType::operator=(const string &s)
 }
 
 
-QType::QType(uint16_t n)
+QType::QType(uint16_t n): QType()
 {
-  QType();
   code=n;
 }