clean up symbol exports

This commit is contained in:
Arvid Norberg 2015-01-01 20:25:39 +00:00
parent c2a05228fd
commit f77e12ac04
17 changed files with 128 additions and 102 deletions

View File

@ -106,6 +106,7 @@ nobase_include_HEADERS = \
session_settings.hpp \ session_settings.hpp \
session_status.hpp \ session_status.hpp \
settings_pack.hpp \ settings_pack.hpp \
sha1.hpp \
sha1_hash.hpp \ sha1_hash.hpp \
size_type.hpp \ size_type.hpp \
sliding_average.hpp \ sliding_average.hpp \

View File

@ -34,13 +34,15 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_CRC32C_HPP_INCLUDE #define TORRENT_CRC32C_HPP_INCLUDE
#include <boost/cstdint.hpp> #include <boost/cstdint.hpp>
#include "libtorrent/export.hpp"
namespace libtorrent namespace libtorrent
{ {
// this is the crc32c (Castagnoli) polynomial // this is the crc32c (Castagnoli) polynomial
boost::uint32_t crc32c_32(boost::uint32_t v); TORRENT_EXTRA_EXPORT boost::uint32_t crc32c_32(boost::uint32_t v);
boost::uint32_t crc32c(boost::uint64_t const* v, int num_words); TORRENT_EXTRA_EXPORT boost::uint32_t crc32c(boost::uint64_t const* v
, int num_words);
} }
#endif #endif

View File

@ -354,20 +354,7 @@ namespace libtorrent
namespace detail namespace detail
{ {
inline bool default_pred(std::string const&) { return true; }
inline bool ignore_subdir(std::string const& leaf)
{ return leaf == ".." || leaf == "."; }
inline void nop(int) {} inline void nop(int) {}
int get_file_attributes(std::string const& p);
std::string get_symlink_path(std::string const& p);
// internal
TORRENT_EXPORT void add_files_impl(file_storage& fs, std::string const& p
, std::string const& l, boost::function<bool(std::string)> pred
, boost::uint32_t flags);
} }
// Adds the file specified by ``path`` to the file_storage object. In case ``path`` // Adds the file specified by ``path`` to the file_storage object. In case ``path``
@ -387,15 +374,10 @@ namespace libtorrent
// //
// The ``flags`` argument should be the same as the flags passed to the `create_torrent`_ // The ``flags`` argument should be the same as the flags passed to the `create_torrent`_
// constructor. // constructor.
template <class Pred> void add_files(file_storage& fs, std::string const& file, Pred p, boost::uint32_t flags = 0) TORRENT_EXPORT void add_files(file_storage& fs, std::string const& file
{ , boost::function<bool(std::string)> p, boost::uint32_t flags = 0);
detail::add_files_impl(fs, parent_path(complete(file)), filename(file), p, flags); TORRENT_EXPORT void add_files(file_storage& fs, std::string const& file
} , boost::uint32_t flags = 0);
inline void add_files(file_storage& fs, std::string const& file, boost::uint32_t flags = 0)
{
detail::add_files_impl(fs, parent_path(complete(file)), filename(file)
, detail::default_pred, flags);
}
// This function will assume that the files added to the torrent file exists at path // This function will assume that the files added to the torrent file exists at path
// ``p``, read those files and hash the content and set the hashes in the ``create_torrent`` // ``p``, read those files and hash the content and set the hashes in the ``create_torrent``
@ -436,32 +418,17 @@ namespace libtorrent
// and pass in utf8 strings // and pass in utf8 strings
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
template <class Pred>
TORRENT_DEPRECATED_PREFIX TORRENT_DEPRECATED_PREFIX
void TORRENT_DEPRECATED add_files(file_storage& fs, std::wstring const& wfile, Pred p, boost::uint32_t flags = 0) TORRENT_EXPORT void add_files(file_storage& fs, std::wstring const& wfile
{ , boost::function<bool(std::string)> p, boost::uint32_t flags = 0) TORRENT_DEPRECATED;
std::string utf8;
wchar_utf8(wfile, utf8);
detail::add_files_impl(fs, parent_path(complete(utf8))
, filename(utf8), p, flags);
}
TORRENT_DEPRECATED_PREFIX TORRENT_DEPRECATED_PREFIX
inline void TORRENT_DEPRECATED add_files(file_storage& fs, std::wstring const& wfile, boost::uint32_t flags = 0) TORRENT_EXPORT void add_files(file_storage& fs, std::wstring const& wfile
{ , boost::uint32_t flags = 0) TORRENT_DEPRECATED;
std::string utf8;
wchar_utf8(wfile, utf8);
detail::add_files_impl(fs, parent_path(complete(utf8))
, filename(utf8), detail::default_pred, flags);
}
inline void set_piece_hashes(create_torrent& t, std::wstring const& p, boost::function<void(int)> f TORRENT_DEPRECATED_PREFIX
, error_code& ec) TORRENT_EXPORT void set_piece_hashes(create_torrent& t, std::wstring const& p
{ , boost::function<void(int)> f, error_code& ec) TORRENT_DEPRECATED;
std::string utf8;
wchar_utf8(p, utf8);
set_piece_hashes(t, utf8, f, ec);
}
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS
template <class Fun> template <class Fun>

View File

@ -85,5 +85,12 @@ POSSIBILITY OF SUCH DAMAGE.
# define TORRENT_EXTRA_EXPORT # define TORRENT_EXTRA_EXPORT
#endif #endif
// only export this type if deprecated functions are enabled
#ifdef TORRENT_NO_DEPRECATE
#define TORRENT_DEPRECATED_EXPORT
#else
#define TORRENT_DEPRECATED_EXPORT TORRENT_EXPORT
#endif
#endif #endif

View File

@ -150,16 +150,16 @@ namespace libtorrent
// internal used by create_torrent.hpp // internal used by create_torrent.hpp
TORRENT_EXPORT std::string parent_path(std::string const& f); TORRENT_EXTRA_EXPORT std::string parent_path(std::string const& f);
TORRENT_EXTRA_EXPORT bool has_parent_path(std::string const& f); TORRENT_EXTRA_EXPORT bool has_parent_path(std::string const& f);
TORRENT_EXTRA_EXPORT char const* filename_cstr(char const* f); TORRENT_EXTRA_EXPORT char const* filename_cstr(char const* f);
// internal used by create_torrent.hpp // internal used by create_torrent.hpp
TORRENT_EXPORT std::string filename(std::string const& f); TORRENT_EXTRA_EXPORT std::string filename(std::string const& f);
TORRENT_EXTRA_EXPORT std::string combine_path(std::string const& lhs TORRENT_EXTRA_EXPORT std::string combine_path(std::string const& lhs
, std::string const& rhs); , std::string const& rhs);
// internal used by create_torrent.hpp // internal used by create_torrent.hpp
TORRENT_EXPORT std::string complete(std::string const& f); TORRENT_EXTRA_EXPORT std::string complete(std::string const& f);
TORRENT_EXTRA_EXPORT bool is_complete(std::string const& f); TORRENT_EXTRA_EXPORT bool is_complete(std::string const& f);
TORRENT_EXTRA_EXPORT std::string current_working_directory(); TORRENT_EXTRA_EXPORT std::string current_working_directory();
#if TORRENT_USE_UNC_PATHS #if TORRENT_USE_UNC_PATHS

View File

@ -46,6 +46,9 @@ namespace libtorrent
{ {
struct file; struct file;
// TODO: 3 the file_entry should be deprecated and add_file() should be
// thought through a bit better
// information about a file in a file_storage // information about a file in a file_storage
struct TORRENT_EXPORT file_entry struct TORRENT_EXPORT file_entry
{ {
@ -104,13 +107,6 @@ namespace libtorrent
bool symlink_attribute:1; bool symlink_attribute:1;
}; };
// only export this type if deprecated functions are enabled
#ifdef TORRENT_NO_DEPRECATED
#define TORRENT_DEPRECATED_EXPORT
#else
#define TORRENT_DEPRECATED_EXPORT TORRENT_EXPORT
#endif
// internal // internal
struct TORRENT_DEPRECATED_EXPORT internal_file_entry struct TORRENT_DEPRECATED_EXPORT internal_file_entry
{ {
@ -236,7 +232,7 @@ namespace libtorrent
// hidden // hidden
file_storage(); file_storage();
// hidden // hidden
~file_storage() {} ~file_storage();
// returns true if the piece length has been initialized // returns true if the piece length has been initialized
// on the file_storage. This is typically taken as a proxy // on the file_storage. This is typically taken as a proxy

View File

@ -54,22 +54,7 @@ extern "C"
} }
#else #else
// from sha1.cpp #include "libtorrent/sha1.hpp"
namespace libtorrent
{
struct TORRENT_EXTRA_EXPORT sha_ctx
{
boost::uint32_t state[5];
boost::uint32_t count[2];
boost::uint8_t buffer[64];
};
TORRENT_EXTRA_EXPORT void SHA1_init(sha_ctx* context);
TORRENT_EXTRA_EXPORT void SHA1_update(sha_ctx* context, boost::uint8_t const* data, boost::uint32_t len);
TORRENT_EXTRA_EXPORT void SHA1_final(boost::uint8_t* digest, sha_ctx* context);
} // namespace libtorrent
#endif #endif
namespace libtorrent namespace libtorrent

View File

@ -0,0 +1,38 @@
/*
SHA-1 C++ conversion
original version:
SHA-1 in C
By Steve Reid <sreid@sea-to-sky.net>
100% Public Domain
changelog at the end of sha1.cpp
*/
#ifndef TORRENT_SHA1_HPP_INCLUDED
#define TORRENT_SHA1_HPP_INCLUDED
#include "libtorrent/config.hpp"
#include <boost/cstdint.hpp>
namespace libtorrent
{
struct TORRENT_EXTRA_EXPORT sha_ctx
{
boost::uint32_t state[5];
boost::uint32_t count[2];
boost::uint8_t buffer[64];
};
// we don't want these to clash with openssl's libcrypto
TORRENT_EXTRA_EXPORT void SHA1_init(sha_ctx* context);
TORRENT_EXTRA_EXPORT void SHA1_update(sha_ctx* context
, boost::uint8_t const* data
, boost::uint32_t len);
TORRENT_EXTRA_EXPORT void SHA1_final(boost::uint8_t* digest, sha_ctx* context);
}
#endif

View File

@ -559,7 +559,7 @@ namespace libtorrent
void file_progress(std::vector<boost::int64_t>& fp, int flags = 0); void file_progress(std::vector<boost::int64_t>& fp, int flags = 0);
#ifndef TORRENT_NO_DEPRECATED #ifndef TORRENT_NO_DEPRECATE
void use_interface(std::string net_interface); void use_interface(std::string net_interface);
#endif #endif

View File

@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_UTF8_HPP_INCLUDED #ifndef TORRENT_UTF8_HPP_INCLUDED
#define TORRENT_UTF8_HPP_INCLUDED #define TORRENT_UTF8_HPP_INCLUDED
#include "libtorrent/config.hpp" #include "libtorrent/export.hpp"
// on windows we need these functions for // on windows we need these functions for
// convert_to_native and convert_from_native // convert_to_native and convert_from_native
@ -66,9 +66,9 @@ namespace libtorrent
// string (``wide``). ``wchar_utf8`` converts a wide character string // string (``wide``). ``wchar_utf8`` converts a wide character string
// (``wide``) to a UTF-8 string (``utf8``). The return value is one of // (``wide``) to a UTF-8 string (``utf8``). The return value is one of
// the enumeration values from utf8_conv_result_t. // the enumeration values from utf8_conv_result_t.
TORRENT_EXPORT utf8_conv_result_t utf8_wchar( TORRENT_EXTRA_EXPORT utf8_conv_result_t utf8_wchar(
const std::string &utf8, std::wstring &wide); const std::string &utf8, std::wstring &wide);
TORRENT_EXPORT utf8_conv_result_t wchar_utf8( TORRENT_EXTRA_EXPORT utf8_conv_result_t wchar_utf8(
const std::wstring &wide, std::string &utf8); const std::wstring &wide, std::string &utf8);
} }
#endif // !BOOST_NO_STD_WSTRING #endif // !BOOST_NO_STD_WSTRING

View File

@ -55,6 +55,11 @@ namespace libtorrent
namespace detail namespace detail
{ {
inline bool default_pred(std::string const&) { return true; }
inline bool ignore_subdir(std::string const& leaf)
{ return leaf == ".." || leaf == "."; }
int get_file_attributes(std::string const& p) int get_file_attributes(std::string const& p)
{ {
#ifdef TORRENT_WINDOWS #ifdef TORRENT_WINDOWS
@ -153,6 +158,49 @@ namespace libtorrent
} }
} // detail namespace } // detail namespace
#if TORRENT_USE_WSTRING
#ifndef TORRENT_NO_DEPRECATE
void add_files(file_storage& fs, std::wstring const& wfile
, boost::function<bool(std::string)> p, boost::uint32_t flags)
{
std::string utf8;
wchar_utf8(wfile, utf8);
detail::add_files_impl(fs, parent_path(complete(utf8))
, filename(utf8), p, flags);
}
void add_files(file_storage& fs
, std::wstring const& wfile, boost::uint32_t flags)
{
std::string utf8;
wchar_utf8(wfile, utf8);
detail::add_files_impl(fs, parent_path(complete(utf8))
, filename(utf8), detail::default_pred, flags);
}
void set_piece_hashes(create_torrent& t, std::wstring const& p
, boost::function<void(int)> f, error_code& ec)
{
std::string utf8;
wchar_utf8(p, utf8);
set_piece_hashes(t, utf8, f, ec);
}
#endif
#endif
void add_files(file_storage& fs, std::string const& file
, boost::function<bool(std::string)> p, boost::uint32_t flags)
{
detail::add_files_impl(fs, parent_path(complete(file)), filename(file), p, flags);
}
void add_files(file_storage& fs, std::string const& file, boost::uint32_t flags)
{
detail::add_files_impl(fs, parent_path(complete(file)), filename(file)
, detail::default_pred, flags);
}
void on_hash(disk_io_job const* j, create_torrent* t void on_hash(disk_io_job const* j, create_torrent* t
, boost::shared_ptr<piece_manager> storage, disk_io_thread* iothread , boost::shared_ptr<piece_manager> storage, disk_io_thread* iothread
, int* piece_counter, int* completed_piece , int* piece_counter, int* completed_piece

View File

@ -47,6 +47,8 @@ namespace libtorrent
, m_num_files(0) , m_num_files(0)
{} {}
file_storage::~file_storage() {}
void file_storage::reserve(int num_files) void file_storage::reserve(int num_files)
{ {
m_files.reserve(num_files); m_files.reserve(num_files);

View File

@ -31,6 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "libtorrent/hasher.hpp" #include "libtorrent/hasher.hpp"
#include "libtorrent/sha1.hpp"
namespace libtorrent namespace libtorrent
{ {

View File

@ -34,12 +34,13 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/session_settings.hpp" #include "libtorrent/session_settings.hpp"
#include "libtorrent/socket_type.hpp" #include "libtorrent/socket_type.hpp"
#include "libtorrent/utp_socket_manager.hpp" #include "libtorrent/utp_socket_manager.hpp"
#include "libtorrent/instantiate_connection.hpp"
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <stdexcept> #include <stdexcept>
namespace libtorrent namespace libtorrent
{ {
TORRENT_EXPORT bool instantiate_connection(io_service& ios bool instantiate_connection(io_service& ios
, proxy_settings const& ps, socket_type& s , proxy_settings const& ps, socket_type& s
, void* ssl_context , void* ssl_context
, utp_socket_manager* sm , utp_socket_manager* sm

View File

@ -83,9 +83,6 @@ using libtorrent::aux::session_impl;
namespace libtorrent namespace libtorrent
{ {
TORRENT_EXPORT void TORRENT_LINK_TEST_NAME() {}
TORRENT_EXPORT void min_memory_usage(settings_pack& set) TORRENT_EXPORT void min_memory_usage(settings_pack& set)
{ {
// receive data directly into disk buffers // receive data directly into disk buffers

View File

@ -13,33 +13,14 @@ changelog at the end of the file.
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
// if you don't want boost #include "libtorrent/sha1.hpp"
// replace with
// #include <stdint.h>
// typedef uint32_t u32;
// typedef uint8_t u8;
#include <boost/cstdint.hpp>
typedef boost::uint32_t u32; typedef boost::uint32_t u32;
typedef boost::uint8_t u8; typedef boost::uint8_t u8;
#include "libtorrent/config.hpp"
namespace libtorrent namespace libtorrent
{ {
struct TORRENT_EXPORT sha_ctx
{
u32 state[5];
u32 count[2];
u8 buffer[64];
};
// we don't want these to clash with openssl's libcrypto
TORRENT_EXPORT void SHA1_init(sha_ctx* context);
TORRENT_EXPORT void SHA1_update(sha_ctx* context, u8 const* data, u32 len);
TORRENT_EXPORT void SHA1_final(u8* digest, sha_ctx* context);
namespace namespace
{ {
union CHAR64LONG16 union CHAR64LONG16

View File

@ -2679,7 +2679,7 @@ namespace libtorrent
m_num_checked_pieces = 0; m_num_checked_pieces = 0;
} }
#ifndef TORRENT_NO_DEPRECATED #ifndef TORRENT_NO_DEPRECATE
void torrent::use_interface(std::string net_interfaces) void torrent::use_interface(std::string net_interfaces)
{ {
settings_pack* p = new settings_pack; settings_pack* p = new settings_pack;