aboutsummaryrefslogtreecommitdiff
path: root/sys/gio/gclose.x
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /sys/gio/gclose.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/gio/gclose.x')
-rw-r--r--sys/gio/gclose.x45
1 files changed, 45 insertions, 0 deletions
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 <gio.h>
+
+# 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