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/. */
15 #include "db/dbtool.h"
16 #include "digest/digesttool.h"
17 #include "enc/enctool.h"
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
) {
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());
61 PR_Init(PR_SYSTEM_THREAD
, PR_PRIORITY_NORMAL
, 1);
63 if (!tool
->Run(arguments
)) {