Portability across architectures..

Don Libes libes at cme-durer.ARPA
Sun Sep 18 03:46:43 AEST 1988


There's another possibility besides ASCII and native form: ASN.1

ASN.1 is a set of ISO standards which address the OSI Presentation
Layer - very similar to the problem you face.

The time/space overhead for ASN.1 data encoding is low.  Each datum
has a few extra bytes on it for length and type info but is otherwise
compactly stored.  For example, an ascii string is stored as an ascii
string.  Ints are stored in binary and allow for arbitrary size.

The nice thing is, you can select the way you want the datatype to be
encoded.  E.g., you can have an int encoded as an integer or string or
any of the other appropriate built-in types - and the result is still
portable.  In other words, you have pretty good control over
everything.

You can also define your own datatypes.  For example, I can (and do)
send linked lists between two processes this way.  And they can be
written in different languages, running on different machines and
different operating systems.

ASN.1 is really several pieces.  I believe there is a complete
implementation in ISODE (available via ftp from udel.edu).

We actively use ASN.1 here.  (We tried ASCII, native forms and mixes
of them, but eventually gave up with them.)  We have our own
implementation that one of our hackers wrote.  It's minimal but small
(object code is only 3K) and fast.  It doesn't do any parsing (8824),
just value encoding/decoding (8825), although we write our standards
following the ASN.1 syntax anyway.  (And yes, you can have it, but it
is undocumented.)

Don Libes          cme-durer.arpa      ...!uunet!cme-durer!libes



More information about the Comp.lang.c mailing list