home *** CD-ROM | disk | FTP | other *** search
- ################################################################################
- #
- # APipe-Handler for AmigaDOS 2.04 or higher.
- #
- # Copyright (C) 1991 by Per Bojsen. All Rights Reserved.
- #
- # Permission is granted to any individual or institution to use, copy,
- # modify, and distribute this software, provided that this complete
- # copyright and permission notice is maintained, intact, in all copies
- # and supporting documentation.
- #
- # This software is provided on an "as is" basis without express or
- # implied warranty.
- #
-
- NOTE: See the CAVEAT section (3) for some important information on the
- implementation of the APipe-Handler.
- NOTE: Update information is included at the end of this file.
-
- This archive contains the source for the APipe-Handler. The archive should
- include the following files:
-
- child.asm
- pgmpipe.c
- APipe-Handler_rev.h
- APipe-Handler_rev.i
- APipe-Handler_rev.rev
- Makefile
- Mountlist
- README
-
-
- 1) Introduction
-
- Some weeks ago I got a strange idea for a new kind of pipe handler. Let's
- call it `APipe-Handler' and its DOS device name `APIPE:'. The special
- thing about this handler is that it interprets the name after the prefix
- `APIPE:' as a command line to be executed. If the `APIPE:<command line>'
- file is opened as MODE_OLDFILE the standard output from the command will be
- available for reading; if the file is opened as MODE_NEWFILE the command will
- get its standard input from the data written to the file.
-
- Here's some examples on the usage of this pipe handler:
-
- 1> search APIPE:alias list ; print the aliases containing list
-
- 2> sort "APIPE:list nohead" CONSOLE: ; sorted list
-
- 3> comm -12 "APIPE:grep list APIPE:alias" "APIPE:grep nohead APIPE:alias"
-
- 4> status >"APIPE:grep uucico" ; does not work with SAS grep: use GNU!
-
- 5> grep uucico APIPE:status
-
- The first two examples show things that could be done in a shell that
- supported anonymous pipes `|' *if* the standard AmigaDOS utilities had the
- ability to read from their standard input.
-
- The third example shows something that is impossible to do with `|' command
- line pipes, and requires several lines (or shells) with PIPE: (comm is a
- program from the GNU text utilities that prints line in common between to
- sorted files).
-
- Example four and five should produce equivalent results.
-
- Other possible uses of APIPE: is as a file to save to from an editor,
- i.e., you could prepare some script or data file and save it directly to
- the command/program from your editor. Or you could insert the output
- from a command into the file you're editing. The editor you're using does
- not need any special support for this besides the ability to save and
- load files :-)
-
- One nice thing about this handler is that it allows for a really simple
- implememtation of the UNIX popen()/pclose() functions: just append the
- command line to `APIPE:' and call fopen() on this string; pclose() is
- simply a wrapper around fclose(). This was the main reason I came up with
- the idea, BTW.
-
-
- 2) How to build APipe-Handler
-
- The build instructions assume you have SAS/C 5.10.
-
- Edit the Makefile to reflect your installation. You may choose to
- activate the machine architecture macros if you have a faster processor.
-
- After you have customized the Makefile, type run your make program
- to build the handler.
-
-
- 3) CAVEAT
-
- The APipe-Handler needs to copy the environment of the requester process
- for the child process which runs the specified command line. The enviroment
- includes the path, IO, current directory, shell variables, and aliases.
-
- Unfortunately, there's currently no way to copy this environment safely
- which is safe under all circumstances. The handler may fail if the process
- opening a file on the handler messes with its environment (like changing
- its path, changing shell variables, etc.) while the ACTION_FINDINPUT or
- ACTION_FINDOUTPUT packet is still pending. Furthermore, the process
- must run with a higher or same priority than the handler process which
- normally runs at priority 5.
-
- Since most programs seems to use the dos.library call Open() to open
- their files the caveat above is probably not a big problem in practice.
-
- If you know of any program that might fall into the category covered by
- the caveat, please let me know. I will try to convince Commodore to
- add some features to new versions of the OS that will make it possible
- to implement the APipe-Handler in a completely safe way. This will be
- easier if many people use/need the APipe-Handler, so if you like the
- concept then give your friends a copy of it!
-
- 4) Send bug reports (and praise/support) to
-
- bojsen@moria.dc.dth.dk
-
- Snail mail:
-
- Per Bojsen
- Maglegaards Alle 51 st. th.
- DK-2860 Soeborg
- Denmark
-
- 5) Release notes.
-
- 37.2 First publically released version.
- 37.3 Now uses the UserShell when starting programs.
- 37.4 Fixed bug in handling multiple outstanding read packets at
- EOF. The bug caused the handler to wait forever.
- 37.5 Improved cloning of filehandles so that >> redirection and
- mixed reading/writing between parent and child process work
- better.
-
- --**--
-
- End of README.
-