Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util/stream: Add ostream_write_str function #3280

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions util/stream/include/stream/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,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_ */
7 changes: 7 additions & 0 deletions util/stream/src/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Loading