NCBI C++ ToolKit
bdb_cverify.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: bdb_cverify.cpp 77790 2017-05-08 13:31:07Z ivanov $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Anatoliy Kuznetsov
27  *
28  * File Description: BDB cache verification utility
29  *
30  */
31 #include <ncbi_pch.hpp>
32 #include <stdio.h>
33 #include <corelib/ncbiapp.hpp>
34 #include <corelib/ncbienv.hpp>
35 #include <corelib/ncbireg.hpp>
36 #include <corelib/ncbiargs.hpp>
37 #include <corelib/ncbistr.hpp>
38 
39 #include <db/bdb/bdb_expt.hpp>
40 #include <db/bdb/bdb_blobcache.hpp>
41 
42 
43 
45 
46 
47 
48 ///////////////////////////////////////////////////////////////////////
49 
50 
51 /// BDB cache verify application
52 ///
53 /// @internal
54 ///
56 {
57 public:
58  void Init(void);
59  int Run(void);
60 };
61 
63 {
64  // Setup command line arguments and parameters
65 
66  // Create command-line argument descriptions class
67  unique_ptr<CArgDescriptions> arg_desc(new CArgDescriptions);
68 
69  // Specify USAGE context
70  arg_desc->SetUsageContext(GetArguments().GetProgramBasename(),
71  "BDB cache verify");
72 
73  arg_desc->AddPositional("cache_path",
74  "BDB cache path",
76 
77  arg_desc->AddPositional("cache_name",
78  "BDB cache name.",
80 
81  arg_desc->AddOptionalKey("errfile",
82  "error_file",
83  "File to dump error messages",
85 
86  arg_desc->AddFlag("fr", "Force environment remove");
87 
88 
89  // Setup arg.descriptions for this application
90  SetupArgDescriptions(arg_desc.release());
91 }
92 
93 
94 
96 {
97  try
98  {
99  CArgs args = GetArgs();
100  const string& cache_path = args["cache_path"].AsString();
101  const string& cache_name = args["cache_name"].AsString();
102 
103  const char* err_file = 0;
104  if (args["errfile"]) {
105  err_file = args["errfile"].AsString().c_str();
106  }
107 
108  bool fr = args["fr"];
109 
110  CBDB_Cache cache;
111  cache.Verify(cache_path.c_str(), cache_name.c_str(), err_file, fr);
112 
113  }
114  catch (CBDB_ErrnoException& ex)
115  {
116  NcbiCerr << "Error: DBD errno exception:" << ex.what();
117  return 1;
118  }
119  catch (CBDB_LibException& ex)
120  {
121  NcbiCerr << "Error: DBD library exception:" << ex.what();
122  return 1;
123  }
124 
125  return 0;
126 }
127 
128 
129 int main(int argc, const char* argv[])
130 {
131  return CBDB_CacheVerifyApp().AppMain(argc, argv);
132 }
ICache interface implementation on top of Berkeley DB.
int main(int argc, const char *argv[])
USING_NCBI_SCOPE
Definition: bdb_cverify.cpp:44
Exception specifications for BDB library.
CArgDescriptions –.
Definition: ncbiargs.hpp:541
CArgs –.
Definition: ncbiargs.hpp:379
BDB cache verify application.
Definition: bdb_cverify.cpp:56
void Init(void)
Initialize the application.
Definition: bdb_cverify.cpp:62
int Run(void)
Run the application.
Definition: bdb_cverify.cpp:95
BDB cache implementation.
BDB errno exception class.
Definition: bdb_expt.hpp:84
BDB library exception.
Definition: bdb_expt.hpp:121
The NCBI C++ standard methods for dealing with std::string.
virtual const CArgs & GetArgs(void) const
Get parsed command line arguments.
Definition: ncbiapp.cpp:305
int AppMain(int argc, const char *const *argv, const char *const *envp=0, EAppDiagStream diag=eDS_Default, const char *conf=NcbiEmptyCStr, const string &name=NcbiEmptyString)
Main function (entry point) for the NCBI application.
Definition: ncbiapp.cpp:819
virtual void SetupArgDescriptions(CArgDescriptions *arg_desc)
Setup the command line argument descriptions.
Definition: ncbiapp.cpp:1195
const CNcbiArguments & GetArguments(void) const
Get the application's cached unprocessed command-line arguments.
@ eString
An arbitrary string.
Definition: ncbiargs.hpp:589
void Verify(const string &cache_path, const string &cache_name, const string &err_file=0, bool force_remove=false)
Run verification of the cache database.
#define NcbiCerr
Definition: ncbistre.hpp:544
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
Defines command line argument related classes.
Defines unified interface to application:
Process information in the NCBI Registry, including working with configuration files.
Modified on Sun May 05 05:15:33 2024 by modify_doxy.py rev. 669887