2023-02-11 20:49:42 +00:00
|
|
|
// This file Copyright © 2008-2023 Mnemosyne LLC.
|
2022-02-07 16:25:02 +00:00
|
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only),
|
2022-01-20 18:27:56 +00:00
|
|
|
// or any future license endorsed by Mnemosyne LLC.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2012-12-14 04:34:42 +00:00
|
|
|
|
2021-12-15 21:25:42 +00:00
|
|
|
#include <array>
|
2021-10-17 20:17:18 +00:00
|
|
|
#include <cctype> /* isdigit() */
|
2021-09-29 00:09:01 +00:00
|
|
|
#include <deque>
|
2021-10-15 13:28:47 +00:00
|
|
|
#include <string_view>
|
2021-10-15 18:13:33 +00:00
|
|
|
#include <optional>
|
2012-12-14 04:34:42 +00:00
|
|
|
|
2022-04-03 18:23:00 +00:00
|
|
|
#include <fmt/compile.h>
|
|
|
|
#include <fmt/format.h>
|
|
|
|
|
2020-08-11 18:11:55 +00:00
|
|
|
#define LIBTRANSMISSION_VARIANT_MODULE
|
2017-11-14 20:21:28 +00:00
|
|
|
|
2012-12-14 04:34:42 +00:00
|
|
|
#include "transmission.h"
|
2021-11-18 05:37:35 +00:00
|
|
|
|
2022-01-24 06:30:00 +00:00
|
|
|
#include "benc.h"
|
2022-01-13 02:13:58 +00:00
|
|
|
#include "quark.h"
|
2022-10-19 16:42:08 +00:00
|
|
|
#include "tr-assert.h"
|
|
|
|
#include "tr-buffer.h"
|
2022-04-03 18:23:00 +00:00
|
|
|
#include "utils.h"
|
2012-12-14 04:34:42 +00:00
|
|
|
#include "variant-common.h"
|
2021-11-18 05:37:35 +00:00
|
|
|
#include "variant.h"
|
2012-12-14 04:34:42 +00:00
|
|
|
|
2021-11-17 03:29:30 +00:00
|
|
|
using namespace std::literals;
|
|
|
|
|
2021-12-29 08:28:12 +00:00
|
|
|
auto constexpr MaxBencStrLength = size_t{ 128 * 1024 * 1024 }; // arbitrary
|
2017-05-16 18:37:00 +00:00
|
|
|
|
2023-01-07 14:27:54 +00:00
|
|
|
// ---
|
2012-12-14 04:34:42 +00:00
|
|
|
|
2022-01-24 06:30:00 +00:00
|
|
|
namespace transmission::benc::impl
|
|
|
|
{
|
|
|
|
|
2012-12-14 04:34:42 +00:00
|
|
|
/**
|
|
|
|
* The initial i and trailing e are beginning and ending delimiters.
|
|
|
|
* You can have negative numbers such as i-3e. You cannot prefix the
|
|
|
|
* number with a zero such as i04e. However, i0e is valid.
|
|
|
|
* Example: i3e represents the integer "3"
|
2021-11-17 03:29:30 +00:00
|
|
|
*
|
|
|
|
* The maximum number of bit of this integer is unspecified,
|
2012-12-14 04:34:42 +00:00
|
|
|
* but to handle it as a signed 64bit integer is mandatory to handle
|
|
|
|
* "large files" aka .torrent for more that 4Gbyte
|
|
|
|
*/
|
2022-01-24 06:30:00 +00:00
|
|
|
std::optional<int64_t> ParseInt(std::string_view* benc)
|
2012-12-14 04:34:42 +00:00
|
|
|
{
|
2021-12-29 08:28:12 +00:00
|
|
|
auto constexpr Prefix = "i"sv;
|
|
|
|
auto constexpr Suffix = "e"sv;
|
|
|
|
|
2021-11-17 03:29:30 +00:00
|
|
|
// find the beginning delimiter
|
|
|
|
auto walk = *benc;
|
2021-12-29 08:28:12 +00:00
|
|
|
if (std::size(walk) < 3 || !tr_strvStartsWith(walk, Prefix))
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2021-11-17 03:29:30 +00:00
|
|
|
return {};
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2012-12-14 16:04:44 +00:00
|
|
|
|
2021-11-17 03:29:30 +00:00
|
|
|
// find the ending delimiter
|
2021-12-29 08:28:12 +00:00
|
|
|
walk.remove_prefix(std::size(Prefix));
|
2022-02-08 05:44:31 +00:00
|
|
|
if (auto const pos = walk.find(Suffix); pos == std::string_view::npos)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2021-11-17 03:29:30 +00:00
|
|
|
return {};
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2012-12-14 16:04:44 +00:00
|
|
|
|
2021-11-17 03:29:30 +00:00
|
|
|
// leading zeroes are not allowed
|
2022-08-05 19:16:25 +00:00
|
|
|
if ((walk[0] == '0' && (isdigit(static_cast<unsigned char>(walk[1])) != 0)) ||
|
|
|
|
(walk[0] == '-' && walk[1] == '0' && (isdigit(static_cast<unsigned char>(walk[2])) != 0)))
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2021-11-17 03:29:30 +00:00
|
|
|
return {};
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 08:28:12 +00:00
|
|
|
// parse the string and make sure the next char is `Suffix`
|
2022-09-02 06:04:09 +00:00
|
|
|
auto const value = tr_parseNum<int64_t>(walk, &walk);
|
2021-12-29 08:28:12 +00:00
|
|
|
if (!value || !tr_strvStartsWith(walk, Suffix))
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2021-11-17 03:29:30 +00:00
|
|
|
return {};
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 08:28:12 +00:00
|
|
|
walk.remove_prefix(std::size(Suffix));
|
2021-11-17 03:29:30 +00:00
|
|
|
*benc = walk;
|
2021-12-29 08:28:12 +00:00
|
|
|
return *value;
|
2012-12-14 04:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Byte strings are encoded as follows:
|
|
|
|
* <string length encoded in base ten ASCII>:<string data>
|
|
|
|
* Note that there is no constant beginning delimiter, and no ending delimiter.
|
|
|
|
* Example: 4:spam represents the string "spam"
|
|
|
|
*/
|
2022-01-24 06:30:00 +00:00
|
|
|
std::optional<std::string_view> ParseString(std::string_view* benc)
|
2012-12-14 04:34:42 +00:00
|
|
|
{
|
2021-11-17 03:29:30 +00:00
|
|
|
// find the ':' delimiter
|
|
|
|
auto const colon_pos = benc->find(':');
|
2021-12-17 05:47:51 +00:00
|
|
|
if (colon_pos == std::string_view::npos)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2021-11-17 03:29:30 +00:00
|
|
|
return {};
|
|
|
|
}
|
2012-12-14 04:34:42 +00:00
|
|
|
|
2021-11-17 03:29:30 +00:00
|
|
|
// get the string length
|
2021-12-29 08:28:12 +00:00
|
|
|
auto svtmp = benc->substr(0, colon_pos);
|
2022-08-05 16:36:01 +00:00
|
|
|
if (!std::all_of(std::begin(svtmp), std::end(svtmp), [](auto ch) { return isdigit(static_cast<unsigned char>(ch)) != 0; }))
|
2022-04-06 21:39:39 +00:00
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2022-09-02 06:04:09 +00:00
|
|
|
auto const len = tr_parseNum<size_t>(svtmp, &svtmp);
|
2021-12-29 08:28:12 +00:00
|
|
|
if (!len || *len >= MaxBencStrLength)
|
2021-11-17 03:29:30 +00:00
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
2012-12-14 04:34:42 +00:00
|
|
|
|
2021-11-17 03:29:30 +00:00
|
|
|
// do we have `len` bytes of string data?
|
2021-12-29 08:28:12 +00:00
|
|
|
svtmp = benc->substr(colon_pos + 1);
|
|
|
|
if (std::size(svtmp) < len)
|
2021-11-17 03:29:30 +00:00
|
|
|
{
|
|
|
|
return {};
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2012-12-14 04:34:42 +00:00
|
|
|
|
2021-12-29 08:28:12 +00:00
|
|
|
auto const string = svtmp.substr(0, *len);
|
|
|
|
*benc = svtmp.substr(*len);
|
2021-11-17 03:29:30 +00:00
|
|
|
return string;
|
2012-12-14 04:34:42 +00:00
|
|
|
}
|
|
|
|
|
2022-01-24 06:30:00 +00:00
|
|
|
} // namespace transmission::benc::impl
|
2012-12-14 04:34:42 +00:00
|
|
|
|
2023-01-07 14:27:54 +00:00
|
|
|
// ---
|
2022-01-24 06:30:00 +00:00
|
|
|
|
2023-01-05 04:16:22 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
namespace parse_helpers
|
|
|
|
{
|
2022-01-24 06:30:00 +00:00
|
|
|
struct MyHandler : public transmission::benc::Handler
|
|
|
|
{
|
|
|
|
tr_variant* const top_;
|
|
|
|
int const parse_opts_;
|
|
|
|
std::deque<tr_variant*> stack_;
|
|
|
|
std::optional<tr_quark> key_;
|
|
|
|
|
|
|
|
MyHandler(tr_variant* top, int parse_opts)
|
|
|
|
: top_{ top }
|
|
|
|
, parse_opts_{ parse_opts }
|
2012-12-14 04:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-08-03 17:03:28 +00:00
|
|
|
MyHandler(MyHandler&&) = delete;
|
|
|
|
MyHandler(MyHandler const&) = delete;
|
|
|
|
MyHandler& operator=(MyHandler&&) = delete;
|
|
|
|
MyHandler& operator=(MyHandler const&) = delete;
|
|
|
|
|
2022-01-25 01:05:24 +00:00
|
|
|
~MyHandler() override = default;
|
2022-01-24 19:07:55 +00:00
|
|
|
|
2022-01-28 22:46:14 +00:00
|
|
|
bool Int64(int64_t value, Context const& /*context*/) final
|
2022-01-24 06:30:00 +00:00
|
|
|
{
|
2022-04-06 20:26:13 +00:00
|
|
|
auto* const variant = get_node();
|
|
|
|
if (variant == nullptr)
|
2012-12-24 22:38:41 +00:00
|
|
|
{
|
2022-04-06 20:26:13 +00:00
|
|
|
return false;
|
2012-12-24 22:38:41 +00:00
|
|
|
}
|
2022-01-24 06:30:00 +00:00
|
|
|
|
2022-04-06 20:26:13 +00:00
|
|
|
tr_variantInitInt(variant, value);
|
2022-01-24 06:30:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-01-28 22:46:14 +00:00
|
|
|
bool String(std::string_view sv, Context const& /*context*/) final
|
2022-01-24 06:30:00 +00:00
|
|
|
{
|
2022-04-06 20:26:13 +00:00
|
|
|
auto* const variant = get_node();
|
|
|
|
if (variant == nullptr)
|
2012-12-24 22:38:41 +00:00
|
|
|
{
|
2022-04-06 20:26:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((parse_opts_ & TR_VARIANT_PARSE_INPLACE) != 0)
|
|
|
|
{
|
|
|
|
tr_variantInitStrView(variant, sv);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tr_variantInitStr(variant, sv);
|
2012-12-24 22:38:41 +00:00
|
|
|
}
|
2022-01-24 06:30:00 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-01-28 22:46:14 +00:00
|
|
|
bool StartDict(Context const& /*context*/) final
|
2022-01-24 06:30:00 +00:00
|
|
|
{
|
2022-04-06 20:26:13 +00:00
|
|
|
auto* const variant = get_node();
|
|
|
|
if (variant == nullptr)
|
2012-12-24 22:38:41 +00:00
|
|
|
{
|
2022-04-06 20:26:13 +00:00
|
|
|
return false;
|
2012-12-24 22:38:41 +00:00
|
|
|
}
|
2022-01-24 06:30:00 +00:00
|
|
|
|
2022-04-06 20:26:13 +00:00
|
|
|
tr_variantInitDict(variant, 0);
|
|
|
|
stack_.push_back(variant);
|
2022-01-24 06:30:00 +00:00
|
|
|
return true;
|
2012-12-24 22:38:41 +00:00
|
|
|
}
|
2012-12-14 04:34:42 +00:00
|
|
|
|
2022-01-28 22:46:14 +00:00
|
|
|
bool Key(std::string_view sv, Context const& /*context*/) final
|
2022-01-24 06:30:00 +00:00
|
|
|
{
|
|
|
|
key_ = tr_quark_new(sv);
|
2012-12-14 04:34:42 +00:00
|
|
|
|
2022-01-24 06:30:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
2021-11-18 05:37:35 +00:00
|
|
|
|
2022-01-28 22:46:14 +00:00
|
|
|
bool EndDict(Context const& /*context*/) final
|
2022-01-24 06:30:00 +00:00
|
|
|
{
|
2022-04-06 20:26:13 +00:00
|
|
|
if (std::empty(stack_))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-12-14 04:34:42 +00:00
|
|
|
|
2022-04-06 20:26:13 +00:00
|
|
|
stack_.pop_back();
|
2022-01-24 06:30:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-12-14 04:34:42 +00:00
|
|
|
|
2022-01-28 22:46:14 +00:00
|
|
|
bool StartArray(Context const& /*context*/) final
|
2012-12-14 04:34:42 +00:00
|
|
|
{
|
2022-04-06 20:26:13 +00:00
|
|
|
auto* const variant = get_node();
|
|
|
|
if (variant == nullptr)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2022-04-06 20:26:13 +00:00
|
|
|
return false;
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2012-12-24 22:38:41 +00:00
|
|
|
|
2022-04-06 20:26:13 +00:00
|
|
|
tr_variantInitList(variant, 0);
|
|
|
|
stack_.push_back(variant);
|
2022-01-24 06:30:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-12-14 04:34:42 +00:00
|
|
|
|
2022-01-28 22:46:14 +00:00
|
|
|
bool EndArray(Context const& /*context*/) final
|
2022-01-24 06:30:00 +00:00
|
|
|
{
|
2022-04-06 20:26:13 +00:00
|
|
|
if (std::empty(stack_))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-12-14 04:34:42 +00:00
|
|
|
|
2022-04-06 20:26:13 +00:00
|
|
|
stack_.pop_back();
|
2022-01-24 06:30:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
2021-11-28 01:58:35 +00:00
|
|
|
|
2022-01-24 06:30:00 +00:00
|
|
|
private:
|
|
|
|
tr_variant* get_node()
|
|
|
|
{
|
|
|
|
tr_variant* node = nullptr;
|
2021-11-17 03:29:30 +00:00
|
|
|
|
2022-01-24 06:30:00 +00:00
|
|
|
if (std::empty(stack_))
|
|
|
|
{
|
|
|
|
node = top_;
|
|
|
|
}
|
2022-04-06 20:26:13 +00:00
|
|
|
else if (auto* parent = stack_.back(); tr_variantIsList(parent))
|
|
|
|
{
|
|
|
|
node = tr_variantListAdd(parent);
|
|
|
|
}
|
|
|
|
else if (key_ && tr_variantIsDict(parent))
|
2022-01-24 06:30:00 +00:00
|
|
|
{
|
2022-04-06 20:26:13 +00:00
|
|
|
node = tr_variantDictAdd(parent, *key_);
|
|
|
|
key_.reset();
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2012-12-14 04:34:42 +00:00
|
|
|
|
2022-01-24 06:30:00 +00:00
|
|
|
return node;
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2022-01-24 06:30:00 +00:00
|
|
|
};
|
2023-01-05 04:16:22 +00:00
|
|
|
} // namespace parse_helpers
|
|
|
|
} // namespace
|
2012-12-14 04:34:42 +00:00
|
|
|
|
2022-01-24 06:30:00 +00:00
|
|
|
bool tr_variantParseBenc(tr_variant& top, int parse_opts, std::string_view benc, char const** setme_end, tr_error** error)
|
|
|
|
{
|
2023-01-05 04:16:22 +00:00
|
|
|
using namespace parse_helpers;
|
2022-01-24 06:30:00 +00:00
|
|
|
using Stack = transmission::benc::ParserStack<512>;
|
2023-01-05 04:16:22 +00:00
|
|
|
|
2022-01-24 06:30:00 +00:00
|
|
|
auto stack = Stack{};
|
|
|
|
auto handler = MyHandler{ &top, parse_opts };
|
2022-04-06 21:39:39 +00:00
|
|
|
return transmission::benc::parse(benc, stack, handler, setme_end, error) && std::empty(stack);
|
2012-12-14 04:34:42 +00:00
|
|
|
}
|
|
|
|
|
2023-01-07 14:27:54 +00:00
|
|
|
// ---
|
2012-12-14 04:34:42 +00:00
|
|
|
|
2023-01-05 04:16:22 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
namespace to_string_helpers
|
|
|
|
{
|
2022-10-19 16:42:08 +00:00
|
|
|
using Buffer = libtransmission::Buffer;
|
|
|
|
|
2023-01-05 04:16:22 +00:00
|
|
|
void saveIntFunc(tr_variant const* val, void* vout)
|
2012-12-14 04:34:42 +00:00
|
|
|
{
|
2022-04-03 18:23:00 +00:00
|
|
|
auto buf = std::array<char, 64>{};
|
2022-11-28 15:45:39 +00:00
|
|
|
auto const* const out = fmt::format_to(std::data(buf), FMT_COMPILE("i{:d}e"), val->val.i);
|
2022-10-19 16:42:08 +00:00
|
|
|
static_cast<Buffer*>(vout)->add(std::data(buf), static_cast<size_t>(out - std::data(buf)));
|
2012-12-14 04:34:42 +00:00
|
|
|
}
|
|
|
|
|
2023-01-05 04:16:22 +00:00
|
|
|
void saveBoolFunc(tr_variant const* val, void* vout)
|
2012-12-14 04:34:42 +00:00
|
|
|
{
|
2022-10-19 16:42:08 +00:00
|
|
|
static_cast<Buffer*>(vout)->add(val->val.b ? "i1e"sv : "i0e"sv);
|
2012-12-14 04:34:42 +00:00
|
|
|
}
|
|
|
|
|
2023-01-05 04:16:22 +00:00
|
|
|
void saveStringImpl(Buffer* tgt, std::string_view sv)
|
2012-12-14 04:34:42 +00:00
|
|
|
{
|
2022-04-03 18:23:00 +00:00
|
|
|
// `${sv.size()}:${sv}`
|
|
|
|
auto prefix = std::array<char, 32>{};
|
2022-11-28 15:45:39 +00:00
|
|
|
auto const* const out = fmt::format_to(std::data(prefix), FMT_COMPILE("{:d}:"), std::size(sv));
|
2022-10-19 16:42:08 +00:00
|
|
|
tgt->add(std::data(prefix), out - std::data(prefix));
|
|
|
|
tgt->add(sv);
|
2012-12-14 04:34:42 +00:00
|
|
|
}
|
|
|
|
|
2023-01-05 04:16:22 +00:00
|
|
|
void saveStringFunc(tr_variant const* v, void* vout)
|
2012-12-14 04:34:42 +00:00
|
|
|
{
|
2021-11-05 06:29:19 +00:00
|
|
|
auto sv = std::string_view{};
|
|
|
|
(void)!tr_variantGetStrView(v, &sv);
|
2022-10-19 16:42:08 +00:00
|
|
|
saveStringImpl(static_cast<Buffer*>(vout), sv);
|
2022-04-03 18:23:00 +00:00
|
|
|
}
|
2019-02-18 22:38:24 +00:00
|
|
|
|
2023-01-05 04:16:22 +00:00
|
|
|
void saveRealFunc(tr_variant const* val, void* vout)
|
2022-04-03 18:23:00 +00:00
|
|
|
{
|
|
|
|
// the benc spec doesn't handle floats; save it as a string.
|
|
|
|
|
|
|
|
auto buf = std::array<char, 64>{};
|
2022-11-28 15:45:39 +00:00
|
|
|
auto const* const out = fmt::format_to(std::data(buf), FMT_COMPILE("{:f}"), val->val.d);
|
2022-10-19 16:42:08 +00:00
|
|
|
saveStringImpl(static_cast<Buffer*>(vout), { std::data(buf), static_cast<size_t>(out - std::data(buf)) });
|
2012-12-14 04:34:42 +00:00
|
|
|
}
|
|
|
|
|
2023-01-05 04:16:22 +00:00
|
|
|
void saveDictBeginFunc(tr_variant const* /*val*/, void* vbuf)
|
2012-12-14 04:34:42 +00:00
|
|
|
{
|
2022-10-19 16:42:08 +00:00
|
|
|
static_cast<Buffer*>(vbuf)->push_back('d');
|
2012-12-14 04:34:42 +00:00
|
|
|
}
|
|
|
|
|
2023-01-05 04:16:22 +00:00
|
|
|
void saveListBeginFunc(tr_variant const* /*val*/, void* vbuf)
|
2012-12-14 04:34:42 +00:00
|
|
|
{
|
2022-10-19 16:42:08 +00:00
|
|
|
static_cast<Buffer*>(vbuf)->push_back('l');
|
2012-12-14 04:34:42 +00:00
|
|
|
}
|
|
|
|
|
2023-01-05 04:16:22 +00:00
|
|
|
void saveContainerEndFunc(tr_variant const* /*val*/, void* vbuf)
|
2012-12-14 04:34:42 +00:00
|
|
|
{
|
2022-10-19 16:42:08 +00:00
|
|
|
static_cast<Buffer*>(vbuf)->push_back('e');
|
2012-12-14 04:34:42 +00:00
|
|
|
}
|
|
|
|
|
2023-01-05 04:16:22 +00:00
|
|
|
struct VariantWalkFuncs const walk_funcs = {
|
2021-08-15 09:41:48 +00:00
|
|
|
saveIntFunc, //
|
|
|
|
saveBoolFunc, //
|
|
|
|
saveRealFunc, //
|
|
|
|
saveStringFunc, //
|
|
|
|
saveDictBeginFunc, //
|
|
|
|
saveListBeginFunc, //
|
|
|
|
saveContainerEndFunc, //
|
2017-04-19 12:04:45 +00:00
|
|
|
};
|
|
|
|
|
2023-01-05 04:16:22 +00:00
|
|
|
} // namespace to_string_helpers
|
|
|
|
} // namespace
|
|
|
|
|
2022-10-19 16:42:08 +00:00
|
|
|
std::string tr_variantToStrBenc(tr_variant const* top)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2023-01-05 04:16:22 +00:00
|
|
|
using namespace to_string_helpers;
|
|
|
|
|
2022-10-19 16:42:08 +00:00
|
|
|
auto buf = libtransmission::Buffer{};
|
|
|
|
tr_variantWalk(top, &walk_funcs, &buf, true);
|
2023-01-28 02:12:09 +00:00
|
|
|
return buf.to_string();
|
2012-12-14 04:34:42 +00:00
|
|
|
}
|