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

Go to the SVN repository for this file.

1 /* $Id: dbapi_driver_check.cpp 100482 2023-08-04 20:28:51Z ucko $
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  * Author: Vladimir Ivanov
27  *
28  * Check DBAPI driver DLL existence.
29  *
30  * Returns 0 exit code if the DBAPI driver DLL with a name specified in
31  * a command line exist. Otherwise returns 1.
32  *
33  */
34 
35 #include <ncbi_pch.hpp>
36 #include <corelib/ncbiexpt.hpp>
37 #include <corelib/ncbi_system.hpp>
41 #include <common/test_assert.h> /* This header must go last */
42 
44 
45 
46 int main(int argc, char* argv[])
47 {
48  // Disable system popup boxes messages
50 
51  // Avoid underlinkage under Apple Developer Tools 15
52  CEndpointKey fake_endpoint("1.2.3.4:5", 0);
54 
55  // Self-check, return magic error code
56  if (argc != 2) {
57  return 99;
58  }
59  string driver_name = argv[1];
60 
63 
64  try {
65  C_DriverMgr drv_mgr;
66  string err_msg;
67  unique_ptr<I_DriverContext> my_context( drv_mgr.GetDriverContext(driver_name,
68  &err_msg));
69  if (!my_context) {
70  return 1;
71  }
72 
73  }
74  catch( const CPluginManagerException& ) {
75  return 5;
76  }
77  catch( const CDB_Exception& ) {
78  return 4;
79  }
80  catch( const CException& ) {
81  return 3;
82  }
83  catch ( const exception& ) {
84  return 2;
85  }
86  catch ( ... ) {
87  return 1;
88  }
89  return 0;
90 }
91 
92 
CDB_Exception –.
Definition: exception.hpp:118
Lightweight representation of just a host and a port.
CPluginManagerException –.
static SSystemFastMutex & GetMutex(void)
int main(int argc, char *argv[])
USING_NCBI_SCOPE
I_DriverContext * GetDriverContext(const string &driver_name, string *err_msg=0, const map< string, string > *attr=0)
Definition: driver_mgr.cpp:308
static bool EnableBackgroundReporting(bool enable)
Enable background reporting.
Definition: ncbiexpt.cpp:496
static void EnableGlobally(bool enable=true)
Enable (or disable, if called with enable = false) loading plugins from DLLs in general.
void SuppressSystemMessageBox(TSuppressSystemMessageBox mode=fSuppress_Default)
Suppress popup messages on execution errors.
Defines NCBI C++ exception handling.
Modified on Wed Sep 04 14:58:45 2024 by modify_doxy.py rev. 669887