RW(1) RW(1) NAME rw - read from a file, write to a file SYNOPSIS rw [-i infilename] [-o outfilename] [-v] DESCRIPTION Rw is for reading from one file, (which may be a named pipe,) and writ- ing what is read to another file, (which may be a named pipe.) It is a template/skeleton for constructing formal file operations on Unix, (specifically for daemons that listen on a pipe.) 1) If the input file is a named pipe, it is opened with O_RDWR, (with no locks,) and if the process writing to the pipe exits, this program will continue to "listen" on the pipe for another process to open the pipe and write data. 2) The output file is opened for each input record from the input file-and closed after the record is written to the output file. Note that opening and closing the output file for every record is a time consuming process-unless absolutely necessary, it is advisable to open and close the output file at the beginning and end of the program. 3) A mandatory lock is placed on the output file, unless it is stdout. If acquisition of the lock fails, an attempt will be made in one second, (up to lock_wait many seconds,) for the lock. 4) If the output file is a named pipe, or stdout, it is not flushed; if it is a regular file, it is. Note that flushing the output file after every record written is a time consuming process-unless flushing is absolutely necessary, it is advisable to remove the write flush code. Flushing a named pipe causes the listing program to exit, and stdout should not be flushed. 5) The input file is read, one character at a time, and the buffered record processed, (written to the output file in this case,) on any '0 character. The read (2) function may not be considered canonical in all cases, (and partial records may be returned from read (2)). OPTIONS -i infilename Input filename, (stdin). -o outfilename Output filename, (stdout). -v Print the version and copyright banner of the program. AUTHORS ---------------------------------------------------------------------- A license is hereby granted to reproduce this software source code and to create executable versions from this source code for personal, non-commercial use. The copyright notice included with the software must be maintained in all copies produced. THIS PROGRAM IS PROVIDED "AS IS". THE AUTHOR PROVIDES NO WARRANTIES WHATSOEVER, EXPRESSED OR IMPLIED, INCLUDING WARRANTIES OF MERCHANTABILITY, TITLE, OR FITNESS FOR ANY PARTICULAR PURPOSE. THE AUTHOR DOES NOT WARRANT THAT USE OF THIS PROGRAM DOES NOT INFRINGE THE INTELLECTUAL PROPERTY RIGHTS OF ANY THIRD PARTY IN ANY COUNTRY. Copyright (c) 1994-2007, John Conover, All Rights Reserved. Comments and/or bug reports should be addressed to: john@email.johncon.com (John Conover) ---------------------------------------------------------------------- December 18, 2007 RW(1)