summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authoralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-03-16 14:42:51 +0000
committeralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-03-16 14:42:51 +0000
commitbadc607fa1a8c5e3d5fcd3a0f70f480bb9e1a1c9 (patch)
tree50a432fa7f84112d18ca245b5cfcdb4b06148bb1 /libmpdemux
parentc748950c9fcc1f50adb7b73b07fff6bfb96e2f5a (diff)
downloadmpv-badc607fa1a8c5e3d5fcd3a0f70f480bb9e1a1c9.tar.bz2
mpv-badc607fa1a8c5e3d5fcd3a0f70f480bb9e1a1c9.tar.xz
Move the subread from FILE to stream_t.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17880 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/stream.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/libmpdemux/stream.h b/libmpdemux/stream.h
index 7407c496a9..0b4361cb74 100644
--- a/libmpdemux/stream.h
+++ b/libmpdemux/stream.h
@@ -208,6 +208,31 @@ inline static int stream_read(stream_t *s,char* mem,int total){
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;
}