[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [coldsync-hackers] Fwd: potential method for automating conduit generation



> A little while back, I ran across a nice open-source gas mileage tracker
> that supports multiple cars (palmfuellog on SourceForge). Like most
> open-source Palm apps, it doesn't have a conduit. Although the data is
> stored in a relatively simple format, I was looking for a way to automate
> the conduit generation process.
>
> Since most Palm apps use a struct for formatting records, I ran c2ph on
> the source code to try and extract the record stucture into a Perl object.
>   The way I understand it, c2ph just parses the debugging info placed in
> the assembly code from the compiler (in order to generate the object
> definition), but it also appears to be choking on the link stage (which I
> didn't figure would be necessary).
>
> Now, in this case, I could probably write the object myself with a little
> review of Perl OOP... however, I thought this would be a neat trick, if
> only it worked...

Attached is work-in-progress conduit support module.  The disclaimer is,
it's incomplete, it's in beta, and if it breaks, you own both pieces.

However, I have successfully used it to deparse records from my NSBasic Palm
app, so my conduit can process them.

It takes an NSBasic Record definition as the structure, however the
appropriate C Structure could be pasted in.  It should function identically.
I haven't yet gotten it to where I can pass in an arbitrary structure, so
for right now it's hardcoded into the module.

This text definition is deparsed into a list of element names and types.
Then, the record is chomped off, one value at a time, leaving each $record
containing a hash of name/value pairs.

I'm pasting it as-is.

Some notes:
Signatures in NSBasic are a specially formatted String.
NONE of the Signature stuff works AT ALL.
Strings are C-style, NUL terminated.
Integers and Floats work great.
NSBasic Dates are 100*year + 100*month + day, stored in a Float.
No promises on any other datatypes.

GOOD LUCK (comments welcome).

L8r,
Rob

LNZReceipt.pm