Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Juggling with binary files?

16 views
Skip to first unread message

Andreas Thiele

unread,
Aug 31, 2006, 9:30:15 AM8/31/06
to
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


Ralf Mattes

unread,
Aug 31, 2006, 9:39:41 AM8/31/06
to
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

Andreas Thiele

unread,
Aug 31, 2006, 9:42:23 AM8/31/06
to

"Ralf Mattes" <r...@mh-freiburg.de> schrieb im Newsbeitrag
news:pan.2006.08.31....@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


Paolo Amoroso

unread,
Aug 31, 2006, 10:23:05 AM8/31/06
to
"Andreas Thiele" <nos...@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

Frode Vatvedt Fjeld

unread,
Aug 31, 2006, 10:54:34 AM8/31/06
to
Paolo Amoroso <amo...@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

Paolo Amoroso

unread,
Aug 31, 2006, 3:05:53 PM8/31/06
to
Frode Vatvedt Fjeld <fro...@cs.uit.no> writes:

> Paolo Amoroso <amo...@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.

Timofei Shatrov

unread,
Sep 1, 2006, 1:47:42 AM9/1/06
to
On Thu, 31 Aug 2006 21:05:53 +0200, Paolo Amoroso <amo...@mclink.it>
tried to confuse everyone with this message:

>Frode Vatvedt Fjeld <fro...@cs.uit.no> writes:
>
>> Paolo Amoroso <amo...@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) |______________|

0 new messages