LCOV - code coverage report
Current view: top level - src/esys/repo/libssh2 - sshimpl.h (source / functions) Hit Total Coverage
Test: esysrepo_coverage.info Lines: 7 7 100.0 %
Date: 2026-08-01 10:43:40 Functions: 0 0 -

          Line data    Source code
       1             : /*!
       2             :  * \file esys/repo/libssh2/sshimpl.h
       3             :  * \brief
       4             :  *
       5             :  * \cond
       6             :  * __legal_b__
       7             :  *
       8             :  * Copyright (c) 2021 Michel Gillet
       9             :  * Distributed under the MIT License.
      10             :  * (See accompanying file LICENSE.txt or
      11             :  * copy at https://opensource.org/licenses/MIT)
      12             :  *
      13             :  * __legal_e__
      14             :  * \endcond
      15             :  *
      16             :  */
      17             : 
      18             : #pragma once
      19             : 
      20             : #include "esys/repo/esysrepo_defs.h"
      21             : 
      22             : #include <libssh2.h>
      23             : 
      24             : #include <memory>
      25             : #include <mutex>
      26             : 
      27             : namespace esys
      28             : {
      29             : 
      30             : namespace repo
      31             : {
      32             : 
      33             : namespace libssh2
      34             : {
      35             : 
      36             : class SSH;
      37             : 
      38             : /*! \class SSHImpl esys/repo/libssh2/sshimpl.h "esys/repo/libssh2/sshimpl.h"
      39             :  * \brief
      40             :  */
      41             : class ESYSREPO_API SSHImpl
      42             : {
      43             : public:
      44             :     //! Default constructor
      45             :     SSHImpl(SSH *self);
      46             : 
      47             :     //! Destructor
      48             :     virtual ~SSHImpl();
      49             : 
      50             :     bool is_agent_present();
      51             : 
      52             : private:
      53             :     //!< \cond DOXY_IMPL
      54             : 
      55             :     class InitRelease
      56             :     {
      57             :     public:
      58           1 :         InitRelease()
      59           1 :         {
      60           1 :             m_result = libssh2_init(0);
      61           1 :             m_init = true;
      62             :         }
      63             : 
      64             :         int get_result()
      65             :         {
      66             :             return m_result;
      67             :         }
      68             : 
      69           1 :         ~InitRelease()
      70             :         {
      71           1 :             if (m_init) libssh2_exit();
      72           1 :         }
      73             : 
      74             :     private:
      75             :         bool m_init = false;
      76             :         int m_result = 0;
      77             :     };
      78             : 
      79             :     SSH *self();
      80             : 
      81             :     static std::unique_ptr<InitRelease> s_init_release;
      82             : 
      83             :     SSH *m_self = nullptr;
      84             :     std::mutex m_mutex;
      85             :     //!< \endcond
      86             : };
      87             : 
      88             : } // namespace libssh2
      89             : 
      90             : } // namespace repo
      91             : 
      92             : } // namespace esys

Generated by: LCOV version 1.14