home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / ZCPR33 / Z3-33 / Z33PNOTE.003 < prev    next >
Text File  |  2000-06-30  |  10KB  |  192 lines

  1.                           ZCPR33 PROGRAMMING NOTES
  2.                           ========================
  3.  
  4. Note Number:    003
  5. Author:         Jay Sage
  6. Date:           June 6, 1987
  7.  
  8.  
  9.                         The ZCPR33 File Name Parser
  10.  
  11.  
  12.      There are two special aspects to the file name parser in ZCPR33.  First 
  13. of all, the command processor provides three standard entry points, similar 
  14. to those provided by the BIOS, so that external programs can make use of the 
  15. parsing code inside the command processor.  Secondly, the result of the 
  16. parsing is designed to provide much more information, such as whether or not 
  17. a directory was specified explicitly and, if so, whether or not the 
  18. directory was a valid one.  Let's take up these two features one at a time.  
  19. Note that routines are (or will be) provided in Z33LIB to perform these 
  20. functions easily.
  21.  
  22.  
  23. The Parser Entry Points
  24. -----------------------
  25.  
  26.      The beginning of the command processor has the following structure:
  27.  
  28.    offset       code
  29.    ------       ----
  30.      0H         JP      actual code
  31.      3H         JR      actual code
  32.      5H         DB      version byte
  33.      6H         DS      ten configuration information bytes
  34.     10H         LD      HL,token pointer
  35.     13H         JP      PARSETAIL
  36.     16H         JP      SCANNER
  37.     19H         command dispatch table
  38.  
  39.      The routine whose entry point is at offset 16H parses a single file 
  40. specification string pointed to by HL into a file control block pointed to 
  41. by DE.  Two important precautions must be observed.
  42.  
  43.      First, the string at HL must have the form of a command token, that is,
  44. it must have a termination character.  The termination characters that are
  45. recognized are a semicolon, and equal sign, a space, or any control
  46. character.  Note that a comma is not included in this list, so that compound
  47. tokens such as "FN1.FT,FN2.FT" will be treated as a single token, and the
  48. second file name and type will be skipped over.  Individual fields in a file
  49. specification are terminated by any of the following characters: space,
  50. equal sign, underscore, semicolon, greater than or less than sign, comma,
  51. or null.  A second colon or period will also terminate the field.  However,
  52. once all the required fields have been identified, the code skips over
  53. characters until it finds the token delimiter from the smaller set of
  54. characters described earlier.  Thus this routine does not function exactly
  55. like the routine ZFNAME in Z3LIB.  Contrary to the statement in "ZCPR3, The
  56. Libraries," ZFNAME does not behave identically to the ZCPR30 parser either.
  57.  
  58.      The second precaution is the more unusual one.  The file control block 
  59. pointed to by DE must have been initialized more extensively than is usual.  
  60. Generally, the fields occupied by the file name and file type do not have to 
  61. be initialized.  For this routine, however, the 11 filename characters must 
  62. all be set to spaces before the routine is called.
  63.  
  64.      The routine whose entry point is at offset 13H parses a pair of file 
  65. specifications pointed to by HL into the two system default file control 
  66. blocks (at 5CH and 6CH).  The file control blocks are initialized by the 
  67. routine, and no user-provided initialization of any sort is required.  After 
  68. this routine has run, the address of the beginning of the second of the two 
  69. file specifications is set into the word at offset 11H so that it will be 
  70. loaded into the HL register automatically when the entry point at offset 10H 
  71. is used.  The entry point at offset 10H is provided in case an external 
  72. program wants to continue parsing the line that the command processor 
  73. parsed.  This would be useful, for example, for an RCP version of SAVE or 
  74. JUMP.
  75.  
  76.      Note that these routines can be used only when the command processor 
  77. has not been overwritten by an application program.  When this is the case, 
  78. these routines offer two advantages.  First, they save code.  Secondly, they 
  79. automatically parse the file specifications in the exact same way that the 
  80. command processor does (naturally!).  This means that the same configuration 
  81. options will apply, such as recognizing DU and/or DIR forms and in the 
  82. correct order, checking passwords, omitting password checking when the wheel 
  83. byte is set, allowing the DU form only when the ENV DUOK flag is set, etc.
  84.  
  85.  
  86. Structure of File Control Blocks Built
  87. --------------------------------------
  88.  
  89.      The file control blocks constructed by the ZCPR33 parser differ in 
  90. several critical ways from those produced by the ZCPR30 command processor.  
  91. In all cases, the purpose is to provide more information.
  92.  
  93.      In its internal operation, the command processor constructs three file 
  94. control blocks.  The external file control block contains a parsed version 
  95. of the command expression (the first token on the command line, token zero).  
  96. The first two tokens in the command tail are parsed into the two system 
  97. default file control blocks.
  98.  
  99.      Let's treat the two system default file control blocks first.  These 
  100. two FCBs are initialized so that all fields contain zeros except as noted 
  101. here.
  102.  
  103.    the drive byte:
  104.  
  105.         This byte is set to zero if no drive is specified explicitly, that 
  106.         is, if there is no 'DU:', 'DIR:', or ':' (alone) prefix.  If a 
  107.         directory is specified, then a drive number in the range 1..16 
  108.         designated by that directory is stored in the drive byte.  A colon 
  109.         alone designates the currently logged directory.  If the designated 
  110.         directory is invalid for any reason, the currently logged drive is 
  111.         used (an error flag, described below, is also set).  A designated 
  112.         directory is invalid if (1) it is a 'DU:' expression with a drive or 
  113.         user number that is outside the allowed range, (2) it is a 'DIR:' 
  114.         expression with a name that is not defined in the named directory 
  115.         register (NDR), or (3) it is a 'DIR:' form designating a password-
  116.         protected directory and the user did not enter the correct password 
  117.         when asked for it.
  118.  
  119. the file name and type fields:
  120.  
  121.         These fields are filled in with the first 8 characters of the string 
  122.         before a period and the first three characters of the string after a 
  123.         period, respectively.  If fewer than 8 and 3 characters, 
  124.         respectively, are present, the name or type is padded out with space 
  125.         characters.  If no name or no type is included in the file 
  126.         specification, then the corresponding field is filled entirely with 
  127.         blanks.  If more than 8 or 3 characters, respectively, are present, 
  128.         the excess characters are ignored.
  129.  
  130. user number byte:
  131.  
  132.         The user number byte at offset 13 decimal (0DH) contains the user 
  133.         number for the file specification.  If no user number is given 
  134.         explicitly (using either the forms 'DU:' or 'U:' or by a named 
  135.         directory specification), then this byte contains the currently 
  136.         logged in user number.  There is no way to tell whether or not a 
  137.         user number was given explicitly (thus the expression 'A:' cannot be 
  138.         distinguished from the expression 'A3:' where the current user area 
  139.         is 3).  This is a defect in the basic design of ZCPR3 file control 
  140.         blocks and cannot be changed at this point.  To overcome this 
  141.         limitation, a program would have to scan the original file 
  142.         specification itself using its own code.
  143.  
  144. record count byte:
  145.  
  146.         The record count byte at offset 0FH in the FCB normally contains a 
  147.         zero byte.  If the directory specified was not valid (for the 
  148.         reasons listed above), a non-zero value is placed in the record 
  149.         count byte.  Programs can use this information to distinguish 
  150.         between an FCB specifying the current directory because that is the 
  151.         directory actually specified and an FCB that does so because the 
  152.         specified directory was invalid.
  153.  
  154.      In a future release of the ZCPR3 command processor, it might be 
  155. possible to use individual bits in the record count byte to indicate 
  156. complete information about the parse, including whether or not a user number 
  157. was specified explicitly.
  158.  
  159.  
  160. The External Command File Control Block
  161. ---------------------------------------
  162.  
  163.      The requested command is parsed into the external command file control
  164. block in exactly the way described above.  However, since this FCB is used
  165. by the command processor before a user program sees it, there are some
  166. changes.
  167.  
  168.      First of all, the drive byte is always set to zero during the search
  169. for a transient program, and it was already zero for any RCP- and CPR-
  170. resident commands.  Consequently, it is not normally possible to get any
  171. information about the kind of command from this byte.  However, the drive
  172. and user number where the command was actually found during loading is put
  173. into the FCB.  The user value is in its normal place at offset 13 (0DH). 
  174. The drive value, in the range 1..16, is kept in the next byte (this way the
  175. two values can be loaded into BC as a word for use by SYSLIB routines like
  176. LOGUD).  If the drive value is 0, then no search was performed for a
  177. transient command; in other words, the command was a resident command.
  178.  
  179.      There is one exception to the above description.  That concerns the FCP
  180. commands, which I carefully did not mention.  The command processor scans
  181. the FCP for ALL commands, whether or not they have a directory prefix. 
  182. Since commands processed by the FCP have not been subjected to the command
  183. processor loader, the external command FCB is still intact from the original
  184. parse.  Consequently, the drive byte can be used to determine whether or not
  185. a directory prefix was included with the command.  This technique is used to
  186. advantage in Z33FCP.  If the invocation of IF, OR, or AND had a directory
  187. specification (including a lone colon), then the FCP module immediately
  188. loads the transient flow processor IF.COM, without first checking to see if
  189. the requested option is supported in the resident code.  Thus a leading
  190. colon can force the more powerful transient flow processor to be run, and
  191. the code required to detect this request in the FCP module is minimal.
  192.