diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-05-18 02:46:13 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-05-18 02:46:13 +0000 |
commit | 48a58073dd9bf781a8e2a127e832941332fc8a41 (patch) | |
tree | 8aeeb19951a63b43c8f054947539ae904b9f4558 /src/inputStream.c | |
parent | ee79a3a8fdd119444ff76d993678a56ed635df2b (diff) | |
download | mpd-48a58073dd9bf781a8e2a127e832941332fc8a41.tar.gz mpd-48a58073dd9bf781a8e2a127e832941332fc8a41.tar.xz mpd-48a58073dd9bf781a8e2a127e832941332fc8a41.zip |
add new inputStream stuff, hopefully something major isn't foobar'd
git-svn-id: https://svn.musicpd.org/mpd/trunk@1049 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/inputStream.c')
-rw-r--r-- | src/inputStream.c | 50 |
1 files changed, 12 insertions, 38 deletions
diff --git a/src/inputStream.c b/src/inputStream.c index 1dea4f271..578749e24 100644 --- a/src/inputStream.c +++ b/src/inputStream.c @@ -18,61 +18,35 @@ #include "inputStream.h" +#include "inputStream_file.h" +#include "inputStream_http.h" + #include <stdio.h> #include <sys/types.h> #include <unistd.h> -#include <errno.h> - -int openInputStreamFromFile(InputStream * inStream, char * filename) { - inStream->fp = fopen(filename,"r"); - if(!inStream->fp) { - inStream->error = errno; - return -1; - } - inStream->offset = 0; +int openInputStream(InputStream * inStream, char * url) { + if(inputStream_fileOpen(inStream,url) == 0) return 0; + if(inputStream_httpOpen(inStream,url) == 0) return 0; - fseek(inStream->fp,0,SEEK_END); - inStream->size = ftell(inStream->fp); - fseek(inStream->fp,0,SEEK_SET); - - return 0; + return -1; } int seekInputStream(InputStream * inStream, long offset, int whence) { - if(fseek(inStream->fp,offset,whence)==0) { - inStream->offset = ftell(inStream->fp); - } - else { - inStream->error = errno; - return -1; - } - - return 0; + return inStream->seekFunc(inStream,offset,whence); } size_t readFromInputStream(InputStream * inStream, void * ptr, size_t size, size_t nmemb) { - size_t readSize; - - readSize = fread(ptr,size,nmemb,inStream->fp); - - if(readSize>0) inStream->offset+=readSize; - - return readSize; + return inStream->readFunc(inStream,ptr,size,nmemb); } int closeInputStream(InputStream * inStream) { - if(fclose(inStream->fp)<0) { - inStream->error = errno; - } - else return -1; - - return 0; + return inStream->closeFunc(inStream); } int inputStreamAtEOF(InputStream * inStream) { - return feof(inStream->fp); + return inStream->atEOFFunc(inStream); } -/* vim:set shiftwidth=4 tabstop=8 expandtab: */ +/* vim:set shiftwidth=8 tabstop=8 expandtab: */ |