home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 575.lha / APipeHandler_v1.3 / README < prev    next >
Text File  |  1991-10-18  |  5KB  |  126 lines

  1. ################################################################################
  2. #
  3. #   APipe-Handler for AmigaDOS 2.04 or higher.
  4. #
  5. #   Copyright (C) 1991 by Per Bojsen.  All Rights Reserved.
  6. #
  7. #   Permission is granted to any individual or institution to use, copy,
  8. #   modify, and distribute this software, provided that this complete
  9. #   copyright and permission notice is maintained, intact, in all copies
  10. #   and supporting documentation.
  11. #
  12. #   This software is provided on an "as is" basis without express or
  13. #   implied warranty.
  14. #
  15.  
  16. NOTE: See the CAVEAT section (3) for some important information on the
  17.       implementation of the APipe-Handler.
  18.  
  19. This archive contains the source for the APipe-Handler.  The archive should
  20. include the following files:
  21.  
  22.         child.asm
  23.         pgmpipe.c
  24.         APipe-Handler_rev.h
  25.         APipe-Handler_rev.i
  26.         APipe-Handler_rev.rev
  27.         Makefile
  28.         Mountlist
  29.         README
  30.  
  31.  
  32. 1) Introduction
  33.  
  34. Some weeks ago I got a strange idea for a new kind of pipe handler.  Let's
  35. call it `APipe-Handler' and its DOS device name `APIPE:'.  The special
  36. thing about this handler is that it interprets the name after the prefix
  37. `APIPE:' as a command line to be executed.  If the `APIPE:<command line>'
  38. file is opened as MODE_OLDFILE the standard output from the command will be
  39. available for reading; if the file is opened as MODE_NEWFILE the command will
  40. get its standard input from the data written to the file.
  41.  
  42. Here's some examples on the usage of this pipe handler:
  43.  
  44.     1> search APIPE:alias list ; print the aliases containing list
  45.  
  46.     2> sort "APIPE:list nohead" CONSOLE: ; sorted list
  47.  
  48.     3> comm -12 "APIPE:grep list APIPE:alias" "APIPE:grep nohead APIPE:alias"
  49.  
  50.     4> status >"APIPE:grep uucico" ; does not work with SAS grep: use GNU!
  51.  
  52.     5> grep uucico APIPE:status
  53.  
  54. The first two examples show things that could be done in a shell that
  55. supported anonymous pipes `|' *if* the standard AmigaDOS utilities had the
  56. ability to read from their standard input.
  57.  
  58. The third example shows something that is impossible to do with `|' command
  59. line pipes, and requires several lines (or shells) with PIPE: (comm is a
  60. program from the GNU text utilities that prints line in common between to
  61. sorted files).
  62.  
  63. Example four and five should produce equivalent results.
  64.  
  65. Other possible uses of APIPE: is as a file to save to from an editor,
  66. i.e., you could prepare some script or data file and save it directly to
  67. the command/program from your editor.  Or you could insert the output
  68. from a command into the file you're editing.  The editor you're using does
  69. not need any special support for this besides the ability to save and
  70. load files :-)
  71.  
  72. One nice thing about this handler is that it allows for a really simple
  73. implememtation of the UNIX popen()/pclose() functions: just append the
  74. command line to `APIPE:' and call fopen() on this string;  pclose() is
  75. simply a wrapper around fclose().  This was the main reason I came up with
  76. the idea, BTW.
  77.  
  78.  
  79. 2) How to build APipe-Handler
  80.  
  81. The build instructions assume you have SAS/C 5.10.
  82.  
  83. Edit the Makefile to reflect your installation.  You may choose to
  84. activate the machine architecture macros if you have a faster processor.
  85.  
  86. After you have customized the Makefile, type run your make program
  87. to build the handler.
  88.  
  89.  
  90. 3) CAVEAT
  91.  
  92. The APipe-Handler needs to copy the environment of the requester process
  93. for the child process which runs the specified command line.  The enviroment
  94. includes the path, IO, current directory, shell variables, and aliases.
  95.  
  96. Unfortunately, there's currently no way to copy this environment safely
  97. which is safe under all circumstances.  The handler may fail if the process
  98. opening a file on the handler messes with its environment (like changing
  99. its path, changing shell variables, etc.) while the ACTION_FINDINPUT or
  100. ACTION_FINDOUTPUT packet is still pending.  Furthermore, the process
  101. must run with a higher or same priority than the handler process which
  102. normally runs at priority 5.
  103.  
  104. Since most programs seems to use the dos.library call Open() to open
  105. their files the caveat above is probably not a big problem in practice.
  106.  
  107. If you know of any program that might fall into the category covered by
  108. the caveat, please let me know.  I will try to convince Commodore to
  109. add some features to new versions of the OS that will make it possible
  110. to implement the APipe-Handler in a completely safe way.  This will be
  111. easier if many people use/need the APipe-Handler, so if you like the
  112. concept then give your friends a copy of it!
  113.  
  114. 4) Send bug reports (and praise/support) to
  115.  
  116.         bojsen@moria.dc.dth.dk
  117.  
  118.    Snail mail:
  119.  
  120.         Per Bojsen
  121.         Maglegaards Alle 51 st. th.
  122.         DK-2860 Soeborg
  123.         Denmark
  124.  
  125. 5) Have fun!
  126.