
On 04/28/2016 04:04 AM, Michal Privoznik wrote:
These functions will be called to determine whether underlying
s/whether/whether the/
file that stream is transferring is currently in a data or hole.
s/stream/the stream/
While virStreamRegisterInData is exposed, virStreamInData does not need to be made a public API as it will be called just internally.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> ---
+int +virStreamRegisterInData(virStreamPtr stream, + virStreamInDataFunc inDataCb, + void *opaque) +{ + VIR_DEBUG("stream=%p, inDataCb=%p opaque=%p", stream, inDataCb, opaque); + + virResetLastError(); + + virCheckStreamReturn(stream, -1); + virCheckNonNullArgReturn(inDataCb, -1); + + if (stream->inDataCb) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("A inData callback is already registered"));
s/A inData/An inData/ (or maybe s/A //)
+/** + * virStreamInData: + * @stream: stream + * @data: are we in data or hole + * @offset: offset to next section + * + * This function will check underlying stream (typically a file)
s/check/check the/
+ * whether the current position the stream is in lies in a data + * section or in a hole.
Reads a bit awkwardly; maybe: This function checks the underlying stream (typically a file) to learn whether the current stream position lies within a data section or a hold.
Upon return @data is set to a nonzero + * value if former is the case, or to zero if @stream is in a + * hole. Moreover, @offset it updated to tell caller how much
s/it/is/ s/much/many/
+ * bytes can be read from @stream until current section changes + * (from data to a hole or vice versa). + * + * As a special case, there's an implicit hole at EOF. In this + * situation this function should set @data = false, @offset = 0 + * and return 0. + * + * Returns 0 on success, + * -1 otherwise + */ +int +virStreamInData(virStreamPtr stream, + int *data, + unsigned long long *offset)
I still wonder if 'length' is a better name than 'offset', but this one doesn't feel quite as awkward as the ones earlier in the series.
+++ b/src/libvirt_public.syms @@ -736,6 +736,7 @@ LIBVIRT_1.3.5 { global: virStreamSkip; virStreamRegisterSkip; + virStreamRegisterInData;
Worth sorting? Interface looks usable so far. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org