Skip to content

Commit 9b308c1

Browse files
ly_out UPDATE add ly_out_printed_total (#2391)
ly_out_printed() only gives the bytes printed in the last writer function call. There are use cases where we need to know total number of bytes written as well. So, expose this with ly_out_printed_total() API
1 parent 94422ed commit 9b308c1

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/out.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,12 @@ ly_out_printed(const struct ly_out *out)
681681
return out->func_printed;
682682
}
683683

684+
LIBYANG_API_DEF size_t
685+
ly_out_printed_total(const struct ly_out *out)
686+
{
687+
return out->printed;
688+
}
689+
684690
LY_ERR
685691
ly_write_skip(struct ly_out *out, size_t count, size_t *position)
686692
{

src/out.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ extern "C" {
6363
*
6464
* - ::ly_out_type()
6565
* - ::ly_out_printed()
66+
* - ::ly_out_printed_total()
6667
*
6768
* - ::ly_out_reset()
6869
* - ::ly_out_free()
@@ -291,6 +292,14 @@ LIBYANG_API_DECL LY_ERR ly_write(struct ly_out *out, const char *buf, size_t len
291292
*/
292293
LIBYANG_API_DECL size_t ly_out_printed(const struct ly_out *out);
293294

295+
/**
296+
* @brief Get the total number of printed bytes of this out structure.
297+
*
298+
* @param[in] out Out structure used.
299+
* @return Number of printed bytes.
300+
*/
301+
LIBYANG_API_DECL size_t ly_out_printed_total(const struct ly_out *out);
302+
294303
/**
295304
* @brief Free the printer handler.
296305
* @param[in] out Printer handler to free.

0 commit comments

Comments
 (0)