home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / POVHELP.ZIP / source / helpdata.doc < prev    next >
Text File  |  1994-08-16  |  21KB  |  451 lines

  1.  
  2.  
  3. /****************************************************************************
  4. *                   HELPDATA.DOC - Version 1.0 - 4 July 1994
  5. *
  6. *  This document describes the format of the POVHELP database.
  7. *
  8. *  from Persistence of Vision Raytracer
  9. *  Copyright 1994 Persistence of Vision Team
  10. *  Copyright 1994 Christopher J. Cason.
  11. *---------------------------------------------------------------------------
  12. *  NOTICE: This data file is provided so that users may experiment with
  13. *  enhancements to POV-Ray and to port the software to platforms other
  14. *  than those supported by the POV-Ray Team.  There are strict rules under
  15. *  which you are permitted to use this file.  The rules are in the file
  16. *  named POVLEGAL.DOC which should be distributed with this file. If
  17. *  POVLEGAL.DOC is not available or for more info please contact the POV-Ray
  18. *  Team Coordinator by leaving a message in CompuServe's Graphics Developer's
  19. *  Forum.  The latest version of POV-Ray may be found there as well.
  20. *
  21. *  POV-Ray files may also be obtained from ftp.uwa.edu.au in pub/povray.
  22. *
  23. *  This document was written in its entirety by Christopher J. Cason.
  24. *  Its use is freely and permanently granted to the POV-Team and POV users
  25. *  under the conditions specified in POVLEGAL.DOC.
  26. *
  27. *  Author : C. J. Cason (cjcason@yarrow.wt.uwa.edu.au, CIS 100032,1644)
  28. *
  29. *****************************************************************************/
  30.  
  31.                P O V - H E L P  -  D A T A B A S E  F O R M A T
  32.                ------------------------------------------------
  33.  
  34. This file is provided to encourage people to write custom help converters
  35. rather than taking an ASCII version of POVRAY.DOC and converting it manually.
  36. Once a converter has been released, whenever we change the docs, the converted
  37. versions can be re-generated easily. The intention is that this database be
  38. ported to other, native, help formats, as well as to output formats such as
  39. LaTeX, Postscript, RTF, etc.
  40.  
  41. NOTE : All 16 and 32-bit words referenced in this document are stored in the
  42. database in Intel (least significant byte first) format.
  43.  
  44.                                 DATABASE HEADER
  45.  
  46. typedef struct
  47. {
  48.   char                  signature [8] ;
  49.   unsigned short        reader_version ;
  50.   unsigned short        database_version ;
  51.   char                  sec_number_len ;
  52.   char                  sec_title_len ;
  53.   unsigned long         flags ;
  54.   unsigned short        author_count ;
  55.   unsigned short        section_count ;
  56.   unsigned short        appendix_count ;
  57.   unsigned short        reference_count ;
  58.   unsigned long         title ;
  59.   unsigned long         title_length ;
  60.   unsigned long         copyright ;
  61.   unsigned long         copyright_length ;
  62.   unsigned long         authors ;
  63.   unsigned long         author_length ;
  64.   unsigned long         table_of_contents ;
  65.   unsigned long         table_of_contents_length ;
  66.   unsigned long         reference_index ;
  67.   unsigned long         reference_index_length ;
  68.   unsigned long         reference_string_length ;
  69.   unsigned long         references ;
  70.   unsigned long         reference_length ;
  71. } help_file_header ;
  72.  
  73. char                  signature [8] ;
  74.  
  75. Should be the string "POV-Help". Used for consistency check.
  76.  
  77. unsigned short        reader_version ;
  78.  
  79. The version of the reader needed to read the database. Version 1.0 == 100.
  80. It is possible to have a newer database version that remains compatible with
  81. older readers. This is to indicate if the reader can handle the database.
  82.  
  83. unsigned short        database_version ;
  84.  
  85. The version of the database. Version 1.0 == 100.
  86.  
  87.   char                  sec_number_len ;
  88.   char                  sec_title_len ;
  89.  
  90. These give the maximum length of the section number and title arrays later
  91. on in the database. Typically, these will be set to the length of the longest
  92. example of each of these that occurred in the input file that created the
  93. database.
  94.  
  95. unsigned long         flags ;
  96.  
  97. Currently don't do much ; later on, will be used to indicate compression, etc.
  98. Also, will be used to indicate if the database was optimised for a specific
  99. platform, what sort of graphics are embedded, etc., etc.
  100.  
  101. unsigned short        author_count ;
  102. unsigned short        section_count ;
  103. unsigned short        appendix_count ;
  104. unsigned short        reference_count ;
  105.  
  106. The number, respectively, of
  107.  
  108.   o Author entries,
  109.   o Sections,
  110.   o Appendices, and
  111.   o References
  112.  
  113. in the database.
  114.  
  115. unsigned long         title ;
  116. unsigned long         title_length ;
  117.  
  118. The absolute offset of the title text in the database file, and its length.
  119.  
  120. unsigned long         copyright ;
  121. unsigned long         copyright_length ;
  122. unsigned long         authors ;
  123. unsigned long         author_length ;
  124.  
  125. Ditto for copyright and authors.
  126.  
  127. unsigned long         table_of_contents ;
  128. unsigned long         table_of_contents_length ;
  129.  
  130. The absolute offset of the table of contents entry in the database file. Also
  131. its length.
  132.  
  133. unsigned long         reference_index ;
  134. unsigned long         reference_index_length ;
  135.  
  136. Ditto for the reference index.
  137.  
  138. unsigned long         reference_string_length ;
  139.  
  140. The length of each reference string in the reference index. Typically the
  141. length of the longest string.
  142.  
  143. unsigned long         references ;
  144. unsigned long         reference_length ;
  145.  
  146. The absolute offset of the reference array, and its length.
  147.  
  148. General Overview.
  149.  
  150. The help database consists of blocks of 'section text' - which are individually
  151. numbered subsections in the source, and include appendices - with embedded
  152. formatting and linking information. Each section can have links that point to
  153. one or several other sections. Users may browse these links.
  154.  
  155. The Table of Contents (TOC) is an array of section numbers (strings) and
  156. section titles (strings again) the length of which is given in the header.
  157. Associated with each entry in the TOC is the absolute 32-bit offset of the
  158. relevant section in the database itself.
  159.  
  160. typedef struct
  161. {
  162.   unsigned long         section ;
  163.   unsigned long         section_length ;
  164.   char                  is_appendix ;
  165.   char                  spare ;
  166. } TOC_entry ;
  167.  
  168. Each entry in the TOC follows this format - the Section offset in the database,
  169. followed by the length of the section, followed by a flag indicating if the
  170. section is an appendix or not. Appendices are not treated very much differently
  171. from non-appendices ; the difference mainly relates to how they are presented
  172. to the ultimate user. NOTE : if your compiler pads structures out to word or
  173. double-word boundaries, be sure (when reading the data from the database) to
  174. read the correct amount of data, which is 10 bytes. (Though I suppose it won't
  175. hurt to read more, as long as you seek back to the correct location.)
  176.  
  177. Immediately following the appendix flag is a character array whose length is
  178. given by the header field 'sec_number_len'. This field contains the ASCII
  179. representation of the section or appendix number, in the form '1.2.3', or
  180. 'E.1', for example. Only as many decimal points as needed are used.
  181.  
  182. Immediately following the section number is the section title. Again, the length
  183. of this array is given in the header, by the field 'sec_title_len'.
  184.  
  185. After this array, the next section entry starts, with no padding.
  186.  
  187. Title
  188.  
  189. The title is plain ASCII text, LF delimited.
  190.  
  191. Authors
  192.  
  193. The authors section is a sequence of LF delimited lines, NULL (0x00) separated
  194. between each author's entry.
  195.  
  196. Copyright
  197.  
  198. The copyright section is formatted in a fashion similar to that of the sections,
  199. using the same codes. However, hypertext links are not supported.
  200.  
  201. References
  202.  
  203. The Reference Index is an array of 32-bit double words which represent offsets
  204. into the database. At the location indicated by each offset is the actual
  205. variable-length reference represented by the index into the array of offsets.
  206.  
  207. The reference itself is preceded by a 16-bit word known as the 'child count'
  208. which gives a count of actual targets for this index, minus one. Each target is
  209. represented by a 32-bit double word which gives the offset into the file of the
  210. targeted text. This may be at the start of or anywhere within a section or
  211. appendix.
  212.  
  213. Typically, the first target will be the most important one and for systems that
  214. only support one target (or 'link') for each reference, this is the one to
  215. choose. Subsequent ones (if the child count is > 0) will be to other sections in
  216. the document which bear relation to the subject being referenced.
  217.  
  218. Remember, the child count gives the number of targets minus one. That is to say,
  219. there is always at least one target (the 'parent') and any subsequent ones are
  220. 'children'. If the child count is 0, there are no children and only one 32-bit
  221. double word will be present.
  222.  
  223. The section on 'Sections' gives more information on references.
  224.  
  225. Sections
  226.  
  227. The section text is a aggregation of ASCII text with special control codes
  228. embedded. Control codes are between 0xe0 and 0xff. LF characters only appear
  229. when a literal LF is required in the text (i.e. the CODE FRAGMENT or PRESERVE
  230. FORMATTING keywords were used in the source text.) Lines are 'long', i.e., they
  231. have had normal line feeds stripped out ; it is the help reader's job to wrap
  232. the lines properly for the output medium in use.
  233.  
  234. Also embedded in the text are references and targets. A reference is a pointer
  235. to a target, a target is something that a reference points to. Targets can
  236. have multiple references pointing to them, and a single reference can have
  237. multiple targets.
  238.  
  239. Take, for example, a reference to the word 'Sphere' in the POV-Ray documentation.
  240. The word 'sphere' would be highlighted at the location of the reference,
  241. indicating that link jumping is possible. If the user selects that reference,
  242. the reader would jump to the first target for that reference, which might be
  243. the definition of the 'Sphere' primitive. Any subsequent targets would be of
  244. lesser importance, perhaps other examples of the usage of that keyword. This
  245. is important, because some hypertext systems can only handle one target for
  246. each reference, and as such the author of the converter program has to be able
  247. to select the most appropriate target if more that one is defined.
  248.  
  249. In the source of the document, each target has a 'priority'. This defaults to
  250. a given value, depending on the context, if one is not specified. After parsing
  251. the document, each target with the same name is first sorted in order of
  252. priority, and then in order of appearance. The author of the document would
  253. presumably make the most important target of the highest priority.
  254.  
  255. All section and appendix titles and numbers are automatically made targets,
  256. and given a higher priority than the default. In the absence of an explicit
  257. override by the author, these targets will appear first in the list of targets.
  258.  
  259. As well as being used for hypertext jumping, targets have their original ASCII
  260. names (as defined in the source text) stored in the database so that they may
  261. be used for keyword searches. (In the section text, targets are identified by
  262. index and not by name.)
  263.  
  264. Currently, the sections have the concept of embedded line drawings. These are
  265. typically ASCII art and are delimited in the text so that an appropriate fixed-
  266. pitch font can be selected by the display program. At a later stage, these will
  267. go away and be replaced by a reference to the image database that will be bound
  268. into the help file. The original ASCII art will be found there, along with IBM
  269. line drawings, monochrome bitmaps, colour bitmaps, or whatever the author has
  270. defined in the source. The reader will be able to choose whichever is best for
  271. its particular output format.
  272.  
  273.                                 Embedded Codes
  274.  
  275. If any code is escaped by the ESCAPE code, it loses any special meaning.
  276. Note that the 'ESCAPE' code referred to here is not an ASCII escape (0x1b) but
  277. the code defined in HELP.H as 'ESCAPE'.
  278.  
  279. See HELP.H for the current definition of each code. These have changed since
  280. the first beta of POV-Help so make sure you've got a current database. [The
  281. old one has a different signature in its header so you'll know it.]
  282.  
  283. BOLD_ON         BOLD_OFF
  284. ITALIC_ON       ITALIC_OFF
  285. HEADING_ON      HEADING_OFF
  286. HIGHLIGHT_ON    HIGHLIGHT_OFF
  287. UNDERSCORE_ON   UNDERSCORE_OFF
  288.  
  289. The above codes are used for formatting. For example, prior to a sentence that
  290. should appear in bold in the output, the BOLD_ON code will appear. When the bold
  291. text ends, the BOLD_OFF code shall appear.
  292.  
  293. The heading code refers to a 'sub-heading' within a section. How you format it
  294. is up to you. You may like to centre the text if it is on a line of its own.
  295.  
  296. Highlight means that he document author wants to show up the text given in a way
  297. other than bold, italic, or underline. Inverse text may be a good idea.
  298.  
  299. NOTE : in the existing database, HIGHLIGHT is used extensively, whereas ITALIC
  300. and UNDERSCORE aren't used at all. This will change shortly, so please make sure
  301. you support them. I suggest you display or print highlight as bold with
  302. underscore, or whatever looks OK under the circumstance, until it is changed.
  303. [Most of the existing highlighted text will be replaced with bold/underscore.]
  304.  
  305. LINE_ON         LINE_OFF
  306.  
  307. These relate to line drawings. They contain standard 7-bit ASCII characters, and
  308. need to be displayed or printed in a fixed-pitch font.
  309.  
  310. CODE_ON         CODE_OFF
  311.  
  312. This delimits a code fragment, i.e., a fragment of source code or some such
  313. thing. They are no different to line drawings (in that their formatting needs
  314. to be preserved and that a fixed-pitch font needs to be used) but they are
  315. delimited as such because -
  316.  
  317.   1) in printed text, different font conventions may be used for code, and
  318.   2) on-line help readers may give the option of pasting the code.
  319.  
  320. For example, although it isn't documented, the ALT-TAB sequence in the DOS
  321. help reader will highlight the current code fragment. This is preparatory to
  322. allowing the code itself to be pasted via the keyboard buffer.
  323.  
  324. PRESERVE_ON     PRESERVE_OFF
  325.  
  326. Preserve refers to 'preserve formatting', a catch-all for any other text in the
  327. source that needs to be displayed in a fixed-pitch font and for which no word-
  328. wrapping should be performed. In all of the above cases, a single LF will end
  329. a line of text.
  330.  
  331. TABLE_ON        TABLE_OFF
  332.  
  333. Currently, Tables are just treated the same as PRESERVE, so please use them
  334. that way. Later on we may change that. Tables are intended for multi-column
  335. data that needs to be aligned in some special way.
  336.  
  337. REFERENCE    REFERENCE_ON    REFERENCE_OFF
  338.  
  339. The Reference code is followed by a 16-bit word giving the reference index.
  340. This value represents a index into the array of references as described earlier.
  341. When this appears in the text of a section, it means that the following word(s)
  342. (as delimited by REFERENCE_ON and REFERENCE_OFF) represent a link to the target
  343. given by the reference index. If the user highlights (or clicks on) the word(s),
  344. the help reader should jump to the first target.
  345.  
  346. REFERENCE_ON and REFERENCE_OFF are used to delimit the text referred to by a
  347. previous REFERENCE, and an online help reader should display the text using
  348. whatever conventions exist for that particular platform.
  349.  
  350. If the output medium is hard copy, and you want to be particularly clever,
  351. you may like to generate a reference to a footnote here, which in turn will
  352. provide a 'see section xxx on page yyy' type message. The difficulty here is
  353. in determining the page numbers in advance (if it is a forward jump) and that
  354. is left as an exercise for the reader. It may be necessary to scan the input
  355. file twice. Alternatively, if you know you are outputting to a file, you may
  356. like to enter dummy data and return later to fix it up with the real page.
  357.  
  358. LIST_ON         LIST_OFF        LIST_ENTRY_ON   LIST_ENTRY_OFF
  359.  
  360. A List is considered a table with two columns - one with the list delimiters,
  361. and the other with the text. For example, all of these are lists -
  362.  
  363.   +Iname                  use alternate file name (default HELP.HLP)
  364.   +N123                   go to the 123rd section {/HIL/} (NOT section 123!)
  365.   +S4.5.6                 go to section '4.5.6'
  366.   +Tsphere or "+Tsphere"  go straight to the first section found with
  367.  
  368.   Up, Down    move highlight bar
  369.   Enter       view selected item
  370.   Escape      exit help viewer
  371.  
  372.   *   Standard include files that pre-define many shapes, colors and textures
  373.   *   Shapes can easily be combined to create new complex shapes. This
  374.       feature is called Constructive Solid Geometry (CSG). POV-Ray
  375.       supports unions, merges, intersections and differences in CSG.
  376.   *   Objects are assigned materials called textures.  (A texture describes
  377.       the coloring and surface properties of a shape.)
  378.  
  379. As you can see, you need to know the length of the longest of the left part
  380. of the table so you know how far to indent the right. In the help database,
  381. the entire list will be bracketed with a LIST_ON and LIST_OFF. Immediately
  382. following the LIST_ON will be a single 8-bit value giving the number of
  383. character units to indent the right-hand column for that list. If you are
  384. using a proportional font, you may want to read the entire list to come up
  385. with a more appropriate value, rather than use the indent value times the
  386. maximum (or average) character width for the font you are using.
  387.  
  388. The 'List Entry' is considered the left hand side of the table, i.e., the left
  389. column. Each of these (whether one single character or a whole sentence) is
  390. bracketed with a LIST_ENTRY_ON and LIST_ENTRY_OFF. Anything after a OFF is part
  391. of the right-hand column of the portion contained in the list entry. You should
  392. not find any line feeds in this text ; it is up to you to align it correctly.
  393.  
  394. [Note that some beta versions of the database have a LF immediately after the
  395. length byte following the LIST_ON. This should be ignored.]
  396.  
  397. PARAGRAPH
  398.  
  399. A Paragraph code indicates the end of a paragraph. In the context of the help
  400. system, it is considered the same as a hard line feed followed by a blank line.
  401.  
  402. More specifically, if the current character position is not at the left-hand
  403. side of the output medium, perform a LF. Then, in either case, perform another.
  404.  
  405. INDENT
  406.  
  407. The Indent code means you should indent the text following the code by whatever
  408. is considered the standard for your output medium. The indent should apply for
  409. the current line only ; that is, until the next LF or Paragraph code.
  410.  
  411. TARGET
  412.  
  413. The Target code delimits a location where a target exists. You don't really
  414. need to do anything about this, so just ignore them.
  415.  
  416.                                   CONVENTIONS
  417.  
  418. Currently, there's no way to really tell what text belongs in which document.
  419. For example, the help database has instructions for using the DOS online help
  420. reader built in, and a FAQ at the end also. Obviously, you don't want to print
  421. that information on hardcopy. Later on, the database will include information
  422. that indicates the nature of each section so you can decide whether to include
  423. it or not. Properly, help for the online help reader should be built into it
  424. and not into the database, and eventually this will be the case. For now,
  425. though, use this convention -
  426.  
  427.   o ignore any section with a section number of less than 1.0. the help for
  428.     the help reader has the section number 0.0.
  429.   o optionally ignore any sections after a section that has the title
  430.     'FREQUENTLY ASKED QUESTIONS' as these are not part of POVRAY.DOC.
  431.  
  432.                                    EXAMPLES
  433.  
  434. Please peruse the source of POVHELP.EXE for an example of an online help reader.
  435. POVHELP may be suitable for porting as it maintains its output in a virtual
  436. screen, the width and length of which can be set from the command line.
  437.  
  438. Please also peruse the source of PHE2TXT.EXE. This is a program derived from
  439. POVHELP that reads the database and outputs a title, table of contents, and
  440. plain ASCII text sections in a page width of the users specification. This
  441. program keeps 'attributes' for each character according to bit flags defined
  442. in HELP.H, which define bold, underline, etc., but doesn't actually use them.
  443. This program may be suitable for porting as the basis of a hardcopy output
  444. converter, provided that the hardcopy uses fixed-pitch characters.
  445.  
  446. PHE2RTF.C is a better (albeit not yet working) example of a converter. It has
  447. all the code needed to read the POV-Help database and issue the appropriate
  448. formatting codes ; the only problem with it is that the RTF it issues is not yet
  449. compatible with Microsoft Word. But that doesn't stop it being used as a basis
  450. of a converter to another format.
  451.