Hi Dom, appended one patch for wv to use my new wv_memory_streams in picf.c and some bugfixes for my recent additions to support.c.
Robert
Index: picf.c =================================================================== RCS file: /cvsroot/wv/picf.c,v retrieving revision 1.27 diff -u -r1.27 picf.c --- picf.c 21 Jan 2002 15:00:42 -0000 1.27 +++ picf.c 18 Feb 2002 18:21:24 -0000 @@ -11,9 +11,11 @@ int wvGetPICF (wvVersion ver, PICF * apicf, wvStream * fd) { - FILE *f; U8 temp; U32 i; + U8 *buf,*p; + size_t size; + long pos = wvStream_tell (fd); apicf->lcb = read_32ubit (fd); @@ -64,17 +66,7 @@ wvTrace ( ("ends at %x\n", wvStream_tell (fd) + apicf->lcb - apicf->cbHeader)); - f = tmpfile (); - if (f == NULL) - { - wvError (("Couldnt create tmpfile: %s\n", strerror (errno))); - apicf->rgb = NULL; - return 0; - } - /* - sprintf(buffer,"/tmp/newtest-%d",s++); - f = fopen(buffer,"w+b"); - */ + i = 0; if (apicf->mfp_mm < 90) @@ -131,40 +123,47 @@ header_len = 14 + 40 + 4 * colors_used; - fputc (0x42, f); /* B */ - fputc (0x4D, f); /* M */ + size = apicf->lcb - apicf->cbHeader; + p = buf = malloc(apicf->lcb - apicf->cbHeader); + + *p++ = 0x42; /* B */ + *p++ = 0x4D; /* M */ - fputc (len & 0x000000FF, f); - fputc ((len & 0x0000FF00) >> 8, f); - fputc ((len & 0x00FF0000) >> 16, f); - fputc ((len & 0xFF000000) >> 24, f); - - fputc (0x00, f); - fputc (0x00, f); - fputc (0x00, f); - fputc (0x00, f); - - fputc (header_len & 0x000000FF, f); - fputc ((header_len & 0x0000FF00) >> 8, f); - fputc ((header_len & 0x00FF0000) >> 16, f); - fputc ((header_len & 0xFF000000) >> 24, f); + *p++ = len & 0x000000FF; + *p++ = (len & 0x0000FF00) >> 8; + *p++ = (len & 0x00FF0000) >> 16; + *p++ = (len & 0xFF000000) >> 24; + + *p++ = 0x00; + *p++ = 0x00; + *p++ = 0x00; + *p++ = 0x00; + + *p++ = header_len & 0x000000FF; + *p++ = (header_len & 0x0000FF00) >> 8; + *p++ = (header_len & 0x00FF0000) >> 16; + *p++ = (header_len & 0xFF000000) >> 24; for(j=0;j< sizeof(bmp_header);j++) - fputc(bmp_header[j],f); + *p++=bmp_header[j]; for (; i < apicf->lcb - apicf->cbHeader-sizeof(bmp_header); i++) - fputc (read_8ubit (fd), f); + *p++= read_8ubit (fd); } else { + size = apicf->lcb - apicf->cbHeader; + p = buf = malloc(size); for (; i < apicf->lcb - apicf->cbHeader; i++) - fputc (read_8ubit (fd), f); + *p++ = read_8ubit (fd); } - rewind (f); - wvStream_FILE_create (&apicf->rgb, f); + /* rewind (f); + wvStream_FILE_create (&apicf->rgb, f); */ + + wvStream_memory_create(&apicf->rgb, buf, size); return 1; } Index: support.c =================================================================== RCS file: /cvsroot/wv/support.c,v retrieving revision 1.24 diff -u -r1.24 support.c --- support.c 15 Feb 2002 15:24:56 -0000 1.24 +++ support.c 18 Feb 2002 18:21:25 -0000 @@ -84,9 +84,15 @@ } void -wvStream_memory_create (wvStream ** in, MemoryStream * inner) +wvStream_memory_create (wvStream ** in, char *buf, size_t size) { wvInternalStream str; + MemoryStream *inner = (MemoryStream *)wvMalloc(sizeof(MemoryStream)); + + inner->mem = buf; + inner->size = size; + inner->current = 0; + str.memory_stream = inner; wvStream_create (in, MEMORY_STREAM, str); } @@ -128,8 +134,9 @@ } else { - return *((U32 *) (in->stream.memory_stream->mem + + ret = *((U32 *) (in->stream.memory_stream->mem + in->stream.memory_stream->current)); + in->stream.memory_stream->current +=4; } #endif return (ret); @@ -158,8 +165,9 @@ } else { - return *((U16 *) (in->stream.memory_stream->mem + + ret = *((U16 *) (in->stream.memory_stream->mem + in->stream.memory_stream->current)); + in->stream.memory_stream->current+=2; } @@ -183,8 +191,11 @@ } else { - return *((U8 *)(in->stream.memory_stream->mem + + U8 ret; + ret = *((U8 *)(in->stream.memory_stream->mem + in->stream.memory_stream->current)); + in->stream.memory_stream->current++; + return ret; } } @@ -204,6 +215,7 @@ { memcpy(ptr, in->stream.memory_stream->mem + in->stream.memory_stream->current,size * nmemb); + in->stream.memory_stream->current+=size* nmemb; return size * nmemb; } } @@ -260,6 +272,7 @@ else { in->stream.memory_stream->current += offset; + return in->stream.memory_stream->current; } } @@ -279,7 +292,7 @@ { in->stream.memory_stream->current = in->stream.memory_stream->size + offset; - return 0; + return in->stream.memory_stream->current; } } @@ -338,6 +351,7 @@ if (in->kind == MEMORY_STREAM) { free (in->stream.memory_stream->mem); + free (in->stream.memory_stream); wvFree (in); return 0; } Index: wv.h =================================================================== RCS file: /cvsroot/wv/wv.h,v retrieving revision 1.99 diff -u -r1.99 wv.h --- wv.h 15 Feb 2002 15:24:56 -0000 1.99 +++ wv.h 18 Feb 2002 18:21:27 -0000 @@ -4443,6 +4439,7 @@ /* These functions take care of memory/file management for wvStreams */ void wvStream_FILE_create (wvStream ** in, FILE * inner); void wvStream_libole2_create (wvStream ** in, MsOleStream * inner); + void wvStream_memory_create (wvStream ** in, char *buf, size_t size); void wvStream_create (wvStream ** in, wvStreamKind kind, wvInternalStream inner); U32 wvStream_close (wvStream * stream);