aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/serialise.hh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-07-21 13:43:20 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-07-21 13:43:20 +0000
commitcdb3f39b64fa9e1d1c85bd3ba3a4b8b1c480bb2c (patch)
tree464053f8d7942ed931e342f0576e85f5586bb0f7 /src/libutil/serialise.hh
parentc58c6165c554d671f87b463c9ab1d47a5d75bbbb (diff)
parent0835447eaacacdb4c1241971c584c88acd274b99 (diff)
Merge remote-tracking branch 'upstream/master' into better-ca-parse-errors
Diffstat (limited to 'src/libutil/serialise.hh')
-rw-r--r--src/libutil/serialise.hh15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/libutil/serialise.hh b/src/libutil/serialise.hh
index 8386a4991..5d9acf887 100644
--- a/src/libutil/serialise.hh
+++ b/src/libutil/serialise.hh
@@ -189,7 +189,7 @@ struct TeeSource : Source
size_t read(unsigned char * data, size_t len)
{
size_t n = orig.read(data, len);
- sink(data, len);
+ sink(data, n);
return n;
}
};
@@ -256,6 +256,19 @@ struct LambdaSource : Source
}
};
+/* Chain two sources together so after the first is exhausted, the second is
+ used */
+struct ChainSource : Source
+{
+ Source & source1, & source2;
+ bool useSecond = false;
+ ChainSource(Source & s1, Source & s2)
+ : source1(s1), source2(s2)
+ { }
+
+ size_t read(unsigned char * data, size_t len) override;
+};
+
/* Convert a function that feeds data into a Sink into a Source. The
Source executes the function as a coroutine. */