mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 20:35:36 +00:00
There're places where manual intervention is still required as uncrustify is not ideal (unfortunately), but at least one may rely on it to do the right thing most of the time (e.g. when sending in a patch). The style itself is quite different from what we had before but making it uniform across all the codebase is the key. I also hope that it'll make the code more readable (YMMV) and less sensitive to further changes.
47 lines
1.6 KiB
C
47 lines
1.6 KiB
C
/*
|
|
* This file Copyright (C) 2008-2014 Mnemosyne LLC
|
|
*
|
|
* It may be used under the GNU GPL versions 2 or 3
|
|
* or any future license endorsed by Mnemosyne LLC.
|
|
*
|
|
*/
|
|
|
|
#ifndef __LIBTRANSMISSION_VARIANT_MODULE__
|
|
#error only libtransmission/variant-*.c should #include this header.
|
|
#endif
|
|
|
|
#pragma once
|
|
|
|
typedef void (* VariantWalkFunc)(const tr_variant* val, void* user_data);
|
|
|
|
struct VariantWalkFuncs
|
|
{
|
|
VariantWalkFunc intFunc;
|
|
VariantWalkFunc boolFunc;
|
|
VariantWalkFunc realFunc;
|
|
VariantWalkFunc stringFunc;
|
|
VariantWalkFunc dictBeginFunc;
|
|
VariantWalkFunc listBeginFunc;
|
|
VariantWalkFunc containerEndFunc;
|
|
};
|
|
|
|
void tr_variantWalk(const tr_variant* top, const struct VariantWalkFuncs* walkFuncs, void* user_data, bool sort_dicts);
|
|
|
|
void tr_variantToBufJson(const tr_variant* top, struct evbuffer* buf, bool lean);
|
|
|
|
void tr_variantToBufBenc(const tr_variant* top, struct evbuffer* buf);
|
|
|
|
void tr_variantInit(tr_variant* v, char type);
|
|
|
|
/* source - such as a filename. Only when logging an error */
|
|
int tr_jsonParse(const char* source, const void* vbuf, size_t len, tr_variant* setme_benc, const char** setme_end);
|
|
|
|
/** @brief Private function that's exposed here only for unit tests */
|
|
int tr_bencParseInt(const uint8_t* buf, const uint8_t* bufend, const uint8_t** setme_end, int64_t* setme_val);
|
|
|
|
/** @brief Private function that's exposed here only for unit tests */
|
|
int tr_bencParseStr(const uint8_t* buf, const uint8_t* bufend, const uint8_t** setme_end, const uint8_t** setme_str,
|
|
size_t* setme_strlen);
|
|
|
|
int tr_variantParseBenc(const void* buf, const void* end, tr_variant* top, const char** setme_end);
|