Re: Storing variable length data in file -- Paging

From: Walter Roberson (roberson_at_ibd.nrc-cnrc.gc.ca)
Date: 02/26/05


Date: 26 Feb 2005 17:13:40 GMT

In article <42208920.E344C9CC@yahoo.com>,
CBFalconer <cbfalconer@worldnet.att.net> wrote:
:A simpler scheme is to assign the high bit of each byte to mean
:'more', and extract 7 bits per byte. This would be something like:

: #define HIBIT 128

Minor phrasing nit. For this scheme, you do not want to assign
the "high" bit of each byte to mean 'more', you want to assign
a -fixed- platform-independant bit for that purpose. Which is
what your code does.

: ch = getc(f); value = 0;

This discussion leads me to ponder platform independance of the
database a bit more.

I do not have my copy of the C89 standard with me and cannot get
it today (building construction work), so perhaps someone could
answer to these points?

a) getc() is defined in terms of 'characters'. For this purpose,
is 'character' equivilent to 'byte' (that is, basic fetchable
units), or is 'character' potentially a multi-byte entity
(e.g., unicode). [I've probably been reading too much about
perl streams...]

b) Are fread() and fwrite() defined in terms of specific numbers
of bits per byte? If not, then if a file is written using
fwrite() on one platform, and is then taken to another platform,
the data that is read in may not have the same byte or character
boundaries. The result would then depend upon the nature of the
process of "taking it to another platform" (e.g., if I recall
correctly, ftp would normally do bytewise renormalization). This,
of course, in addition to the usual problem that
fwrite( (char *)&value, sizeof(value), 1, STREAM) is going to
write in a platform-dependant byte order.

I guess all this was why xdr was invented...

-- 
Admit it -- you peeked ahead to find out how this message ends!


Relevant Pages

  • Re: different struct sizes
    ... (as a particular platform defines the word "byte") ... When I ported lcc-win32 to a DSP, ... Each character took *one* byte. ... so stdio support isn't ...
    (comp.lang.c)
  • Re: include file rule
    ... except the new-line character and " '. ... inside quotation marks in my source code in #include directives. ... But what if I give you my source to port to some platform where these ... include files and source files when you put them on your file system. ...
    (comp.lang.c.moderated)
  • Re: getline and CR, LF, CR/LF, VS/Linux
    ... > What is the correct method for handling text files which may ... > have a CR character at the end of each line? ... one platform format and try reading in another, ...
    (microsoft.public.vc.stl)
  • Re: Bolton station
    ... The station has character, and long may it continue to do so! ... That's not the word that comes to mind when waiting for a connection ... I think most of the character disappeared with the ridiculous 80s ... to the bus station but not when you want to get from platform 1 to ...
    (uk.railway)
  • Re: [PATCH 4/5] Convert PowerPC MPC i2c to of_platform_driver from platform_driver
    ... drivers and instead develop a framework for instantiating platform ... I have to work with what is in the kernel tree so this patch is based ... when a new scheme is adopted the drivers should be converted then. ...
    (Linux-Kernel)

Loading