Disk ARchive 2.7.16
Full featured and portable backup and archiving tool
Loading...
Searching...
No Matches
i_entrepot_libcurl.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2024 Denis Corbin
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 2
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18//
19// to contact the author, see the AUTHOR file
20/*********************************************************************/
21
25
26#ifndef I_ENTREPOT_LIBCURL_HPP
27#define I_ENTREPOT_LIBCURL_HPP
28
29#include "../my_config.h"
30
31extern "C"
32{
33#if LIBCURL_AVAILABLE
34#if HAVE_CURL_CURL_H
35#include <curl/curl.h>
36#endif
37#endif
38}
39
40#include <string>
41#include <deque>
42#include "entrepot_libcurl.hpp"
43#include "secu_string.hpp"
44#include "mem_ui.hpp"
46
47namespace libdar
48{
49
52
54
55#if defined ( LIBCURL_AVAILABLE ) && defined ( LIBTHREADAR_AVAILABLE )
56
57 class entrepot_libcurl::i_entrepot_libcurl : public entrepot, public mem_ui
58 {
59 public:
60 i_entrepot_libcurl(const std::shared_ptr<user_interaction> & dialog,
61 mycurl_protocol proto,
62 const std::string & login,
63 const secu_string & password,
64 const std::string & host,
65 const std::string & port,
66 bool auth_from_file,
67 const std::string & sftp_pub_keyfile,
68 const std::string & sftp_prv_keyfile,
69 const std::string & sftp_known_hosts,
70 U_I waiting_time,
71 bool verbose
72 );
73 i_entrepot_libcurl(const i_entrepot_libcurl & ref) = default;
74 i_entrepot_libcurl(i_entrepot_libcurl && ref) = default;
75 i_entrepot_libcurl & operator = (const i_entrepot_libcurl & ref) = delete;
76 i_entrepot_libcurl & operator = (i_entrepot_libcurl && ref) noexcept = delete;
77 ~i_entrepot_libcurl() throw () {};
78
79
80 // inherited from class entrepot
81
84 virtual std::string get_url() const override { return base_URL + get_full_path().display_without_root(); };
85 virtual void read_dir_reset() const override;
86 virtual bool read_dir_next(std::string & filename) const override;
87 virtual entrepot *clone() const override { return new (std::nothrow) i_entrepot_libcurl(*this); };
88
89 protected:
90
91 // inherited from class entrepot
92
93 virtual fichier_global *inherited_open(const std::shared_ptr<user_interaction> & dialog,
94 const std::string & filename,
95 gf_mode mode,
96 bool force_permission,
97 U_I permission,
98 bool fail_if_exists,
99 bool erase) const override;
100
101 virtual void inherited_unlink(const std::string & filename) const override;
102 virtual void read_dir_flush() override;
103
104 private:
105 mycurl_protocol x_proto;
106 std::string base_URL;
107 mycurl_easyhandle_sharing easyh;
108 std::deque<std::string> current_dir;
109 std::string reading_dir_tmp;
110 U_I wait_delay;
111 bool verbosity;
112
113 std::string get_libcurl_URL() const;
114 void set_libcurl_authentication(user_interaction & dialog,
115 const std::string & location,
116 const std::string & login,
117 const secu_string & password,
118 bool auth_from_file,
119 const std::string & sftp_pub_keyfile,
120 const std::string & sftp_prv_keyfile,
121 const std::string & sftp_known_hosts
122 );
123 void detruit();
124
125 static std::string mycurl_protocol2string(mycurl_protocol proto);
126 static std::string build_url_from(mycurl_protocol proto, const std::string & host, const std::string & port);
127 static size_t get_ftp_listing_callback(void *buffer, size_t size, size_t nmemb, void *userp);
128 static size_t null_callback(void *buffer, size_t size, size_t nmemb, void *userp) { return size*nmemb; };
129 static bool mycurl_is_protocol_available(mycurl_protocol proto);
130
131 // needed to access the entrepot inherited protected methods
132 friend class entrepot_libcurl;
133 };
134
135#endif
137
138} // end of namespace
139
140#endif
defines the implementation for remote filesystem entrepot using libcurl
class mem_ui definition. This class is to be used as parent class to handle user_interaction object m...
include macro defined by the configure script and some specific additional ones
used to optimize network session establised by libcurl
libdar namespace encapsulate all libdar symbols
Definition archive.hpp:47
this file contains the definition of secu_string class, a std::string like class but allocated in sec...