Add signalSyncPoint to the WebGraphicsContext3D command buffer impls.
[chromium-blink-merge.git] / net / tools / crl_set_dump / crl_set_dump.cc
blob6034bd063b43e1120a61851ab7e2ebd47df42f8b
1 // Copyright (c) 2011 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.
5 // This utility can dump the contents of CRL set, optionally augmented with a
6 // delta CRL set.
8 #include <errno.h>
9 #include <stdio.h>
10 #include <stdlib.h>
12 #include <string>
14 #include "base/at_exit.h"
15 #include "base/file_util.h"
16 #include "base/memory/ref_counted.h"
17 #include "base/string_number_conversions.h"
18 #include "net/cert/crl_set.h"
20 static int Usage(const char* argv0) {
21 fprintf(stderr, "Usage: %s <crl-set file> [<delta file>]"
22 " [<resulting output file>]\n", argv0);
23 return 1;
26 int main(int argc, char** argv) {
27 base::AtExitManager at_exit_manager;
29 base::FilePath crl_set_filename, delta_filename, output_filename;
31 if (argc < 2 || argc > 4)
32 return Usage(argv[0]);
34 crl_set_filename = base::FilePath::FromUTF8Unsafe(argv[1]);
35 if (argc >= 3)
36 delta_filename = base::FilePath::FromUTF8Unsafe(argv[2]);
37 if (argc >= 4)
38 output_filename = base::FilePath::FromUTF8Unsafe(argv[3]);
40 std::string crl_set_bytes, delta_bytes;
41 if (!file_util::ReadFileToString(crl_set_filename, &crl_set_bytes))
42 return 1;
43 if (!delta_filename.empty() &&
44 !file_util::ReadFileToString(delta_filename, &delta_bytes)) {
45 return 1;
48 scoped_refptr<net::CRLSet> crl_set, final_crl_set;
49 if (!net::CRLSet::Parse(crl_set_bytes, &crl_set)) {
50 fprintf(stderr, "Failed to parse CRLSet\n");
51 return 1;
54 if (!delta_bytes.empty()) {
55 if (!crl_set->ApplyDelta(delta_bytes, &final_crl_set)) {
56 fprintf(stderr, "Failed to apply delta to CRLSet\n");
57 return 1;
59 } else {
60 final_crl_set = crl_set;
63 if (!output_filename.empty()) {
64 const std::string out = final_crl_set->Serialize();
65 if (file_util::WriteFile(output_filename, out.data(),
66 out.size()) == -1) {
67 fprintf(stderr, "Failed to write resulting CRL set\n");
68 return 1;
72 const net::CRLSet::CRLList& crls = final_crl_set->crls();
73 for (net::CRLSet::CRLList::const_iterator i = crls.begin(); i != crls.end();
74 i++) {
75 printf("%s\n", base::HexEncode(i->first.data(), i->first.size()).c_str());
76 for (std::vector<std::string>::const_iterator j = i->second.begin();
77 j != i->second.end(); j++) {
78 printf(" %s\n", base::HexEncode(j->data(), j->size()).c_str());
82 return 0;