Re: [Circle] Suggestion for crossplatform binary format

From: Rasmus 'Con' Ronlev (
Date: 08/14/96

On Tue, 13 Aug 1996, Jack Wilson wrote:

> Why not prefix every Circle binary file with a 32 bit integer (such
> as 0x01020304).  If, when the file is loaded, the driver detects that
> the number is not equal to 16909060 (decimal for 0x01020304), it will
> know that the file was saved in a different format than the driver
> is currently using, so it can convert.

Well, it's a good idea, but as it happens with many good ideas, they don't
work inreal life... The problem here is, that you'll then 'sit' on the
mashine that does not understand the pfile format!
This statement has two parts :) :

1) You COULD convert the so called little endian -> big endian format of
   storing numbers and stuff. It would require some fiddeling arround,
   but I'm sure that someone with a greater knowledge than me could do
   that as easily as snapping their fingers.
   Another option would be to use the systemdependent htons/htonl
   functions when writing a pfile, and ntohs/ntohl when reading it, this
   SHOULD at all times keep the int's etc in so called NET BYTE ORDER.
   All this is great, but when you read the seccond point you'll wheep *g*

2) All this is great, and should work nicely, but now after pondering a
   little about the above, like some programmers do (others just jump
   right into it, and think about what went wrong afterwards, like me :),
   there are some system/OS dependent things.
   This is the SIZE of datatypes, i.e. a int might be 16 bytes on Linux
   and 32 on SUN systems (THIS IS NOT A FACT, PURE FICTION as an example).
   thus when you (after converting a pfile to net byte order) load it on
   the other mashine you'll get errors anyway, because the system expects
   another size/length on your datatype(s)...

Well, all this can be avoided if you convert your playerfiles and all
other binary files into a text/ascii file, either at the point where you
want to convert your binary files, or simple change all the code in the
mud to ALLWAYS use ascii/text files. This will ofcourse be a lot more
portable, but uhm.... the least secure thing I've ever seen *g*
Ofcourse you trust everyone having access to your files, so security is no
subject... Just something to think about when deciding on wether you might
want to change everything to text datafiles.

Whee... now I'm finnished with my little novell.
I didn't know squat about this untill I attemped to make a playerfile
conversion utility, and I can say, that you will be able to convert SUN
binary file to a Linux binary file format, as long as you don't need to
convert special stuff like dates etc... (Well, at least I couldn't get it
to work)... I can NOT give out any code for this, as I got pissed at my
attemps of writing the perfect code, and could'nt.. (so it's long

It's my hope, that someone will take all this to her/his heart, and come
up with some brilliant idea/code, and make it available to anyone who
needs it, as it happens a couple of times in a muds lifetime that it needs
to change site, and as allways in life, you have to be unlucky and get a
new site that does not support the previous file formats... *snicker*

Blame Intel :)


     Rasmus Rønlev DOEK'94      WWW:
     Student instructor         MUD: 5000
       Student, B.Sc in Computer Science and Business Administration.

| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   |

This archive was generated by hypermail 2b30 : 12/07/00 PST