avformat/{aviobuf,avio_internal}: add ff_read_string_to_bprint_overwrite

For now, same as ff_read_line_to_bprint_overwrite, but reads until
the end of a null-terminated string.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
pull/369/head
Jan Ekström 3 years ago committed by Jan Ekström
parent 94f227bac1
commit 151f46e84d
  1. 12
      libavformat/avio_internal.h
  2. 5
      libavformat/aviobuf.c

@ -245,4 +245,16 @@ struct AVBPrint;
*/ */
int64_t ff_read_line_to_bprint_overwrite(AVIOContext *s, struct AVBPrint *bp); int64_t ff_read_line_to_bprint_overwrite(AVIOContext *s, struct AVBPrint *bp);
/**
* Read a whole null-terminated string of text from AVIOContext to an AVBPrint
* buffer overwriting its contents. Stop reading after reaching a \\0 or
* EOF.
*
* @param s the read-only AVIOContext
* @param bp the AVBPrint buffer
* @return the length of the read string not including the terminating null,
* negative on error, or if the buffer becomes truncated.
*/
int64_t ff_read_string_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp);
#endif /* AVFORMAT_AVIO_INTERNAL_H */ #endif /* AVFORMAT_AVIO_INTERNAL_H */

@ -863,6 +863,11 @@ int64_t ff_read_line_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp)
return read_string_to_bprint_overwrite(s, bp, FFBPrintReadLine); return read_string_to_bprint_overwrite(s, bp, FFBPrintReadLine);
} }
int64_t ff_read_string_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp)
{
return read_string_to_bprint_overwrite(s, bp, FFBPrintReadString);
}
int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen) int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen)
{ {
int i; int i;

Loading…
Cancel
Save