caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Dhek Uir <dhekuir@gmail.com>
To: David Allsopp <dra-news@metastack.com>
Cc: "caml-list@inria.fr" <caml-list@inria.fr>, Drup <drupyog+caml@zoho.com>
Subject: Re: [Caml-list] Simple compression library
Date: Mon, 2 Feb 2015 18:53:48 +0100	[thread overview]
Message-ID: <CAJn4uc5r1YOckkxVyVZB8CCH9imKrFN=6zW9nWGF6-8NkKZm4w@mail.gmail.com> (raw)
In-Reply-To: <E51C5B015DBD1348A1D85763337FB6D9E98B2CBF@Remus.metastack.local>

[-- Attachment #1: Type: text/plain, Size: 1481 bytes --]

Wow, I completely overlooked that. I was convinced that
Gzip.input/Gzip.really_input returned the number of *compressed* characters
read. I misread "uncompresses up to len characters" as "advances the
compressed buffer up to len characters". The phrase "[Gzip.input] returns
the actual number of characters read" didn't help me either.

Anyway, thanks a lot, it's much simpler than I expected!




On Mon, Feb 2, 2015 at 6:38 PM, David Allsopp <dra-news@metastack.com>
wrote:

> Dhek Uir wrote:
> > But since camlzip does not have an input_value function, it seems I must
> set up
> > a buffer to decompress the data, then use Marshal to obtain input data
> from the
> > decompressed buffer. But if I use Marshal.from_string to read the
> decompressed
> > buffer, then I need to keep track of its position (which is not returned
> by
> > Marshal.from_string), and check whether the buffer is nearly empty, so
> that I
> > may need to re-read from the compressed in_channel, etc, etc. Did I miss
> the
> > right function again?
>
> Marshal has everything you need:
>
> let input_value ch =
>   let header = String.create Marshal.header_size
>   in
>     Gzip.really_input ch header 0 Marshal.header_size;
>     let buffer = String.create (Marshal.total_size header 0)
>     in
>       Gzip.really_input ch buffer Marshal.header_size (Marshal.data_size
> header 0);
>       String.unsafe_blit header 0 buffer 0 Marshal.header_size;
>       Marshal.from_string buffer 0
>
>
> David
>

[-- Attachment #2: Type: text/html, Size: 2031 bytes --]

      reply	other threads:[~2015-02-02 17:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-02 15:39 Dhek Uir
2015-02-02 15:43 ` Jacques-Henri Jourdan
2015-02-02 16:05   ` Dhek Uir
2015-02-02 16:48     ` Drup
2015-02-02 17:00       ` Dhek Uir
2015-02-02 17:38         ` David Allsopp
2015-02-02 17:53           ` Dhek Uir [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJn4uc5r1YOckkxVyVZB8CCH9imKrFN=6zW9nWGF6-8NkKZm4w@mail.gmail.com' \
    --to=dhekuir@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=dra-news@metastack.com \
    --cc=drupyog+caml@zoho.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).