aboutsummaryrefslogtreecommitdiff
path: root/sys/gio/cursor/gtrfetch.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/cursor/gtrfetch.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'sys/gio/cursor/gtrfetch.x')
-rw-r--r--sys/gio/cursor/gtrfetch.x48
1 files changed, 48 insertions, 0 deletions
diff --git a/sys/gio/cursor/gtrfetch.x b/sys/gio/cursor/gtrfetch.x
new file mode 100644
index 00000000..44ccfe60
--- /dev/null
+++ b/sys/gio/cursor/gtrfetch.x
@@ -0,0 +1,48 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <gio.h>
+include <gki.h>
+include "gtr.h"
+
+# GTR_FETCH_NEXT_INSTRUCTION -- Return a pointer to the next GKI metacode
+# instruction in the input buffer. Only complete instructions resident in
+# a contiguous section of memory are returned. EOF is returned when the
+# end of the current buffer is reached, or when the last instruction in the
+# frame buffer is not yet complete. EOF does not signify the end of the
+# metacode stream.
+
+int procedure gtr_fetch_next_instruction (tr, gki)
+
+pointer tr # pointer to giotr descriptor
+pointer gki # pointer to next instruction (output)
+
+int nleft, length
+pointer ip, itop
+
+begin
+ ip = TR_IP(tr)
+ itop = TR_OP(tr)
+
+ # Search for the beginning of the next instruction.
+ while (Mems[ip] != BOI && ip < itop)
+ ip = ip + 1
+
+ nleft = itop - ip
+ if (nleft < 3) {
+ # The length field of the next instruction is not yet present.
+ TR_IP(tr) = ip
+ return (EOF)
+ } else {
+ length = Mems[ip+GKI_HDR_LENGTH-1]
+ if (length > nleft) {
+ # Entire instruction is not yet present in buffer.
+ TR_IP(tr) = ip
+ return (EOF)
+ } else {
+ # Entire instruction is present in buffer.
+ TR_IP(tr) = ip + length
+ gki = ip
+ return (length)
+ }
+ }
+end