Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1332)

Unified Diff: net/base/dns_util.cc

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/dns_util.h ('k') | net/base/dns_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/dns_util.cc
diff --git a/net/base/dns_util.cc b/net/base/dns_util.cc
deleted file mode 100644
index f75cd956663e77123cb90a8614cdba27b667f6f7..0000000000000000000000000000000000000000
--- a/net/base/dns_util.cc
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/base/dns_util.h"
-
-#include <cstring>
-
-namespace net {
-
-// Based on DJB's public domain code.
-bool DNSDomainFromDot(const base::StringPiece& dotted, std::string* out) {
- const char* buf = dotted.data();
- unsigned n = dotted.size();
- char label[63];
- size_t labellen = 0; /* <= sizeof label */
- char name[255];
- size_t namelen = 0; /* <= sizeof name */
- char ch;
-
- for (;;) {
- if (!n)
- break;
- ch = *buf++;
- --n;
- if (ch == '.') {
- if (labellen) {
- if (namelen + labellen + 1 > sizeof name)
- return false;
- name[namelen++] = static_cast<char>(labellen);
- memcpy(name + namelen, label, labellen);
- namelen += labellen;
- labellen = 0;
- }
- continue;
- }
- if (labellen >= sizeof label)
- return false;
- label[labellen++] = ch;
- }
-
- if (labellen) {
- if (namelen + labellen + 1 > sizeof name)
- return false;
- name[namelen++] = static_cast<char>(labellen);
- memcpy(name + namelen, label, labellen);
- namelen += labellen;
- labellen = 0;
- }
-
- if (namelen + 1 > sizeof name)
- return false;
- if (namelen == 0) // Empty names e.g. "", "." are not valid.
- return false;
- name[namelen++] = 0; // This is the root label (of length 0).
-
- *out = std::string(name, namelen);
- return true;
-}
-
-std::string DNSDomainToString(const base::StringPiece& domain) {
- std::string ret;
-
- for (unsigned i = 0; i < domain.size() && domain[i]; i += domain[i] + 1) {
-#if CHAR_MIN < 0
- if (domain[i] < 0)
- return std::string();
-#endif
- if (domain[i] > 63)
- return std::string();
-
- if (i)
- ret += ".";
-
- if (static_cast<unsigned>(domain[i]) + i + 1 > domain.size())
- return std::string();
-
- domain.substr(i + 1, domain[i]).AppendToString(&ret);
- }
- return ret;
-}
-
-std::string TrimEndingDot(const base::StringPiece& host) {
- base::StringPiece host_trimmed = host;
- size_t len = host_trimmed.length();
- if (len > 1 && host_trimmed[len - 1] == '.') {
- host_trimmed.remove_suffix(1);
- }
- return host_trimmed.as_string();
-}
-
-} // namespace net
« no previous file with comments | « net/base/dns_util.h ('k') | net/base/dns_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698