Re: infinint, libdar
Denis Corbin <[email protected]>
| Newsgroups | gmane.comp.sysutils.backup.dar.general |
|---|---|
| Organization | none |
| Message-ID | <[email protected]> |
I thought I had replied to this mail, but cannot find my answer in the mailing-list archive, so if I didn't replied sorry to reply so late ! The infinint when saved in file (in archive) are a variable byte field representing the integer in network byte order. To determine how much byte it has of length, this field is preceded by a header of variable length, which is called "preamble" in the comments of the code (see real_infinint.cpp and the infinint::dump() method for details). This preamble contains only one bit set to one. This bit is located in the last byte of the preamble. So while we read 0x00 the preamble is not finished, when we reach a non null byte, this is the end of the header, and this byte must have only one bit set to one. If we count the number of bit (not byte) that have been read and which are set to zero before this bit set to 1, we get the size of the infinint field that follows the preamble in TG unit. A TG is actually fixed to 4 byte. I don't remember well where from I took "TG" for, G for Group, and T maybe for Tributary ? TG = Tributary Group ? OK It was quite three years ago (July 2001), and I had not to fix any bug in this part since that time ! By the way, there is room to have the preamble of infinint changed its structure, by giving a first byte containing two or more bits set to one... actual code detects this condition and consider this is a format it does not know, or a data corruption. Let's take an example, in memory we have an infinint of 5 bytes (0x FA.79.00.12.34, in network order), so we need two TG, to store it, (8 bytes), the preamble is then 0x40 (it would have been 0x80 for 1 TG, or 0x00.80 for 9 TG (for a 36 bytes integer!) for example) We must add tree bytes of padding to have the integer field be exactly 2 TG (=8 bytes) and not 5 bytes only, as it is in memory. So the resulting string written in file is: 0x40.00.00.00.FA.79.00.12.34 ----+--------+--------------+ Pre.| Padding| integer field| ----+-----------+-----------+ Pre.| 1 TG | 1 TG | the dot '.' in this notation separate each byte. Wesley Leggette wrote: > In libdar, it's my impression that infinint's are dumped like this: > > 0x00 + bit pattern - header indicating how long the infinint is > byte fields - actual data in network byte order > > I'm having a hard time trying to figure out how exactly the header is > formed. > > As a school project, I'm working on implementing a dar library in java, > hence the above question. > > Also, I'd like to be able to use individual parts of libdar (to compare > libdar output with what I write in java). Is it best to set up a > generic_file and then call various dump() functions, or is there an > easier way? > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IBM Linux Tutorials > Free Linux tutorial presented by Daniel Robbins, President and CEO of > GenToo technologies. Learn everything from fundamentals to system > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click