mod_sed is an Apache module that embeds a copy of the sed command.
Version: 0.1mod_sed is an Apache module that embeds a copy of the sed command. This means that you can automatically filter data without having to spawn a CGI process.
License: The Apache License 2.0
Operating System: Linux
It probably doesn't have a lot of practical use, but I wrote it anyway. The main purpose was for me to learn how to write an apache module.
To build, you should just be able to type in "make". I'm still working on the portability aspects of this module, so it might not run on your system yet. All patches appreciated.
You'll need apxs(8) to build this module, because at present, I don't understand Apache's static configuration (again, patches welcome). Either edit the Makefile to specify the location of it, or put it on the command line like this:
% make APXS=/usr/local/sbin/apxs
If your system doesn't have an fgetln(3) call (to test, see if "man fgetln" returns anything), you'll also have to uncomment a line in the Makefile.
To install, "make install" should copy the mod_sed.so to your data directory and put the correct lines in your httpd.conf to enable it.
This is all the documentation you get until I write some more, I'm afraid.
You'll need: A directory or file that you want to run sed over inside Apache. In my case, this is "/usr/local/www/data/sed/". Copies of the files are in the "eg" subirectory. The httpd.conf fragment I used looked like this:
< Directory /usr/local/www/data/sed >
SedPathMap /foo /usr/local/www/data/sedscr.foo
< /Directory >
You'll need to make sure that the directory you specify is visible from Apache. In fact, it's probably a good idea to do that /before/ installing this module...
The important bit to activate mod_sed is the "SetHandler" line. That enables all files under that directory to be passed through mod_sed.
The "SedExtendedRegex" line asks that sed use Enhanced Regexes instead of basic ones. If you don't know what that means, always include this line. For more details on the differences between basic regexes and extended regexes see re_format(7).
The "SedProgram" keyword can specify either a whole sed program (like you would give on the command line with -e) or a pathname to a file containing a sed program (this is generally the preferred option). To determine between the two, mod_sed will attempt to see if a file by that name exists, otherwise it'll try and compile it as a program.
The last command, "SedPathMap" takes two arguments: a PATH_INFO and another SedProgram argument. What it means is that when somebody requests a file:
The sed program in /usr/local/www/data/sedscr.foo will get run instead of the default in SedProgram. This can be very handy for serving up alternative versions of files.