aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/photcal/mctable/mctcopy.gx
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 /noao/digiphot/photcal/mctable/mctcopy.gx
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'noao/digiphot/photcal/mctable/mctcopy.gx')
-rw-r--r--noao/digiphot/photcal/mctable/mctcopy.gx63
1 files changed, 63 insertions, 0 deletions
diff --git a/noao/digiphot/photcal/mctable/mctcopy.gx b/noao/digiphot/photcal/mctable/mctcopy.gx
new file mode 100644
index 00000000..c30f321a
--- /dev/null
+++ b/noao/digiphot/photcal/mctable/mctcopy.gx
@@ -0,0 +1,63 @@
+include "../lib/mctable.h"
+
+
+# MCT_COPY - Copy one table into another. The destination table is allocated
+# or reallocated if necessary.
+
+procedure mct_copy (itable, otable)
+
+pointer itable # input table descriptor
+pointer otable # output table descriptor
+
+int isize, osize # table sizes
+
+errchk mct_alloc()
+
+begin
+ # Check input pointer and magic number.
+ if (itable == NULL)
+ call error (0, "mct_copy: Null input table pointer")
+ if (MCT_MAGIC (itable) != MAGIC)
+ call error (0, "mct_copy: Bad input magic number")
+
+ # Compute input table size.
+ isize = MCT_MAXROW (itable) * MCT_MAXCOL (itable)
+
+ # Check output pointer. Try to minimize space allocation.
+ if (otable == NULL)
+ call mct_alloc (otable, MCT_MAXROW (itable), MCT_MAXCOL (itable),
+ MCT_TYPE (itable))
+ else if (MCT_MAGIC (otable) == MAGIC) {
+ osize = MCT_MAXROW (otable) * MCT_MAXCOL (otable)
+ if (isize != osize || MCT_TYPE (itable) != MCT_TYPE (otable))
+ call realloc (MCT_DATA (otable), isize, MCT_TYPE (itable))
+ } else
+ call error (0, "mct_copy: Bad output magic number")
+
+ # Copy structure.
+ MCT_MAGIC (otable) = MCT_MAGIC (itable)
+ MCT_TYPE (otable) = MCT_TYPE (itable)
+ MCT_MAXROW (otable) = MCT_MAXROW (itable)
+ MCT_MAXCOL (otable) = MCT_MAXCOL (itable)
+ MCT_INCROWS (otable) = MCT_INCROWS (itable)
+ MCT_NPROWS (otable) = MCT_NPROWS (itable)
+ MCT_NPCOLS (otable) = MCT_NPCOLS (itable)
+ MCT_NGROWS (otable) = MCT_NGROWS (itable)
+ MCT_NGCOLS (otable) = MCT_NGCOLS (itable)
+
+ # Copy data buffer.
+ switch (MCT_TYPE (otable)) {
+ $for (csilrdxp)
+ case TY_PIXEL:
+ $if (datatype == p)
+ call amovi (Memi[MCT_DATA (itable)], Memi[MCT_DATA (otable)],
+ isize)
+ $else
+ call amov$t (Mem$t[MCT_DATA (itable)], Mem$t[MCT_DATA (otable)],
+ isize)
+ $endif
+ $endfor
+ default:
+ call error (0, "mct_copy: Unknown table type")
+ }
+end