From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- sys/imio/iki/stf/stfordgpb.x | 64 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 sys/imio/iki/stf/stfordgpb.x (limited to 'sys/imio/iki/stf/stfordgpb.x') diff --git a/sys/imio/iki/stf/stfordgpb.x b/sys/imio/iki/stf/stfordgpb.x new file mode 100644 index 00000000..7099e106 --- /dev/null +++ b/sys/imio/iki/stf/stfordgpb.x @@ -0,0 +1,64 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include +include "stf.h" + +# STF_ORDERGPB -- Order the GPB, putting the group parameters in the +# new image in the same order as in the old image. +# NOTE: no longer called by stf_opix; save this code for future use! +# + +procedure stf_ordergpb (o_stf, n_stf) + +pointer o_stf # STF descriptor of old image +pointer n_stf # STF descriptor of new image + +pointer sp, temp_pdes, pp, o_plist, n_plist +int o_pcount, n_pcount, otop, ntop, op, np, offset, sz_param, pn +bool streq() + +begin + o_pcount = STF_PCOUNT(o_stf) + n_pcount = STF_PCOUNT(n_stf) + if (o_pcount <= 0) + return + + call smark (sp) + call salloc (temp_pdes, LEN_PDES, TY_STRUCT) + + o_plist = STF_PDES(o_stf,1) + n_plist = STF_PDES(n_stf,1) + otop = (o_pcount * LEN_PDES) + ntop = (n_pcount * LEN_PDES) + + # Search the new parameter list for a parameter with the same name + # as a parameter in the old parameter list. When a match is found, + # move the new parameter into the same position as it is in the + # old parameter list. + + for (op=0; op < otop; op=op+LEN_PDES) + for (np=op; np < ntop; np=np+LEN_PDES) + if (streq (P_PTYPE(o_plist+op), P_PTYPE(n_plist+np))) { + if (op != np) { + # Swap parameters between old and new positions + call amovi (Memi[n_plist+op], Memi[temp_pdes], + LEN_PDES) + call amovi (Memi[n_plist+np], Memi[n_plist+op], + LEN_PDES) + call amovi (Memi[temp_pdes], Memi[n_plist+np], + LEN_PDES) + } + break + } + + # Update the field offsets. + offset = 0 + for (pn=1; pn <= n_pcount; pn=pn+1) { + pp = STF_PDES(n_stf,pn) + P_OFFSET(pp) = offset + sz_param = P_PSIZE(pp) / NBITS_BYTE / SZB_CHAR + offset = offset + sz_param + } + + call sfree (sp) +end -- cgit