diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /sys/fmio/fmclose.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/fmio/fmclose.x')
-rw-r--r-- | sys/fmio/fmclose.x | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/sys/fmio/fmclose.x b/sys/fmio/fmclose.x new file mode 100644 index 00000000..87e20674 --- /dev/null +++ b/sys/fmio/fmclose.x @@ -0,0 +1,51 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include <syserr.h> +include <error.h> +include <knet.h> +include "fmio.h" + +# FM_CLOSE -- Close a datafile opened under FMIO. + +procedure fm_close (fm) + +pointer fm #I FMIO descriptor + +pointer lf +int status, i +errchk fmio_bind, fm_fcfree, fmio_errchk + +begin + # An open-new-file followed by a close should create an empty datafile. + if (FM_ACTIVE(fm) == NO) + call fmio_bind (fm) + + # Shut down the file cache, if in use (does a sync). + if (FM_FCACHE(fm) != NULL) + call fm_fcfree (fm) + else + call fm_sync (fm) + + # Report any posted errors. + call fmio_errchk (fm) + + # Close the physical datafile. + call zclsbf (FM_CHAN(fm), status) + if (status == ERR) + iferr (call syserrs (SYS_FMCLOSE, FM_DFNAME(fm))) + call erract (EA_WARN) + + # Free any storage used by the runtime file table. + lf = FM_FTABLE(fm) + do i = 0, FM_NLFILES(fm) { + if (LF_PAGEMAP(lf) != NULL) + call mfree (LF_PAGEMAP(lf), TY_INT) + lf = lf + LEN_FTE + } + + # Free the main descriptor. + call mfree (FM_PTABLE(fm), TY_SHORT) + call mfree (FM_PTINDEX(fm), TY_INT) + call mfree (FM_FTABLE(fm), TY_INT) + call mfree (fm, TY_STRUCT) +end |