From 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 Mon Sep 17 00:00:00 2001 From: Joe Hunkeler Date: Tue, 11 Aug 2015 16:51:37 -0400 Subject: Repatch (from linux) of OSX IRAF --- sys/mwcs/mwswattrs.x | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 sys/mwcs/mwswattrs.x (limited to 'sys/mwcs/mwswattrs.x') diff --git a/sys/mwcs/mwswattrs.x b/sys/mwcs/mwswattrs.x new file mode 100644 index 00000000..14fc72bd --- /dev/null +++ b/sys/mwcs/mwswattrs.x @@ -0,0 +1,57 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include +include "mwcs.h" + +# MW_SWATTRS -- Set the string value of the named WCS attribute for axis N. +# The attribute is created if not already defined. If axis N=0 is specified, +# the attribute pertains to the entire WCS, not just one axis. + +procedure mw_swattrs (mw, axis, attribute, valstr) + +pointer mw #I pointer to MWCS descriptor +int axis #I axis to which attribute belongs +char attribute[ARB] #I attribute name +char valstr[ARB] #I attribute value + +pointer wp, ap +int atno, i +bool streq() +int mw_refstr() +errchk syserrs, mw_refstr + +begin + # Get current WCS. + wp = MI_WCS(mw) + if (wp == NULL) + call syserrs (SYS_MWNOWCS, "mw_swattrs") + + # Lookup the named attribute and replace the pointer to the value + # string if found. Otherwise, add a new attribute. + + atno = 0 + do i = 1, WCS_NWATTR(wp) { + ap = WCS_WATTR(wp,i) + if (AT_AXIS(ap) == axis) + if (streq (S(mw,AT_NAME(ap)), attribute)) { + atno = i + break + } + } + + # Add a new attribute? + if (atno == 0) { + atno = WCS_NWATTR(wp) + 1 + if (atno > MAX_WATTR) + call syserrs (SYS_MWATOVFL, attribute) + else { + WCS_NWATTR(wp) = atno + ap = WCS_WATTR(wp,atno) + AT_AXIS(ap) = axis + AT_NAME(ap) = mw_refstr (mw, attribute) + } + } + + # Store the value string. + AT_VALUE(ap) = mw_refstr (mw, valstr) +end -- cgit