diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /noao/digiphot/photcal/mctable/mctput.gx | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'noao/digiphot/photcal/mctable/mctput.gx')
-rw-r--r-- | noao/digiphot/photcal/mctable/mctput.gx | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/noao/digiphot/photcal/mctable/mctput.gx b/noao/digiphot/photcal/mctable/mctput.gx new file mode 100644 index 00000000..893678b1 --- /dev/null +++ b/noao/digiphot/photcal/mctable/mctput.gx @@ -0,0 +1,68 @@ +include "../lib/mctable.h" + +$for (csilrdxp) +# MCT_PUT - Put value randomly (generic) + +procedure mct_put$t (table, row, col, value) + +pointer table # table descriptor +int row # row number +int col # column number +PIXEL value # data value + +int offset +pointer base +errchk mct_indef() + +begin + # Check pointer and magic number. + if (table == NULL) + call error (0, "mct_put: Null table pointer") + if (MCT_MAGIC (table) != MAGIC) + call error (0, "mct_put: Bad magic number") + + # Check the table type. + if (MCT_TYPE (table) != TY_PIXEL) + call error (0, "mct_put: Wrong table type") + + # Test row and column values. + if (row < 1) + call error (0, "mct_put: Row number less than one") + if (col < 1 || col > MCT_MAXCOL (table)) + call error (0, "mct_put: Column out of range") + + # Reallocate space if necessary. + if (row > MCT_MAXROW (table)) { + + # Compute offset of new area. + offset = MCT_MAXROW (table) * MCT_MAXCOL (table) + + # Recompute new number of rows and reallocate buffer. + MCT_MAXROW (table) = MCT_MAXROW (table) + MCT_INCROWS (table) + call realloc (MCT_DATA (table), + MCT_MAXROW (table) * MCT_MAXCOL (table), TY_PIXEL) + + # Compute base address of new area and clear it with INDEF. + base = MCT_DATA (table) + offset + call mct_indef (table, base, + MCT_INCROWS (table) * MCT_MAXCOL (table)) + } + + # Update row and column counter, only if the new entries are beyond + # the old limits. + + if (row > MCT_NPROWS (table)) { + MCT_NPROWS (table) = row + MCT_NPCOLS (table) = col + } else if (col > MCT_NPCOLS (table)) + MCT_NPCOLS (table) = col + + # Enter variable. + base = MCT_DATA (table) + (row - 1) * MCT_MAXCOL (table) + $if (datatype == p) + MEMP[base + col - 1] = value + $else + Mem$t[base + col - 1] = value + $endif +end +$endfor |