mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-08 08:58:00 +00:00
Add BinarySource_REWIND_TO.
A partial cherry-pick of commit 32d61d7c48
omitting the parts that aren't needed on this branch.
This commit is contained in:
parent
a56b79b598
commit
d51b3d7eb6
11
marshal.c
11
marshal.c
@ -235,6 +235,17 @@ ptrlen BinarySource_get_pstring(BinarySource *src)
|
||||
return make_ptrlen(consume(len), len);
|
||||
}
|
||||
|
||||
void BinarySource_REWIND_TO__(BinarySource *src, size_t pos)
|
||||
{
|
||||
if (pos <= src->len) {
|
||||
src->pos = pos;
|
||||
src->err = BSE_NO_ERROR; /* clear any existing error */
|
||||
} else {
|
||||
src->pos = src->len;
|
||||
src->err = BSE_OUT_OF_DATA; /* new error if we rewind out of range */
|
||||
}
|
||||
}
|
||||
|
||||
static void stdio_sink_write(BinarySink *bs, const void *data, size_t len)
|
||||
{
|
||||
stdio_sink *sink = BinarySink_DOWNCAST(bs, stdio_sink);
|
||||
|
@ -255,6 +255,10 @@ static inline void BinarySource_INIT__(BinarySource *src, ptrlen data)
|
||||
(object)->binarysource_)
|
||||
#define BinarySource_COPIED(obj) \
|
||||
((obj)->binarysource_->binarysource_ = (obj)->binarysource_)
|
||||
#define BinarySource_REWIND_TO(src, pos) \
|
||||
BinarySource_REWIND_TO__((src)->binarysource_, pos)
|
||||
#define BinarySource_REWIND(src) \
|
||||
BinarySource_REWIND_TO__((src)->binarysource_, 0)
|
||||
|
||||
#define get_data(src, len) \
|
||||
BinarySource_get_data(BinarySource_UPCAST(src), len)
|
||||
@ -305,6 +309,8 @@ ptrlen BinarySource_get_pstring(BinarySource *);
|
||||
mp_int *BinarySource_get_mp_ssh1(BinarySource *src);
|
||||
mp_int *BinarySource_get_mp_ssh2(BinarySource *src);
|
||||
|
||||
void BinarySource_REWIND_TO__(BinarySource *src, size_t pos);
|
||||
|
||||
/*
|
||||
* A couple of useful standard BinarySink implementations, which live
|
||||
* as sensibly here as anywhere else: one that makes a BinarySink
|
||||
|
Loading…
Reference in New Issue
Block a user