diff options
Diffstat (limited to 'src/input/input_pnm.c')
-rw-r--r-- | src/input/input_pnm.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/input/input_pnm.c b/src/input/input_pnm.c index e30d0e721..35f4ea2d1 100644 --- a/src/input/input_pnm.c +++ b/src/input/input_pnm.c @@ -43,9 +43,11 @@ #include "pnm.h" #include "net_buf_ctrl.h" - +/* #define LOG +*/ +#define BUFSIZE 1025 extern int errno; @@ -71,7 +73,7 @@ typedef struct { nbc_t *nbc; - char scratch[1025]; + char scratch[BUFSIZE]; } pnm_input_plugin_t; @@ -121,11 +123,23 @@ static buf_element_t *pnm_plugin_read_block (input_plugin_t *this_gen, } static off_t pnm_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin) { - /* pnm_input_plugin_t *this = (pnm_input_plugin_t *) this_gen; - */ - return -1; + printf ("input_pnm: seek %lld bytes, origin %d\n", + offset, origin); + + /* only realtive forward-seeking is implemented */ + + if ((origin == SEEK_CUR) && (offset >= 0)) { + + for (;((int)offset) - BUFSIZE > 0; offset -= BUFSIZE) { + this->curpos += pnm_plugin_read (this_gen, this->scratch, BUFSIZE); + } + + this->curpos += pnm_plugin_read (this_gen, this->scratch, offset); + } + + return this->curpos; } static off_t pnm_plugin_get_length (input_plugin_t *this_gen) { |