| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 tool manages privacy blacklists. Primarily for loading a text | 5 // This tool manages privacy blacklists. Primarily for loading a text |
| 6 // blacklist into the binary aggregate blacklist. | 6 // blacklist into the binary aggregate blacklist. |
| 7 #include <iostream> | 7 #include <iostream> |
| 8 | 8 |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "chrome/browser/privacy_blacklist/blacklist.h" | 11 #include "chrome/browser/privacy_blacklist/blacklist.h" |
| 12 #include "chrome/browser/privacy_blacklist/blacklist_io.h" | 12 #include "chrome/browser/privacy_blacklist/blacklist_io.h" |
| 13 | 13 |
| 14 #ifdef OS_POSIX | 14 #ifdef OS_POSIX |
| 15 #define ICHAR char | 15 #define ICHAR char |
| 16 #define ICERR std::cerr | 16 #define ICERR std::cerr |
| 17 #define IMAIN main | 17 #define IMAIN main |
| 18 #else | 18 #else |
| 19 #define ICHAR wchar_t | 19 #define ICHAR wchar_t |
| 20 #define ICERR std::wcerr | 20 #define ICERR std::wcerr |
| 21 #define IMAIN wmain | 21 #define IMAIN wmain |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 int PrintUsage(int argc, ICHAR* argv[]) { | 26 int PrintUsage(int argc, ICHAR* argv[]) { |
| 27 ICERR << "Usage: " << argv[0] << " <source> <target>\n" | 27 ICERR << "Usage: " << argv[0] << " <source>... <target>\n" |
| 28 " <source> is the text blacklist (.pbl) to load.\n" | 28 " <source> are text blacklists (.pbl) to load.\n" |
| 29 " <target> is the binary output blacklist repository.\n\n" | 29 " <target> is the binary output blacklist repository.\n\n" |
| 30 "Adds all entries from <source> to <target>.\n" | 30 "Adds all entries from <source> to <target>.\n" |
| 31 "Creates <target> if it does not exist.\n"; | 31 "Creates <target> if it does not exist.\n"; |
| 32 return 1; | 32 return 1; |
| 33 } | 33 } |
| 34 | 34 |
| 35 } | 35 } |
| 36 | 36 |
| 37 int IMAIN(int argc, ICHAR* argv[]) { | 37 int IMAIN(int argc, ICHAR* argv[]) { |
| 38 base::EnableTerminationOnHeapCorruption(); | 38 base::EnableTerminationOnHeapCorruption(); |
| 39 | 39 |
| 40 if (argc < 3) | 40 if (argc < 3) |
| 41 return PrintUsage(argc, argv); | 41 return PrintUsage(argc, argv); |
| 42 | 42 |
| 43 FilePath input(argv[1]); | 43 BlacklistIO io; |
| 44 FilePath output(argv[2]); | 44 for (int current = 1; current < argc-1; ++current) { |
| 45 FilePath input(argv[current]); |
| 46 if (!io.Read(input)) { |
| 47 ICERR << "Error reading input file " << argv[current] << "\n"; |
| 48 return -1; |
| 49 } |
| 50 } |
| 45 | 51 |
| 46 BlacklistIO io; | 52 FilePath output(argv[argc-1]); |
| 47 if (io.Read(input)) { | 53 if (!io.Write(output)) |
| 48 if (io.Write(output)) { | 54 ICERR << "Error writing output file " << argv[2] << "\n"; |
| 49 return 0; | 55 |
| 50 } else { | 56 return 0; |
| 51 ICERR << "Error writing output file " << argv[2] << "\n"; | |
| 52 } | |
| 53 } else { | |
| 54 ICERR << "Error reading input file " << argv[1] << "\n"; | |
| 55 } | |
| 56 return -1; | |
| 57 } | 57 } |
| OLD | NEW |