aboutsummaryrefslogtreecommitdiff
path: root/sys/gio/stdgraph/stgclose.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/gio/stdgraph/stgclose.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'sys/gio/stdgraph/stgclose.x')
-rw-r--r--sys/gio/stdgraph/stgclose.x47
1 files changed, 47 insertions, 0 deletions
diff --git a/sys/gio/stdgraph/stgclose.x b/sys/gio/stdgraph/stgclose.x
new file mode 100644
index 00000000..3d7eb70b
--- /dev/null
+++ b/sys/gio/stdgraph/stgclose.x
@@ -0,0 +1,47 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include "stdgraph.h"
+
+# STG_CLOSE -- Close the STDGRAPH kernel. Free all storage associated with the
+# stdgraph descriptor. Note that the stdgraph kernel may be multiply opened
+# (connected to two or more graphics steams, e.g., both STDGRAPH and STDIMAGE),
+# hence we do not physically close down until the last stream is closed.
+
+procedure stg_close()
+
+include "stdgraph.com"
+
+begin
+ g_nopen = g_nopen - 1
+
+ if (g_nopen <= 0) {
+ call stg_deactivatews (0)
+ call flush (g_out)
+ call mfree (SG_SBUF(g_sg), TY_CHAR)
+ call mfree (g_sg, TY_STRUCT)
+
+ if (g_tty != NULL) {
+ call ttycdes (g_tty)
+ g_tty = NULL
+ }
+
+ if (g_term != NULL) {
+ call ttycdes (g_term)
+ g_term = NULL
+ }
+
+ if (g_pbtty != NULL) {
+ call ttycdes (g_pbtty)
+ g_pbtty = NULL
+ }
+
+ if (g_msgbuf != NULL) {
+ call mfree (g_msgbuf, TY_CHAR)
+ g_msgbuf = NULL
+ g_msgbuflen = 0
+ g_msglen = 0
+ }
+
+ g_nopen = 0
+ }
+end