home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / compress / misc / xdata / xdata.doc < prev    next >
Text File  |  1995-02-27  |  14KB  |  336 lines

  1.  
  2.  
  3.                                 xData v1.1
  4.                              xDataPrefs v1.1a
  5.  
  6.                          (C) Martin W.Scott, 1993.
  7.  
  8.                           (NB: Requires OS 2.0+)
  9.  
  10.  
  11. xData  is a program that allows other programs to read xpk-compressed files
  12. as  if  they were normal files.  It is similar to PP by Michael Berg, which
  13. provided a similar facility for PowerPacked files.
  14.  
  15. However,  PP  caused  problems  on  my  system  (it  crashed),  and anyway,
  16. PowerPacker  has  been  superseded  by the more powerful and extensible xpk
  17. standard.   Unfortunately,  it takes a long time for data-handling programs
  18. to  catch-up  and recognise the xpk standard, not to mention those programs
  19. that can't read any compressed files.
  20.  
  21. The  xpk  system  is  distributed  with  a  handler,  xfh,  which  allows a
  22. pseudo-partition  to  be  set  up  to  handle  xpk'd  files in a completely
  23. transparent  manner.   Whilst  this  method  is  always  going  to  be more
  24. system-friendly than the patch method employed by xData and PP, it isn't as
  25. user-friendly -- all your packed files have to be kept in the one place.  I
  26. didn't  want to install the xfh handler, so wrote xData.  And remember that
  27. the  xpk  system handles the decompression of PowerPacked files too, giving
  28. increased flexibility to xData.
  29.  
  30. I  have  not  included the xpk libraries.  If you haven't got them and like
  31. what  you've  read  so far, you should obtain the complete xpk distribution
  32. (by ftp or fish disks).
  33.  
  34.  
  35. How does it work
  36. ----------------
  37. xData  patches  a  few  dos  routines to allow named programs to read xpk'd
  38. files.   These named programs are called clients.  This is different to PP,
  39. which  affected  ALL programs, and caused many incompatability problems (on
  40. my system at any rate), which is why I decided on the client model.
  41.  
  42. Clients are added using the xDataPrefs program; when a client opens a xpk'd
  43. file, the file is decompressed to the t: directory and the client reads the
  44. decompressed  file.  When the client closes the file, the temporary file is
  45. deleted (but it's not quite that simple -- see technical details below).
  46.  
  47. If  a  client  examines  the length of a compressed file, the xData patches
  48. actually  tell  it  the  uncompressed  length (in case the client allocates
  49. memory for the whole file to load into).
  50.  
  51. This client arrangement might seem restrictive, but it guarantees (though I
  52. don't  :) system compatability.  Most users only compress certain files and
  53. use certain programs to read them, so these are the only programs that need
  54. to use patched routines.  It allows you to use your favourite data-handling
  55. programs  rather  than  xpk-ified versions, e.g.  you can use ViewTex where
  56. before you had to use ShowIFF or PPMore (for PowerPacked files).
  57.  
  58.  
  59. Starting xData
  60. --------------
  61. Best   done   at  startup.   Can  be  run  from  Shell  or  Workbench,  and
  62. auto-detaches  if  run  from  a  shell.   You  can  put  it  in  WBStartup,
  63. user-startup   or  startup-sequence.   Since  it's  sort-of  a  preferences
  64. handler,  I  put  it after the IPrefs command in the startup-sequence.  The
  65. only restriction is that it must be run after ENV: has been set-up.
  66.  
  67. xData  is  a  commodity,  so it may be deactivated and reactivated with the
  68. Commodities  Exchange.   If the patches cannot be removed (because a client
  69. has a compressed file open), the user is notified.  xData may be terminated
  70. from the Exchange too (or by re-running it).
  71.  
  72. NB:  I've  noticed  one  or  two problems disabling xData while clients are
  73. manipulating  files, because they open/examine them repeatedly, and turning
  74. the  patches  off in the middle of all this can confuse them.  xData checks
  75. that all its files are closed, but can't anticipate these sort of problems.
  76. However,  there is no problem in disabling/enabling xData while clients are
  77. not busy opening files.
  78.  
  79.  
  80. Editing Preferences
  81. -------------------
  82. Preferences are edited using the xDataPrefs program, which is based closely
  83. on standard Workbench 2.1 preference editors.  All the usual menu items are
  84. there,  and  the  gadgets  work as you'd expect.  Only the CLI interface is
  85. lacking.  From the CLI, xDataPrefs takes either no arguments (in which case
  86. the edit window is opened) or one argument, a preferences file to use.
  87.  
  88. On  starting  xDataPrefs,  you will see two lists: the left-hand one is the
  89. list  of  clients  xData currently recognises, and the other is the list of
  90. processes running on your system.  If you wish to add as a client a program
  91. that  is  already  running,  look for it in the process list, select it and
  92. click on the Export gadget.  It will then be transfered to the client list.
  93.  
  94. The process list does not update regularly -- you must click on the Refresh
  95. gadget to update the list.
  96.  
  97. Other  new  clients are added with the Add gadget (surprise); pressing this
  98. results  in  'New  client' being added to the list.  Press right-amiga-x to
  99. clear  the  string  gadget  and  enter the new client's name (see below for
  100. details  on  names to choose).  You would use this method if the client you
  101. wanted wasn't running.
  102.  
  103. A sample client list is 
  104.  
  105.     DPaint
  106.     ViewTex
  107.     More
  108.     MuchMore
  109.     Display
  110.     CygnusEd
  111.     egrep
  112.  
  113. etc. Case is not significant.
  114.  
  115. The  way  names  are given to processes on the Amiga is non-trivial.  There
  116. are three general classes:
  117.  
  118. 1. Workbench Processes
  119.  
  120.     These  are  the  simplest, and the process name is the name of
  121.         the  icon  used  to  start  it.   e.g.  double-clicking on the
  122.         DPaint icon creates a process called 'DPaint'.
  123.  
  124. 2. Shell Processes
  125.  
  126.     Process  names  are  generally  non-descriptive,  e.g.   Shell
  127.         Process,  but the actual command a shell process is running is
  128.         stored  elsewhere,  and  xData  looks there.  The names stored
  129.         there  vary depending on how the command was invoked, and what
  130.         Shell  you're  using,  but  all you need to worry about is the
  131.         command  name,  i.e.   the file part, not the path part.  e.g.
  132.         from the shell, the process started by the command
  133.  
  134.         'run work:gfx/dpaint'
  135.  
  136.     will  match  the  client entry 'dpaint', even if the full path
  137.         and command is stored in the process.
  138.  
  139. 3. Custom Processes
  140.  
  141.     These  are  processes created by programs which are not of the
  142.         first  2  types.   For  example,  I  would type 'ced' to start
  143.         CygnusEd  from  a  Shell, it actually creates a process called
  144.         'CygnusEd',   so  to  enable  the  editor  to  load  xpk'd  or
  145.         PowerPacked files, a client called 'CygnusEd' must be added.
  146.  
  147. So,  the  names  to  use  as  clients  are  just  the names of the programs
  148. themselves,  with  no  paths. Using the process list, you can usually find
  149. the correct process name to add to the client list.
  150.  
  151.  
  152. Problem Examples
  153. ----------------
  154. A  couple  of  examples I have come across, that may also be instructive in
  155. other situations:
  156.  
  157. PROGRAM: ADPro
  158. PROBLEM: Doesn't recognise xpk'd files when 'ADPro' is a client.
  159. SOLUTION:  ADPro  uses sub-processes to operate on files, including loading
  160. and  saving  them.  The name of the sub-process used to load a file depends
  161. on  the  file's  type.  i.e.  when loading an IFF file, a process with name
  162. 'IFF'  is  created.  Therefore, adding a client called 'IFF' will allow you
  163. to  load  xpk'd IFF files.  There is no need to make 'ADPro' a client, just
  164. the relevant loaders.
  165.  
  166. PROGRAM: DirWork
  167. PROBLEM: Seems to determine what xpk'd files are, but can't load them.
  168. SOLUTION:  DirWork  program  spawns  separate  processes  to  view text and
  169. pictures,  so as well as adding the DirWork command to your client list (so
  170. that  DirWork recognises crunched files as IFF etc.) you must add the names
  171. of  its  spawn  processes  (which  do  the loading).  A quick glance at the
  172. process  list  shows  that these are called 'DW - More' and 'DW - Show', so
  173. adding the clients
  174.  
  175.     DirWork
  176.     DW - More
  177.     DW - Show
  178.  
  179. makes DirWork a fully-working client.
  180.  
  181. PROGRAM: xyzprogram (a dummy example)
  182. PROBLEM: Doesn't work as client (name is definitely right)
  183.      OR: Crashes system when made a client
  184. SOLUTION: Don't add it as a client.
  185.  
  186. That last one isn't meant to be a joke.  If a program doesn't work when you
  187. think  it  ought  to, you'll just have to live with the fact, or contact me
  188. with details and I'll see what I can do.
  189.  
  190.  
  191. Notes and Caveats
  192. -----------------
  193.  
  194.    o    When  a  client  saves over a compressed file, the new file is
  195.         not  recompressed  (I may extend xData's capabilities, but for
  196.         now, recompression is unimplemented).
  197.  
  198.    o    If  a  client  copies  a  file (e.g.  DirWork) the destination
  199.         version  is  actually  uncompressed.   Non-clients  copy files
  200.         without  this problem, of course.  This is a pain in the ar*e,
  201.         but  there's  not  a  lot  I  can do about it (short of adding
  202.         mind-reading  capabilities  to  xData).  If this really annoys
  203.         you,  don't  make the offending program a client.  In the case
  204.         of  DirWork,  if  you  have buttons to load text or view pics,
  205.         selecting  these  will  start the subprocesses without DirWork
  206.         needing  to know the file types, so you can remove it from the
  207.         client  list,  just  leavine  'DW - More' etc.  You have to do
  208.         without the auto-recognition if you do this though.
  209.  
  210.     I've  recently  been  using  the  new BrowserII, and it's type
  211.         recognition  system  is powerful enough to detect not only xpk
  212.         files, but also what they are, WITHOUT being made a client.
  213.  
  214.    o    Xpk'd executables will not be auto-decompressed when loaded by
  215.         clients  (for  example,  binary  editors).   This  is to avoid
  216.         conflicts  with xLoadSeg, but shouldn't be a problem (the only
  217.         instance  I  can think of when a program would want to load an
  218.         executable  is  the binary editor example).  However, xData is
  219.         completely compatible with xLoadSeg.
  220.  
  221.    o    Remember  that  the  xpk  system handles PowerPacked files, so
  222.         xData does too.  (So if you run PP, you can junk it).
  223.  
  224.  
  225. Hints
  226. -----
  227. To temporarily remove an client from the list, start the preferences editor
  228. and  prefix  the  client name with a ';' (or something like that).  It will
  229. then fail to match program.
  230.  
  231.  
  232. Credits
  233. -------
  234. xData and xDataPrefs are written entirely in C, compiled with SAS/C 5.10.
  235.  
  236. The gadget imagery was created using the excellent GadToolsBox.
  237.  
  238. The system patch method is based on a Commodore-supplied example (but done
  239. in an cache-friendly way).
  240.  
  241. The xpk compression system is the creation of Urban Dominik Mueller.
  242.  
  243. PowerPacker.library is copyright Nico François.
  244.  
  245.  
  246. Technical Details
  247. -----------------
  248. Here's  a brief explanation of what xData does.  When a program attempts to
  249. Open()  a  file  for  reading,  xData  checks its client list to see if the
  250. caller  is  a client.  If so, the file is checked to see if it is xpk'd (or
  251. PowerPacked),  and  if it is, the file is decompressed to the t: directory,
  252. under  a  unique  name.   Then xData opens the decompressed file and passes
  253. that  handle  to  the  caller.   Normal calls to AmigaDos functions Read(),
  254. Seek()  etc.   result in actions on the decompressed file; when the file is
  255. Close()ed, xData checks whether or not the file was decompressed, and if it
  256. was,  notes  that  the  file  is  closed; it will then be really closed and
  257. deleted (at least) 5 seconds later, by the main xData task.  The reason for
  258. postponing  the deletion is that many programs check what the file contains
  259. (by opening it), close it and reopen it for use.  Strange though this is (a
  260. Seek()  would  be  better  in many cases), it does lead to compressed files
  261. being   decompressed   twice   (or  more),  which  slows  down  performance
  262. significantly  in  the  case  of large files (and on slow processors).  The
  263. postponement is for a period of 5 seconds, which seems a reasonable tradeof
  264. between speeding up reopens and keeping memory use down. Examples of
  265. programs that sometimes open twice are ViewTex and Deluxe Paint.
  266.  
  267. If a client calls Examine(), xData checks if the file is compressed, and if
  268. so,  returns  its  decompressed length.  It determines the length by making
  269. some assumptions about the format of an xpk'd (or PowerPacked) file, rather
  270. than  decompressing the file.  This results in minimum overhead (though the
  271. overhead  is greater than an ordinary Examine(), because the file has to be
  272. opened  and  partially  read.   The assumptions about file format shouldn't
  273. cause  problems  with  future  versions of the xpk system, as the format is
  274. very unlikely to change.  However, I shall keep in touch with the author of
  275. xpk, Urban D. Mueller, to avoid future compatability problems.
  276.  
  277.  
  278. History
  279. -------
  280.  v1.1a    - xDataPrefs: fixed stupid memory bug (wasn't freeing task-list).
  281.  
  282.  v1.1    - xDataPrefs: major enhancement - now has task list so addition of
  283.           new clients is simplified.
  284.  
  285.     - xData: now postpones deletion for 5 seconds (for reasons why, see
  286.           technical details above).
  287.  
  288.  v1.0a    - xDataPrefs: fixed bug when entering name on empty list.
  289.  
  290.     - xDataPrefs: window now font-sensitive.
  291.  
  292.  v1.0ß    - initial release.
  293.  
  294.  
  295. Legalese and Distribution
  296. -------------------------
  297. It  seemed  fitting (and safe) to use the same disclaimer as the xpk system
  298. has, so here it is, pertaining to the xData package:
  299.  
  300. This  package  may  be  freely  distributed,  as  long as it is kept in its
  301. original,  complete,  and  unmodified  form.   It may not be distributed by
  302. itself or in a commercial package of any kind without my permission.
  303.  
  304. These  programs  are  distributed in the hope that they will be useful, but
  305. WITHOUT  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  306. or FITNESS FOR A PARTICULAR PURPOSE.
  307.  
  308. All  of  that  said,  I spend a lot of time writing and polishing stuff for
  309. release,  and would appreciate any monetary contributions if you find xData
  310. useful.   None  of  my  work  is  shareware,  but  do believe people should
  311. acknowledge others' work if they rate and use it [end of plea].
  312.  
  313.  
  314. Contact
  315. -------
  316. I can be reached with comments, suggestions, bug reports, praise, money etc.
  317. at the following addresses:
  318.  
  319. BEFORE END OF JULY 1993:
  320.  
  321.     Martin W. Scott,
  322.     23 Drum Brae North,
  323.     Edinburgh  EH4 8AT
  324.     United Kingdom
  325.  
  326. AFTER END OF JULY 1993:
  327.  
  328.     Martin W. Scott, c/o 
  329.     557 Great Western Road,
  330.     Ground flat right,
  331.     Aberdeen  AB1 7PA
  332.     United Kingdom
  333.  
  334. OR BY EMAIL UNTIL END OF JULY 1993: mws@castle.ed.ac.uk
  335.  
  336.