@ -809,13 +809,17 @@ typedef enum FFBPrintReadStringMode {
} FFBPrintReadStringMode ;
static int64_t read_string_to_bprint ( AVIOContext * s , AVBPrint * bp ,
FFBPrintReadStringMode mode )
FFBPrintReadStringMode mode ,
int64_t max_len )
{
int len , end ;
int64_t read = 0 ;
char tmp [ 1024 ] ;
char c ;
if ( ! max_len )
return 0 ;
do {
len = 0 ;
do {
@ -824,10 +828,11 @@ static int64_t read_string_to_bprint(AVIOContext *s, AVBPrint *bp,
c = = ' \0 ' ) ;
if ( ! end )
tmp [ len + + ] = c ;
} while ( ! end & & len < sizeof ( tmp ) ) ;
} while ( ! end & & len < sizeof ( tmp ) & &
( ( max_len < 0 ) | | ( read + len < max_len ) ) ) ;
av_bprint_append_data ( bp , tmp , len ) ;
read + = len ;
} while ( ! end ) ;
} while ( ! end & & ( ( max_len < 0 ) | | ( read < max_len ) ) ) ;
if ( mode = = FFBPrintReadLine & &
c = = ' \r ' & & avio_r8 ( s ) ! = ' \n ' & & ! avio_feof ( s ) )
@ -843,12 +848,13 @@ static int64_t read_string_to_bprint(AVIOContext *s, AVBPrint *bp,
}
static int64_t read_string_to_bprint_overwrite ( AVIOContext * s , AVBPrint * bp ,
FFBPrintReadStringMode mode )
FFBPrintReadStringMode mode ,
int64_t max_len )
{
int64_t ret ;
av_bprint_clear ( bp ) ;
ret = read_string_to_bprint ( s , bp , mode ) ;
ret = read_string_to_bprint ( s , bp , mode , max_len ) ;
if ( ret < 0 )
return ret ;
@ -860,12 +866,13 @@ static int64_t read_string_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp,
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 , - 1 ) ;
}
int64_t ff_read_string_to_bprint_overwrite ( AVIOContext * s , AVBPrint * bp )
int64_t ff_read_string_to_bprint_overwrite ( AVIOContext * s , AVBPrint * bp ,
int64_t max_len )
{
return read_string_to_bprint_overwrite ( s , bp , FFBPrintReadString ) ;
return read_string_to_bprint_overwrite ( s , bp , FFBPrintReadString , max_len ) ;
}
int avio_get_str ( AVIOContext * s , int maxlen , char * buf , int buflen )