mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avutil/bprint: Add av_bprint_fd_contents()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
06dae71d47
commit
fcd1f6bc9d
@ -22,6 +22,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include "avassert.h"
|
||||
#include "avstring.h"
|
||||
#include "bprint.h"
|
||||
@ -304,6 +305,22 @@ void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_cha
|
||||
}
|
||||
}
|
||||
|
||||
int av_bprint_fd_contents(AVBPrint *pb, int fd)
|
||||
{
|
||||
int ret;
|
||||
char buf[1024];
|
||||
while (1) {
|
||||
ret = read(fd, buf, sizeof(buf));
|
||||
if (!ret)
|
||||
return 0;
|
||||
else if (ret < 0)
|
||||
return AVERROR(errno);
|
||||
av_bprint_append_data(pb, buf, ret);
|
||||
if (!av_bprint_is_complete(pb))
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#undef printf
|
||||
|
@ -213,4 +213,11 @@ int av_bprint_finalize(AVBPrint *buf, char **ret_str);
|
||||
void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_chars,
|
||||
enum AVEscapeMode mode, int flags);
|
||||
|
||||
/**
|
||||
* Read contents of fd into print buffer up to EOF.
|
||||
*
|
||||
* @return 0 for success, error code otherwise
|
||||
*/
|
||||
int av_bprint_fd_contents(AVBPrint *pb, int fd);
|
||||
|
||||
#endif /* AVUTIL_BPRINT_H */
|
||||
|
@ -56,8 +56,8 @@
|
||||
*/
|
||||
|
||||
#define LIBAVUTIL_VERSION_MAJOR 52
|
||||
#define LIBAVUTIL_VERSION_MINOR 90
|
||||
#define LIBAVUTIL_VERSION_MICRO 101
|
||||
#define LIBAVUTIL_VERSION_MINOR 91
|
||||
#define LIBAVUTIL_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
||||
LIBAVUTIL_VERSION_MINOR, \
|
||||
|
Loading…
Reference in New Issue
Block a user