xref: /aosp_15_r20/external/cronet/net/tools/content_decoder_tool/content_decoder_tool_bin.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "net/tools/content_decoder_tool/content_decoder_tool.h"
6 
7 #include <iostream>
8 #include <memory>
9 #include <vector>
10 
11 #include "base/command_line.h"
12 
13 namespace {
14 
15 // Print the command line help.
PrintHelp(const char * command_line_name)16 void PrintHelp(const char* command_line_name) {
17   std::cout << command_line_name << " content_encoding [content_encoding]..."
18             << std::endl
19             << std::endl;
20   std::cout << "Decodes the stdin into the stdout using an content_encoding "
21             << "list given in arguments. This list is expected to be the "
22             << "Content-Encoding HTTP response header's value split by ','."
23             << std::endl;
24 }
25 
26 }  // namespace
27 
main(int argc,char * argv[])28 int main(int argc, char* argv[]) {
29   base::CommandLine::Init(argc, argv);
30   const base::CommandLine& command_line =
31       *base::CommandLine::ForCurrentProcess();
32 
33   std::vector<std::string> content_encodings = command_line.GetArgs();
34   if (content_encodings.size() == 0) {
35     PrintHelp(argv[0]);
36     return 1;
37   }
38   return !net::ContentDecoderToolProcessInput(content_encodings, &std::cin,
39                                               &std::cout);
40 }
41