From: Andreas Thiele
Subject: Juggling with binary files?
Date: 
Message-ID: <ed6o97$der$03$1@news.t-online.com>
Hi,

currently I have to process binary files. They contain 8, 16 and 32 bit values in little and big 
endian format as well as 8 bit characters and any mix of these. I am thinking about easy access to 
the individual values and don't want to re-invent the wheel.

Thought about something roughly like

(defrecord my-rec :size 512 first-value :long second-value :int-le third-value :char :position 200 
forth-value (:char 10))

(with-record-slots (first-value forth-value) my-rec
  (any-function first-value)
  (another-function forth-value))

So I have several questions:

1. Does something like this already exist?
2. If not 1., should I think about making it stream based (perhaps using gray-streams) for my 
implementation?
3. If 2., is trivial-gray-streams 
http://common-lisp.net/project/cl-plus-ssl/download/trivial-gray-streams.tar.gz enough (I use 
LispWorks)?

Andreas

From: Ralf Mattes
Subject: Re: Juggling with binary files?
Date: 
Message-ID: <pan.2006.08.31.13.39.39.515486@mh-freiburg.de>
On Thu, 31 Aug 2006 15:30:15 +0200, Andreas Thiele wrote:

> Hi,
> 
> currently I have to process binary files. They contain 8, 16 and 32 bit values in little and big 
> endian format as well as 8 bit characters and any mix of these. I am thinking about easy access to 
> the individual values and don't want to re-invent the wheel.

Peter `the Siebel' Seibel has some nice code in his book
"Practical Common Lisp" (chapters on reading MP3 data). This
should be a good starting point without wheel reinvention.

 HTH Ralf Mattes

P.S: The book is online - just cliki it up

> Thought about something roughly like
> 
> (defrecord my-rec :size 512 first-value :long second-value :int-le third-value :char :position 200 
> forth-value (:char 10))
> 
> (with-record-slots (first-value forth-value) my-rec
>   (any-function first-value)
>   (another-function forth-value))
> 
> So I have several questions:
> 
> 1. Does something like this already exist?
> 2. If not 1., should I think about making it stream based (perhaps using gray-streams) for my 
> implementation?
> 3. If 2., is trivial-gray-streams 
> http://common-lisp.net/project/cl-plus-ssl/download/trivial-gray-streams.tar.gz enough (I use 
> LispWorks)?
> 
> Andreas
From: Andreas Thiele
Subject: Re: Juggling with binary files?
Date: 
Message-ID: <ed6p05$qsq$00$1@news.t-online.com>
"Ralf Mattes" <··@mh-freiburg.de> schrieb im Newsbeitrag 
···································@mh-freiburg.de...
> On Thu, 31 Aug 2006 15:30:15 +0200, Andreas Thiele wrote:
>
...
>
> Peter `the Siebel' Seibel has some nice code in his book
> "Practical Common Lisp" (chapters on reading MP3 data). This
> should be a good starting point without wheel reinvention.
>
> HTH Ralf Mattes
>
> P.S: The book is online - just cliki it up
>
...

Aaarg :)) Thanks for the hint - I owe a printed copy of PCL ...

Andreas
From: Paolo Amoroso
Subject: Re: Juggling with binary files?
Date: 
Message-ID: <87odu1rnli.fsf@plato.moon.paoloamoroso.it>
"Andreas Thiele" <······@nospam.com> writes:

> currently I have to process binary files. They contain 8, 16 and 32 bit values in little and big 
> endian format as well as 8 bit characters and any mix of these. I am thinking about easy access to 
> the individual values and don't want to re-invent the wheel.
[...]
> 1. Does something like this already exist?

Yes, see:

  Practical: Parsing Binary Files
  (chapter 24 of Peter Seibel's book "Practical Common Lisp";
  source code available at the book site)
  http://www.gigamonkeys.com/book/practical-parsing-binary-files.html

  BINARY-TYPES
  www.cl-user.net/asp/libs/binary-types


Paolo
-- 
Why Lisp? http://wiki.alu.org/RtL%20Highlight%20Film
The Common Lisp Directory: http://www.cl-user.net
From: Frode Vatvedt Fjeld
Subject: Re: Juggling with binary files?
Date: 
Message-ID: <2hr6yxez11.fsf@vserver.cs.uit.no>
Paolo Amoroso <·······@mclink.it> writes:

>   Practical: Parsing Binary Files
>   (chapter 24 of Peter Seibel's book "Practical Common Lisp";
>   source code available at the book site)
>   http://www.gigamonkeys.com/book/practical-parsing-binary-files.html
> 
>   BINARY-TYPES
>   www.cl-user.net/asp/libs/binary-types

I think it would be appropriate to proclaim that my "binary-types"
package should be considered superseded by Peter's package, which
looks to be much nicer code (not to mention the documentation!).

-- 
Frode Vatvedt Fjeld
From: Paolo Amoroso
Subject: Re: Juggling with binary files?
Date: 
Message-ID: <87psegrai6.fsf@plato.moon.paoloamoroso.it>
Frode Vatvedt Fjeld <······@cs.uit.no> writes:

> Paolo Amoroso <·······@mclink.it> writes:
[...]
>>   BINARY-TYPES
>>   www.cl-user.net/asp/libs/binary-types
>
> I think it would be appropriate to proclaim that my "binary-types"
> package should be considered superseded by Peter's package, which
> looks to be much nicer code (not to mention the documentation!).

I have updated the entry.


Paolo
-- 
Why Lisp? http://wiki.alu.org/RtL%20Highlight%20Film
The Common Lisp Directory: http://www.cl-user.net
From: Timofei Shatrov
Subject: Re: Juggling with binary files?
Date: 
Message-ID: <44f7c8d4.2869395@news.readfreenews.net>
On Thu, 31 Aug 2006 21:05:53 +0200, Paolo Amoroso <·······@mclink.it>
tried to confuse everyone with this message:

>Frode Vatvedt Fjeld <······@cs.uit.no> writes:
>
>> Paolo Amoroso <·······@mclink.it> writes:
>[...]
>>>   BINARY-TYPES
>>>   www.cl-user.net/asp/libs/binary-types
>>
>> I think it would be appropriate to proclaim that my "binary-types"
>> package should be considered superseded by Peter's package, which
>> looks to be much nicer code (not to mention the documentation!).
>
>I have updated the entry.
>

It's probably worth it to release the PCL code as a separate library, as
happened with CL-FAD.

-- 
|Don't believe this - you're not worthless              ,gr---------.ru
|It's us against millions and we can't take them all... |  ue     il   |
|But we can take them on!                               |     @ma      |
|                       (A Wilhelm Scream - The Rip)    |______________|