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