home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpmug / cpmug085.ark / SQUEEZ16.DOC < prev    next >
Encoding:
Text File  |  1984-04-29  |  22.3 KB  |  532 lines

  1. USAGE AND RECOMPILATION DOCUMENTATION FOR:         7/18/81
  2.      SQ.COM    1.6  File squeezer
  3.      USQ.COM   1.9  File unsqueezer
  4.      FLS.COM   1.1  Ambiguous file name expander
  5.  
  6. note (07/16/82): FLS.COM is now unnecessary.  With versions
  7. 1.6 and 1.9 of SQ and USQ, respectively, a multi-file handling
  8. capability is built-in to both SQ and USQ.
  9.  
  10. DISTRIBUTION RIGHTS:
  11. I   allow  unrestricted  non-profit  distribution  of   this 
  12. software  and  invite  users groups  to  spread  it  around. 
  13. However,  any distribution for profit requires my permission 
  14. in  advance.  This applies only to the above listed programs 
  15. and their program source and documentation files.  I do sell  
  16. other software.
  17.  
  18. PURPOSE:
  19. The file squeezer,  SQ, compresses files into a more compact 
  20. form.  This provides:
  21.      1.   Faster transmission by modem.
  22.      2.   Fewer diskettes to distribute a program  package. 
  23.           (Include USQ.COM and instructions, both unsqueezed.)
  24.      3.   Fewer diskettes for archival storage.
  25.  
  26. Any file can be squeezed,  but program source files and text 
  27. files  benefit the most,  typically shrinking by 35%.  Files 
  28. containing only a limited character set,  such as dictionary 
  29. files,  may shrink as much as 48%.  Squeezed files look like 
  30. gibbersh and must be unsqueezed before they can be used.
  31.  
  32. The  unsqueezer,  USQ,  expands  squeezed files  into  exact 
  33. duplicates  of the original or provides a quick,  unsqueezed 
  34. display  of  the  tops  of  (or  all  of)  squeezed   files. 
  35. Unsqueezing requires only a single pass.
  36.  
  37. Both SQ and USQ accept batches of work specified by lists of 
  38. file  names  (with  drives  if  needed)  and   miscellaneous 
  39. options. They accept these parameters in any of three ways:
  40.  
  41.      1. On the CP/M command line.
  42.      2. From the console keyboard.
  43.      3. From a file.
  44.  
  45. > FLS.COM NO LONGER NEEDED
  46. >
  47. > The  FLS program can be used (on the same command line!)  to 
  48. > expand parameter lists containing wild-card (ambiguous) file 
  49. > names into lists with the specific file names required by SQ 
  50. > and USQ.
  51.  
  52. This  combination of programs allows you to issue  a  single 
  53. command which will produce many squeezed or unsqueezed files 
  54. from and to various diskettes. For example, to unsqueeze all 
  55. squeezed  ASM files on drive B and send the results to drive 
  56. C  and also unsqueeze all squeezed TXT files on drive A  and 
  57. send the results to drive D:
  58.      A>fls c: b:*.aqm d: *.tqt |usq
  59.  
  60. ---> A>usq c: b:*.aqm d: *.tqt        <---- vers. 1.9 does same thing
  61.                         as if FLS had been used
  62.  
  63. For detailed instructions see USAGE.
  64. This  DOES  run under plain old vanilla CP/M!  Many  of  the 
  65. smarts  are buried in the COM files in the form  of  library 
  66. routines  provided  with the BDS C package  (available  from 
  67. Lifeboat).
  68.  
  69. The  above example simulates a "pipe" (indicated by the "|") 
  70. by sending the "console" output of the fls.com program to  a 
  71. temporary  file  and  then running the sq.com  program  with 
  72. options  which  cause  it to read its  parameters  from  its 
  73. "console" input, which is really redirected to come from the 
  74. temporary file.
  75.  
  76. THEORY:
  77. The  data  in the file is treated at the byte  level  rather 
  78. then  the word level,  and can contain absolutely  anything. 
  79. The compression is in two stages: first repeated byte values 
  80. are  compressed  and  then a  Huffman  code  is  dynamically 
  81. generated  to match the properties of each particular  file. 
  82. This requires two passes over the source data.
  83.  
  84. The  decoding  table is included in the  squeezed  file,  so 
  85. squeezing  short  files can actually  lengthen  them.  Fixed 
  86. decoding  tables  are not used because  English and  various 
  87. computer  languages vary greatly as to upper and lower  case 
  88. proportions  and  use of special  characters.  Much  of  the 
  89. savings  comes  from  not  assigning codes  to  unused  byte 
  90. values.
  91.  
  92. More detailed comments are included in the source files.
  93.  
  94. USAGE TUTORIAL:
  95. As usual, you have to learn how to tell the programs what to 
  96. do  (i.e.,  what parameters to type after the program name). 
  97. First I will introduce the various possibilities by example. 
  98. Then I will summarize the rules.
  99.  
  100. In  the simplest case either SQ or USQ can simply  be  given 
  101. one or more file names (with or without drive names):
  102.      A>sq xyz.asm
  103.      A>sq thisfile.doc b:thatfile.doc
  104. will   create  squeezed  files  xyz.aqm,   thisfile.dqc  and 
  105. thatfile.dqc,  all  on the current drive,  A.  The  original 
  106. files are not disturbed. Note that the names of the squeezed 
  107. files are generated by rules - you don't specify them.
  108.  
  109. Likewise,
  110.      A>usq xyz.aqm
  111. will  create file xyz.asm on the A  drive,  overwriting  the 
  112. original.  (The  original name is recreated from information 
  113. stored in the squeezed version.) The squeezed version is not 
  114. disturbed.
  115.  
  116. Each file name is processed in order,  and you can list  all 
  117. the files you can fit in a command.  The file names given to 
  118. SQ and USQ must be specific. You will learn below how to use 
  119. the FLS program to expand patterns like *.asm (all files  of 
  120. type  asm) into a list of specific names and feed them  into 
  121. SQ or USQ.
  122.  
  123. The above examples let the destination drive default to  the 
  124. current logged drive, which was shown in the prompt to be A. 
  125. You can change the destination drive as often as you like in 
  126. the parameter list. For example,
  127.      A>sq x.asm b: y.asm z.asm c: d:s.asm
  128. will create x.aqm on the current drive,  A,  y.aqm and z.aqm 
  129. on the B drive and s.aqm on the C drive. Note that the first 
  130. three originals are on drive A and the last one is on  drive 
  131. D.  Remember  that each parameter is processed in order,  so 
  132. you must change the destination drive before you specify the 
  133. files to be created on that drive.
  134.  
  135. Eventually you will have diskettes with many squeezed  files 
  136. on  them and you will wonder what is in which file.  If they 
  137. weren't  squeezed you would use the TYPE command to look  at 
  138. the  comments at the beginning of the  files.  But  squeezed 
  139. files  just  make  a mess on your CRT screen when  you  TYPE 
  140. them,  so  I have provided the required feature as a preview 
  141. option to the USQ program.
  142.      A>usq -10 x.bas b:y.asm
  143. will  not take the time to create unsqueezed files.  Instead 
  144. it  will  unsqueeze  the first 10 lines  of  each  file  and 
  145. display  them  on your console.  The display from each  file 
  146. consists of the file names, the data and a formfeed (FF).
  147. Also,
  148.      A>usq - c:xyz.mac
  149. will  unsqueeze  and display the first 65,535 lines  of  any 
  150. files listed. That's the biggest number you can give it, and 
  151. is intended to display the whole file.
  152.  
  153. This   preview  option  also  ensures  that  the   data   is 
  154. displayable.  The  parity bit is stripped off (some Wordstar 
  155. files  use  it for format control) and any  unusual  control 
  156. characters  are  converted to periods.  You'll see  some  of 
  157. these  at  the end of the files as the CP/M end of  file  is 
  158. treated  as  data  and  the  remainder  of  the  sector   is 
  159. displayed.
  160.  
  161. You are now familiar with all of the operational  parameters 
  162. of SQ and USQ.  But so far you have always typed them on the 
  163. command line which caused the program to be run. For reasons 
  164. which  will become apparent later,  I have also provided  an 
  165. interactive  mode.   If  there  are  no  parameters  (except 
  166. directed  i/o  parameters,  described later) on the  command 
  167. line,  SQ  and USQ will prompt with an asterisk  and  accept 
  168. parameters from the console keyboard. Each parameter must be 
  169. followed  by  RETURN and will be processed  immediately.  An 
  170. empty  command (just RETURN) will cause the program to  exit 
  171. back  to  CP/M.  Try it - it will help you  understand  what 
  172. follows.
  173.  
  174. Now lets get into directed i/o, which will be new to most of 
  175. you,  but will save you so much work you will wonder how you 
  176. ever got along without it.
  177.  
  178. Perhaps you frequently squeeze or unsqueeze the same list of 
  179. files  and you would like to type the list once and be  done 
  180. with it. Use an editor (or FLS, described below) to create a 
  181. file  with  one  parameter per line.  For  example  call  it 
  182. commands.lst.
  183.  
  184. Then,
  185. A>sq <commands.lst
  186. will  cause the command list file to be read as if you  were 
  187. typing it! You will see it on the console.
  188.  
  189. That was redirected console input.  Now assume that you have 
  190. a very long list of files to squeeze or unsqueeze and  while 
  191. you  are  taking a nap the progress comments and maybe  some 
  192. error  comments  scroll  off  the  screen.  Redirecting  the 
  193. console   output   will  let  you  capture   the   progress 
  194. information  in a file so you can check it later.  The error 
  195. comments will have the screen to themselves.
  196.  
  197. For example,
  198. A>sq <commands.lst >out
  199. will send the progress comments to the file "out", which you 
  200. can TYPE later.  The routine display of the program name and 
  201. version, etc., will still go to the console.
  202.  
  203. A more practical example is to send that information to  the 
  204. console and to the file.
  205. A>sq <commands.lst +out
  206. will do that.
  207.  
  208. Redirected  input  and output are independent - you  can  do 
  209. either, both or neither.
  210.  
  211. There is one more form of redirection called a "pipe". It is 
  212. by far the most important to you.  Recall that I promised to 
  213. tell  you how to use ambiguous file names such as *.asm (all 
  214. files  of  type asm on the current default drive)  or  *.?q? 
  215. (all files having a "q" as the second letter of their type). 
  216. That last example just happens to mean "all squeezed files", 
  217. assuming  you don't have any other files with such  a  silly 
  218. name (I hope).
  219.  
  220. I  have  provided  a program called FLS  which  is  intended 
  221. primarily for use in pipes. Here is an example:
  222. A>fls c: x.asm y*.asm >temp.$$$
  223. will  simply  pass the first two parameters through  to  the 
  224. console output,  which is being redirected to a file  called 
  225. temp.$$$.  But  the third parameter will be replaced by  all 
  226. the  files  on the current drive which are of type  asm  and 
  227. have names beginning with y.
  228.  
  229. FLS  is  smart  enough to know that a letter followed  by  a 
  230. colon and nothing else is a destination drive name  intended 
  231. for  SQ or USQ.  It will also treat any parameter  beginning 
  232. with  a  - (minus sign) as an option to be  passed  through. 
  233. Anything  else  is considered a file name or pattern and  is 
  234. checked against the directory of the appropriate drive.
  235.  
  236. Therefore you could use:
  237. A>fls b: c:*.aqm *.aqm -10 stuff.dqc >temp.$$$
  238. A>usq <temp.$$$
  239. A>era temp.$$$
  240. to unsqueeze all files of type aqm on drives C and A and put 
  241. the unsqueezed files on drive B,  and then preview the first 
  242. 10 lines of file stuff.dqc.
  243.  
  244. Here  is where the pipe comes in.  The above three  commands 
  245. can be abbreviated as:
  246. A>fls b: c:*.aqm *.aqm -10 stuff.dqc |usq
  247.  
  248. That  little  "|" is the pipe option and it causes  the  FLS 
  249. output to be redirected to a temporary file and when that is 
  250. done  it  actually  runs USQ for you with the  proper  input 
  251. redirection and then erases the temporary file.
  252.  
  253. If  that  isn't  enough,  you  can still  use  the  +  or  > 
  254. redirection  option  at the end of that line to capture  the 
  255. console output from USQ.
  256. A>fls b: c:*.aqm *.aqm -10 stuff.dqc |usq >out
  257.  
  258. If you plan your comments carefully you can produce a single 
  259. file containing an abstract of an entire library of squeezed 
  260. files in one step!
  261. A>fls -25 *.?q? |usq >abstract
  262.  
  263. One  final point.  Anywhere you specify a file name you  can 
  264. specify a drive in front of it.  That applies to redirection 
  265. and well as files to be squeezed and unsqueezed.  If a  name 
  266. begins  with a - (minus sign) it will look like an option to 
  267. FLS unless you put a drive name in front of it (b:-sq.077).
  268.  
  269. USAGE SUMMARY:
  270. The previous section gradually presented the various options 
  271. by example. This section gives a condensed and more abstract 
  272. description  and is intended for reference.  If you couldn't 
  273. see  the forest for the trees,  maybe this will give  you  a 
  274. better view.
  275.  
  276. The parameter handling of these programs is straightforward. 
  277. Parameters  fall into two classes:  directed i/o options and 
  278. operational parameters . Note that parameters read from files 
  279. or  from the console are not forced to upper case,  but  the 
  280. internal  file  handling routines all treat  lower  case  as 
  281. upper case.
  282.  
  283. When  a  file to be written already exists,  it  is  quietly 
  284. overwritten.
  285.  
  286.  
  287.  
  288. Directed I/O parameters:
  289. The  first  action  taken by these programs  is  to  process 
  290. directed  i/o parameters from the CP/M command  line.  These 
  291. parameters are optional and take the forms:
  292.  
  293.      <file     read console input from file
  294.      >file     send most console output to file
  295.      +file     send most console output to file and console
  296.      |pgm ...  send most console output to a temporary file
  297.                then run PGM.COM and take console input
  298.                from the temporary file. "..." represent the
  299.                parameters for PGM. This is called "piping".
  300.  
  301. Only  one input and one output redirection can apply to each 
  302. program. After the program has arranged for any directed i/o 
  303. parameters to be obeyed they are deleted from the  parameter 
  304. list seen by the rest of the program.
  305.  
  306. Operational parameters:
  307. The   program  then  checks  if  there  are  any   remaining 
  308. parameters from the CP/M command line.  If there  are,  they 
  309. are obeyed. If and only if there are no remaining parameters 
  310. on  the  command line,  the program prompts for them at  the 
  311. console.  If  console input has been directed to a file  one 
  312. parameter  is  read and obeyed from each line of  the  file. 
  313. Otherwise,  the  user  follows each typed parameter  with  a 
  314. RETURN and an empty command exits the program.
  315.  
  316. Each  operational parameter is obeyed without looking  ahead 
  317. to  other  parameters,  so options should precede  the  file 
  318. names to which they apply.
  319.  
  320. SQ operational parameters are a list of the following types:
  321.      drive:         set the current destination drive
  322.      filename       file to be squeezed
  323.      drive:filename  "   "    "    "
  324.  
  325. SQ does not change the files being squeezed. New, squeezed 
  326. files are created on the destination drive (defaults to  the 
  327. current drive) with names derived from the original name but 
  328. with  the second letter of the file type (extention) changed 
  329. to Q.  When there is no type, QQQ is used. The original name 
  330. is saved in the squeezed file.
  331.  
  332. USQ  operational  parameters  are a list  of  the  following 
  333. types:
  334.      drive:         set the current destination drive
  335.      filename       file to be squeezed
  336.      drive:filename  "   "    "    "
  337.      -count         Preview (display on the console) the first
  338.                     "count"  lines  of  each   file,   where 
  339.                     "count" is a number from 1 to 65535.
  340.  
  341. If  the  -count  option IS NOT in effect  then  USQ  creates 
  342. unsqueezed  versions of the listed files on the  destination 
  343. drive,  which  defaults to the current  logged  drive.  Each 
  344. unsqueezed  file is CRC checked against the CRC value of the 
  345. original file, which is part of the squeezed file.
  346.  
  347. The  -count  option is for  previewing  squeezed  files.  It 
  348. allows  you  to  skim  through a group  of  squeezed  files, 
  349. peeking  at  the first "count" lines in each.  The  >  or  + 
  350. output  redirection  option could be used  to  capture  this 
  351. information  in a file,  along with the corresponding  file 
  352. names, thus forming an abstract of the files on a disk.
  353.  
  354. When  the  -count option is used the CRC check is  cancelled 
  355. and  the  output is forced into printable form by  stripping 
  356. the  parity bit and changing most unprintable characters  to 
  357. periods.  The exceptions are CR,  LF, TAB and FF. The output 
  358. from  each file is terminated by an FF.  PIP can be used  to 
  359. strip FFs and provide formatted printing if desired. "Count" 
  360. defaults to the maximum value,  65,535,  in case you want to 
  361. look at a whole file.
  362.  
  363. FLS operational parameters:  FLS is a "filter",  which means 
  364. it  accepts input from the console input or command line and 
  365. transforms the input according to a set of rules to  produce 
  366. console  output.  That's fine for getting familiar with FLS, 
  367. but to make it useful you "pipe" its output to the input  of 
  368. SQ or USQ.
  369.  
  370. Any FLS parameter which is of the form:
  371.      drive:
  372. or   -anything
  373. is  copied  to console output unchanged.
  374.  
  375. Any  other  FLS operational parameter is treated as  a  file 
  376. name and is checked against the directory of the appropriate 
  377. drive. If it contains * or ? it is replaced by a list of all 
  378. the files which fit the pattern.  If nothing is found in the 
  379. directory  an error comment is sent to the console,  even if 
  380. normal console output has been redirected to a file.
  381.  
  382. IMPORTANT:  when  using  a pipe from FLS or any other  input 
  383. redirection to get the file list,  etc.,  on which USQ or SQ 
  384. are  to operate you must NOT put any parameters  other  than 
  385. redirection  following  the program name.  They must be  all 
  386. together in the input parameter list. Example:
  387.  
  388. A>fls -10  b:*.cq |usq +saveout
  389. is  the  proper way to preview the top (first 10  lines)  of 
  390. each  squeezed  .C file on the B drive.  The -10  is  passed 
  391. through  FLS  to USQ.  The results will be displayed on  the 
  392. console  and  saved in file "saveout" on the  A  drive.  The 
  393. saveout  file lets you confirm the list of  processed  files 
  394. even  if  the display scrolls off the screen  while  running 
  395. unattended.
  396.  
  397. In summary, i/o redirection parameters (those prefixed by +, 
  398. <,  >,  or |) always follow the command to which they apply, 
  399. but  operational parameters  (destination  drive,  -options) 
  400. must be with the file name list.
  401.  
  402. EXAMPLES:
  403. 1. Unsqueeze all squeezed files on the current drive and put 
  404. the resulting unsqueezed files on the same drive.
  405.      A>fls *.?q? |usq
  406.  
  407. 2.  Look  at  the first 10 lines of every squeezed  file  on 
  408. drive B.
  409.     A>fls -10 b:*.?Q? |usq
  410. note  that since the file names for USQ came from  FLS,  the 
  411. count option had to come from there too.
  412.  
  413. 4.  Squeeze all .ASM files on the B and C drives and put the 
  414. squeezed files on the D drive.
  415.      A>fls d: b:*.asm c:*.asm |sq
  416. Note that if d:  had not been first the squeezed files would 
  417. have gone to the A drive.
  418.  
  419. 5.  Squeeze file xyz.c on the A drive and put the results on 
  420. the A drive.
  421.      A>sq xyz.c
  422.  
  423. 6.  Build  a  parameter list of all ASM files on drive C  in 
  424. file XX.PAR and view it on the console.
  425.      A>fls c:*.asm +xx.par
  426.  
  427. 7. Use the above list to squeeze the files to the A drive.
  428.      A>sq <xx.par
  429.  
  430. 8. As above, but results to the B drive.
  431.      A>b:
  432.      B>a:sq <a:xx.par
  433.  
  434. 9.  Squeeze  all ASM and C files on the A drive and put  the 
  435. results on the B drive. Capture the progress comments in the 
  436. file "out" without displaying them.
  437.      A>fls b: *.asm *.c |sq >out
  438.  
  439. 10.  Preview  the first 24 lines of each squeezed  ASM  file 
  440. THEN unsqueeze them (unless stopped via cntl-C).
  441.      A>fls -24 *.aqm a: *.aqm |usq
  442. Note  that  specification  of a  destination  drive  cancels 
  443. previewing.
  444.  
  445. RECOMPILATION:
  446. These programs are written in C and the instructions are for 
  447. the BDS C compiler. The libraries must have been adapted for 
  448. directed i/o as described in DIO2.C.
  449.  
  450. The  procedures below indicate the various C language source 
  451. files  (file  type .C) required to  recompile.  Those  files 
  452. contain  #include statements which cause header files  (file 
  453. type  .H) to be read and compiled.  The BDSCIO.H header file 
  454. contains information about your system,  including how  much 
  455. space  to reserve for file buffers.  You should use your own 
  456. version of this file.
  457.  
  458. The source files DIO2.C, SQDIO.C and USQDIO.C are identical! 
  459. If you only get one,  just use PIP to create the rest.  They 
  460. are separate only to provide separate CRL files,  which  are 
  461. needed  because of the different external variable  options. 
  462. Note  that  they  do  not  include  all  the  header  files, 
  463. therefore  the  other  source  files must  include  the  dio 
  464. related headers first.
  465.  
  466. DIO.C is supplied with BDS C.  The above three files  differ 
  467. from  the official version only by a change to the  dioflush 
  468. function to ensure TEMPIN.$$$ is deleted before another file 
  469. is renamed to that name.  (CP/M is stupid enough to make two 
  470. files of the same name!).
  471.  
  472. The procedure for building the SQ.COM and USQ.COM files from 
  473. their  source files follows.  Note that I have  renamed  the 
  474. first  phase  of the BDS C compiler to CC.COM.  Also I  will 
  475. assume  the BDS C package is on drive D and the SQ  and  USQ 
  476. related files are on B along with BDSCIO.H and DIO.H.
  477.  
  478. Each  CC command produces a CRL file with specific addresses 
  479. for  external variables.  If you recompile a file  with  the 
  480. same  value in the -e option you don't have to recompile the 
  481. other  files,  just  do the desired CC and then  repeat  the 
  482. entire CLINK.
  483.  
  484. CLINK's -s option prints statistics. Top of memory means the 
  485. current TPA. Stack space is what's left over. These programs 
  486. require  stack  space for local  variables,  including  some 
  487. healthy i/o buffers.  Also some functions are recursive.  If 
  488. SQ doesn't have several K of stack space it will probably go 
  489. crazy and do almost anything.
  490.  
  491. For SQ (note not all use -o):
  492. D>cc b:sq.c -o -e3200
  493. D>cc b:sqdio.c -e3200
  494. D>cc b:tr1.c -o -e3200
  495. D>cc b:tr2.c -o -e3200
  496. D>cc b:io.c -o -e3200
  497. D>clink b:sq sqdio tr2 tr1 io -s
  498.  
  499. The linker will display some statistics. Check that the last 
  500. code  address is less than the start address of the external 
  501. variables (3200 in this example).  If not,  repeat the above 
  502. with a higher address in the -e options.
  503.  
  504. For USQ (note: -e2800 may be enough. Note not all use -o):
  505. D>cc b:usq.c -o -e2900
  506. D>cc b:usqdio.c -e2900
  507. D>cc b:utr.c -o -e2900
  508. D>clink b:usq usqdio utr -s
  509.  
  510. Check the addresses as described above.
  511.  
  512. For FLS:
  513. D>cc b:fls.c
  514. D>cc b:dio2.c
  515. D>clink b:fls dio2
  516.  
  517. IN CASE OF TROUBLE:
  518. I  welcome  suggestions  and  bug  reports,   but  you  must 
  519. understand that some of the ideas I get would involve almost 
  520. as much program development as the original package.  I have 
  521. what I want and (I hope) what most users want,  so I am  not 
  522. motivated  to  spend  many more  months  creating  something 
  523. entirely  different  which  just  happens  to  involve  data 
  524. compression. The data compression routines are probably less 
  525. than  half of this package,  and are designed to operate  on 
  526. large blocks of data, such as files.
  527.  
  528.         Dick Greenlaw
  529.                 251 Colony Ct.
  530.                 Gahanna, Ohio 43230
  531.                 614-475-0172 weekends and evenings
  532.