home *** CD-ROM | disk | FTP | other *** search
/ Frostbyte's 1980s DOS Shareware Collection / floppyshareware.zip / floppyshareware / BOUT / INTRFC.ZIP / INTRFC.DOC < prev    next >
Text File  |  1988-05-07  |  6KB  |  134 lines

  1. INTRFC - Program to print interface information for TPU files. (May, 1988) 
  2.  
  3. Written for the public domain by D.J. Murdoch (CIS 71631,122 or 
  4. Fidonet 163/14:DJ MURDOCH) 
  5.  
  6. INTRODUCTION
  7.  
  8.      I started INTRFC because I got a library of Turbo Pascal 4.0 
  9. subroutines from a bulletin board which had some errors in the 
  10. documentation.  One of the functions wanted its arguments to be a 
  11. special type, but the doc's didn't tell me which one.  TP gave me 
  12. an error message saying I wasn't using the right type, but 
  13. wouldn't tell me which one to use either.  I decided to decode 
  14. the TPU file and figure out what TP wanted.  Once I got started, 
  15. it was hard to stop.  So, I ended up writing INTRFC, which prints 
  16. out almost all the information you'll ever need about the 
  17. interface to a TPU unit.  (You can also get information about 
  18. units in TPL's; see below.) 
  19.  
  20.      Because of the way it was written, i.e. entirely by 
  21. guesswork, I'm sure there are numerous special cases that it 
  22. doesn't handle properly.  That's one reason the source code is 
  23. there - so other people can fix up my mistakes.
  24.  
  25.      The other reason I included source code is because it will 
  26. serve as a bit of documentation for the TPU file format while we 
  27. all wait for Borland to publish it.  (I imagine they want to be 
  28. free to change the format before they publish it, making INTRFC 
  29. obsolete when TP 4.1 arrives.)  Others who want to do completely 
  30. different things to a TPU file may benefit from reading it.  (The 
  31. other difficulty with a program written the way this one was is 
  32. that comments are almost non-existent.  If you have any short 
  33. questions about it that you can't figure out, send them to me at 
  34. one of the addresses above.) 
  35.  
  36. USAGE:  INTRFC [unit path]
  37.  
  38.      The user interface (sorry!) to INTRFC is really primitive.  
  39. Just run it without any arguments, and answer the prompt for a 
  40. unit.  Don't type the ".TPU".  It expects to find any referenced 
  41. units in the current directory.  Or, if you like, specify a path 
  42. on the command line where it can find the other units.  (It needs 
  43. to look in them for names and types sometimes).  This path should 
  44. also contain the TURBO.TPL file containing the system units.
  45.  
  46.     After it prints the interface to the unit you specify, it 
  47. will ask for another one.  To quit, you'll have to hit break or 
  48. Ctrl-C. (F6 or Ctrl-Z might also work, by crashing it.)  Both 
  49. input and output can be redirected using "<" and ">".  (Watch out 
  50. though, the prompts get redirected too.  I warned you it was 
  51. primitive.) 
  52.  
  53. TPU STRUCTURE 
  54.  
  55.     Below are some notes on the general structure of a TPU file.  
  56. For more detail, see the source code.  When I named something 
  57. there with a totally obscure name (like i1, or ofs1) it generally 
  58. meant that I don't have any idea what it was for. 
  59.  
  60.     There are three parts to a TPU file - the symbol area, the 
  61. code area, and the data area.  (TPUMOVER will tell you how big 
  62. each is.)  INTRFC only looks at the symbol area.
  63.  
  64.     At the start of it, there's a table giving sizes and offsets 
  65. of important parts of the file.  Most important is the hash table 
  66. - it gives the addresses (16 bit pointers) of many of the objects 
  67. that are defined in the interface block.  (The hash function 
  68. seems to be a simple one.  Letters A-Z and a-z get mapped to 0-
  69. 25, underscores and digits get their ascii codes, and longer 
  70. strings get the sum of the codes of their characters, modulo the 
  71. table size).  In case of a collision (i.e. hash(object 1) = 
  72. hash(object 2) ), there's a pointer at the beginning of each 
  73. object to the next one with the same hash value.
  74.  
  75.     Things being defined are stored in variations on 2 or 3 
  76. kinds of record.  The main storage is as what I call an Object.  
  77. This gives a pointer to the next object with the same hash 
  78. number, the name of the object, and is followed by the 
  79. Information.  The Information defines what "kind" of object this 
  80. is, i.e. a variable, type, constant, etc.  It also gives some 
  81. information about the object, often including references to the 
  82. third kind of record, the Type Definitions.  These are like 
  83. Information records, subdividing the various types, e.g. array, 
  84. string, set, etc. 
  85.  
  86.     All variables have an offset.  If they are part of a record, 
  87. this is the offset within the record.  If not, then I assume 
  88. these are the offsets in the data segment (but haven't checked).
  89.  
  90. TPL STRUCTURE 
  91.  
  92.     TPL files have a very simple structure.  They seem to be just 
  93. a collection of TPU files strung together.  (The header might be 
  94. slightly varied; I'm not sure.)  You can thus get INTRFC to print 
  95. the interface to the units in a TPL without a lot of trouble.  
  96. Just look through the file for the characters "TPU0".  These 
  97. signal the start of a new unit.  Chop the file just before these 
  98. strings, and save the pieces in files named *.TPU.  INTRFC will 
  99. work on these pieces.  (If you're only interested in the first 
  100. one, you don't even need to chop.  Just make a copy with 
  101. extension TPU.)
  102.  
  103. LIMITATIONS
  104.  
  105.     There are tons of limitations to INTRFC.  It doesn't know how 
  106. to print any but the simplest types of constants.  It won't print 
  107. the values of typed constants.  It won't read files bigger than 
  108. 64K.  Etc. Etc. Etc.  If you want it to do something differently 
  109. just go ahead and change it!  I recommend compiling with all 
  110. possible checks turned on, since it's pretty easy to get lost in 
  111. all those pointers.  
  112.  
  113. FILES
  114.  
  115. The following files should be included in this package.
  116.  
  117. INTRFC.DOC      - This file.
  118. INTRFC.EXE      - The executable program.
  119. GLOBALS.PAS     - The global declarations.
  120. HASH.PAS        - The routines to walk through the hash table, and 
  121.                   to get units 
  122. INTRFC.PAS      - The main program. 
  123. OBJSTUFF.PAS    - The various routines for printing objects. 
  124. TEST1.PAS       - A test unit. 
  125. UTIL.PAS        - Various utility routines. 
  126.  
  127. THAT'S IT!
  128.  
  129.      Have fun with INTRFC and Turbo Pascal.  I'd like to hear of 
  130. any novel uses. 
  131.  
  132. D.J. Murdoch
  133.  
  134.