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/gio/gclose.x | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 sys/gio/gclose.x (limited to 'sys/gio/gclose.x') diff --git a/sys/gio/gclose.x b/sys/gio/gclose.x new file mode 100644 index 00000000..a6802a0a --- /dev/null +++ b/sys/gio/gclose.x @@ -0,0 +1,45 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include + +# GCLOSE -- Close a graphics stream previously opened with GOPEN. Flush any +# buffered polyline output, output the close worstation metacode instruction, +# close the output stream, close the graphcap descriptor, and return all +# buffer space. + +procedure gclose (gp) + +pointer gp # graphics descriptor + +int fd +int and() + +begin + fd = GP_FD(gp) + + if (and (GP_GFLAGS(gp), GF_WSOPEN) != 0) { + call gflush (gp) + call gki_closews (fd, GP_DEVNAME(gp)) + + # If the output stream is a file rather than a standard graphics + # stream, write a WCS savefile to permit restoration of the WCS if + # the device is subsequently opened in APPEND mode. + + if (fd > STDPLOT) + call gwrwcs (GP_DEVNAME(gp), + Memi[GP_WCSPTR(gp,1)], LEN_WCSARRAY) + + # If the output file was opened by GOPEN (as indicated by the + # CLOSEFD flag), close the file. + + if (and (GP_GFLAGS(gp), GF_CLOSEFD) != 0) + call close (fd) + else + call flush (fd) + } + + call ttycdes (GP_TTY(gp)) + call mfree (gp, TY_STRUCT) + call gki_redir (fd, NULL, NULL, NULL) + call gexfls_clear (fd) +end -- cgit