From 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 Mon Sep 17 00:00:00 2001 From: Joe Hunkeler Date: Tue, 11 Aug 2015 16:51:37 -0400 Subject: Repatch (from linux) of OSX IRAF --- sys/fmio/fmclose.x | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 sys/fmio/fmclose.x (limited to 'sys/fmio/fmclose.x') 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 +include +include +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 -- cgit