| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This command-line program converts an effective-TLD data file in UTF-8 from | 5 // This command-line program converts an effective-TLD data file in UTF-8 from |
| 6 // the format provided by Mozilla to the format expected by Chrome. This | 6 // the format provided by Mozilla to the format expected by Chrome. This |
| 7 // program generates an intermediate file which is then used by gperf to | 7 // program generates an intermediate file which is then used by gperf to |
| 8 // generate a perfect hash map. The benefit of this approach is that no time is | 8 // generate a perfect hash map. The benefit of this approach is that no time is |
| 9 // spent on program initialization to generate the map of this data. | 9 // spent on program initialization to generate the map of this data. |
| 10 // | 10 // |
| 11 // Running this program finds "effective_tld_names.dat" in the expected location | 11 // Running this program finds "effective_tld_names.dat" in the expected location |
| 12 // in the source checkout and generates "effective_tld_names.gperf" next to it. | 12 // in the source checkout and generates "effective_tld_names.gperf" next to it. |
| 13 // | 13 // |
| 14 // Any errors or warnings from this program are recorded in tld_cleanup.log. | 14 // Any errors or warnings from this program are recorded in tld_cleanup.log. |
| 15 // | 15 // |
| 16 // In particular, it | 16 // In particular, it |
| 17 // * Strips blank lines and comments, as well as notes for individual rules. | 17 // * Strips blank lines and comments, as well as notes for individual rules. |
| 18 // * Strips a single leading and/or trailing dot from each rule, if present. | 18 // * Strips a single leading and/or trailing dot from each rule, if present. |
| 19 // * Logs a warning if a rule contains '!' or '*.' other than at the beginning | 19 // * Logs a warning if a rule contains '!' or '*.' other than at the beginning |
| 20 // of the rule. (This also catches multiple ! or *. at the start of a rule.) | 20 // of the rule. (This also catches multiple ! or *. at the start of a rule.) |
| 21 // * Logs a warning if GURL reports a rule as invalid, but keeps the rule. | 21 // * Logs a warning if GURL reports a rule as invalid, but keeps the rule. |
| 22 // * Canonicalizes each rule's domain by converting it to a GURL and back. | 22 // * Canonicalizes each rule's domain by converting it to a GURL and back. |
| 23 // * Adds explicit rules for true TLDs found in any rule. | 23 // * Adds explicit rules for true TLDs found in any rule. |
| 24 // * Marks entries in the file between "// ===BEGIN PRIVATE DOMAINS===" | 24 // * Marks entries in the file between "// ===BEGIN PRIVATE DOMAINS===" |
| 25 // and "// ===END PRIVATE DOMAINS===" as private. | 25 // and "// ===END PRIVATE DOMAINS===" as private. |
| 26 | 26 |
| 27 #include "base/at_exit.h" | 27 #include "base/at_exit.h" |
| 28 #include "base/command_line.h" | 28 #include "base/command_line.h" |
| 29 #include "base/file_util.h" | |
| 30 #include "base/files/file_path.h" | 29 #include "base/files/file_path.h" |
| 30 #include "base/files/file_util.h" |
| 31 #include "base/i18n/icu_util.h" | 31 #include "base/i18n/icu_util.h" |
| 32 #include "base/logging.h" | 32 #include "base/logging.h" |
| 33 #include "base/path_service.h" | 33 #include "base/path_service.h" |
| 34 #include "base/process/memory.h" | 34 #include "base/process/memory.h" |
| 35 #include "net/tools/tld_cleanup/tld_cleanup_util.h" | 35 #include "net/tools/tld_cleanup/tld_cleanup_util.h" |
| 36 | 36 |
| 37 int main(int argc, const char* argv[]) { | 37 int main(int argc, const char* argv[]) { |
| 38 base::EnableTerminationOnHeapCorruption(); | 38 base::EnableTerminationOnHeapCorruption(); |
| 39 if (argc != 1) { | 39 if (argc != 1) { |
| 40 fprintf(stderr, "Normalizes and verifies UTF-8 TLD data files\n"); | 40 fprintf(stderr, "Normalizes and verifies UTF-8 TLD data files\n"); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 net::tld_cleanup::NormalizeFile(input_file, output_file); | 85 net::tld_cleanup::NormalizeFile(input_file, output_file); |
| 86 if (result != net::tld_cleanup::kSuccess) { | 86 if (result != net::tld_cleanup::kSuccess) { |
| 87 fprintf(stderr, | 87 fprintf(stderr, |
| 88 "Errors or warnings processing file. See log in tld_cleanup.log."); | 88 "Errors or warnings processing file. See log in tld_cleanup.log."); |
| 89 } | 89 } |
| 90 | 90 |
| 91 if (result == net::tld_cleanup::kError) | 91 if (result == net::tld_cleanup::kError) |
| 92 return 1; | 92 return 1; |
| 93 return 0; | 93 return 0; |
| 94 } | 94 } |
| OLD | NEW |