aboutsummaryrefslogtreecommitdiff
path: root/sys/qpoe/qpsync.x
diff options
context:
space:
mode:
Diffstat (limited to 'sys/qpoe/qpsync.x')
-rw-r--r--sys/qpoe/qpsync.x51
1 files changed, 51 insertions, 0 deletions
diff --git a/sys/qpoe/qpsync.x b/sys/qpoe/qpsync.x
new file mode 100644
index 00000000..692136d6
--- /dev/null
+++ b/sys/qpoe/qpsync.x
@@ -0,0 +1,51 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include "qpoe.h"
+
+# QP_SYNC -- Update the poefile on disk.
+
+procedure qp_sync (qp)
+
+pointer qp #I QPOE descriptor
+
+int n, fd
+pointer sp, qph
+int fm_fopen()
+errchk qp_flushpar, fm_fopen, write, stsave
+
+begin
+ # Flush the put-parameter buffer.
+ call qp_flushpar (qp)
+
+ # Update the QPOE descriptor and symbol table in the datafile.
+ if (QP_MODIFIED(qp) != NO) {
+ call smark (sp)
+ call salloc (qph, LEN_QPH, TY_STRUCT)
+ call aclri (Memi[qph], LEN_QPH)
+
+ QPH_MAGIC(qph) = QP_MAGIC(qp)
+ QPH_VERSION(qph) = QPOE_VERSION
+ QPH_STOFFSET(qph) = LEN_QPH * SZ_STRUCT + 1
+
+ # The encoded QPOE header and symbol table are stored in a
+ # binary lfile in the datafile.
+
+ fd = fm_fopen (QP_FM(qp), LF_QPOE, NEW_FILE, BINARY_FILE)
+
+ # Update the QPOE file header.
+ n = LEN_QPH * SZ_STRUCT
+ call miipak32 (Memi[qph], Memi[qph], LEN_QPH, TY_STRUCT)
+ call write (fd, Memi[qph], n)
+
+ # Update the symbol table.
+ call stsqueeze (QP_ST(qp))
+ call stsave (QP_ST(qp), fd)
+
+ QP_MODIFIED(qp) = NO
+ call close (fd)
+ call sfree (sp)
+ }
+
+ # Update the datafile itself.
+ call fm_fcsync (QP_FM(qp))
+end