Bug 1909074. Don't pass OFFSET_BY_ORIGIN to GetResultingTransformMatrix when it's...
[gecko.git] / security / nss / nss-tool / nss_tool.cc
blob8864f140da005f23385be1ced74390556b314b03
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include <algorithm>
6 #include <cstring>
7 #include <iostream>
8 #include <memory>
9 #include <string>
10 #include <vector>
12 #include <prinit.h>
14 #include "argparse.h"
15 #include "db/dbtool.h"
16 #include "digest/digesttool.h"
17 #include "enc/enctool.h"
18 #include "tool.h"
20 static void Usage() {
21 std::cerr << "Usage: nss <command> <subcommand> [options]" << std::endl;
22 std::cerr << " nss db [--path <directory>] <commands>" << std::endl;
23 std::cerr << " nss encrypt <options>" << std::endl;
24 std::cerr << " nss decrypt <options>" << std::endl;
25 std::cerr << " nss digest <options>" << std::endl;
28 static const std::string kDbCommand = "db";
29 static const std::string kEncryptCommand = "encrypt";
30 static const std::string kDecryptCommand = "decrypt";
31 static const std::string kDigestCommand = "digest";
33 int main(int argc, char **argv) {
34 if (argc < 2) {
35 Usage();
36 return 1;
38 std::vector<std::string> arguments(argv + 2, argv + argc);
40 std::unique_ptr<Tool> tool = nullptr;
41 if (argv[1] == kDbCommand) {
42 tool = std::unique_ptr<Tool>(new DBTool());
44 if (argv[1] == kEncryptCommand) {
45 tool = std::unique_ptr<Tool>(new EncTool());
46 arguments.push_back("--encrypt");
48 if (argv[1] == kDecryptCommand) {
49 tool = std::unique_ptr<Tool>(new EncTool());
50 arguments.push_back("--decrypt");
52 if (argv[1] == kDigestCommand) {
53 tool = std::unique_ptr<Tool>(new DigestTool());
55 if (!tool) {
56 Usage();
57 return 1;
60 int exit_code = 0;
61 PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1);
63 if (!tool->Run(arguments)) {
64 exit_code = 1;
67 PR_Cleanup();
69 return exit_code;