RSS Feed

Lisp Project of the Day

cl-pack

You can support this project by donating at:

Donate using PatreonDonate using Liberapay

Or see the list of project sponsors.

cl-packdata-structuresserialization

It supplies Perl/PHP/Ruby/Python compatible pack() and unpack() functions to allow easy use of (binary format) protocols and files with the above-mentioned languages and C.

I've tested :cl-pack using an example from its README. Seems it does not work as expected, because it is unable to unpack the data, created by itself:

POFTHEDAY> (defparameter *data*
              (cl-pack:pack "VgA*c*"
                            #x41424344
                            161.99
                            " a string "
                            69 70 71))
 *DATA*
 POFTHEDAY> *data*
 "DCBAC!ýq a string EFG"
 POFTHEDAY> (cl-pack:unpack "VgA*c*" *data*)
 1094861636 (31 bits, #x41424344)
 161.99
 "a string EFG"

As you can see, it wasn't able to unpack three unsigned chars from the end of the structure.

I've decided :cl-pack isn't able to distinguish the end of the line, and changed format string to the null-terminated string.

But it doesn't work either:

POFTHEDAY> (defparameter *data*
              (cl-pack:pack "VgZ*c*"
                            #x41424344
                            161.99
                            "a string"
                            69 70 71))
 *DATA*
 POFTHEDAY> *data*
 "DCBAC!ýqa string^@EFG"
 POFTHEDAY> (cl-pack:unpack "VgZ*c*" *data*)
 1094861636 (31 bits, #x41424344)
 161.99
 "a string^@EFG"

Is it a fail, or I just did something wrong?


Brought to you by 40Ants under Creative Commons License