This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 297da0533 util/stream: Add ostream_write_str function
297da0533 is described below
commit 297da05336a83fd159175fe4f75c548d584606cc
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Mon Jul 1 14:34:06 2024 +0200
util/stream: Add ostream_write_str function
This is simple utility function to write null terminated
string to stream.
Function is already referenced in msc_fat_view.
---
util/stream/include/stream/stream.h | 10 ++++++++++
util/stream/src/stream.c | 7 +++++++
2 files changed, 17 insertions(+)
diff --git a/util/stream/include/stream/stream.h
b/util/stream/include/stream/stream.h
index a28c94d3d..ac23e361c 100644
--- a/util/stream/include/stream/stream.h
+++ b/util/stream/include/stream/stream.h
@@ -249,4 +249,14 @@ ostream_write_uint32(struct out_stream *ostream, uint32_t
data)
return ostream_write(ostream, (uint8_t *)&data, 4, false);
}
+/**
+ * Write null terminated string to output stream
+ *
+ * @param ostream - stream to write to
+ * @param str - string to write to stream
+ *
+ * @return number of bytes written, negative on error
+ */
+int ostream_write_str(struct out_stream *ostream, const char *str);
+
#endif /* H_STREAM_ */
diff --git a/util/stream/src/stream.c b/util/stream/src/stream.c
index fe7605157..80473505b 100644
--- a/util/stream/src/stream.c
+++ b/util/stream/src/stream.c
@@ -136,3 +136,10 @@ stream_pump(struct in_stream *istream, struct out_stream
*ostream, uint32_t coun
}
return pumped;
}
+
+int
+ostream_write_str(struct out_stream *ostream, const char *str)
+{
+ int len = strlen(str);
+ return ostream_write(ostream, (const uint8_t *)str, len, false);
+}