home *** CD-ROM | disk | FTP | other *** search
/ Arawak OS/2 Shareware / PAKLED.ISO / program / inf01.doc < prev    next >
Text File  |  1992-10-21  |  10KB  |  270 lines

  1.  
  2.   Having become extremely frustrated by VIEW.EXE's penchant for windows
  3.   that come and go, without even opening large enough to see everything
  4.   in them, I thought I'd try to turn .INF files into something more
  5.   conventional.  While I don't have code to offer, I can tell you what I
  6.   learned about .INF format--it was enough to produce more-or-less
  7.   readable more-or-less plaintext from .INFs.
  8.   
  9.   I offer this in the hope that somebody will give the community a
  10.   really nice, tasteful, convenient, doesn't-use-too-much-screen-real-estate 
  11.   .INF browser to replace VIEW.EXE.
  12.   
  13.   All of this was developed by looking at .INF files without any
  14.   documentation of the format except what VIEW.EXE showed for a
  15.   particular feature.
  16.  
  17.   I don't have a lot of personal interest in refining this document with
  18.   additional escape sequences, etc., but I would be happy to correspond
  19.   with someone who wanted to fill in the details, or to clarify anything
  20.   that may be confusing.  If someone could point us to an official document
  21.   describing the format that would be most helpful.
  22.  
  23.   -- Carl Hauser (chauser.parc@xerox.com)
  24.   
  25.   All numeric quantities are least-significant-byte first in the file
  26.   (little-endian). 
  27.   
  28.   **** Types ****
  29.  
  30.      bit1    1 bit boolean
  31.      int4    4 bit unsigned integer
  32.      char8    8 bit character (ASCII more-or-less)
  33.      int8    8 bit unsigned integer
  34.      int16    16 bit unsigned integer
  35.      int32    32 bit unsigned integer 
  36.      
  37.   **** The File Header ****
  38.   
  39.       Starting at file offset 0 the following structure can overlay the file
  40.       to provide some starting values:
  41.       {
  42.         char8 unknown[8];    // unknown purpose
  43.         int16 ntoc;        // 16 bit number of entries in the tocarray
  44.         int32 tocstart;     // 32 bit file offset of the start of the tocarray
  45.         int32 tocstrlen;    // number of bytes in file occupied by the
  46.                 // table-of-contents strings
  47.         int32 tocstrtablestart;    // 32 bit file offset of the start of the
  48.                     // strings for the table-of-contents
  49.         int16 nslots;    // number of "slots"
  50.         int32 slotsstart;    // file offset of the slots array
  51.         int32 dictlen;    // number of bytes occupied by the "dictionary"
  52.         int16 ndict;    // number of entries in the dictionary
  53.         int32 dictstart;    // file offset of the start of the dictionary
  54.       }
  55.       I think there's more to the header and that it describes the index,
  56.       but I didn't decode that.
  57.     
  58.   **** The table of contents array ****
  59.   
  60.       Beginning at file offset tocstart, this structure can overlay the
  61.       file:
  62.       {
  63.           int32  tocentrystart[ntoc];    // array of file offsets of
  64.                         // tocentries
  65.       }
  66.   
  67.   **** The table of contents entries ****
  68.   
  69.       Beginning at each file offset, tocentrystart[i]:
  70.       {
  71.          int8 len;        // 8 bit length of the entry including this byte
  72.          bit1 haschildren;    // following nodes are a higher level
  73.          bit1 hidden;    // this entry doesn't appear in VIEW.EXE's
  74.                 // presentation of the toc
  75.          bit1 extended;    // extended entry format
  76.          bit1 stuff;    // ??
  77.          int4 level;     // nesting level
  78.          int8 ntocslots;    // number of "slots" occupied by the article for
  79.                 // this toc entry
  80.       }
  81.  
  82.       if the "extended" bit is not 1, this is immediately followed by 
  83.  
  84.       {
  85.          int16 tocslots[ntocslots];    // indices of the slots that make up
  86.                     // the article for this entry
  87.          char8 title[];        // the remainder of the tocentry               
  88.                     // until len byteshave been used
  89.       }
  90.  
  91.       if extended is 1 there are intervening bytes that (I think) describe
  92.       the kind, size and position of the window in which to display the
  93.       article.  I haven't decoded these bytes, though in most cases the
  94.       following tells how many there are.  Overlay the following on the next
  95.       two bytes
  96.       { 
  97.          int8 w1;
  98.          int8 w2;
  99.       }
  100.  
  101.       Here's a C code fragment for computing the number of bytes to skip
  102.       int bytestoskip = 0; 
  103.       if (w1 & 0x8) { bytestoskip += 2 };
  104.       if (w1 & 0x1) { bytestoskip += 5 };
  105.       if (w1 & 0x2) { bytestoskip += 5 };
  106.       if (w2 & 0x4) { bytestoskip += 2 };
  107.  
  108.       skip over bytestoskip bytes (after w2) and find the tocslots and title
  109.       as in the non-extended case.
  110.   
  111.   **** The Slots array ****
  112.   
  113.       Beginning at file offset slotsstart (provided by the file header) find
  114.       {
  115.          int32 slots[nslots];    // file offset of the article
  116.                     // corresponding  to this slot
  117.       }
  118.   
  119.   **** The Dictionary ****
  120.   
  121.       Beginning at  file offset dictstart (provided by the file header) and
  122.       continuing until ndict entries have been read (and dictlen bytes have
  123.       been consumed from the file) find a sequence of null-terminated
  124.       strings.  Build a table mapping i to the ith string.
  125.       {
  126.          char8*    strings[ndict];
  127.       }
  128.   
  129.   **** The Article entries ****
  130.   
  131.       Beginning at file offset slots[i] the following structure can overlay
  132.       the file:
  133.       {
  134.          int8     stuff;        // ??
  135.          int32     localdictpos;    // file offset of the local dictionary
  136.          int8    nlocaldict;    // number of entries in the local dictionary
  137.          int16    ntext;        // number of bytes in the text
  138.          int8    text[ntext];    // encoded text of the article
  139.       }
  140.  
  141.   **** The Local dictionary ****
  142.  
  143.       Beginning at file position localdictpos (for each article) there is an
  144.       array:
  145.       {
  146.          int16    localwords[nlocaldict];
  147.       }
  148.   
  149.   **** The Text ****
  150.   
  151.       The text for an article then consists of words obtained by referencing
  152.       strings[localwords[text[i]]] for i in [0..ntext), with the following
  153.       exceptions.  If text[i] is greater than nlocaldict it means
  154.      0xfa => end-of-paragraph
  155.      0xfc => if in-an-example then end-of-line 
  156.          else  spacing =  !spacing             // see below
  157.      0xfd => if in-an-example then end-of-line else spacing = TRUE
  158.      0xfe => space
  159.      0xff => escape sequence                 // see below
  160.      
  161.       When spacing is true, each word needs a space put after it.  When
  162.       false, the words are abutted and spaces are supplied using 0xfe or the
  163.       dictionary.  Examples are entered and left with 0xff escape sequences.  
  164.       the variable "spacing" is initially TRUE..
  165.  
  166.   **** 0xff escape sequences ****
  167.  
  168.       These are used to change fonts, make cross references, enter and leave
  169.       examples, etc.  The general format is
  170.       {
  171.          int8    FF;         // always equals 0xff
  172.          int8    esclen;        // length of the sequence including esclen (but
  173.                     // excluding FF)
  174.          int8    escCode;    // which escape function
  175.       }
  176.  
  177.      escCodes I have partially deciphered are
  178.     
  179.       0x02 or 0x11 =>    (esclen==3) goto horizontal position.
  180.                 The remaining byte is an int8
  181.                 describing the position.  0x00 is the
  182.                 left margin and starts a new line; I
  183.                 don't know the units for other values.
  184.  
  185.       0x04 =>         (esclen==3) change font.  The
  186.                 remaining byte is an int8 denoting the
  187.                 font: I've determined 0x00 is normal,
  188.                 0x01 is italic and 0x02 is bold in
  189.                 VIEW's presentation.
  190.     
  191.       0x05 or 0x07 =>     (esclen varies) beginning of cross
  192.                 reference.  The next two bytes of the
  193.                 escape sequence are an int16 index of
  194.                 the tocentrystart array.  The
  195.                 remaining bytes describe the size,
  196.                 position and characteristics of the
  197.                 window created when the
  198.                 cross-reference is followed by VIEW.
  199.                 I have not decoded this.
  200.  
  201.       0x08 =>         (escLen==2) end of cross reference
  202.                 introduced by escape code 0x05 or 0x07
  203.     
  204.       0x0B =>         (escLen==2) begin example.  set
  205.                 spacing to FALSE
  206.       
  207.       0x0C =>         (escLen==2) end example.  set spacing
  208.                 to TRUE
  209.       
  210.       0x0F =>         if esclen==5 an inlined cross
  211.                 reference: the title of the referenced
  212.                 article becomes part of the text.
  213.                 This is probably the case even if
  214.                 esclen is not 5, but I don't know the
  215.                 decoding.  In the case that esclen is
  216.                 5, I don't know the purpose of the
  217.                 byte following the escCode, but the
  218.                 two bytes after that are an int16
  219.                 index of the tocentrystart array.
  220.       
  221.       0x19 =>         (esclen==3) change font?  I haven't
  222.                 checked VIEW's decoding of the next
  223.                 byte.  I used the same decoding as for
  224.                 0x04
  225.       
  226.       0x1C => (escLen==2)    I don't know it's function. I just ignored it.
  227.       
  228.       I doubt that this is an exhaustive list of the possible escape codes,
  229.       but it covers most of what I found in the Control Program,  REXX, and
  230.       CSet/2 references.  With a little more work and some playing with the
  231.       info compiler to produce (chosen-plaintext, ciphertext) pairs it
  232.       shouldn't be hard to pick out the whole decoding including the window
  233.       positions.
  234.   
  235.       One other transformation I had to make was of the character box
  236.       characters.  Maybe these are standard but they weren't in the font I
  237.       was using.  These characters appear in strings in the dicitonary. 
  238.       They are given here in octal together with their translation
  239.       
  240.       020, 021    => blank seems satisfactory
  241.       037         => solid down arrow: used to give direction to
  242.                 a line in the syntax diagrams
  243.       0263         => vertical bar
  244.       0264         => left connector: vertical bar with short
  245.                 horizontal bar extending left from the
  246.                 center
  247.       0277, 0300     => top right or bottom left corner; one is
  248.                 one, the other is the other and I
  249.                 can't tell which from my translation
  250.       0301         => up connector: horizontal line with vertical
  251.                 line extending up from the center
  252.       0302         => down connector: horizontal line with
  253.                 vertical line extending down from the
  254.                 center
  255.       0303         => right connector: vertical bar with short
  256.                 horizontal bar extending right from
  257.                 the center
  258.       0304         => horizontal bar
  259.       0305         => cross connector, i.e. looks like + only
  260.                 slightly larger to connect with
  261.                 adjacent chars
  262.       0331, 0332     => top left or bottom right corner; one is
  263.                 one, the other is the other and I
  264.                 can't tell which from my translation
  265.                 
  266.                 
  267. History:
  268. October 22, 1992: version for initial posting
  269.  
  270.