--- /dev/null
+/*
+ * 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.
+ */
+#pragma once
+
+inline unsigned char dns_tolower(unsigned char c)
+{
+ if(c>='A' && c<='Z')
+ c+='a'-'A';
+ return c;
+}
#include <boost/container/string.hpp>
#endif
+#include "ascii.hh"
+
uint32_t burtleCI(const unsigned char* k, uint32_t length, uint32_t init);
// #include "dns.hh"
NOTE: For now, everything MUST be . terminated, otherwise it is an error
*/
-inline unsigned char dns2_tolower(unsigned char c)
-{
- if(c>='A' && c<='Z')
- return c+('a'-'A');
- return c;
-}
-
class DNSName
{
public:
DNSName ret;
ret.d_storage = d_storage;
for(auto & c : ret.d_storage) {
- c=dns2_tolower(c);
+ c=dns_tolower(c);
}
return ret;
}
return std::lexicographical_compare(d_storage.rbegin(), d_storage.rend(),
rhs.d_storage.rbegin(), rhs.d_storage.rend(),
[](const unsigned char& a, const unsigned char& b) {
- return dns2_tolower(a) < dns2_tolower(b);
+ return dns_tolower(a) < dns_tolower(b);
}); // note that this is case insensitive, including on the label lengths
}
rhs.d_storage.c_str() + rhspos[rhscount] + 1,
rhs.d_storage.c_str() + rhspos[rhscount] + 1 + *(rhs.d_storage.c_str() + rhspos[rhscount]),
[](const unsigned char& a, const unsigned char& b) {
- return dns2_tolower(a) < dns2_tolower(b);
+ return dns_tolower(a) < dns_tolower(b);
});
// cout<<"Forward: "<<res<<endl;
d_storage.c_str() + ourpos[ourcount] + 1,
d_storage.c_str() + ourpos[ourcount] + 1 + *(d_storage.c_str() + ourpos[ourcount]),
[](const unsigned char& a, const unsigned char& b) {
- return dns2_tolower(a) < dns2_tolower(b);
+ return dns_tolower(a) < dns_tolower(b);
});
// cout<<"Reverse: "<<res<<endl;
if(res)
auto us = d_storage.cbegin();
auto p = rhs.d_storage.cbegin();
for(; us != d_storage.cend() && p != rhs.d_storage.cend(); ++us, ++p) {
- if(dns2_tolower(*p) != dns2_tolower(*us))
+ if(dns_tolower(*p) != dns_tolower(*us))
return false;
}
return true;