aboutsummaryrefslogtreecommitdiff
path: root/sys/gio/sgikern/sgiopenws.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/sgikern/sgiopenws.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/gio/sgikern/sgiopenws.x')
-rw-r--r--sys/gio/sgikern/sgiopenws.x98
1 files changed, 98 insertions, 0 deletions
diff --git a/sys/gio/sgikern/sgiopenws.x b/sys/gio/sgikern/sgiopenws.x
new file mode 100644
index 00000000..a2a5a7eb
--- /dev/null
+++ b/sys/gio/sgikern/sgiopenws.x
@@ -0,0 +1,98 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include <gki.h>
+include <error.h>
+include "sgi.h"
+
+# SGI_OPENWS -- Open the named workstation. Once a workstation has been
+# opened we leave it open until some other workstation is opened or the
+# kernel is closed. Opening a workstation involves initialization of the
+# kernel data structures, following by initialization of the device itself.
+
+procedure sgi_openws (devname, n, mode)
+
+short devname[ARB] # device name
+int n # length of device name
+int mode # access mode
+
+pointer sp, buf
+pointer ttygdes()
+bool streq()
+int sgk_open()
+bool need_open, same_dev
+include "sgi.com"
+
+begin
+ call smark (sp)
+ call salloc (buf, max (SZ_FNAME, n), TY_CHAR)
+
+ # If a device was named when the kernel was opened then output will
+ # always go to that device (g_device) regardless of the device named
+ # in the OPENWS instruction. If no device was named (null string)
+ # then unpack the device name, passed as a short integer array.
+
+ if (g_device[1] == EOS) {
+ call achtsc (devname, Memc[buf], n)
+ Memc[buf+n] = EOS
+ } else
+ call strcpy (g_device, Memc[buf], SZ_FNAME)
+
+ # Find out if first time, and if not, if same device as before
+ # note that if (g_kt == NULL), then same_dev is false.
+
+ same_dev = false
+ need_open = true
+
+ if (g_kt != NULL) {
+ same_dev = (streq (Memc[SGI_DEVNAME(g_kt)], Memc[buf]))
+ if (!same_dev) {
+ # Does this device require a frame advance at end of metafile?
+ if (SGI_ENDFRAME(g_kt) == YES)
+ call sgk_frame (g_out)
+ call sgk_close (g_out)
+ } else
+ need_open = false
+ }
+
+ # Initialize the kernel data structures. Open graphcap descriptor
+ # for the named device, allocate and initialize descriptor and common.
+ # graphcap entry for device must exist.
+
+ if (need_open) {
+ if (!same_dev) {
+ if (g_kt != NULL)
+ call ttycdes (g_tty)
+ iferr (g_tty = ttygdes (Memc[buf]))
+ call erract (EA_ERROR)
+
+ # Initialize data structures if we had to open a new device.
+ call sgi_init (g_tty, Memc[buf])
+ call sgi_reset()
+ }
+
+ # Open the output file. Metacode output to the device will be
+ # spooled and then disposed of to the device at CLOSEWS time.
+
+ iferr (g_out = sgk_open (Memc[SGI_DEVNAME(g_kt)], g_tty)) {
+ call ttycdes (g_tty)
+ call erract (EA_ERROR)
+ } else {
+ # Does this device require a frame advance at start of metafile?
+ if (SGI_STARTFRAME(g_kt) == YES)
+ call sgk_frame (g_out)
+ g_nframes = 0
+ g_ndraw = 0
+ }
+ }
+
+ # Clear the screen if device is being opened in new_file mode.
+ # This is a nop if we really opened a new device, but it will clear
+ # the screen if this is just a reopen of the same device in new file
+ # mode.
+
+ if (mode == NEW_FILE)
+ call sgi_clear (0)
+
+ call sfree (sp)
+end