diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
commit | fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch) | |
tree | bdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/fio/fswapfd.x | |
download | iraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz |
Initial commit
Diffstat (limited to 'sys/fio/fswapfd.x')
-rw-r--r-- | sys/fio/fswapfd.x | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sys/fio/fswapfd.x b/sys/fio/fswapfd.x new file mode 100644 index 00000000..d51d69a9 --- /dev/null +++ b/sys/fio/fswapfd.x @@ -0,0 +1,37 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include <config.h> +include <fio.h> + +define SWAPI {tempi=$1;$1=$2;$2=tempi} +define SWAPL {templ=$1;$1=$2;$2=templ} +define SWAPP {tempp=$1;$1=$2;$2=tempp} + +# FSWAPFD -- Swap the file descriptors of two open files. All i/o to file +# fd1 is redirected to fd2 and vice versa, until the swap is reversed. +# We are used by FREDIR to temporarily redirect i/o (normally to one of the +# standard streams) to a special file. If CLOSE is called to close a +# redirected file, we are called to unswap the two streams and then the +# redirection file is closed. All the i/o pointers, buffer pointers, and +# so on of the original stream are restored to exactly the condition they +# were in before (unless i/o has occurred on the other file during the +# interim). + +procedure fswapfd (fd1, fd2) + +int fd1, fd2 # file descriptors to be swapped. +int tempi +long templ +pointer tempp +include <fio.com> + +begin + SWAPL (boffset[fd1], boffset[fd2]) + SWAPP (bufptr[fd1], bufptr[fd2]) + SWAPP (buftop[fd1], buftop[fd2]) + SWAPP (iop[fd1], iop[fd2]) + SWAPP (itop[fd1], itop[fd2]) + SWAPP (otop[fd1], otop[fd2]) + SWAPP (fiodes[fd1], fiodes[fd2]) + SWAPI (redir_fd[fd1], redir_fd[fd2]) +end |