[MPlayer-cvslog] CVS: main/libmpdemux stream.h,1.77,1.78

Alban Bedel CVS syncmail at mplayerhq.hu
Thu Mar 16 15:42:54 CET 2006


CVS change done by Alban Bedel CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv20536/libmpdemux

Modified Files:
	stream.h 
Log Message:
Move the subread from FILE to stream_t.


Index: stream.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/stream.h,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- stream.h	1 Mar 2006 22:26:18 -0000	1.77
+++ stream.h	16 Mar 2006 14:42:51 -0000	1.78
@@ -208,6 +208,31 @@
   return total;
 }
 
+inline static unsigned char* stream_read_line(stream_t *s,unsigned char* mem, int max) {
+  int len;
+  unsigned char* end,*ptr = mem;;
+  do {
+    len = s->buf_len-s->buf_pos;
+    // try to fill the buffer
+    if(len <= 0 &&
+       (!cache_stream_fill_buffer(s) || 
+        (len = s->buf_len-s->buf_pos) <= 0)) break;
+    end = memchr((void*)(s->buffer+s->buf_pos),'\n',len);
+    if(end) len = end - (s->buffer+s->buf_pos) + 1;
+    if(len > 0 && max > 1) {
+      int l = len > max-1 ? max-1 : len;
+      memcpy(ptr,s->buffer+s->buf_pos,l);
+      max -= l;
+      ptr += l;
+    }
+    s->buf_pos += len;
+  } while(!end);
+  if(s->eof && ptr == mem) return NULL;
+  if(max > 0) ptr[0] = 0;
+  return mem;
+}
+
+
 inline static int stream_eof(stream_t *s){
   return s->eof;
 }




More information about the MPlayer-cvslog mailing list