changeset 6301:1b2b5dbcf549 libavformat

improve ff_get_line to return line length
author aurel
date Wed, 21 Jul 2010 21:40:10 +0000
parents e62d23b0547d
children 869753e625c4
files aviobuf.c internal.h
diffstat 2 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/aviobuf.c	Wed Jul 21 21:39:01 2010 +0000
+++ b/aviobuf.c	Wed Jul 21 21:40:10 2010 +0000
@@ -554,18 +554,19 @@
     return buf;
 }
 
-void ff_get_line(ByteIOContext *s, char *buf, int maxlen)
+int ff_get_line(ByteIOContext *s, char *buf, int maxlen)
 {
     int i = 0;
     char c;
 
     do {
         c = get_byte(s);
-        if (i < maxlen-1)
+        if (c && i < maxlen-1)
             buf[i++] = c;
     } while (c != '\n' && c);
 
     buf[i] = 0;
+    return i;
 }
 
 uint64_t get_be64(ByteIOContext *s)
--- a/internal.h	Wed Jul 21 21:39:01 2010 +0000
+++ b/internal.h	Wed Jul 21 21:40:10 2010 +0000
@@ -167,7 +167,7 @@
  */
 void ff_put_v(ByteIOContext *bc, uint64_t val);
 
-void ff_get_line(ByteIOContext *s, char *buf, int maxlen);
+int ff_get_line(ByteIOContext *s, char *buf, int maxlen);
 
 #define SPACE_CHARS " \t\r\n"