On Wed December 31 2008, Frank B. Brokken wrote:
> Hi William,
> 
> Thanks for your reply. I followed your suggestion and changed the buffer size
> to 480: where the original program shows `500' it now has
> `480'. Unfortunately, after uncommenting the `Doesn't work' section the
> problem remains. Only the first block is decoded. Since 480 clearly fits the
> requirement of being divisible by both 8 and 6 I'm slightly worried about how
> to `find the exact point where an 8 bit is not shared'.
> 
> So I thought about reading larger chunks and extracting a smaller number of
> characters so as not to exhaust the input buffer. After all extracting in
> blocks from a s_mem that completely contains the encoded file works fine, so
> why not do it while s_mem is being filled? 
> 
> But this was met with variable results: reading blocks of 700 bytes and then
> converting 480 bytes after each read-operation works fine, but reading blocks
> of 500 bytes and then extracting blocks of 240 bytes fails.
> 

Are you stripping the bytes that might appear in the stream
that do not represent encoded characters or a part of the count?

> Somehow I don't like this shotgun-approach, thinking that there must be a more
> systematic way to handle my problem....
> 

There is, I posted the link to one such solution.  Have you read it?


> Anyway, here are the essential changes I made to read + extract information:
> 

Is this a homework assignment?

Mike
>         size_t const bufSize = 700;
>         size_t const readBlock = 480;
> 
>         while ((inlen = fread(inbuf, 1, bufSize, stdin)) != 0)
>         {
>             BIO_write(mem, inbuf, inlen);
>             BIO_flush(mem);
>                                             // decode some chars at each
>                                             // read from stdin
>             inlen = BIO_read(bio, inbuf, readBlock);
> 
>             if (inlen <= 0)                 // once this happens no more
>                 break;                      // successful decodes occur
> 
>             fwrite(inbuf, 1, inlen, stdout);
>         }
> 
> So, thanks again for the reply, but I think I'm still looking for a general
> (algorithmic) solution....
> 
> Cheers,
> 


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to