Index: /trunk/psLib/psLib.kdevelop.filelist
===================================================================
--- /trunk/psLib/psLib.kdevelop.filelist	(revision 2272)
+++ /trunk/psLib/psLib.kdevelop.filelist	(revision 2273)
@@ -1,451 +1,1 @@
 # KDevelop Custom Project File List
-psLib.kdevelop
-psLib.kdevses
-testbin/CVS/Entries
-testbin/CVS/Repository
-testbin/CVS/Root
-test/FullUnitTest
-test/Makefile
-test/psTest.c
-test/psTest.h
-test/runTest
-test/tst_template.c
-test/sysUtils/Makefile
-test/sysUtils/tst_psAbort.c
-test/sysUtils/tst_psError.c
-test/sysUtils/tst_psLogMsg.c
-test/sysUtils/tst_psMemory.c
-test/sysUtils/tst_psStringCopy.c
-test/sysUtils/tst_psTrace.c
-test/sysUtils/verified/tst_psAbort.stderr
-test/sysUtils/verified/tst_psAbort.stdout
-test/sysUtils/verified/tst_psError.stderr
-test/sysUtils/verified/tst_psError.stdout
-test/sysUtils/verified/tst_psHash00.stderr
-test/sysUtils/verified/tst_psHash00.stdout
-test/sysUtils/verified/tst_psHash01.stderr
-test/sysUtils/verified/tst_psHash01.stdout
-test/sysUtils/verified/tst_psHash02.stderr
-test/sysUtils/verified/tst_psHash03.stderr
-test/sysUtils/verified/tst_psHash03.stdout
-test/sysUtils/verified/tst_psHash04.stderr
-test/sysUtils/verified/tst_psHash04.stdout
-test/sysUtils/verified/tst_psLogMsg.stderr
-test/sysUtils/verified/tst_psLogMsg.stdout
-test/sysUtils/verified/tst_psMemory.stderr
-test/sysUtils/verified/tst_psStringCopy.stderr
-test/sysUtils/verified/tst_psStringCopy.stdout
-test/sysUtils/verified/tst_psTrace.stderr
-test/sysUtils/verified/tst_psTrace.stdout
-test/sysUtils/verified/CVS/Entries
-test/sysUtils/verified/CVS/Repository
-test/sysUtils/verified/CVS/Root
-test/sysUtils/CVS/Entries
-test/sysUtils/CVS/Entries.Log
-test/sysUtils/CVS/Repository
-test/sysUtils/CVS/Root
-test/sysUtils/builddir/CVS/Entries
-test/sysUtils/builddir/CVS/Repository
-test/sysUtils/builddir/CVS/Root
-test/image/Makefile
-test/image/tst_psImage.c
-test/image/tst_psImageExtraction.c
-test/image/tst_psImageFFT.c
-test/image/tst_psImageIO.c
-test/image/tst_psImageManip.c
-test/image/tst_psImageStats00.c
-test/image/tst_psImageStats01.c
-test/image/tst_psImageStats02.c
-test/image/tst_psImageStats03.c
-test/image/verified/fOut.fits
-test/image/verified/sOut.fits
-test/image/verified/tst_psImage.stderr
-test/image/verified/tst_psImageExtraction.stderr
-test/image/verified/tst_psImageFFT.stderr
-test/image/verified/tst_psImageIO.stderr
-test/image/verified/tst_psImageManip.stderr
-test/image/verified/tst_psImageManip.stdout
-test/image/verified/tst_psImageStats00.stderr
-test/image/verified/tst_psImageStats00.stdout
-test/image/verified/tst_psImageStats01.stderr
-test/image/verified/tst_psImageStats01.stdout
-test/image/verified/tst_psImageStats02.stdout
-test/image/verified/CVS/Entries
-test/image/verified/CVS/Repository
-test/image/verified/CVS/Root
-test/image/CVS/Entries
-test/image/CVS/Entries.Log
-test/image/CVS/Repository
-test/image/CVS/Root
-test/dataManip/Makefile
-test/dataManip/tst_psFunc00.c
-test/dataManip/tst_psFunc01.c
-test/dataManip/tst_psFunc02.c
-test/dataManip/tst_psFunc03.c
-test/dataManip/tst_psFunc04.c
-test/dataManip/tst_psFunc05.c
-test/dataManip/tst_psFunc07.c
-test/dataManip/tst_psHist00.c
-test/dataManip/tst_psHist01.c
-test/dataManip/tst_psHist02.c
-test/dataManip/tst_psHist03.c
-test/dataManip/tst_psMatrix01.c
-test/dataManip/tst_psMatrix02.c
-test/dataManip/tst_psMatrix03.c
-test/dataManip/tst_psMatrix04.c
-test/dataManip/tst_psMatrix05.c
-test/dataManip/tst_psMatrix06.c
-test/dataManip/tst_psMatrix07.c
-test/dataManip/tst_psMatrixVectorArithmetic01.c
-test/dataManip/tst_psMatrixVectorArithmetic02.c
-test/dataManip/tst_psMatrixVectorArithmetic03.c
-test/dataManip/tst_psMinimize00.c
-test/dataManip/tst_psMinimize01.c
-test/dataManip/tst_psMinimize02.c
-test/dataManip/tst_psMinimize03.c
-test/dataManip/tst_psMinimize04.c
-test/dataManip/tst_psMinimize05.c
-test/dataManip/tst_psMinimize06.c
-test/dataManip/tst_psStats00.c
-test/dataManip/tst_psStats01.c
-test/dataManip/tst_psStats02.c
-test/dataManip/tst_psStats03.c
-test/dataManip/tst_psStats04.c
-test/dataManip/tst_psStats05.c
-test/dataManip/tst_psStats06.c
-test/dataManip/tst_psStats07.c
-test/dataManip/tst_psStats08.c
-test/dataManip/tst_psStats09.c
-test/dataManip/tst_psVectorFFT.c
-test/dataManip/verified/tst_psFunc00.stderr
-test/dataManip/verified/tst_psFunc00.stdout
-test/dataManip/verified/tst_psFunc01.stdout
-test/dataManip/verified/tst_psHist00.stdout
-test/dataManip/verified/tst_psHist01.stdout
-test/dataManip/verified/tst_psHist02.stdout
-test/dataManip/verified/tst_psMatrix01.stdout
-test/dataManip/verified/tst_psMatrix02.stderr
-test/dataManip/verified/tst_psMatrix02.stdout
-test/dataManip/verified/tst_psMatrix03.stderr
-test/dataManip/verified/tst_psMatrix03.stdout
-test/dataManip/verified/tst_psMatrix04.stderr
-test/dataManip/verified/tst_psMatrix04.stdout
-test/dataManip/verified/tst_psMatrix05.stdout
-test/dataManip/verified/tst_psMatrix06.stdout
-test/dataManip/verified/tst_psMatrix07.stderr
-test/dataManip/verified/tst_psMatrix07.stdout
-test/dataManip/verified/tst_psMatrixVectorArithmetic01.stderr
-test/dataManip/verified/tst_psMatrixVectorArithmetic01.stdout
-test/dataManip/verified/tst_psMatrixVectorArithmetic02.stdout
-test/dataManip/verified/tst_psMatrixVectorArithmetic03.stderr
-test/dataManip/verified/tst_psMatrixVectorArithmetic03.stdout
-test/dataManip/verified/tst_psStats00.stdout
-test/dataManip/verified/tst_psStats01.stdout
-test/dataManip/verified/tst_psStats02.stdout
-test/dataManip/verified/tst_psStats03.stdout
-test/dataManip/verified/tst_psStats05.stdout
-test/dataManip/verified/tst_psStats06.stdout
-test/dataManip/verified/tst_psStats07.stdout
-test/dataManip/verified/tst_psStats08.stdout
-test/dataManip/verified/tst_psStats09.stdout
-test/dataManip/verified/tst_psVectorFFT.stderr
-test/dataManip/verified/CVS/Entries
-test/dataManip/verified/CVS/Repository
-test/dataManip/verified/CVS/Root
-test/dataManip/CVS/Entries
-test/dataManip/CVS/Entries.Log
-test/dataManip/CVS/Repository
-test/dataManip/CVS/Root
-test/dataManip/builddir/CVS/Entries
-test/dataManip/builddir/CVS/Repository
-test/dataManip/builddir/CVS/Root
-test/CVS/Entries
-test/CVS/Entries.Log
-test/CVS/Repository
-test/CVS/Root
-test/collections/Makefile
-test/collections/tst_psArray.c
-test/collections/tst_psBitSet.c
-test/collections/tst_psHash00.c
-test/collections/tst_psHash01.c
-test/collections/tst_psHash02.c
-test/collections/tst_psHash03.c
-test/collections/tst_psHash04.c
-test/collections/tst_psList.c
-test/collections/tst_psVector.c
-test/collections/tst_psVectorSort_01.c
-test/collections/tst_psVectorSort_02.c
-test/collections/tst_psVectorSort_03.c
-test/collections/tst_psVectorSort_04.c
-test/collections/verified/tst_psArray.stdout
-test/collections/verified/tst_psBitSet.stderr
-test/collections/verified/tst_psHash00.stderr
-test/collections/verified/tst_psHash00.stdout
-test/collections/verified/tst_psHash01.stderr
-test/collections/verified/tst_psHash01.stdout
-test/collections/verified/tst_psHash02.stderr
-test/collections/verified/tst_psHash03.stderr
-test/collections/verified/tst_psHash03.stdout
-test/collections/verified/tst_psHash04.stderr
-test/collections/verified/tst_psHash04.stdout
-test/collections/verified/tst_psList.stderr
-test/collections/verified/tst_psSort_01.stderr
-test/collections/verified/tst_psSort_01.stdout
-test/collections/verified/tst_psSort_02.stdout
-test/collections/verified/tst_psSort_03.stderr
-test/collections/verified/tst_psSort_03.stdout
-test/collections/verified/tst_psSort_04.stderr
-test/collections/verified/tst_psSort_04.stdout
-test/collections/verified/tst_psVector.stderr
-test/collections/verified/tst_psVector.stdout
-test/collections/verified/tst_psVector_01.stderr
-test/collections/verified/tst_psVector_01.stdout
-test/collections/verified/tst_psVector_02.stdout
-test/collections/verified/tst_psVector_03.stdout
-test/collections/verified/tst_psVectorSort_01.stderr
-test/collections/verified/tst_psVectorSort_01.stdout
-test/collections/verified/tst_psVectorSort_02.stderr
-test/collections/verified/tst_psVectorSort_02.stdout
-test/collections/verified/tst_psVectorSort_03.stderr
-test/collections/verified/tst_psVectorSort_03.stdout
-test/collections/verified/tst_psVectorSort_04.stderr
-test/collections/verified/tst_psVectorSort_04.stdout
-test/collections/verified/CVS/Entries
-test/collections/verified/CVS/Repository
-test/collections/verified/CVS/Root
-test/collections/CVS/Entries
-test/collections/CVS/Entries.Log
-test/collections/CVS/Repository
-test/collections/CVS/Root
-test/collections/builddir/CVS/Entries
-test/collections/builddir/CVS/Repository
-test/collections/builddir/CVS/Root
-test/astronomy/header_1.fits
-test/astronomy/header_2.fits
-test/astronomy/Makefile
-test/astronomy/tst_psMetadata_01.c
-test/astronomy/tst_psMetadata_02.c
-test/astronomy/tst_psMetadata_03.c
-test/astronomy/tst_psMetadata_04.c
-test/astronomy/tst_psMetadata_05.c
-test/astronomy/tst_psMetadata_06.c
-test/astronomy/tst_psTime_01.c
-test/astronomy/tst_psTime_02.c
-test/astronomy/verified/tst_psMetadata_01.stderr
-test/astronomy/verified/tst_psMetadata_01.stdout
-test/astronomy/verified/tst_psMetadata_02.stderr
-test/astronomy/verified/tst_psMetadata_02.stdout
-test/astronomy/verified/tst_psMetadata_03.stderr
-test/astronomy/verified/tst_psMetadata_03.stdout
-test/astronomy/verified/tst_psMetadata_04.stderr
-test/astronomy/verified/tst_psMetadata_04.stdout
-test/astronomy/verified/tst_psMetadata_05.stderr
-test/astronomy/verified/tst_psMetadata_05.stdout
-test/astronomy/verified/tst_psMetadata_06.stdout
-test/astronomy/verified/tst_psTime_01.stdout
-test/astronomy/verified/tst_psTime_02.stderr
-test/astronomy/verified/tst_psTime_02.stdout
-test/astronomy/verified/CVS/Entries
-test/astronomy/verified/CVS/Repository
-test/astronomy/verified/CVS/Root
-test/astronomy/CVS/Entries
-test/astronomy/CVS/Entries.Log
-test/astronomy/CVS/Repository
-test/astronomy/CVS/Root
-test/astronomy/builddir/tst_psMetadata_01.d
-test/astronomy/builddir/tst_psMetadata_02.d
-test/astronomy/builddir/tst_psMetadata_03.d
-test/astronomy/builddir/tst_psMetadata_04.d
-test/astronomy/builddir/tst_psMetadata_05.d
-test/astronomy/builddir/tst_psMetadata_06.d
-test/astronomy/builddir/tst_psTime_01.d
-test/astronomy/builddir/tst_psTime_02.d
-test/astronomy/builddir/CVS/Entries
-test/astronomy/builddir/CVS/Repository
-test/astronomy/builddir/CVS/Root
-src/Doxyfile
-src/mainpage.dox
-src/Makefile
-src/Makefile.Globals
-src/parseErrorCodes.pl
-src/psErrorCodes.dat
-src/pslib.h
-src/sysUtils/Makefile
-src/sysUtils/psAbort.c
-src/sysUtils/psAbort.h
-src/sysUtils/psError.c
-src/sysUtils/psError.h
-src/sysUtils/psErrorCodes.c
-src/sysUtils/psErrorCodes.h
-src/sysUtils/psLogMsg.c
-src/sysUtils/psLogMsg.h
-src/sysUtils/psMemory.c
-src/sysUtils/psMemory.h
-src/sysUtils/psString.c
-src/sysUtils/psString.h
-src/sysUtils/psSysUtilsErrors.dat
-src/sysUtils/psSysUtilsErrors.h
-src/sysUtils/psTrace.c
-src/sysUtils/psTrace.h
-src/sysUtils/psType.h
-src/sysUtils/README
-src/sysUtils/makedir/psAbort.d
-src/sysUtils/makedir/psError.d
-src/sysUtils/makedir/psErrorCodes.d
-src/sysUtils/makedir/psHash.d
-src/sysUtils/makedir/psLogMsg.d
-src/sysUtils/makedir/psMemory.d
-src/sysUtils/makedir/psString.d
-src/sysUtils/makedir/psTrace.d
-src/sysUtils/makedir/CVS/Entries
-src/sysUtils/makedir/CVS/Repository
-src/sysUtils/makedir/CVS/Root
-src/sysUtils/CVS/Entries
-src/sysUtils/CVS/Entries.Log
-src/sysUtils/CVS/Repository
-src/sysUtils/CVS/Root
-src/image/Makefile
-src/image/psImage.c
-src/image/psImage.h
-src/image/psImageConvolve.c
-src/image/psImageConvolve.h
-src/image/psImageErrors.dat
-src/image/psImageErrors.h
-src/image/psImageExtraction.c
-src/image/psImageExtraction.h
-src/image/psImageFFT.c
-src/image/psImageFFT.h
-src/image/psImageIO.c
-src/image/psImageIO.h
-src/image/psImageManip.c
-src/image/psImageManip.h
-src/image/psImageStats.c
-src/image/psImageStats.h
-src/image/makedir/psImage.d
-src/image/makedir/psImageConvolve.d
-src/image/makedir/psImageExtraction.d
-src/image/makedir/psImageFFT.d
-src/image/makedir/psImageIO.d
-src/image/makedir/psImageManip.d
-src/image/makedir/psImageStats.d
-src/image/makedir/CVS/Entries
-src/image/makedir/CVS/Repository
-src/image/makedir/CVS/Root
-src/image/CVS/Entries
-src/image/CVS/Entries.Log
-src/image/CVS/Repository
-src/image/CVS/Root
-src/dataManip/Makefile
-src/dataManip/psDataManipErrors.dat
-src/dataManip/psDataManipErrors.h
-src/dataManip/psFunctions.c
-src/dataManip/psFunctions.h
-src/dataManip/psMatrix.c
-src/dataManip/psMatrix.h
-src/dataManip/psMatrixVectorArithmetic.c
-src/dataManip/psMatrixVectorArithmetic.h
-src/dataManip/psMinimize.c
-src/dataManip/psMinimize.h
-src/dataManip/psStats.c
-src/dataManip/psStats.h
-src/dataManip/psVectorFFT.c
-src/dataManip/psVectorFFT.h
-src/dataManip/makedir/psFunctions.d
-src/dataManip/makedir/psMatrix.d
-src/dataManip/makedir/psMatrixVectorArithmetic.d
-src/dataManip/makedir/psMinimize.d
-src/dataManip/makedir/psStats.d
-src/dataManip/makedir/psVectorFFT.d
-src/dataManip/makedir/CVS/Entries
-src/dataManip/makedir/CVS/Repository
-src/dataManip/makedir/CVS/Root
-src/dataManip/CVS/Entries
-src/dataManip/CVS/Entries.Log
-src/dataManip/CVS/Repository
-src/dataManip/CVS/Root
-src/CVS/Entries
-src/CVS/Entries.Log
-src/CVS/Repository
-src/CVS/Root
-src/collections/Makefile
-src/collections/psArray.c
-src/collections/psArray.h
-src/collections/psBitSet.c
-src/collections/psBitSet.h
-src/collections/psCollectionsErrors.dat
-src/collections/psCollectionsErrors.h
-src/collections/psCompare.c
-src/collections/psCompare.h
-src/collections/psHash.c
-src/collections/psHash.h
-src/collections/psList.c
-src/collections/psList.h
-src/collections/psScalar.c
-src/collections/psScalar.h
-src/collections/psVector.c
-src/collections/psVector.h
-src/collections/makedir/psArray.d
-src/collections/makedir/psBitSet.d
-src/collections/makedir/psCompare.d
-src/collections/makedir/psHash.d
-src/collections/makedir/psList.d
-src/collections/makedir/psScalar.d
-src/collections/makedir/psVector.d
-src/collections/makedir/CVS/Entries
-src/collections/makedir/CVS/Repository
-src/collections/makedir/CVS/Root
-src/collections/CVS/Entries
-src/collections/CVS/Entries.Log
-src/collections/CVS/Repository
-src/collections/CVS/Root
-src/astronomy/Makefile
-src/astronomy/psAstrometry.c
-src/astronomy/psAstrometry.h
-src/astronomy/psAstronomyErrors.dat
-src/astronomy/psAstronomyErrors.h
-src/astronomy/psCoord.c
-src/astronomy/psCoord.h
-src/astronomy/psMetadata.c
-src/astronomy/psMetadata.h
-src/astronomy/psPhotometry.h
-src/astronomy/psTime.c
-src/astronomy/psTime.h
-src/astronomy/slalib.h
-src/astronomy/makedir/psAstrometry.d
-src/astronomy/makedir/psCoord.d
-src/astronomy/makedir/psMetadata.d
-src/astronomy/makedir/psTime.d
-src/astronomy/makedir/CVS/Entries
-src/astronomy/makedir/CVS/Repository
-src/astronomy/makedir/CVS/Root
-src/astronomy/depend/CVS/Entries
-src/astronomy/depend/CVS/Repository
-src/astronomy/depend/CVS/Root
-src/astronomy/CVS/Entries
-src/astronomy/CVS/Entries.Log
-src/astronomy/CVS/Repository
-src/astronomy/CVS/Root
-lib/CVS/Entries
-lib/CVS/Repository
-lib/CVS/Root
-include/CVS/Entries
-include/CVS/Repository
-include/CVS/Root
-data/eopc01.1900-2004
-data/finals.all
-data/readme.eopc01
-data/readme.finals
-data/readme.ser7
-data/readme.tai-utc
-data/ser7.dat
-data/tai-utc.dat
-data/CVS/Entries
-data/CVS/Repository
-data/CVS/Root
-CVS/Entries
-CVS/Entries.Log
-CVS/Repository
-CVS/Root
-test/image/tst_psImageConvolve.c
-test/astronomy/tst_psAstrometry.c
-test/astronomy/tst_psMetadataIO.c
Index: /trunk/psLib/psLib.kdevses
===================================================================
--- /trunk/psLib/psLib.kdevses	(revision 2272)
+++ /trunk/psLib/psLib.kdevses	(revision 2273)
@@ -2,40 +2,9 @@
 <!DOCTYPE KDevPrjSession>
 <KDevPrjSession>
- <DocsAndViews NumberOfDocuments="3" >
-  <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/src/Doxyfile" >
-   <View0 line="27" Type="???" >
-    <AdditionalSettings Top="2" Width="1212" Attach="1" Height="1027" Left="2" MinMaxMode="0" />
-   </View0>
-  </Doc0>
-  <Doc1 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageExtraction.c" >
-   <View0 line="311" Type="???" >
-    <AdditionalSettings Top="2" Width="1212" Attach="1" Height="752" Left="2" MinMaxMode="0" />
-   </View0>
-  </Doc1>
-  <Doc2 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageErrors.dat" >
-   <View0 line="21" Type="???" >
-    <AdditionalSettings Top="2" Width="1212" Attach="1" Height="1001" Left="2" MinMaxMode="0" />
-   </View0>
-  </Doc2>
- </DocsAndViews>
+ <DocsAndViews NumberOfDocuments="0" />
  <pluginList>
   <kdevbookmarks>
-   <bookmarks>
-    <bookmark url="/home/desonia/psLib/test/dataManip/tst_psImageManip.c" >
-     <mark line="615" />
-     <mark line="652" />
-     <mark line="593" />
-    </bookmark>
-    <bookmark url="/home/desonia/psLib/src/dataManip/psMatrixVectorArithmetic.c" >
-     <mark line="60" />
-    </bookmark>
-    <bookmark url="/home/desonia/psLib/src/collections/psBitSet.c" >
-     <mark line="194" />
-    </bookmark>
-   </bookmarks>
+   <bookmarks/>
   </kdevbookmarks>
-  <kdevsubversion>
-   <subversion recurseresolve="1" recurserelocate="1" recursemerge="1" recursecommit="1" base="" recursepropget="1" recurseswitch="1" recurseupdate="1" recursepropset="1" recursediff="1" recurserevert="1" forcemove="1" recursecheckout="1" forceremove="1" recurseadd="1" recurseproplist="1" forcemerge="1" />
-  </kdevsubversion>
   <kdevvalgrind>
    <executable path="" params="" />
Index: /trunk/psLib/src/Makefile.Globals
===================================================================
--- /trunk/psLib/src/Makefile.Globals	(revision 2272)
+++ /trunk/psLib/src/Makefile.Globals	(revision 2273)
@@ -5,6 +5,6 @@
 ##  Assumptions:    Variable "prefix" already defined
 ##
-##  $Revision: 1.21 $  $Name: not supported by cvs2svn $
-##  $Date: 2004-11-01 18:55:38 $
+##  $Revision: 1.22 $  $Name: not supported by cvs2svn $
+##  $Date: 2004-11-04 01:04:57 $
 ##
 ##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -54,5 +54,5 @@
 # Set initial value for CFLAGS which will include all OS common flags for GCC
 GCOVFLAGS :=
-CFLAGS := -O0 -g2 -std=c99 -D_GNU_SOURCE -pipe $(GCOVFLAGS)
+CFLAGS := -Werror -O0 -g2 -std=c99 -D_GNU_SOURCE -pipe $(GCOVFLAGS)
 
 ifdef NO_TRACE
Index: /trunk/psLib/src/astro/psCoord.c
===================================================================
--- /trunk/psLib/src/astro/psCoord.c	(revision 2272)
+++ /trunk/psLib/src/astro/psCoord.c	(revision 2273)
@@ -10,6 +10,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 23:31:43 $
+*  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:04:57 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -27,4 +27,5 @@
 #include "psConstants.h"
 #include "psError.h"
+#include "psAstronomyErrors.h"
 #include <math.h>
 #include <float.h>
@@ -278,10 +279,16 @@
 
     } else if (projection->type == PS_PROJ_PAR) {
-        psError(__func__, "The projection type PS_PROJ_PAR is undefined.\n");
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED,
+                "PS_PROJ_PAR");
 
     } else if (projection->type == PS_PROJ_GLS) {
-        psError(__func__, "The projection type PS_PROJ_GLS is undefined.\n");
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED,
+                "PS_PROJ_GLS");
     } else {
-        psError(__func__, "Unknown projection type.\n");
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNKNOWN,
+                projection->type);
     }
 
@@ -333,10 +340,16 @@
 
     } else if (projection->type == PS_PROJ_PAR) {
-        psError(__func__, "The projection type PS_PROJ_PAR is undefined.\n");
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED,
+                "PS_PROJ_PAR");
 
     } else if (projection->type == PS_PROJ_GLS) {
-        psError(__func__, "The projection type PS_PROJ_GLG is undefined.\n");
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED,
+                "PS_PROJ_GLS");
     } else {
-        psError(__func__, "Unknown projection type.\n");
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNKNOWN,
+                projection->type);
     }
 
@@ -407,5 +420,7 @@
         } else if (unit == PS_RADIAN) {}
         else {
-            psError(__func__, "Unknown offset unit: 0x%x\n", unit);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psCoord_UNITS_UNKNOWN,
+                    unit);
         }
 
@@ -413,5 +428,7 @@
     }
 
-    psError(__func__, "Unrecognized offset mode\n");
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+            PS_ERRORTEXT_psCoord_OFFSET_MODE_UNKNOWN,
+            mode);
     return (NULL);
 }
@@ -469,5 +486,7 @@
             tmpD = offset->d;
         } else {
-            psError(__func__, "Unknown offset unit: 0x%x\n", unit);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psCoord_UNITS_UNKNOWN,
+                    unit);
         }
 
@@ -483,5 +502,8 @@
     }
 
-    psError(__func__, "Unrecognized offset mode\n");
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+            PS_ERRORTEXT_psCoord_OFFSET_MODE_UNKNOWN,
+            mode);
+
     return (NULL);
 }
Index: /trunk/psLib/src/astro/psTime.c
===================================================================
--- /trunk/psLib/src/astro/psTime.c	(revision 2272)
+++ /trunk/psLib/src/astro/psTime.c	(revision 2273)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:30 $
+ *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -31,5 +31,5 @@
 #include "psMetadata.h"
 #include "psMetadataIO.h"
-
+#include "psConstants.h"
 #include "psAstronomyErrors.h"
 
@@ -151,5 +151,5 @@
     char line[LINESIZE];
     psS32 j = 0;
-    psS32 maxLines = 100;
+    psS32 maxLines = 1000;
     psF64 *ptr = NULL;
     psImage *table = NULL;
@@ -159,5 +159,7 @@
     fd=fopen(fileName, "r");
     if(fd==NULL) {
-        psError(__func__, " : Line %d - Couldn't open %s", __LINE__, fileName);
+        psError(PS_ERR_IO,true,
+                PS_ERRORTEXT_psTime_FILE_NOT_FOUND,
+                fileName,"Tai-Utc");
         return NULL;
     }
@@ -168,5 +170,7 @@
     while(fgets(line, LINESIZE, fd) != NULL) {
         if(j>=maxLines) {
-            psError(__func__, " : Line %d - Too many rows in file. Max size: %d", __LINE__, maxLines);
+            psError(PS_ERR_IO,true,
+                    PS_ERRORTEXT_psTime_FILE_TOO_MANY_ROWS,
+                    fileName,maxLines);
             return NULL;
             psFree(table);
@@ -201,5 +205,7 @@
     fd=fopen(fileName, "r");
     if(fd==NULL) {
-        psError(__func__, " : Line %d - Couldn't open %s", __LINE__, fileName);
+        psError(PS_ERR_IO,true,
+                PS_ERRORTEXT_psTime_FILE_NOT_FOUND,
+                fileName,"Ser7");
         return NULL ;
     }
@@ -218,5 +224,7 @@
 
             if(j>=maxLines) {
-                psError(__func__, " : Line %d - Too many rows in file. Max size: %d", __LINE__, maxLines);
+                psError(PS_ERR_IO,true,
+                        PS_ERRORTEXT_psTime_FILE_TOO_MANY_ROWS,
+                        fileName,maxLines);
                 return NULL;
                 psFree(table);
@@ -240,115 +248,4 @@
 }
 
-/* Not yet used...
-static psImage* readEopcFile(char *fileName)
-{
-    char line[LINESIZE];
-    psS32 i = 0;
-    psS32 j = 0;
-    psS32 maxLines = 2500;
-    psImage *table = NULL;
-    FILE *fd = NULL;
- 
- 
-    fd=fopen(fileName, "r");
-    if(fd==NULL) {
-        psError(__func__, " : Line %d - Couldn't open %s", __LINE__, fileName);
-        return NULL ;
-    }
- 
-    // Table shouldn't be larger than 2500 rows. All columns are read.
-    table  = psImageAlloc(11, maxLines, PS_TYPE_F64);
-    for(i=0; i<3; i++) {
-        if((fgets(line, LINESIZE, fd) != NULL)) {
-            psError(__func__, " : Line %d - Error reading %s", __LINE__, fileName);
-        }
-    }
- 
-    while(fgets(line, LINESIZE, fd) != NULL) {
-        if(j>=maxLines) {
-            psError(__func__, " : Line %d - Too many rows in file. Max size: %d", __LINE__, maxLines);
-            return NULL;
-            psFree(table);
-        }
-        psF64 *ptr = table->data.F64[j++];
-        sscanf(line, "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",
-               ptr, ptr+1, ptr+2, ptr+3, ptr+4, ptr+5, ptr+6, ptr+7, ptr+8, ptr+9, ptr+10);
-    }
- 
-    *(psU32 *)&table->numRows = j;
- 
-    return table;
-}
- 
-static psImage* readFinalsFile(char *fileName)
-{
-    char line[LINESIZE];
-    psS32 j = 0;
-    psS32 maxLines = 15000;
-    psImage *table = NULL;
-    FILE *fd = NULL;
- 
- 
-    fd=fopen(fileName, "r");
-    if(fd==NULL) {
-        psError(__func__, " : Line %d - Couldn't open %s", __LINE__, fileName);
-        return NULL ;
-    }
- 
-    // Table shouldn't be larger than 15000 rows. Select columns are read.
-    table  = psImageAlloc(6, maxLines, PS_TYPE_F64);
-    while(fgets(line, LINESIZE, fd) != NULL) {
-        if(j>=maxLines) {
-            psError(__func__, " : Line %d - Too many rows in file. Max size: %d", __LINE__, maxLines);
-            return NULL;
-            psFree(table);
-        }
- 
-        psF64 *ptr = table->data.F64[j++];
-        ptr = table->data.F64[j++];
- 
-        // Sometimes there are blank entries in this table, so check for a space to determine if there is no entry
-        if(*(line+7) == ' ') {                   // MJD
-            *ptr = 0.0;
-        } else {
-            *ptr = atof(line+7);
-        }
- 
-        if(*(line+18) == ' ') {                  // Polar motion X
-            *(ptr+1) = 0.0;
-        } else {
-            *(ptr+1) = atof(line+18);
-        }
- 
-        if(*(line+27) == ' ') {                  // Polar motion X error
-            *(ptr+2) = 0.0;
-        } else {
-            *(ptr+2) = atof(line+27);
-        }
- 
-        if(*(line+37) == ' ') {                  // Polar motion Y
-            *(ptr+3) = 0.0;
-        } else {
-            *(ptr+3) = atof(line+37);
-        }
- 
-        if(*(line+46) == ' ') {                  // Polar motion Y error
-            *(ptr+4) = 0.0;
-        } else {
-            *(ptr+4) = atof(line+46);
-        }
- 
-        if(*(line+58) == ' ') {                  // UT1-UTC
-            *(ptr+5) = 0.0;
-        } else {
-            *(ptr+5) = atof(line+58);
-        }
-    }
- 
-    *(psU32 *)&table->numRows = j;
- 
-    return table;
-}
-*/
 
 static double lookupTaiUtcTable(const psTime *time)
@@ -389,5 +286,7 @@
             hiIdx++;
             if(hiIdx >= numRows) {
-                psError(__func__, " : Line %d - High index too big. Value: %d", __LINE__, hiIdx);
+                psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                        PS_ERRORTEXT_psTime_TIME_POSTDATES_TABLE,
+                        jd, "TAI-UTC");
                 return 0.0;
             }
@@ -395,14 +294,18 @@
         loIdx = hiIdx--;
         if(loIdx < 0) {
-            psError(__func__, " : Line %d - Low index too small. Value: %d", __LINE__, loIdx);
+            psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                    PS_ERRORTEXT_psTime_TIME_PREDATES_TABLE,
+                    jd, "TAI-UTC");
             return 0.0;
         }
 
+        // since rows of table can not have same jd, this check is probably not needed.
         denom = table->data.F64[hiIdx][0]-table->data.F64[loIdx][0];
         if(fabs(denom) < FLT_EPSILON) {
-            psError(__func__, " : Line %d - Divide by zero error during interpolation", __LINE__);
+            psError(PS_ERR_UNKNOWN,true,
+                    PS_ERRORTEXT_psTime_TABLE_DUPLICATE_ROWS
+                    "Ser7");
             return 0.0;
         } else {
-
             // Interpolate three constants required to calculate TAI-UTC
             const1 = table->data.F64[loIdx][1]+(table->data.F64[hiIdx][1]-table->data.F64[loIdx][1])
@@ -445,13 +348,19 @@
     mjdUtc = psTimeToMJD(time);
     if(mjdUtc < table->data.F64[0][3]) {                                    // MJD time before start of table
-        psError(__func__, " : Line %d - MJD too small. Value: %d", __LINE__, mjdUtc);
+        psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                PS_ERRORTEXT_psTime_TIME_PREDATES_TABLE,
+                mjdUtc, "Ser7");
 
     } else if(mjdUtc > table->data.F64[numRows-1][3]) {                     // MJD time after end of table
-        psError(__func__, " : Line %d - MJD too big. Value: %d", __LINE__, mjdUtc);
+        psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                PS_ERRORTEXT_psTime_TIME_POSTDATES_TABLE,
+                mjdUtc, "Ser7");
     } else {                                                                // All other times..interpolate
         while(mjdUtc > table->data.F64[hiIdx][3]) {
             hiIdx++;
             if(hiIdx >= numRows) {
-                psError(__func__, " : Line %d - High index too big. Value: %d", __LINE__, hiIdx);
+                psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                        PS_ERRORTEXT_psTime_TIME_POSTDATES_TABLE,
+                        mjdUtc, "Ser7");
                 return 0.0;
             }
@@ -460,10 +369,14 @@
         loIdx = hiIdx--;
         if(loIdx < 0) {
-            psError(__func__, " : Line %d - Low index too small. Value: %d", __LINE__, loIdx);
+            psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                    PS_ERRORTEXT_psTime_TIME_PREDATES_TABLE,
+                    mjdUtc, "Ser7");
         }
 
         denom = table->data.F64[hiIdx][3] - table->data.F64[loIdx][3];
         if(fabs(denom) < FLT_EPSILON) {
-            psError(__func__, " : Line %d - Divide by zero error during interpolation", __LINE__);
+            psError(PS_ERR_UNKNOWN,true,
+                    PS_ERRORTEXT_psTime_TABLE_DUPLICATE_ROWS,
+                    "Ser7");
         } else {
             out = table->data.F64[loIdx][col]+(table->data.F64[hiIdx][col]-table->data.F64[loIdx][col])
@@ -525,12 +438,11 @@
     // Error checks
     if(type!=PS_TIME_TAI && type!=PS_TIME_UTC) {
-        psError(__func__, " : Line %d - Incorrect type. Type: %d", __LINE__, type);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psTime_TYPE_UNKNOWN,
+                type);
         return NULL;
     }
 
     outTime = (psTime*)psAlloc(sizeof(psTime));
-    if(outTime == NULL) {
-        psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
-    }
 
     outTime->sec = 0;
@@ -551,5 +463,6 @@
 
     if (gettimeofday(&now, (struct timezone *)0) == -1) {
-        psError(__func__, " : Line %d - Failed to get time", __LINE__);
+        psError(PS_ERR_OS_CALL_FAILED, true,
+                PS_ERRORTEXT_psTime_GET_TOD_FAILED);
         return NULL;
     }
@@ -573,23 +486,21 @@
 
     // Error checks
-    if(time == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return NULL;
-    } else if(time->usec >= 1e6) {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return NULL;
-    } else if(time->type == type) {
-        psError(__func__, " : Line %d - Time already in correct psTime type. Time type: %d", __LINE__, type);
-        return NULL;
+    PS_PTR_CHECK_NULL(time,NULL);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
+
+    if (time->type == type) { // time already right type.  That was easy!
+        return time;
     }
 
     delta = psTimeGetTAIDelta(time);
 
-    if(type == PS_TIME_UTC) {
+    if (type == PS_TIME_UTC) {
         time->sec = time->sec - delta;    // User wants UTC time. Subtract leapseconds.
     } else if(type == PS_TIME_TAI) {
         time->sec = time->sec + delta;    // User wants TAI time. Add leapseconds.
     } else {
-        psError(__func__, " : Line %d - Invalid psTimeType: %d", __LINE__, type);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psTime_TYPE_UNKNOWN,
+                type);
     }
 
@@ -623,11 +534,6 @@
 
     // Error checks
-    if(time == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return 0;
-    } else if(time->usec >= 1e6) {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return 0;
-    }
+    PS_PTR_CHECK_NULL(time,NAN);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
 
     // Calculate TAI or UTC time based on type of time user passes
@@ -698,11 +604,6 @@
 
     // Error checks
-    if(time == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return 0.0;
-    } else if(time->usec >= 1e6) {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return 0.0;
-    }
+    PS_PTR_CHECK_NULL(time,NAN);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
 
     return lookupSer7Table(time, 6);
@@ -717,13 +618,6 @@
 
     // Error checks
-    if(time == NULL)
-    {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return NULL;
-    } else if(time->usec >= 1e6)
-    {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(time,NULL);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
 
     x = lookupSer7Table((psTime*)time, 4);
@@ -741,11 +635,6 @@
 
     // Error checks
-    if(time == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return 0.0;
-    } else if(time->usec >= 1e6) {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return 0.0;
-    }
+    PS_PTR_CHECK_NULL(time,NAN);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
 
     return lookupTaiUtcTable(time);
@@ -758,17 +647,8 @@
 
     // Error checks
-    if(time1 == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed for first input", __LINE__);
-        return 0;
-    } else if(time1->usec >= 1e6) {
-        psError(__func__, " : Line %d - First input time microseconds too big. Value %u", __LINE__, time1->usec);
-        return 0;
-    } else if(time2 == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed for second input", __LINE__);
-        return 0;
-    } else if(time2->usec >= 1e6) {
-        psError(__func__, " : Line %d - First input time microseconds too big. Value %u", __LINE__, time2->usec);
-        return 0;
-    }
+    PS_PTR_CHECK_NULL(time1,0);
+    PS_PTR_CHECK_NULL(time2,0);
+    PS_INT_CHECK_RANGE(time1->usec,0,1e6-1,0);
+    PS_INT_CHECK_RANGE(time1->usec,0,1e6-1,0);
 
     diff = abs(psTimeGetTAIDelta((psTime*)time1)-psTimeGetTAIDelta((psTime*)time2));
@@ -781,13 +661,7 @@
     double jd = 0.0;
 
-
-    // Error checks
-    if(time == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return 0.0;
-    } else if(time->usec >= 1e6) {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return 0.0;
-    }
+    // Error checks
+    PS_PTR_CHECK_NULL(time,NAN);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
 
     // Julian date conversion
@@ -807,11 +681,6 @@
 
     // Error checks
-    if(time == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return 0.0;
-    } else if(time->usec >= 1e6) {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return 0.0;
-    }
+    PS_PTR_CHECK_NULL(time,NAN);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
 
     // Modified Julian date conversion
@@ -835,11 +704,6 @@
 
     // Error checks
-    if(time == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return NULL;
-    } else if(time->usec >= 1e6) {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(time,NULL);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
 
     tempString = psAlloc(MAX_TIME_STRING_LENGTH);
@@ -854,9 +718,11 @@
     // Converts psTime to YYYY-MM-DDThh:mm:ss.sss in string form
     if (!strftime(tempString, MAX_TIME_STRING_LENGTH, "%Y-%m-%dT%H:%M:%S", tmTime)) {
-        psError(__func__, " : Line %d - Failed strftime conversion", __LINE__);
+        psError(PS_ERR_OS_CALL_FAILED, true,
+                PS_ERRORTEXT_psTime_CONVERT_TIME_TO_STRING_FAILED);
     }
 
     if (snprintf(timeString, MAX_TIME_STRING_LENGTH, "%s.%3.3dZ", tempString, ms) < 0) {
-        psError(__func__, " : Line %d - Failed snprintf conversion", __LINE__);
+        psError(PS_ERR_OS_CALL_FAILED, true,
+                PS_ERRORTEXT_psTime_APPEND_MSEC_FAILED);
     }
     psFree(tempString);
@@ -869,15 +735,10 @@
     struct timeval timevalTime;
 
-
-    // Error checks
-    if(time == NULL)
-    {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return timevalTime;
-    } else if(time->usec >= 1e6)
-    {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return timevalTime;
-    }
+    timevalTime.tv_sec = 0;
+    timevalTime.tv_usec = 0;
+
+    // Error checks
+    PS_PTR_CHECK_NULL(time,timevalTime);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,timevalTime);
 
     timevalTime.tv_sec = time->sec;
@@ -901,13 +762,6 @@
 
     // Error checks
-    if(time == NULL)
-    {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return NULL;
-    } else if(time->usec >= 1e6)
-    {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(time,NULL);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
 
     seconds = time->sec%60;
@@ -945,8 +799,4 @@
     // Allocate output
     tmTime = (struct tm*)psAlloc(sizeof(struct tm));
-    if (tmTime == NULL)
-    {
-        psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
-    }
 
     tmTime->tm_year = year - 1900;
@@ -982,7 +832,5 @@
 
     // Error check
-    if(outTime->usec >= 1e6) {
-        psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec);
-    }
+    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
 
     return outTime;
@@ -1010,7 +858,5 @@
 
     // Error check
-    if(outTime->usec >= 1e6) {
-        psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec);
-    }
+    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
 
     return outTime;
@@ -1020,67 +866,28 @@
 {
     char tempString[MAX_TIME_STRING_LENGTH];
-    psS32 month;
-    psS32 day;
-    psS32 year;
-    psS32 hour;
-    psS32 minute;
-    psS32 second;
     psS32 millisecond;
     struct tm tmTime;
     psTime *outTime = NULL;
 
-
-    // Preserve input string by creating duplicate
-    strncpy(tempString, time, MAX_TIME_STRING_LENGTH);
-
     // Convert YYYY-MM-DDThh:mm:ss.sss in string form to tm time
-    year = atoi(strtok(tempString, "-"));
-    if (year < 0) {
-        psError(__func__, "Years less than 0 not allowed. Value: %d", year);
-        return outTime;
-    }
-
-    month = atoi(strtok(NULL, "-"));
-    if (month < 1 || month > 12) {
-        psError(__func__, "Month must have a value from 1 to 12. Value: %d", month);
-        return outTime;
-    }
-
-    day = atoi(strtok(NULL, "T"));
-    if (day < 1 || day > 31) {
-        psError(__func__, "Day must have a value from 1 to 31. Value: %d", day);
-        return outTime;
-    }
-
-    hour = atoi(strtok(NULL, ":"));
-    if (hour < 0 || hour > 23) {
-        psError(__func__, "Hour must have a value from 0 to 23. Value: %d", hour);
-        return outTime;
-    }
-
-    minute = atoi(strtok(NULL, ":"));
-    if (minute < 0 || minute > 59) {
-        psError(__func__, "Minute must have a value from 0 to 59. Value: %d", minute);
-        return outTime;
-    }
-
-    second = atoi(strtok(NULL, "."));
-    if (second < 0 || second > 59) {
-        psError(__func__, "Second must have a value from 0 to 59. Value: %d", second);
-        return outTime;
-    }
-
-    millisecond = atoi(strtok(NULL, "Z"));
-    if (millisecond < 0 || millisecond > 1000) {
-        psError(__func__, "Millisecond must have a value from 0 to 999. Value: %d", millisecond);
-        return outTime;
-    }
-
-    tmTime.tm_year = year - 1900;
-    tmTime.tm_mon = month - 1;
-    tmTime.tm_mday = day;
-    tmTime.tm_hour = hour;
-    tmTime.tm_min = minute;
-    tmTime.tm_sec = second;
+    if (sscanf(time, "%d-%d-%dT%d:%d:%d.%d",
+               &tmTime.tm_year,&tmTime.tm_mon,&tmTime.tm_mday,
+               &tmTime.tm_hour,&tmTime.tm_min,&tmTime.tm_sec,&millisecond) < 7) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psTime_ISOTIME_MALFORMED,
+                time);
+        return NULL;
+    }
+
+    PS_INT_CHECK_NON_NEGATIVE(tmTime.tm_year, outTime);
+    PS_INT_CHECK_RANGE(tmTime.tm_mon,1,12,outTime);
+    PS_INT_CHECK_RANGE(tmTime.tm_mday,1,31,outTime);
+    PS_INT_CHECK_RANGE(tmTime.tm_hour,0,23,outTime);
+    PS_INT_CHECK_RANGE(tmTime.tm_min,0,59,outTime);
+    PS_INT_CHECK_RANGE(tmTime.tm_sec,0,59,outTime);
+    PS_INT_CHECK_RANGE(millisecond,0,999,outTime);
+
+    tmTime.tm_year -= 1900;
+    tmTime.tm_mon--;
     tmTime.tm_isdst = -1;
 
@@ -1089,23 +896,14 @@
     outTime->usec = millisecond * 1000;
 
+    return outTime;
+}
+
+psTime* psTimeFromTimeval(const struct timeval *time)
+{
+    psTime *outTime = NULL;
+
+
     // Error check
-    if(outTime->usec >= 1e6) {
-        psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec);
-    }
-
-    return outTime;
-}
-
-psTime* psTimeFromTimeval(const struct timeval *time)
-{
-    psTime *outTime = NULL;
-
-
-    // Error check
-    if(time == NULL)
-    {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(time,NULL);
 
     // Allocate psTime struct
@@ -1117,8 +915,5 @@
 
     // Error check
-    if(outTime->usec >= 1e6)
-    {
-        psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec);
-    }
+    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
 
     return outTime;
@@ -1138,9 +933,5 @@
 
     // Error check
-    if(time == NULL)
-    {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(time,NULL);
 
     // Allocate psTime struct
@@ -1183,8 +974,5 @@
 
     // Error check
-    if(outTime->usec >= 1e6)
-    {
-        psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec);
-    }
+    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
 
     return outTime;
@@ -1199,18 +987,12 @@
 
     // Error checks
+    PS_PTR_CHECK_NULL(tai1,NULL);
+    PS_PTR_CHECK_NULL(tai2,NULL);
+    PS_INT_CHECK_RANGE(tai1->usec,0,1e6-1,NULL);
+    PS_INT_CHECK_RANGE(tai2->usec,0,1e6-1,NULL);
+
     if(tai1->type != tai2->type) {
-        psError(__func__, " : Line %d - Argument types inconsistent for time addition", __LINE__);
-        return NULL;
-    } else if(tai1 == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed for first input", __LINE__);
-        return NULL;
-    } else if(tai1->usec >= 1e6) {
-        psError(__func__, " : Line %d - Argument 1 microseconds too big. Value %u", __LINE__, tai1->usec);
-        return NULL;
-    } else if(tai2 == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed for second input", __LINE__);
-        return NULL;
-    } else if(tai2->usec >= 1e6) {
-        psError(__func__, " : Line %d - Argument 2 microseconds too big. Value %u", __LINE__, tai2->usec);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psTime_TYPE_MISMATCH);
         return NULL;
     }
@@ -1233,7 +1015,5 @@
 
     // Error check
-    if(outTime->usec >= 1e6) {
-        psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec);
-    }
+    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
 
     return outTime;
@@ -1248,18 +1028,11 @@
 
     // Error checks
+    PS_PTR_CHECK_NULL(tai1,NULL);
+    PS_PTR_CHECK_NULL(tai2,NULL);
+    PS_INT_CHECK_RANGE(tai1->usec,0,1e6-1,NULL);
+    PS_INT_CHECK_RANGE(tai2->usec,0,1e6-1,NULL);
     if(tai1->type != tai2->type) {
-        psError(__func__, " : Line %d - Argument types inconsistent for time subtraction", __LINE__);
-        return NULL;
-    } else if(tai1 == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed for first input", __LINE__);
-        return NULL;
-    } else if(tai1->usec >= 1e6) {
-        psError(__func__, " : Line %d - Argument 1 microseconds too big. Value %u", __LINE__, tai1->usec);
-        return NULL;
-    } else if(tai2 == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed for second input", __LINE__);
-        return NULL;
-    } else if(tai2->usec >= 1e6) {
-        psError(__func__, " : Line %d - Argument 2 microseconds too big. Value %u", __LINE__, tai2->usec);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psTime_TYPE_MISMATCH);
         return NULL;
     }
@@ -1294,18 +1067,12 @@
 
     // Error checks
+    // Error checks
+    PS_PTR_CHECK_NULL(tai1,NULL);
+    PS_PTR_CHECK_NULL(tai2,NULL);
+    PS_INT_CHECK_RANGE(tai1->usec,0,1e6-1,NULL);
+    PS_INT_CHECK_RANGE(tai2->usec,0,1e6-1,NULL);
     if(tai1->type != tai2->type) {
-        psError(__func__, " : Line %d - Argument types inconsistent for time subtraction", __LINE__);
-        return NULL;
-    } else if(tai1 == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed for first input", __LINE__);
-        return NULL;
-    } else if(tai1->usec >= 1e6) {
-        psError(__func__, " : Line %d - Argument 1 microseconds too big. Value %u", __LINE__, tai1->usec);
-        return NULL;
-    } else if(tai2 == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed for second input", __LINE__);
-        return NULL;
-    } else if(tai2->usec >= 1e6) {
-        psError(__func__, " : Line %d - Argument 2 microseconds too big. Value %u", __LINE__, tai2->usec);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psTime_TYPE_MISMATCH);
         return NULL;
     }
Index: /trunk/psLib/src/astronomy/psAstrometry.c
===================================================================
--- /trunk/psLib/src/astronomy/psAstrometry.c	(revision 2272)
+++ /trunk/psLib/src/astronomy/psAstrometry.c	(revision 2273)
@@ -8,6 +8,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.49 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 23:49:00 $
+ *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -25,4 +25,6 @@
 #include "psError.h"
 #include "psConstants.h"
+#include "psAstronomyErrors.h"
+
 #include "slalib.h"
 
@@ -868,5 +870,7 @@
     // generate an error if cell->toTP is not linear.
     if (0 == isProjectionLinear(cell->toTP)) {
-        psError(__func__, "the cell->toTP transfrom is not linear.\n");
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psAstrometry_NONLINEAR_TRANSFORM,
+                "cell to tangent plane");
     }
 
Index: /trunk/psLib/src/astronomy/psAstronomyErrors.dat
===================================================================
--- /trunk/psLib/src/astronomy/psAstronomyErrors.dat	(revision 2272)
+++ /trunk/psLib/src/astronomy/psAstronomyErrors.dat	(revision 2273)
@@ -7,2 +7,45 @@
 #  N.B. in code, the ERRORNAME appears as PS_ERRORTEXT_ERRORNAME
 ####################################################################
+psTime_FILE_NOT_FOUND                  Failed to open file %s.  No %s information is available.
+psTime_FILE_TOO_MANY_ROWS              Too many rows found in file %s. Max number of rows allowed is %d.
+psTime_TIME_POSTDATES_TABLE            Specified psTime postdates (%g) the table of %s information.
+psTime_TIME_PREDATES_TABLE             Specified psTime predates (%g) the table of %s information.
+psTime_TABLE_DUPLICATE_ROWS            The %s table was found to have two rows of the same time value.
+psTime_TYPE_UNKNOWN                    Specified type, %d, is not supported.
+psTime_TYPE_MISMATCH                   Specified psTime parameters must have same type.
+psTime_GET_TOD_FAILED                  Failed to determine the current time from gettimeofday function.
+psTime_CONVERT_TIME_TO_STRING_FAILED   Failed to convert a time via strftime function.
+psTime_APPEND_MSEC_FAILED              Failed to append millisecond to time string with snprintf function.
+psTime_USEC_INVALID                    The psTime usec attribute value, %u, is invalid.  Must be less than 1e6.
+psTime_ISOTIME_MALFORMED               Specified ISO Time string, '%s', is malformed.  Must be in 'YYYY-MM-DDThh:mm:ss.sss' format.
+#
+psCoord_PROJECTION_TYPE_UNDEFINED      The projection type, %s, is undefined.
+psCoord_PROJECTION_TYPE_UNKNOWN        The projection type, %d, is unknown.
+psCoord_UNITS_UNKNOWN                  Specified units, 0x%x, is not supported.
+psCoord_OFFSET_MODE_UNKNOWN            Specified offset mode, 0x%x, is not supported.
+#
+psAstrometry_NONLINEAR_TRANSFORM       The %s transfrom is not linear.  Only linear transforms are supported. 
+#
+psMetadata_METATYPE_INVALID            Specified psMetadataType, %d, is not supported.
+psMetadata_ADD_LIST_FAILED             Failed to add metadata item, %s, to items list.
+psMetadata_ADD_TABLE_FAILED            Failed to add metadata item, %s, to items table.
+psMetadata_REMOVE_LIST_FAILED          Failed to remove metadata item, %s, from metadata list.
+psMetadata_REMOVE_LIST_INDEX_FAILED    Failed to remove metadata item, at index %d, from metadata list.
+psMetadata_REMOVE_TABLE_FAILED         Failed to remove metadata item, %s, from metadata table.
+psMetadata_ADD_COLLECTION_FAILED       Failed to add metadata item, %s, to metadata collection list.
+psMetadata_ADD_FAILED                  Failed to add metadata item to metadata collection list.
+psMetadata_FIND_FAILED                 Could not find metadata item, %s.
+psMetadata_FIND_INDEX_FAILED           Could not find metadata item at index %d.
+#
+psMetadataIO_TYPE_INVALID              Specified type, %d, is not supported.
+psMetadataIO_EXTNUM_NOTPOSITIVE        Specified extension number, %d, is invalid.  Value must be positive if no extension name is given.
+psMetadataIO_FITS_METATYPE_INVALID     Specified FITS metadata type, %c, is not supported.
+psMetadataIO_ADD_FAILED                Failed to add metadata item, %s.
+psMetadataIO_FILE_OPEN_FAILED          Failed to open file '%s'.  Check if it exists and it has the proper permissions.
+psMetadataIO_FILE_MULTIPLE_CHAR        More than one '%c' character not allowed.  Found on line %d of %s.
+psMetadataIO_FILE_ELEMENT_NULL         Failed to read a metadata %s on line %d of %s.
+psMetadataIO_FILE_TYPE_INVALID         Metadata type '%s', found on line %d of %s, is not invalid.
+psMetadataIO_OVERWRITE_ITEM            Duplicate Metadata item, %s, found on line %d of %s.  Overwrite not allowed.
+psMetadataIO_PARSE_FAILED              Failed to parse the value '%s' of metadata item %s, type %s, on line %d of %s.
+
+
Index: /trunk/psLib/src/astronomy/psAstronomyErrors.h
===================================================================
--- /trunk/psLib/src/astronomy/psAstronomyErrors.h	(revision 2272)
+++ /trunk/psLib/src/astronomy/psAstronomyErrors.h	(revision 2273)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 19:35:55 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -30,4 +30,41 @@
 
 //~Start #define PS_ERRORTEXT_$1 "$2"
+#define PS_ERRORTEXT_psTime_FILE_NOT_FOUND "Failed to open file %s.  No %s information is available."
+#define PS_ERRORTEXT_psTime_FILE_TOO_MANY_ROWS "Too many rows found in file %s. Max number of rows allowed is %d."
+#define PS_ERRORTEXT_psTime_TIME_POSTDATES_TABLE "Specified psTime postdates (%g) the table of %s information."
+#define PS_ERRORTEXT_psTime_TIME_PREDATES_TABLE "Specified psTime predates (%g) the table of %s information."
+#define PS_ERRORTEXT_psTime_TABLE_DUPLICATE_ROWS "The %s table was found to have two rows of the same time value."
+#define PS_ERRORTEXT_psTime_TYPE_UNKNOWN "Specified type, %d, is not supported."
+#define PS_ERRORTEXT_psTime_TYPE_MISMATCH "Specified psTime parameters must have same type."
+#define PS_ERRORTEXT_psTime_GET_TOD_FAILED "Failed to determine the current time from gettimeofday function."
+#define PS_ERRORTEXT_psTime_CONVERT_TIME_TO_STRING_FAILED "Failed to convert a time via strftime function."
+#define PS_ERRORTEXT_psTime_APPEND_MSEC_FAILED "Failed to append millisecond to time string with snprintf function."
+#define PS_ERRORTEXT_psTime_USEC_INVALID "The psTime usec attribute value, %u, is invalid.  Must be less than 1e6."
+#define PS_ERRORTEXT_psTime_ISOTIME_MALFORMED "Specified ISO Time string, '%s', is malformed.  Must be in 'YYYY-MM-DDThh:mm:ss.sss' format."
+#define PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED "The projection type, %s, is undefined."
+#define PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNKNOWN "The projection type, %d, is unknown."
+#define PS_ERRORTEXT_psCoord_UNITS_UNKNOWN "Specified units, 0x%x, is not supported."
+#define PS_ERRORTEXT_psCoord_OFFSET_MODE_UNKNOWN "Specified offset mode, 0x%x, is not supported."
+#define PS_ERRORTEXT_psAstrometry_NONLINEAR_TRANSFORM "The %s transfrom is not linear.  Only linear transforms are supported. "
+#define PS_ERRORTEXT_psMetadata_METATYPE_INVALID "Specified psMetadataType, %d, is not supported."
+#define PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED "Failed to add metadata item, %s, to items list."
+#define PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED "Failed to add metadata item, %s, to items table."
+#define PS_ERRORTEXT_psMetadata_REMOVE_LIST_FAILED "Failed to remove metadata item, %s, from metadata list."
+#define PS_ERRORTEXT_psMetadata_REMOVE_LIST_INDEX_FAILED "Failed to remove metadata item, at index %d, from metadata list."
+#define PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED "Failed to remove metadata item, %s, from metadata table."
+#define PS_ERRORTEXT_psMetadata_ADD_COLLECTION_FAILED "Failed to add metadata item, %s, to metadata collection list."
+#define PS_ERRORTEXT_psMetadata_ADD_FAILED "Failed to add metadata item to metadata collection list."
+#define PS_ERRORTEXT_psMetadata_FIND_FAILED "Could not find metadata item, %s."
+#define PS_ERRORTEXT_psMetadata_FIND_INDEX_FAILED "Could not find metadata item at index %d."
+#define PS_ERRORTEXT_psMetadataIO_TYPE_INVALID "Specified type, %d, is not supported."
+#define PS_ERRORTEXT_psMetadataIO_EXTNUM_NOTPOSITIVE "Specified extension number, %d, is invalid.  Value must be positive if no extension name is given."
+#define PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID "Specified FITS metadata type, %c, is not supported."
+#define PS_ERRORTEXT_psMetadataIO_ADD_FAILED "Failed to add metadata item, %s."
+#define PS_ERRORTEXT_psMetadataIO_FILE_OPEN_FAILED "Failed to open file '%s'.  Check if it exists and it has the proper permissions."
+#define PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR "More than one '%c' character not allowed.  Found on line %d of %s."
+#define PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL "Failed to read a metadata %s on line %d of %s."
+#define PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID "Metadata type '%s', found on line %d of %s, is not invalid."
+#define PS_ERRORTEXT_psMetadataIO_OVERWRITE_ITEM "Duplicate Metadata item, %s, found on line %d of %s.  Overwrite not allowed."
+#define PS_ERRORTEXT_psMetadataIO_PARSE_FAILED "Failed to parse the value '%s' of metadata item %s, type %s, on line %d of %s."
 //~End
 
Index: /trunk/psLib/src/astronomy/psCoord.c
===================================================================
--- /trunk/psLib/src/astronomy/psCoord.c	(revision 2272)
+++ /trunk/psLib/src/astronomy/psCoord.c	(revision 2273)
@@ -10,6 +10,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 23:31:43 $
+*  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:04:57 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -27,4 +27,5 @@
 #include "psConstants.h"
 #include "psError.h"
+#include "psAstronomyErrors.h"
 #include <math.h>
 #include <float.h>
@@ -278,10 +279,16 @@
 
     } else if (projection->type == PS_PROJ_PAR) {
-        psError(__func__, "The projection type PS_PROJ_PAR is undefined.\n");
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED,
+                "PS_PROJ_PAR");
 
     } else if (projection->type == PS_PROJ_GLS) {
-        psError(__func__, "The projection type PS_PROJ_GLS is undefined.\n");
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED,
+                "PS_PROJ_GLS");
     } else {
-        psError(__func__, "Unknown projection type.\n");
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNKNOWN,
+                projection->type);
     }
 
@@ -333,10 +340,16 @@
 
     } else if (projection->type == PS_PROJ_PAR) {
-        psError(__func__, "The projection type PS_PROJ_PAR is undefined.\n");
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED,
+                "PS_PROJ_PAR");
 
     } else if (projection->type == PS_PROJ_GLS) {
-        psError(__func__, "The projection type PS_PROJ_GLG is undefined.\n");
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNDEFINED,
+                "PS_PROJ_GLS");
     } else {
-        psError(__func__, "Unknown projection type.\n");
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psCoord_PROJECTION_TYPE_UNKNOWN,
+                projection->type);
     }
 
@@ -407,5 +420,7 @@
         } else if (unit == PS_RADIAN) {}
         else {
-            psError(__func__, "Unknown offset unit: 0x%x\n", unit);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psCoord_UNITS_UNKNOWN,
+                    unit);
         }
 
@@ -413,5 +428,7 @@
     }
 
-    psError(__func__, "Unrecognized offset mode\n");
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+            PS_ERRORTEXT_psCoord_OFFSET_MODE_UNKNOWN,
+            mode);
     return (NULL);
 }
@@ -469,5 +486,7 @@
             tmpD = offset->d;
         } else {
-            psError(__func__, "Unknown offset unit: 0x%x\n", unit);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psCoord_UNITS_UNKNOWN,
+                    unit);
         }
 
@@ -483,5 +502,8 @@
     }
 
-    psError(__func__, "Unrecognized offset mode\n");
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+            PS_ERRORTEXT_psCoord_OFFSET_MODE_UNKNOWN,
+            mode);
+
     return (NULL);
 }
Index: /trunk/psLib/src/astronomy/psMetadata.c
===================================================================
--- /trunk/psLib/src/astronomy/psMetadata.c	(revision 2272)
+++ /trunk/psLib/src/astronomy/psMetadata.c	(revision 2273)
@@ -12,6 +12,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 00:57:30 $
+*  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:04:57 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -35,4 +35,6 @@
 #include "psMetadata.h"
 #include "psString.h"
+#include "psAstronomyErrors.h"
+#include "psConstants.h"
 
 /******************************************************************************/
@@ -123,8 +125,6 @@
 
 
-    if (name == NULL) {
-        psError(__func__, "Null value for name not allowed");
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(name,NULL);
+
     // Allocate metadata item
     metadataItem = (psMetadataItem* ) psAlloc(sizeof(psMetadataItem));
@@ -147,9 +147,16 @@
     // Set metadata item type
     metadataItem->type = type;
+    metadataItem->data.V = NULL;
+
+    // Allocate metadata items with same name.
+    metadataItem->items = psListAlloc(NULL);
+
+    // Allocate and set metadata item name
+    metadataItem->name = (char *)psAlloc(sizeof(char) * MAX_STRING_LENGTH);
+    vsprintf(metadataItem->name, name, argPtr);
 
     // Set metadata item value
     switch (type) {
     case PS_META_ITEM_SET:
-        metadataItem->data.V = NULL;
         break;
     case PS_META_BOOL:
@@ -180,13 +187,10 @@
     case PS_META_UNKNOWN:
     default:
-        psError(__func__, "Invalid psMetadataType: %d", type);
-    }
-
-    // Allocate and set metadata item name
-    metadataItem->name = (char *)psAlloc(sizeof(char) * MAX_STRING_LENGTH);
-    vsprintf(metadataItem->name, name, argPtr);
-
-    // Allocate metadata items with same name.
-    metadataItem->items = psListAlloc(NULL);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psMetadata_METATYPE_INVALID,
+                type);
+        psFree(metadataItem);
+        metadataItem = NULL;
+    }
 
     return metadataItem;
@@ -224,33 +228,14 @@
     psMetadataType newType = PS_META_ITEM_SET;
 
-    if(md == NULL) {
-        psError( __func__, "Null metadata collection not allowed" );
-        return false;
-    }
-
-    if(metadataItem == NULL) {
-        psError( __func__, "Null metadata item not allowed" );
-        return false;
-    }
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->table,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
+    PS_PTR_CHECK_NULL(metadataItem,NULL);
+    PS_PTR_CHECK_NULL(metadataItem->name,NULL);
 
     newType = metadataItem->type;
-
     mdTable = md->table;
-    if(mdTable == NULL) {
-        psError( __func__, "Null metadata table not allowed" );
-        return false;
-    }
-
     mdList = md->list;
-    if(mdList == NULL) {
-        psError( __func__, "Null metadata list not allowed");
-        return false;
-    }
-
     key = metadataItem->name;
-    if(key == NULL) {
-        psError(__func__, "Null key item not allowed");
-        return false;
-    }
 
     // See if key is already in table
@@ -262,6 +247,7 @@
             // Add leaf node to existing folder node
             if(!psListAdd(existingEntry->items, PS_LIST_TAIL, metadataItem)) {
-                psError( __func__, "Couldn't add metadata item to items list. Name: %s",
-                         metadataItem->name );
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED,
+                        metadataItem->name );
                 return false;
             }
@@ -272,5 +258,7 @@
 
             if(!psListAdd(newFolderEntry->items, PS_LIST_TAIL, existingEntry)) {
-                psError( __func__, "Couldn't add metadata item to items list. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED,
+                        key);
                 psFree(newFolderEntry);
                 return false;
@@ -278,5 +266,7 @@
 
             if(!psListAdd(newFolderEntry->items, PS_LIST_TAIL, metadataItem)) {
-                psError( __func__, "Couldn't add metadata item to items list. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED,
+                        key);
                 psFree(newFolderEntry);
                 return false;
@@ -284,5 +274,7 @@
 
             if(!psHashRemove(mdTable, key)) {
-                psError( __func__, "Couldn't remove metadata item from metadata table. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED,
+                        key);
                 psFree(newFolderEntry);
                 return false;
@@ -290,5 +282,7 @@
 
             if(!psHashAdd(mdTable, key, newFolderEntry)) {
-                psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED,
+                        key);
                 psFree(newFolderEntry);
                 return false;
@@ -301,15 +295,21 @@
             // Folder node replaces leaf or folder node - Put old node into new folder and remove from table
             if(!psListAdd(metadataItem->items, PS_LIST_TAIL, existingEntry)) {
-                psError( __func__, "Couldn't add metadata item to items list. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED,
+                        key);
                 return false;
             }
 
             if(!psHashRemove(mdTable, key)) {
-                psError( __func__, "Couldn't remove metadata item from metadata table. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED,
+                        key);
                 return false;
             }
 
             if(!psHashAdd(mdTable, key, metadataItem)) {
-                psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED,
+                        key);
                 return false;
             }
@@ -319,5 +319,7 @@
         // Node doesn't exist - Add new metadata item to metadata collection's hash
         if(!psHashAdd(mdTable, key, metadataItem)) {
-            psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key);
+            psError(PS_ERR_UNKNOWN,false,
+                    PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED,
+                    key);
             return false;
         }
@@ -328,6 +330,7 @@
     if(metadataItem->type != PS_META_ITEM_SET) {
         if(!psListAdd(mdList, location, metadataItem)) {
-            psError( __func__, "Couldn't add metadata item to metadata collection list. Name: %s",
-                     metadataItem->name );
+            psError(PS_ERR_UNKNOWN,false,
+                    PS_ERRORTEXT_psMetadata_ADD_COLLECTION_FAILED,
+                    key);
             return false;
         }
@@ -348,6 +351,6 @@
 
     if (!psMetadataAddItem(md, metadataItem, where)) {
-        psError(__func__, "Couldn't add metadata item to metadata collection list. Name: %s",
-                metadataItem->name);
+        psError(PS_ERR_UNKNOWN,false,
+                PS_ERRORTEXT_psMetadata_ADD_FAILED);
         psFree(metadataItem);
         return false;
@@ -368,20 +371,11 @@
 
 
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return false;
-    }
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->table,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
 
     mdList = md->list;
-    if (mdList == NULL) {
-        psError(__func__, "Null metadata list not allowed");
-        return false;
-    }
-
     mdTable = md->table;
-    if (mdTable == NULL) {
-        psError(__func__, "Null metadata table not allowed");
-        return false;
-    }
+
     // Select removal by key or index
     if (key != NULL) {
@@ -390,5 +384,7 @@
         entry = (psMetadataItem* ) psHashLookup(mdTable, key);
         if (entry == NULL) {
-            psError(__func__, "Couldn't find metadata item. Name: %s", key);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psMetadata_FIND_FAILED,
+                    key);
             return false;
         }
@@ -402,5 +398,7 @@
             while (entryChild != NULL) {
                 if (!psListRemove(mdList, PS_LIST_UNKNOWN, entryChild)) {
-                    psError(__func__, "Couldn't remove metadata item from list. Name: %s", key);
+                    psError(PS_ERR_UNKNOWN,false,
+                            PS_ERRORTEXT_psMetadata_REMOVE_LIST_FAILED,
+                            key);
                     return false;
                 }
@@ -411,5 +409,7 @@
             // Table entry has no children. Remove entry from metadata collection's list
             if (!psListRemove(mdList, PS_LIST_UNKNOWN, entry)) {
-                psError(__func__, "Couldn't remove metadata item from list. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_REMOVE_LIST_FAILED,
+                        key);
                 return false;
             }
@@ -417,5 +417,7 @@
         // Remove entry from metadata collection's table
         if (!psHashRemove(mdTable, key)) {
-            psError(__func__, "Couldn't remove metadata item from table. Name: %s", key);
+            psError(PS_ERR_UNKNOWN,false,
+                    PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED,
+                    key);
             return false;
         }
@@ -425,5 +427,7 @@
         entry = psListGet(mdList, where);
         if (entry == NULL) {
-            psError(__func__, "Couldn't find metadata item in list. Index: %d", where);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psMetadata_FIND_INDEX_FAILED,
+                    where);
             return false;
         }
@@ -431,5 +435,7 @@
         key = entry->name;
         if (key == NULL) {
-            psError(__func__, "Null key name not allowed. Index: %d", where);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psMetadata_REMOVE_LIST_INDEX_FAILED,
+                    where);
             return false;
         }
@@ -447,19 +453,9 @@
 
 
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->table,NULL);
+    PS_PTR_CHECK_NULL(key,NULL);
 
     mdTable = md->table;
-    if (mdTable == NULL) {
-        psError(__func__, "Null metadata table not allowed");
-        return NULL;
-    }
-
-    if (key == NULL) {
-        psError(__func__, "Null key name not allowed");
-        return NULL;
-    }
 
     entry = (psMetadataItem* ) psHashLookup(mdTable, key);
@@ -473,64 +469,40 @@
 psMetadataItem* psMetadataGet(psMetadata* restrict md, psS32 where)
 {
+    psMetadataItem* entry = NULL;
+
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
+
+    entry = (psMetadataItem* ) psListGet(md->list, where);
+    if (entry == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psMetadata_FIND_INDEX_FAILED,
+                where);
+        return NULL;
+    }
+
+    return entry;
+}
+
+psBool psMetadataSetIterator(psMetadata* restrict md, psS32 where)
+{
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
+
+    psListSetIterator(md->list, where);
+
+    return true;
+}
+
+psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which)
+{
     psList* mdList = NULL;
     psMetadataItem* entry = NULL;
 
 
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
 
     mdList = md->list;
-    if (mdList == NULL) {
-        psError(__func__, "Null metadata list not allowed");
-        return NULL;
-    }
-
-    entry = (psMetadataItem* ) psListGet(mdList, where);
-    if (entry == NULL) {
-        psError(__func__, "Couldn't find metadata item with given index. Index: %d", where);
-        return NULL;
-    }
-
-    return entry;
-}
-
-psBool psMetadataSetIterator(psMetadata* restrict md, psS32 where)
-{
-    psList* mdList = NULL;
-
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return false;
-    }
-
-    mdList = md->list;
-    if (mdList == NULL) {
-        psError(__func__, "Null metadata list not allowed");
-        return false;
-    }
-
-    psListSetIterator(mdList, where);
-
-    return true;
-}
-
-psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which)
-{
-    psList* mdList = NULL;
-    psMetadataItem* entry = NULL;
-
-
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return NULL;
-    }
-
-    mdList = md->list;
-    if (mdList == NULL) {
-        psError(__func__, "Null metadata list not allowed");
-        return NULL;
-    }
 
     psListSetIterator(mdList, which);
@@ -559,14 +531,8 @@
 
 
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
 
     mdList = md->list;
-    if (mdList == NULL) {
-        psError(__func__, "Null metadata list not allowed");
-        return NULL;
-    }
 
     psListSetIterator(mdList, which);
Index: /trunk/psLib/src/astronomy/psMetadataIO.c
===================================================================
--- /trunk/psLib/src/astronomy/psMetadataIO.c	(revision 2272)
+++ /trunk/psLib/src/astronomy/psMetadataIO.c	(revision 2273)
@@ -9,6 +9,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 00:57:30 $
+*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:04:57 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -29,4 +29,6 @@
 #include "psMetadata.h"
 #include "psMetadataIO.h"
+#include "psConstants.h"
+#include "psAstronomyErrors.h"
 
 
@@ -38,10 +40,10 @@
 #define FITS_ERROR(STRING,PS_ERROR) \
 fits_get_errstatus(status, fitsErr); \
-psError(__func__, STRING, PS_ERROR, fitsErr); \
+psError(PS_ERR_IO,true, STRING, PS_ERROR, fitsErr); \
 status = 0; \
 fits_close_file(fd, &status); \
 if(status){ \
     fits_get_errstatus(status, fitsErr); \
-    psError(__func__, "Couldn't close FITS file. FITS error: %s", fitsErr); \
+    psError(PS_ERR_IO,true, "Couldn't close FITS file. FITS error: %s", fitsErr); \
 } \
 status = 0; \
@@ -281,5 +283,7 @@
             default:
                 *status = 1;
-                psError(__func__, "Invalid type: %d", elemType);
+                psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                        PS_ERRORTEXT_psMetadataIO_TYPE_INVALID,
+                        elemType);
             }
 
@@ -302,18 +306,7 @@
     psMetadataType type;
 
-    if (fd == NULL) {
-        psError(__func__, "Null file descriptor not allowed");
-        return;
-    }
-
-    if (format == NULL) {
-        psError(__func__, "Null format not allowed");
-        return;
-    }
-
-    if (metadataItem == NULL) {
-        psError(__func__, "Null metadata not allowed");
-        return;
-    }
+    PS_PTR_CHECK_NULL(fd,);
+    PS_PTR_CHECK_NULL(format,);
+    PS_PTR_CHECK_NULL(metadataItem,);
 
     type = metadataItem->type;
@@ -336,5 +329,7 @@
         break;
     default:
-        psError(__func__, " Invalid psMetadataType to print: %d", type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE,true,
+                PS_ERRORTEXT_psMetadata_METATYPE_INVALID,
+                (int)type);
     }
 }
@@ -358,8 +353,5 @@
     fitsfile *fd = NULL;
 
-    if(fileName == NULL) {
-        psError(__func__, "Null fileName not allowed");
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(fileName,NULL);
 
     fits_open_file(&fd, fileName, READONLY, &status);
@@ -369,9 +361,8 @@
     }
 
-    if (extName == NULL && extNum == 0) {
-        psError(__func__, "Null extName and extNum = 0 not allowed");
-        return NULL;
-    } else if (extName && (extNum != -1) ) {
-        psError(__func__, "If extName specified, extNum arguments should be -1.");
+    if (extName == NULL && extNum < 1) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psMetadataIO_EXTNUM_NOTPOSITIVE,
+                extNum);
         return NULL;
     }
@@ -435,10 +426,14 @@
         case 'X':
         default:
-            psError(__func__, "Invalid psMetadataType: %c", keyType);
+            psError(PS_ERR_IO, true,
+                    PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID,
+                    keyType);
             return output;
         }
 
         if (!success) {
-            psError(__func__, "Failed to add metadata item. Name: %s", keyName);
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psMetadataIO_ADD_FAILED,
+                    keyName);
             return output;
         }
@@ -471,9 +466,9 @@
 
     // Check for nulls
-    if(fileName == NULL) {
-        psError(__func__, "Null fileName not allowed");
-        return -1;
-    } else if((fp=fopen(fileName, "r")) == NULL) {
-        psError(__func__, "Couldn't open file. Name: %s", fileName);
+    PS_PTR_CHECK_NULL(fileName,-1);
+    if((fp=fopen(fileName, "r")) == NULL) {
+        psError(PS_ERR_IO, true,
+                PS_ERRORTEXT_psMetadataIO_FILE_OPEN_FAILED,
+                fileName);
         return -1;
     }
@@ -486,7 +481,4 @@
     // Create reusable line for continuous read
     line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char));
-    if (line == NULL) {
-        psAbort(__func__, "Failed to allocate reusable line");
-    }
 
     // While loop to parse the file
@@ -504,13 +496,19 @@
             if(repeatedChars(linePtr, '@') > 1) {
                 failedLines++;
-                psError(__func__, "More than one @ charecter not allowed. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR,
+                        '@', lineCount, fileName);
                 continue;
             } else if(repeatedChars(linePtr, '*') > 1) {
                 failedLines++;
-                psError(__func__, "More than one * charecter not allowed. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR,
+                        '*', lineCount, fileName);
                 continue;
             } else if(repeatedChars(linePtr, '~') > 0) {
                 failedLines++;
-                psError(__func__, "Illegal character. Character:~ Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR,
+                        '~', lineCount, fileName);
                 continue;
             }
@@ -521,5 +519,7 @@
                 failedLines++;
                 status = 0;
-                psError(__func__, "Null name not allowed. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
+                        "name",lineCount, fileName);
                 continue;
             }
@@ -530,5 +530,7 @@
                 failedLines++;
                 status = 0;
-                psError(__func__, "Null type not allowed. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
+                        "type",lineCount, fileName);
                 continue;
             } else if(!strncmp(strType, "*", 1)) {
@@ -551,5 +553,7 @@
             } else {
                 failedLines++;
-                psError(__func__, "Invalid psMetadataType. Type: %s Line %d: %s", strType, lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID,
+                        strType, lineCount, fileName);
                 continue;
             }
@@ -565,5 +569,7 @@
                     failedLines++;
                     status = 0;
-                    psError(__func__, "Null value not allowed. Line %d: %s", lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
+                            "value",lineCount, fileName);
                     continue;
                 }
@@ -575,5 +581,7 @@
                 failedLines++;
                 status = 0;
-                psError(__func__, "Failed to parse comment. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
+                        "comment",lineCount, fileName);
                 continue;
             }
@@ -589,6 +597,7 @@
                     } else {
                         failedLines++;
-                        psError(__func__, "Overwrite for name not allowed. Name: %s. Line %d: %s", strName,
-                                lineCount, line);
+                        psError(PS_ERR_IO, true,
+                                PS_ERRORTEXT_psMetadataIO_OVERWRITE_ITEM,
+                                strName, lineCount, fileName);
                         continue;
                     }
@@ -608,5 +617,7 @@
                     status = 0;
                     failedLines++;
-                    psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
+                            strValue, strName, strType, lineCount, fileName);
                     continue;
                 }
@@ -619,5 +630,7 @@
                     status = 0;
                     failedLines++;
-                    psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
+                            strValue, strName, strType, lineCount, fileName);
                     continue;
                 }
@@ -631,5 +644,7 @@
                     status = 0;
                     failedLines++;
-                    psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
+                            strValue, strName, strType, lineCount, fileName);
                     continue;
                 }
@@ -645,5 +660,7 @@
                     status = 0;
                     failedLines++;
-                    psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
+                            strValue, strName, strType, lineCount, fileName);
                     continue;
                 }
@@ -651,5 +668,7 @@
             default:
                 failedLines++;
-                psError(__func__, "Invalid psMetadataType. Type: %d Line %d: %s", mdType, lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID,
+                        mdType, lineCount, fileName);
                 continue;
             } // switch
Index: /trunk/psLib/src/astronomy/psTime.c
===================================================================
--- /trunk/psLib/src/astronomy/psTime.c	(revision 2272)
+++ /trunk/psLib/src/astronomy/psTime.c	(revision 2273)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:30 $
+ *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -31,5 +31,5 @@
 #include "psMetadata.h"
 #include "psMetadataIO.h"
-
+#include "psConstants.h"
 #include "psAstronomyErrors.h"
 
@@ -151,5 +151,5 @@
     char line[LINESIZE];
     psS32 j = 0;
-    psS32 maxLines = 100;
+    psS32 maxLines = 1000;
     psF64 *ptr = NULL;
     psImage *table = NULL;
@@ -159,5 +159,7 @@
     fd=fopen(fileName, "r");
     if(fd==NULL) {
-        psError(__func__, " : Line %d - Couldn't open %s", __LINE__, fileName);
+        psError(PS_ERR_IO,true,
+                PS_ERRORTEXT_psTime_FILE_NOT_FOUND,
+                fileName,"Tai-Utc");
         return NULL;
     }
@@ -168,5 +170,7 @@
     while(fgets(line, LINESIZE, fd) != NULL) {
         if(j>=maxLines) {
-            psError(__func__, " : Line %d - Too many rows in file. Max size: %d", __LINE__, maxLines);
+            psError(PS_ERR_IO,true,
+                    PS_ERRORTEXT_psTime_FILE_TOO_MANY_ROWS,
+                    fileName,maxLines);
             return NULL;
             psFree(table);
@@ -201,5 +205,7 @@
     fd=fopen(fileName, "r");
     if(fd==NULL) {
-        psError(__func__, " : Line %d - Couldn't open %s", __LINE__, fileName);
+        psError(PS_ERR_IO,true,
+                PS_ERRORTEXT_psTime_FILE_NOT_FOUND,
+                fileName,"Ser7");
         return NULL ;
     }
@@ -218,5 +224,7 @@
 
             if(j>=maxLines) {
-                psError(__func__, " : Line %d - Too many rows in file. Max size: %d", __LINE__, maxLines);
+                psError(PS_ERR_IO,true,
+                        PS_ERRORTEXT_psTime_FILE_TOO_MANY_ROWS,
+                        fileName,maxLines);
                 return NULL;
                 psFree(table);
@@ -240,115 +248,4 @@
 }
 
-/* Not yet used...
-static psImage* readEopcFile(char *fileName)
-{
-    char line[LINESIZE];
-    psS32 i = 0;
-    psS32 j = 0;
-    psS32 maxLines = 2500;
-    psImage *table = NULL;
-    FILE *fd = NULL;
- 
- 
-    fd=fopen(fileName, "r");
-    if(fd==NULL) {
-        psError(__func__, " : Line %d - Couldn't open %s", __LINE__, fileName);
-        return NULL ;
-    }
- 
-    // Table shouldn't be larger than 2500 rows. All columns are read.
-    table  = psImageAlloc(11, maxLines, PS_TYPE_F64);
-    for(i=0; i<3; i++) {
-        if((fgets(line, LINESIZE, fd) != NULL)) {
-            psError(__func__, " : Line %d - Error reading %s", __LINE__, fileName);
-        }
-    }
- 
-    while(fgets(line, LINESIZE, fd) != NULL) {
-        if(j>=maxLines) {
-            psError(__func__, " : Line %d - Too many rows in file. Max size: %d", __LINE__, maxLines);
-            return NULL;
-            psFree(table);
-        }
-        psF64 *ptr = table->data.F64[j++];
-        sscanf(line, "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",
-               ptr, ptr+1, ptr+2, ptr+3, ptr+4, ptr+5, ptr+6, ptr+7, ptr+8, ptr+9, ptr+10);
-    }
- 
-    *(psU32 *)&table->numRows = j;
- 
-    return table;
-}
- 
-static psImage* readFinalsFile(char *fileName)
-{
-    char line[LINESIZE];
-    psS32 j = 0;
-    psS32 maxLines = 15000;
-    psImage *table = NULL;
-    FILE *fd = NULL;
- 
- 
-    fd=fopen(fileName, "r");
-    if(fd==NULL) {
-        psError(__func__, " : Line %d - Couldn't open %s", __LINE__, fileName);
-        return NULL ;
-    }
- 
-    // Table shouldn't be larger than 15000 rows. Select columns are read.
-    table  = psImageAlloc(6, maxLines, PS_TYPE_F64);
-    while(fgets(line, LINESIZE, fd) != NULL) {
-        if(j>=maxLines) {
-            psError(__func__, " : Line %d - Too many rows in file. Max size: %d", __LINE__, maxLines);
-            return NULL;
-            psFree(table);
-        }
- 
-        psF64 *ptr = table->data.F64[j++];
-        ptr = table->data.F64[j++];
- 
-        // Sometimes there are blank entries in this table, so check for a space to determine if there is no entry
-        if(*(line+7) == ' ') {                   // MJD
-            *ptr = 0.0;
-        } else {
-            *ptr = atof(line+7);
-        }
- 
-        if(*(line+18) == ' ') {                  // Polar motion X
-            *(ptr+1) = 0.0;
-        } else {
-            *(ptr+1) = atof(line+18);
-        }
- 
-        if(*(line+27) == ' ') {                  // Polar motion X error
-            *(ptr+2) = 0.0;
-        } else {
-            *(ptr+2) = atof(line+27);
-        }
- 
-        if(*(line+37) == ' ') {                  // Polar motion Y
-            *(ptr+3) = 0.0;
-        } else {
-            *(ptr+3) = atof(line+37);
-        }
- 
-        if(*(line+46) == ' ') {                  // Polar motion Y error
-            *(ptr+4) = 0.0;
-        } else {
-            *(ptr+4) = atof(line+46);
-        }
- 
-        if(*(line+58) == ' ') {                  // UT1-UTC
-            *(ptr+5) = 0.0;
-        } else {
-            *(ptr+5) = atof(line+58);
-        }
-    }
- 
-    *(psU32 *)&table->numRows = j;
- 
-    return table;
-}
-*/
 
 static double lookupTaiUtcTable(const psTime *time)
@@ -389,5 +286,7 @@
             hiIdx++;
             if(hiIdx >= numRows) {
-                psError(__func__, " : Line %d - High index too big. Value: %d", __LINE__, hiIdx);
+                psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                        PS_ERRORTEXT_psTime_TIME_POSTDATES_TABLE,
+                        jd, "TAI-UTC");
                 return 0.0;
             }
@@ -395,14 +294,18 @@
         loIdx = hiIdx--;
         if(loIdx < 0) {
-            psError(__func__, " : Line %d - Low index too small. Value: %d", __LINE__, loIdx);
+            psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                    PS_ERRORTEXT_psTime_TIME_PREDATES_TABLE,
+                    jd, "TAI-UTC");
             return 0.0;
         }
 
+        // since rows of table can not have same jd, this check is probably not needed.
         denom = table->data.F64[hiIdx][0]-table->data.F64[loIdx][0];
         if(fabs(denom) < FLT_EPSILON) {
-            psError(__func__, " : Line %d - Divide by zero error during interpolation", __LINE__);
+            psError(PS_ERR_UNKNOWN,true,
+                    PS_ERRORTEXT_psTime_TABLE_DUPLICATE_ROWS
+                    "Ser7");
             return 0.0;
         } else {
-
             // Interpolate three constants required to calculate TAI-UTC
             const1 = table->data.F64[loIdx][1]+(table->data.F64[hiIdx][1]-table->data.F64[loIdx][1])
@@ -445,13 +348,19 @@
     mjdUtc = psTimeToMJD(time);
     if(mjdUtc < table->data.F64[0][3]) {                                    // MJD time before start of table
-        psError(__func__, " : Line %d - MJD too small. Value: %d", __LINE__, mjdUtc);
+        psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                PS_ERRORTEXT_psTime_TIME_PREDATES_TABLE,
+                mjdUtc, "Ser7");
 
     } else if(mjdUtc > table->data.F64[numRows-1][3]) {                     // MJD time after end of table
-        psError(__func__, " : Line %d - MJD too big. Value: %d", __LINE__, mjdUtc);
+        psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                PS_ERRORTEXT_psTime_TIME_POSTDATES_TABLE,
+                mjdUtc, "Ser7");
     } else {                                                                // All other times..interpolate
         while(mjdUtc > table->data.F64[hiIdx][3]) {
             hiIdx++;
             if(hiIdx >= numRows) {
-                psError(__func__, " : Line %d - High index too big. Value: %d", __LINE__, hiIdx);
+                psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                        PS_ERRORTEXT_psTime_TIME_POSTDATES_TABLE,
+                        mjdUtc, "Ser7");
                 return 0.0;
             }
@@ -460,10 +369,14 @@
         loIdx = hiIdx--;
         if(loIdx < 0) {
-            psError(__func__, " : Line %d - Low index too small. Value: %d", __LINE__, loIdx);
+            psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                    PS_ERRORTEXT_psTime_TIME_PREDATES_TABLE,
+                    mjdUtc, "Ser7");
         }
 
         denom = table->data.F64[hiIdx][3] - table->data.F64[loIdx][3];
         if(fabs(denom) < FLT_EPSILON) {
-            psError(__func__, " : Line %d - Divide by zero error during interpolation", __LINE__);
+            psError(PS_ERR_UNKNOWN,true,
+                    PS_ERRORTEXT_psTime_TABLE_DUPLICATE_ROWS,
+                    "Ser7");
         } else {
             out = table->data.F64[loIdx][col]+(table->data.F64[hiIdx][col]-table->data.F64[loIdx][col])
@@ -525,12 +438,11 @@
     // Error checks
     if(type!=PS_TIME_TAI && type!=PS_TIME_UTC) {
-        psError(__func__, " : Line %d - Incorrect type. Type: %d", __LINE__, type);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psTime_TYPE_UNKNOWN,
+                type);
         return NULL;
     }
 
     outTime = (psTime*)psAlloc(sizeof(psTime));
-    if(outTime == NULL) {
-        psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
-    }
 
     outTime->sec = 0;
@@ -551,5 +463,6 @@
 
     if (gettimeofday(&now, (struct timezone *)0) == -1) {
-        psError(__func__, " : Line %d - Failed to get time", __LINE__);
+        psError(PS_ERR_OS_CALL_FAILED, true,
+                PS_ERRORTEXT_psTime_GET_TOD_FAILED);
         return NULL;
     }
@@ -573,23 +486,21 @@
 
     // Error checks
-    if(time == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return NULL;
-    } else if(time->usec >= 1e6) {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return NULL;
-    } else if(time->type == type) {
-        psError(__func__, " : Line %d - Time already in correct psTime type. Time type: %d", __LINE__, type);
-        return NULL;
+    PS_PTR_CHECK_NULL(time,NULL);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
+
+    if (time->type == type) { // time already right type.  That was easy!
+        return time;
     }
 
     delta = psTimeGetTAIDelta(time);
 
-    if(type == PS_TIME_UTC) {
+    if (type == PS_TIME_UTC) {
         time->sec = time->sec - delta;    // User wants UTC time. Subtract leapseconds.
     } else if(type == PS_TIME_TAI) {
         time->sec = time->sec + delta;    // User wants TAI time. Add leapseconds.
     } else {
-        psError(__func__, " : Line %d - Invalid psTimeType: %d", __LINE__, type);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psTime_TYPE_UNKNOWN,
+                type);
     }
 
@@ -623,11 +534,6 @@
 
     // Error checks
-    if(time == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return 0;
-    } else if(time->usec >= 1e6) {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return 0;
-    }
+    PS_PTR_CHECK_NULL(time,NAN);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
 
     // Calculate TAI or UTC time based on type of time user passes
@@ -698,11 +604,6 @@
 
     // Error checks
-    if(time == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return 0.0;
-    } else if(time->usec >= 1e6) {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return 0.0;
-    }
+    PS_PTR_CHECK_NULL(time,NAN);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
 
     return lookupSer7Table(time, 6);
@@ -717,13 +618,6 @@
 
     // Error checks
-    if(time == NULL)
-    {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return NULL;
-    } else if(time->usec >= 1e6)
-    {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(time,NULL);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
 
     x = lookupSer7Table((psTime*)time, 4);
@@ -741,11 +635,6 @@
 
     // Error checks
-    if(time == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return 0.0;
-    } else if(time->usec >= 1e6) {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return 0.0;
-    }
+    PS_PTR_CHECK_NULL(time,NAN);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
 
     return lookupTaiUtcTable(time);
@@ -758,17 +647,8 @@
 
     // Error checks
-    if(time1 == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed for first input", __LINE__);
-        return 0;
-    } else if(time1->usec >= 1e6) {
-        psError(__func__, " : Line %d - First input time microseconds too big. Value %u", __LINE__, time1->usec);
-        return 0;
-    } else if(time2 == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed for second input", __LINE__);
-        return 0;
-    } else if(time2->usec >= 1e6) {
-        psError(__func__, " : Line %d - First input time microseconds too big. Value %u", __LINE__, time2->usec);
-        return 0;
-    }
+    PS_PTR_CHECK_NULL(time1,0);
+    PS_PTR_CHECK_NULL(time2,0);
+    PS_INT_CHECK_RANGE(time1->usec,0,1e6-1,0);
+    PS_INT_CHECK_RANGE(time1->usec,0,1e6-1,0);
 
     diff = abs(psTimeGetTAIDelta((psTime*)time1)-psTimeGetTAIDelta((psTime*)time2));
@@ -781,13 +661,7 @@
     double jd = 0.0;
 
-
-    // Error checks
-    if(time == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return 0.0;
-    } else if(time->usec >= 1e6) {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return 0.0;
-    }
+    // Error checks
+    PS_PTR_CHECK_NULL(time,NAN);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
 
     // Julian date conversion
@@ -807,11 +681,6 @@
 
     // Error checks
-    if(time == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return 0.0;
-    } else if(time->usec >= 1e6) {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return 0.0;
-    }
+    PS_PTR_CHECK_NULL(time,NAN);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
 
     // Modified Julian date conversion
@@ -835,11 +704,6 @@
 
     // Error checks
-    if(time == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return NULL;
-    } else if(time->usec >= 1e6) {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(time,NULL);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
 
     tempString = psAlloc(MAX_TIME_STRING_LENGTH);
@@ -854,9 +718,11 @@
     // Converts psTime to YYYY-MM-DDThh:mm:ss.sss in string form
     if (!strftime(tempString, MAX_TIME_STRING_LENGTH, "%Y-%m-%dT%H:%M:%S", tmTime)) {
-        psError(__func__, " : Line %d - Failed strftime conversion", __LINE__);
+        psError(PS_ERR_OS_CALL_FAILED, true,
+                PS_ERRORTEXT_psTime_CONVERT_TIME_TO_STRING_FAILED);
     }
 
     if (snprintf(timeString, MAX_TIME_STRING_LENGTH, "%s.%3.3dZ", tempString, ms) < 0) {
-        psError(__func__, " : Line %d - Failed snprintf conversion", __LINE__);
+        psError(PS_ERR_OS_CALL_FAILED, true,
+                PS_ERRORTEXT_psTime_APPEND_MSEC_FAILED);
     }
     psFree(tempString);
@@ -869,15 +735,10 @@
     struct timeval timevalTime;
 
-
-    // Error checks
-    if(time == NULL)
-    {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return timevalTime;
-    } else if(time->usec >= 1e6)
-    {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return timevalTime;
-    }
+    timevalTime.tv_sec = 0;
+    timevalTime.tv_usec = 0;
+
+    // Error checks
+    PS_PTR_CHECK_NULL(time,timevalTime);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,timevalTime);
 
     timevalTime.tv_sec = time->sec;
@@ -901,13 +762,6 @@
 
     // Error checks
-    if(time == NULL)
-    {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return NULL;
-    } else if(time->usec >= 1e6)
-    {
-        psError(__func__, " : Line %d - Input time microseconds too big. Value %u", __LINE__, time->usec);
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(time,NULL);
+    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
 
     seconds = time->sec%60;
@@ -945,8 +799,4 @@
     // Allocate output
     tmTime = (struct tm*)psAlloc(sizeof(struct tm));
-    if (tmTime == NULL)
-    {
-        psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
-    }
 
     tmTime->tm_year = year - 1900;
@@ -982,7 +832,5 @@
 
     // Error check
-    if(outTime->usec >= 1e6) {
-        psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec);
-    }
+    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
 
     return outTime;
@@ -1010,7 +858,5 @@
 
     // Error check
-    if(outTime->usec >= 1e6) {
-        psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec);
-    }
+    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
 
     return outTime;
@@ -1020,67 +866,28 @@
 {
     char tempString[MAX_TIME_STRING_LENGTH];
-    psS32 month;
-    psS32 day;
-    psS32 year;
-    psS32 hour;
-    psS32 minute;
-    psS32 second;
     psS32 millisecond;
     struct tm tmTime;
     psTime *outTime = NULL;
 
-
-    // Preserve input string by creating duplicate
-    strncpy(tempString, time, MAX_TIME_STRING_LENGTH);
-
     // Convert YYYY-MM-DDThh:mm:ss.sss in string form to tm time
-    year = atoi(strtok(tempString, "-"));
-    if (year < 0) {
-        psError(__func__, "Years less than 0 not allowed. Value: %d", year);
-        return outTime;
-    }
-
-    month = atoi(strtok(NULL, "-"));
-    if (month < 1 || month > 12) {
-        psError(__func__, "Month must have a value from 1 to 12. Value: %d", month);
-        return outTime;
-    }
-
-    day = atoi(strtok(NULL, "T"));
-    if (day < 1 || day > 31) {
-        psError(__func__, "Day must have a value from 1 to 31. Value: %d", day);
-        return outTime;
-    }
-
-    hour = atoi(strtok(NULL, ":"));
-    if (hour < 0 || hour > 23) {
-        psError(__func__, "Hour must have a value from 0 to 23. Value: %d", hour);
-        return outTime;
-    }
-
-    minute = atoi(strtok(NULL, ":"));
-    if (minute < 0 || minute > 59) {
-        psError(__func__, "Minute must have a value from 0 to 59. Value: %d", minute);
-        return outTime;
-    }
-
-    second = atoi(strtok(NULL, "."));
-    if (second < 0 || second > 59) {
-        psError(__func__, "Second must have a value from 0 to 59. Value: %d", second);
-        return outTime;
-    }
-
-    millisecond = atoi(strtok(NULL, "Z"));
-    if (millisecond < 0 || millisecond > 1000) {
-        psError(__func__, "Millisecond must have a value from 0 to 999. Value: %d", millisecond);
-        return outTime;
-    }
-
-    tmTime.tm_year = year - 1900;
-    tmTime.tm_mon = month - 1;
-    tmTime.tm_mday = day;
-    tmTime.tm_hour = hour;
-    tmTime.tm_min = minute;
-    tmTime.tm_sec = second;
+    if (sscanf(time, "%d-%d-%dT%d:%d:%d.%d",
+               &tmTime.tm_year,&tmTime.tm_mon,&tmTime.tm_mday,
+               &tmTime.tm_hour,&tmTime.tm_min,&tmTime.tm_sec,&millisecond) < 7) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psTime_ISOTIME_MALFORMED,
+                time);
+        return NULL;
+    }
+
+    PS_INT_CHECK_NON_NEGATIVE(tmTime.tm_year, outTime);
+    PS_INT_CHECK_RANGE(tmTime.tm_mon,1,12,outTime);
+    PS_INT_CHECK_RANGE(tmTime.tm_mday,1,31,outTime);
+    PS_INT_CHECK_RANGE(tmTime.tm_hour,0,23,outTime);
+    PS_INT_CHECK_RANGE(tmTime.tm_min,0,59,outTime);
+    PS_INT_CHECK_RANGE(tmTime.tm_sec,0,59,outTime);
+    PS_INT_CHECK_RANGE(millisecond,0,999,outTime);
+
+    tmTime.tm_year -= 1900;
+    tmTime.tm_mon--;
     tmTime.tm_isdst = -1;
 
@@ -1089,23 +896,14 @@
     outTime->usec = millisecond * 1000;
 
+    return outTime;
+}
+
+psTime* psTimeFromTimeval(const struct timeval *time)
+{
+    psTime *outTime = NULL;
+
+
     // Error check
-    if(outTime->usec >= 1e6) {
-        psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec);
-    }
-
-    return outTime;
-}
-
-psTime* psTimeFromTimeval(const struct timeval *time)
-{
-    psTime *outTime = NULL;
-
-
-    // Error check
-    if(time == NULL)
-    {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(time,NULL);
 
     // Allocate psTime struct
@@ -1117,8 +915,5 @@
 
     // Error check
-    if(outTime->usec >= 1e6)
-    {
-        psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec);
-    }
+    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
 
     return outTime;
@@ -1138,9 +933,5 @@
 
     // Error check
-    if(time == NULL)
-    {
-        psError(__func__, " : Line %d - NULL value not allowed", __LINE__);
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(time,NULL);
 
     // Allocate psTime struct
@@ -1183,8 +974,5 @@
 
     // Error check
-    if(outTime->usec >= 1e6)
-    {
-        psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec);
-    }
+    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
 
     return outTime;
@@ -1199,18 +987,12 @@
 
     // Error checks
+    PS_PTR_CHECK_NULL(tai1,NULL);
+    PS_PTR_CHECK_NULL(tai2,NULL);
+    PS_INT_CHECK_RANGE(tai1->usec,0,1e6-1,NULL);
+    PS_INT_CHECK_RANGE(tai2->usec,0,1e6-1,NULL);
+
     if(tai1->type != tai2->type) {
-        psError(__func__, " : Line %d - Argument types inconsistent for time addition", __LINE__);
-        return NULL;
-    } else if(tai1 == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed for first input", __LINE__);
-        return NULL;
-    } else if(tai1->usec >= 1e6) {
-        psError(__func__, " : Line %d - Argument 1 microseconds too big. Value %u", __LINE__, tai1->usec);
-        return NULL;
-    } else if(tai2 == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed for second input", __LINE__);
-        return NULL;
-    } else if(tai2->usec >= 1e6) {
-        psError(__func__, " : Line %d - Argument 2 microseconds too big. Value %u", __LINE__, tai2->usec);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psTime_TYPE_MISMATCH);
         return NULL;
     }
@@ -1233,7 +1015,5 @@
 
     // Error check
-    if(outTime->usec >= 1e6) {
-        psError(__func__, " : Line %d - Output time microseconds too big. Value %u", __LINE__, outTime->usec);
-    }
+    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
 
     return outTime;
@@ -1248,18 +1028,11 @@
 
     // Error checks
+    PS_PTR_CHECK_NULL(tai1,NULL);
+    PS_PTR_CHECK_NULL(tai2,NULL);
+    PS_INT_CHECK_RANGE(tai1->usec,0,1e6-1,NULL);
+    PS_INT_CHECK_RANGE(tai2->usec,0,1e6-1,NULL);
     if(tai1->type != tai2->type) {
-        psError(__func__, " : Line %d - Argument types inconsistent for time subtraction", __LINE__);
-        return NULL;
-    } else if(tai1 == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed for first input", __LINE__);
-        return NULL;
-    } else if(tai1->usec >= 1e6) {
-        psError(__func__, " : Line %d - Argument 1 microseconds too big. Value %u", __LINE__, tai1->usec);
-        return NULL;
-    } else if(tai2 == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed for second input", __LINE__);
-        return NULL;
-    } else if(tai2->usec >= 1e6) {
-        psError(__func__, " : Line %d - Argument 2 microseconds too big. Value %u", __LINE__, tai2->usec);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psTime_TYPE_MISMATCH);
         return NULL;
     }
@@ -1294,18 +1067,12 @@
 
     // Error checks
+    // Error checks
+    PS_PTR_CHECK_NULL(tai1,NULL);
+    PS_PTR_CHECK_NULL(tai2,NULL);
+    PS_INT_CHECK_RANGE(tai1->usec,0,1e6-1,NULL);
+    PS_INT_CHECK_RANGE(tai2->usec,0,1e6-1,NULL);
     if(tai1->type != tai2->type) {
-        psError(__func__, " : Line %d - Argument types inconsistent for time subtraction", __LINE__);
-        return NULL;
-    } else if(tai1 == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed for first input", __LINE__);
-        return NULL;
-    } else if(tai1->usec >= 1e6) {
-        psError(__func__, " : Line %d - Argument 1 microseconds too big. Value %u", __LINE__, tai1->usec);
-        return NULL;
-    } else if(tai2 == NULL) {
-        psError(__func__, " : Line %d - NULL value not allowed for second input", __LINE__);
-        return NULL;
-    } else if(tai2->usec >= 1e6) {
-        psError(__func__, " : Line %d - Argument 2 microseconds too big. Value %u", __LINE__, tai2->usec);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psTime_TYPE_MISMATCH);
         return NULL;
     }
Index: /trunk/psLib/src/collections/psBitSet.c
===================================================================
--- /trunk/psLib/src/collections/psBitSet.c	(revision 2272)
+++ /trunk/psLib/src/collections/psBitSet.c	(revision 2273)
@@ -11,6 +11,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -72,8 +72,7 @@
 
     if (n < 0) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetAlloc",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psBitSet_ALLOC_NEG_SIZE,
-                   n);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psBitSet_ALLOC_NEG_SIZE,
+                n);
         return NULL;
     }
@@ -99,14 +98,12 @@
 
     if (inBitSet == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetSet",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psBitSet_SET_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psBitSet_SET_NULL);
         return inBitSet;
     } else if ( (bit < 0) ||
                 (bit > inBitSet->n * 8 - 1) ) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetSet",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
-                   bit,inBitSet->n * 8 - 1);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
+                bit,inBitSet->n * 8 - 1);
         return inBitSet;
     }
@@ -124,14 +121,12 @@
 
     if (inBitSet == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetClear",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psBitSet_SET_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psBitSet_SET_NULL);
         return inBitSet;
     } else if ( (bit < 0) ||
                 (bit > inBitSet->n * 8 - 1) ) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetClear",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
-                   bit,inBitSet->n * 8 - 1);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
+                bit,inBitSet->n * 8 - 1);
         return inBitSet;
     }
@@ -149,14 +144,12 @@
 
     if (inBitSet == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetTest",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psBitSet_SET_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psBitSet_SET_NULL);
         return false;
     } else if ( (bit < 0) ||
                 (bit > inBitSet->n * 8 - 1) ) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetTest",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
-                   bit,inBitSet->n * 8 - 1);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
+                bit,inBitSet->n * 8 - 1);
         return false;
     }
@@ -180,7 +173,6 @@
 
     if (inBitSet1 == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psBitSet_FIRST_OPERAND_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psBitSet_FIRST_OPERAND_NULL);
         psFree(outBitSet);
         return NULL;
@@ -189,7 +181,6 @@
 
     if (operator == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psBitSet_OPERATOR_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psBitSet_OPERATOR_NULL);
         psFree(outBitSet);
         return NULL;
@@ -217,8 +208,7 @@
         psFree(tempStr);
         psFree(outBitSet);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psBitSet_OPERATOR_INVALID,
-                   operator);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psBitSet_OPERATOR_INVALID,
+                operator);
         return NULL;
     }
@@ -227,7 +217,6 @@
     if (op != NOT_OP) {
         if (inBitSet2 == NULL) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
-                       PS_ERR_BAD_PARAMETER_NULL, true,
-                       PS_ERRORTEXT_psBitSet_SECOND_OPERAND_NULL);
+            psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                    PS_ERRORTEXT_psBitSet_SECOND_OPERAND_NULL);
             psFree(outBitSet);
             return NULL;
@@ -235,7 +224,6 @@
 
         if (inBitSet1->n != inBitSet2->n) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
-                       PS_ERR_BAD_PARAMETER_SIZE, true,
-                       PS_ERRORTEXT_psBitSet_OPERANDS_SIZE_DIFFER);
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    PS_ERRORTEXT_psBitSet_OPERANDS_SIZE_DIFFER);
             psFree(outBitSet);
             return NULL;
@@ -287,7 +275,6 @@
 {
     if (inBitSet == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetNot",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psBitSet_OPERAND_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psBitSet_OPERAND_NULL);
         psFree(outBitSet);
         return NULL;
@@ -297,7 +284,6 @@
 
     if (outBitSet == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetNot",
-                   PS_ERR_UNKNOWN, false,
-                   PS_ERRORTEXT_psBitSet_NOT_OP_FAILED);
+        psError(PS_ERR_UNKNOWN, false,
+                PS_ERRORTEXT_psBitSet_NOT_OP_FAILED);
     }
 
Index: /trunk/psLib/src/collections/psHash.c
===================================================================
--- /trunk/psLib/src/collections/psHash.c	(revision 2272)
+++ /trunk/psLib/src/collections/psHash.c	(revision 2273)
@@ -11,6 +11,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 23:31:43 $
+*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:04:57 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -228,7 +228,6 @@
     // the way this procedure is called.
     if ((table == NULL) || (key == NULL)) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "doHashWork",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psHash_KEY_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psHash_KEY_NULL);
         return NULL;
     }
@@ -249,5 +248,6 @@
     // anyway.
     if ((hash < 0) || (hash >= table->nbucket)) {
-        psError(__func__, "Internal hash function out of range (%d)", hash);
+        psError(PS_ERR_UNKNOWN, true,
+                "Internal hash function out of range (%d)", hash);
     }
     // ptr will have the correct hash bucket.
@@ -347,19 +347,16 @@
 {
     if (table == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psHashAdd",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psHash_KEY_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psHash_KEY_NULL);
         return false;
     }
     if (key == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psHashAdd",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psHash_TABLE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psHash_TABLE_NULL);
         return false;
     }
     if (data == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psHashAdd",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psHash_DATA_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psHash_DATA_NULL);
     }
 
@@ -382,13 +379,11 @@
 {
     if (table == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psHashLookup",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psHash_KEY_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psHash_KEY_NULL);
         return NULL;
     }
     if (key == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psHashLookup",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psHash_TABLE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psHash_TABLE_NULL);
         return NULL;
     }
@@ -414,13 +409,11 @@
 
     if (table == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psHashRemove",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psHash_TABLE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psHash_TABLE_NULL);
         return false;
     }
     if (key == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psHashRemove",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psHash_KEY_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psHash_KEY_NULL);
         return false;
     }
Index: /trunk/psLib/src/collections/psList.c
===================================================================
--- /trunk/psLib/src/collections/psList.c	(revision 2272)
+++ /trunk/psLib/src/collections/psList.c	(revision 2273)
@@ -6,6 +6,6 @@
  *  @author Robert Daniel DeSonia, MHPCC
  *
- *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -136,5 +136,6 @@
 
         if (position == NULL) {
-            psError(__func__, "%s failed to move cursor to specified location (%d)", __func__, location);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    "Failed to move cursor to specified location (%d)", location);
             position = list->head;         // since we no list->size != 0, this must be non-NULL
         }
@@ -173,5 +174,5 @@
 
     if (list == NULL) {
-        psError(__func__, "list parameter found to be NULL in %s", __func__);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true, "list parameter found to be NULL.");
         return false;
     }
@@ -194,5 +195,5 @@
 
         if (location == PS_LIST_UNKNOWN) {
-            psError(__func__, "Failed to find item in given psList.");
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Failed to find item in given psList.");
             pthread_mutex_unlock(&list->lock)
             ;
@@ -206,5 +207,6 @@
 
     if (elem == NULL) {
-        psError(__func__, "Couldn't position to given index (%d) to remove element from list.", location);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "Couldn't position to given index (%d) to remove element from list.", location);
         pthread_mutex_unlock(&list->lock)
         ;
@@ -257,5 +259,6 @@
 
     if (list == NULL) {
-        psError(__func__, "Unexpected null pointer for psList parameter (%s:%d).", __FILE__, __LINE__);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                "Unexpected null pointer for psList parameter.");
         return;
     }
@@ -314,5 +317,6 @@
     default:
         if (where <= PS_LIST_HEAD) {   // bascially same as PS_LIST_UNKNOWN above
-            psError(__func__, "Can't move to an unknown position.  Not moving the iterator position.");
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    "Can't move to an unknown position.  Not moving the iterator position.");
         } else {
             cursor = listGetIterator(list);
Index: /trunk/psLib/src/collections/psMetadata.c
===================================================================
--- /trunk/psLib/src/collections/psMetadata.c	(revision 2272)
+++ /trunk/psLib/src/collections/psMetadata.c	(revision 2273)
@@ -12,6 +12,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 00:57:30 $
+*  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:04:57 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -35,4 +35,6 @@
 #include "psMetadata.h"
 #include "psString.h"
+#include "psAstronomyErrors.h"
+#include "psConstants.h"
 
 /******************************************************************************/
@@ -123,8 +125,6 @@
 
 
-    if (name == NULL) {
-        psError(__func__, "Null value for name not allowed");
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(name,NULL);
+
     // Allocate metadata item
     metadataItem = (psMetadataItem* ) psAlloc(sizeof(psMetadataItem));
@@ -147,9 +147,16 @@
     // Set metadata item type
     metadataItem->type = type;
+    metadataItem->data.V = NULL;
+
+    // Allocate metadata items with same name.
+    metadataItem->items = psListAlloc(NULL);
+
+    // Allocate and set metadata item name
+    metadataItem->name = (char *)psAlloc(sizeof(char) * MAX_STRING_LENGTH);
+    vsprintf(metadataItem->name, name, argPtr);
 
     // Set metadata item value
     switch (type) {
     case PS_META_ITEM_SET:
-        metadataItem->data.V = NULL;
         break;
     case PS_META_BOOL:
@@ -180,13 +187,10 @@
     case PS_META_UNKNOWN:
     default:
-        psError(__func__, "Invalid psMetadataType: %d", type);
-    }
-
-    // Allocate and set metadata item name
-    metadataItem->name = (char *)psAlloc(sizeof(char) * MAX_STRING_LENGTH);
-    vsprintf(metadataItem->name, name, argPtr);
-
-    // Allocate metadata items with same name.
-    metadataItem->items = psListAlloc(NULL);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psMetadata_METATYPE_INVALID,
+                type);
+        psFree(metadataItem);
+        metadataItem = NULL;
+    }
 
     return metadataItem;
@@ -224,33 +228,14 @@
     psMetadataType newType = PS_META_ITEM_SET;
 
-    if(md == NULL) {
-        psError( __func__, "Null metadata collection not allowed" );
-        return false;
-    }
-
-    if(metadataItem == NULL) {
-        psError( __func__, "Null metadata item not allowed" );
-        return false;
-    }
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->table,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
+    PS_PTR_CHECK_NULL(metadataItem,NULL);
+    PS_PTR_CHECK_NULL(metadataItem->name,NULL);
 
     newType = metadataItem->type;
-
     mdTable = md->table;
-    if(mdTable == NULL) {
-        psError( __func__, "Null metadata table not allowed" );
-        return false;
-    }
-
     mdList = md->list;
-    if(mdList == NULL) {
-        psError( __func__, "Null metadata list not allowed");
-        return false;
-    }
-
     key = metadataItem->name;
-    if(key == NULL) {
-        psError(__func__, "Null key item not allowed");
-        return false;
-    }
 
     // See if key is already in table
@@ -262,6 +247,7 @@
             // Add leaf node to existing folder node
             if(!psListAdd(existingEntry->items, PS_LIST_TAIL, metadataItem)) {
-                psError( __func__, "Couldn't add metadata item to items list. Name: %s",
-                         metadataItem->name );
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED,
+                        metadataItem->name );
                 return false;
             }
@@ -272,5 +258,7 @@
 
             if(!psListAdd(newFolderEntry->items, PS_LIST_TAIL, existingEntry)) {
-                psError( __func__, "Couldn't add metadata item to items list. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED,
+                        key);
                 psFree(newFolderEntry);
                 return false;
@@ -278,5 +266,7 @@
 
             if(!psListAdd(newFolderEntry->items, PS_LIST_TAIL, metadataItem)) {
-                psError( __func__, "Couldn't add metadata item to items list. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED,
+                        key);
                 psFree(newFolderEntry);
                 return false;
@@ -284,5 +274,7 @@
 
             if(!psHashRemove(mdTable, key)) {
-                psError( __func__, "Couldn't remove metadata item from metadata table. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED,
+                        key);
                 psFree(newFolderEntry);
                 return false;
@@ -290,5 +282,7 @@
 
             if(!psHashAdd(mdTable, key, newFolderEntry)) {
-                psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED,
+                        key);
                 psFree(newFolderEntry);
                 return false;
@@ -301,15 +295,21 @@
             // Folder node replaces leaf or folder node - Put old node into new folder and remove from table
             if(!psListAdd(metadataItem->items, PS_LIST_TAIL, existingEntry)) {
-                psError( __func__, "Couldn't add metadata item to items list. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED,
+                        key);
                 return false;
             }
 
             if(!psHashRemove(mdTable, key)) {
-                psError( __func__, "Couldn't remove metadata item from metadata table. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED,
+                        key);
                 return false;
             }
 
             if(!psHashAdd(mdTable, key, metadataItem)) {
-                psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED,
+                        key);
                 return false;
             }
@@ -319,5 +319,7 @@
         // Node doesn't exist - Add new metadata item to metadata collection's hash
         if(!psHashAdd(mdTable, key, metadataItem)) {
-            psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key);
+            psError(PS_ERR_UNKNOWN,false,
+                    PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED,
+                    key);
             return false;
         }
@@ -328,6 +330,7 @@
     if(metadataItem->type != PS_META_ITEM_SET) {
         if(!psListAdd(mdList, location, metadataItem)) {
-            psError( __func__, "Couldn't add metadata item to metadata collection list. Name: %s",
-                     metadataItem->name );
+            psError(PS_ERR_UNKNOWN,false,
+                    PS_ERRORTEXT_psMetadata_ADD_COLLECTION_FAILED,
+                    key);
             return false;
         }
@@ -348,6 +351,6 @@
 
     if (!psMetadataAddItem(md, metadataItem, where)) {
-        psError(__func__, "Couldn't add metadata item to metadata collection list. Name: %s",
-                metadataItem->name);
+        psError(PS_ERR_UNKNOWN,false,
+                PS_ERRORTEXT_psMetadata_ADD_FAILED);
         psFree(metadataItem);
         return false;
@@ -368,20 +371,11 @@
 
 
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return false;
-    }
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->table,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
 
     mdList = md->list;
-    if (mdList == NULL) {
-        psError(__func__, "Null metadata list not allowed");
-        return false;
-    }
-
     mdTable = md->table;
-    if (mdTable == NULL) {
-        psError(__func__, "Null metadata table not allowed");
-        return false;
-    }
+
     // Select removal by key or index
     if (key != NULL) {
@@ -390,5 +384,7 @@
         entry = (psMetadataItem* ) psHashLookup(mdTable, key);
         if (entry == NULL) {
-            psError(__func__, "Couldn't find metadata item. Name: %s", key);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psMetadata_FIND_FAILED,
+                    key);
             return false;
         }
@@ -402,5 +398,7 @@
             while (entryChild != NULL) {
                 if (!psListRemove(mdList, PS_LIST_UNKNOWN, entryChild)) {
-                    psError(__func__, "Couldn't remove metadata item from list. Name: %s", key);
+                    psError(PS_ERR_UNKNOWN,false,
+                            PS_ERRORTEXT_psMetadata_REMOVE_LIST_FAILED,
+                            key);
                     return false;
                 }
@@ -411,5 +409,7 @@
             // Table entry has no children. Remove entry from metadata collection's list
             if (!psListRemove(mdList, PS_LIST_UNKNOWN, entry)) {
-                psError(__func__, "Couldn't remove metadata item from list. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_REMOVE_LIST_FAILED,
+                        key);
                 return false;
             }
@@ -417,5 +417,7 @@
         // Remove entry from metadata collection's table
         if (!psHashRemove(mdTable, key)) {
-            psError(__func__, "Couldn't remove metadata item from table. Name: %s", key);
+            psError(PS_ERR_UNKNOWN,false,
+                    PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED,
+                    key);
             return false;
         }
@@ -425,5 +427,7 @@
         entry = psListGet(mdList, where);
         if (entry == NULL) {
-            psError(__func__, "Couldn't find metadata item in list. Index: %d", where);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psMetadata_FIND_INDEX_FAILED,
+                    where);
             return false;
         }
@@ -431,5 +435,7 @@
         key = entry->name;
         if (key == NULL) {
-            psError(__func__, "Null key name not allowed. Index: %d", where);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psMetadata_REMOVE_LIST_INDEX_FAILED,
+                    where);
             return false;
         }
@@ -447,19 +453,9 @@
 
 
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->table,NULL);
+    PS_PTR_CHECK_NULL(key,NULL);
 
     mdTable = md->table;
-    if (mdTable == NULL) {
-        psError(__func__, "Null metadata table not allowed");
-        return NULL;
-    }
-
-    if (key == NULL) {
-        psError(__func__, "Null key name not allowed");
-        return NULL;
-    }
 
     entry = (psMetadataItem* ) psHashLookup(mdTable, key);
@@ -473,64 +469,40 @@
 psMetadataItem* psMetadataGet(psMetadata* restrict md, psS32 where)
 {
+    psMetadataItem* entry = NULL;
+
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
+
+    entry = (psMetadataItem* ) psListGet(md->list, where);
+    if (entry == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psMetadata_FIND_INDEX_FAILED,
+                where);
+        return NULL;
+    }
+
+    return entry;
+}
+
+psBool psMetadataSetIterator(psMetadata* restrict md, psS32 where)
+{
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
+
+    psListSetIterator(md->list, where);
+
+    return true;
+}
+
+psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which)
+{
     psList* mdList = NULL;
     psMetadataItem* entry = NULL;
 
 
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
 
     mdList = md->list;
-    if (mdList == NULL) {
-        psError(__func__, "Null metadata list not allowed");
-        return NULL;
-    }
-
-    entry = (psMetadataItem* ) psListGet(mdList, where);
-    if (entry == NULL) {
-        psError(__func__, "Couldn't find metadata item with given index. Index: %d", where);
-        return NULL;
-    }
-
-    return entry;
-}
-
-psBool psMetadataSetIterator(psMetadata* restrict md, psS32 where)
-{
-    psList* mdList = NULL;
-
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return false;
-    }
-
-    mdList = md->list;
-    if (mdList == NULL) {
-        psError(__func__, "Null metadata list not allowed");
-        return false;
-    }
-
-    psListSetIterator(mdList, where);
-
-    return true;
-}
-
-psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which)
-{
-    psList* mdList = NULL;
-    psMetadataItem* entry = NULL;
-
-
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return NULL;
-    }
-
-    mdList = md->list;
-    if (mdList == NULL) {
-        psError(__func__, "Null metadata list not allowed");
-        return NULL;
-    }
 
     psListSetIterator(mdList, which);
@@ -559,14 +531,8 @@
 
 
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
 
     mdList = md->list;
-    if (mdList == NULL) {
-        psError(__func__, "Null metadata list not allowed");
-        return NULL;
-    }
 
     psListSetIterator(mdList, which);
Index: /trunk/psLib/src/collections/psMetadataIO.c
===================================================================
--- /trunk/psLib/src/collections/psMetadataIO.c	(revision 2272)
+++ /trunk/psLib/src/collections/psMetadataIO.c	(revision 2273)
@@ -9,6 +9,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 00:57:30 $
+*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:04:57 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -29,4 +29,6 @@
 #include "psMetadata.h"
 #include "psMetadataIO.h"
+#include "psConstants.h"
+#include "psAstronomyErrors.h"
 
 
@@ -38,10 +40,10 @@
 #define FITS_ERROR(STRING,PS_ERROR) \
 fits_get_errstatus(status, fitsErr); \
-psError(__func__, STRING, PS_ERROR, fitsErr); \
+psError(PS_ERR_IO,true, STRING, PS_ERROR, fitsErr); \
 status = 0; \
 fits_close_file(fd, &status); \
 if(status){ \
     fits_get_errstatus(status, fitsErr); \
-    psError(__func__, "Couldn't close FITS file. FITS error: %s", fitsErr); \
+    psError(PS_ERR_IO,true, "Couldn't close FITS file. FITS error: %s", fitsErr); \
 } \
 status = 0; \
@@ -281,5 +283,7 @@
             default:
                 *status = 1;
-                psError(__func__, "Invalid type: %d", elemType);
+                psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                        PS_ERRORTEXT_psMetadataIO_TYPE_INVALID,
+                        elemType);
             }
 
@@ -302,18 +306,7 @@
     psMetadataType type;
 
-    if (fd == NULL) {
-        psError(__func__, "Null file descriptor not allowed");
-        return;
-    }
-
-    if (format == NULL) {
-        psError(__func__, "Null format not allowed");
-        return;
-    }
-
-    if (metadataItem == NULL) {
-        psError(__func__, "Null metadata not allowed");
-        return;
-    }
+    PS_PTR_CHECK_NULL(fd,);
+    PS_PTR_CHECK_NULL(format,);
+    PS_PTR_CHECK_NULL(metadataItem,);
 
     type = metadataItem->type;
@@ -336,5 +329,7 @@
         break;
     default:
-        psError(__func__, " Invalid psMetadataType to print: %d", type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE,true,
+                PS_ERRORTEXT_psMetadata_METATYPE_INVALID,
+                (int)type);
     }
 }
@@ -358,8 +353,5 @@
     fitsfile *fd = NULL;
 
-    if(fileName == NULL) {
-        psError(__func__, "Null fileName not allowed");
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(fileName,NULL);
 
     fits_open_file(&fd, fileName, READONLY, &status);
@@ -369,9 +361,8 @@
     }
 
-    if (extName == NULL && extNum == 0) {
-        psError(__func__, "Null extName and extNum = 0 not allowed");
-        return NULL;
-    } else if (extName && (extNum != -1) ) {
-        psError(__func__, "If extName specified, extNum arguments should be -1.");
+    if (extName == NULL && extNum < 1) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psMetadataIO_EXTNUM_NOTPOSITIVE,
+                extNum);
         return NULL;
     }
@@ -435,10 +426,14 @@
         case 'X':
         default:
-            psError(__func__, "Invalid psMetadataType: %c", keyType);
+            psError(PS_ERR_IO, true,
+                    PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID,
+                    keyType);
             return output;
         }
 
         if (!success) {
-            psError(__func__, "Failed to add metadata item. Name: %s", keyName);
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psMetadataIO_ADD_FAILED,
+                    keyName);
             return output;
         }
@@ -471,9 +466,9 @@
 
     // Check for nulls
-    if(fileName == NULL) {
-        psError(__func__, "Null fileName not allowed");
-        return -1;
-    } else if((fp=fopen(fileName, "r")) == NULL) {
-        psError(__func__, "Couldn't open file. Name: %s", fileName);
+    PS_PTR_CHECK_NULL(fileName,-1);
+    if((fp=fopen(fileName, "r")) == NULL) {
+        psError(PS_ERR_IO, true,
+                PS_ERRORTEXT_psMetadataIO_FILE_OPEN_FAILED,
+                fileName);
         return -1;
     }
@@ -486,7 +481,4 @@
     // Create reusable line for continuous read
     line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char));
-    if (line == NULL) {
-        psAbort(__func__, "Failed to allocate reusable line");
-    }
 
     // While loop to parse the file
@@ -504,13 +496,19 @@
             if(repeatedChars(linePtr, '@') > 1) {
                 failedLines++;
-                psError(__func__, "More than one @ charecter not allowed. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR,
+                        '@', lineCount, fileName);
                 continue;
             } else if(repeatedChars(linePtr, '*') > 1) {
                 failedLines++;
-                psError(__func__, "More than one * charecter not allowed. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR,
+                        '*', lineCount, fileName);
                 continue;
             } else if(repeatedChars(linePtr, '~') > 0) {
                 failedLines++;
-                psError(__func__, "Illegal character. Character:~ Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR,
+                        '~', lineCount, fileName);
                 continue;
             }
@@ -521,5 +519,7 @@
                 failedLines++;
                 status = 0;
-                psError(__func__, "Null name not allowed. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
+                        "name",lineCount, fileName);
                 continue;
             }
@@ -530,5 +530,7 @@
                 failedLines++;
                 status = 0;
-                psError(__func__, "Null type not allowed. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
+                        "type",lineCount, fileName);
                 continue;
             } else if(!strncmp(strType, "*", 1)) {
@@ -551,5 +553,7 @@
             } else {
                 failedLines++;
-                psError(__func__, "Invalid psMetadataType. Type: %s Line %d: %s", strType, lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID,
+                        strType, lineCount, fileName);
                 continue;
             }
@@ -565,5 +569,7 @@
                     failedLines++;
                     status = 0;
-                    psError(__func__, "Null value not allowed. Line %d: %s", lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
+                            "value",lineCount, fileName);
                     continue;
                 }
@@ -575,5 +581,7 @@
                 failedLines++;
                 status = 0;
-                psError(__func__, "Failed to parse comment. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
+                        "comment",lineCount, fileName);
                 continue;
             }
@@ -589,6 +597,7 @@
                     } else {
                         failedLines++;
-                        psError(__func__, "Overwrite for name not allowed. Name: %s. Line %d: %s", strName,
-                                lineCount, line);
+                        psError(PS_ERR_IO, true,
+                                PS_ERRORTEXT_psMetadataIO_OVERWRITE_ITEM,
+                                strName, lineCount, fileName);
                         continue;
                     }
@@ -608,5 +617,7 @@
                     status = 0;
                     failedLines++;
-                    psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
+                            strValue, strName, strType, lineCount, fileName);
                     continue;
                 }
@@ -619,5 +630,7 @@
                     status = 0;
                     failedLines++;
-                    psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
+                            strValue, strName, strType, lineCount, fileName);
                     continue;
                 }
@@ -631,5 +644,7 @@
                     status = 0;
                     failedLines++;
-                    psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
+                            strValue, strName, strType, lineCount, fileName);
                     continue;
                 }
@@ -645,5 +660,7 @@
                     status = 0;
                     failedLines++;
-                    psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
+                            strValue, strName, strType, lineCount, fileName);
                     continue;
                 }
@@ -651,5 +668,7 @@
             default:
                 failedLines++;
-                psError(__func__, "Invalid psMetadataType. Type: %d Line %d: %s", mdType, lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID,
+                        mdType, lineCount, fileName);
                 continue;
             } // switch
Index: /trunk/psLib/src/collections/psScalar.c
===================================================================
--- /trunk/psLib/src/collections/psScalar.c	(revision 2272)
+++ /trunk/psLib/src/collections/psScalar.c	(revision 2273)
@@ -8,6 +8,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-12 19:32:44 $
+ *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -70,8 +70,7 @@
         break;
     default:
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarAlloc",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE,
-                   dataType);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE,
+                dataType);
     }
 
@@ -85,7 +84,6 @@
 
     if (scalar == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarCopy",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psScalar_COPY_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psScalar_COPY_NULL);
         return NULL;
     }
@@ -130,8 +128,7 @@
         break;
     default:
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarCopy",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE,
-                   dataType);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE,
+                dataType);
     }
 
Index: /trunk/psLib/src/collections/psVector.c
===================================================================
--- /trunk/psLib/src/collections/psVector.c	(revision 2272)
+++ /trunk/psLib/src/collections/psVector.c	(revision 2273)
@@ -10,6 +10,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 00:57:31 $
+*  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:04:57 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -70,7 +70,6 @@
 
     if (in == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorRealloc",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psVector_REALLOC_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psVector_REALLOC_NULL);
         return NULL;
     } else if (in->nalloc != nalloc) {     // No need to realloc to same size
@@ -99,7 +98,6 @@
             in->type.dimen !=  PS_DIMEN_TRANSV) {
         psFree(in);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorRecycle",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVector_NOT_A_VECTOR);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVector_NOT_A_VECTOR);
         return NULL;
     }
@@ -122,7 +120,6 @@
 {
     if (in == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psVector_SORT_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psVector_SORT_NULL);
         psFree(out);
         return NULL;
@@ -183,8 +180,7 @@
                 char* typeStr; \
                 PS_TYPE_NAME(typeStr,type); \
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", \
-                           PS_ERR_BAD_PARAMETER_TYPE, true, \
-                           PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, \
-                           typeStr); \
+                psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+                        PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, \
+                        typeStr); \
                 psFree(out); \
             } \
@@ -209,8 +205,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
-                       typeStr);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
+                    typeStr);
             psFree(out);
 
@@ -232,7 +227,6 @@
 
     if (inVector == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psVector_SORT_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psVector_SORT_NULL);
         psFree(outVector);
         return NULL;
@@ -300,8 +294,7 @@
         break;
     default:
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
-                   inType);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
+                inType);
     }
 
@@ -317,7 +310,6 @@
 
     if (inVector == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSortIndex",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psVector_SORT_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psVector_SORT_NULL);
         psFree(outVector);
         return NULL;
@@ -400,8 +392,7 @@
         break;
     default:
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSortIndex",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
-                   inType);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
+                inType);
     }
 
Index: /trunk/psLib/src/dataManip/psConstants.h
===================================================================
--- /trunk/psLib/src/dataManip/psConstants.h	(revision 2272)
+++ /trunk/psLib/src/dataManip/psConstants.h	(revision 2273)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-03 22:58:53 $
+ *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -32,5 +32,6 @@
 #define PS_INT_CHECK_NON_NEGATIVE(NAME, RVAL) \
 if (NAME < 0) { \
-    psError(__func__,"Error: %s is less than 0.", #NAME); \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s is less than 0.", #NAME); \
     return(RVAL); \
 }
@@ -38,12 +39,23 @@
 #define PS_INT_CHECK_POSITIVE(NAME, RVAL) \
 if (NAME < 1) { \
-    psError(__func__,"Error: %s is 0 or less.", #NAME); \
-    return(RVAL); \
-}
-
-// Produce an error if ((NAME1 > NAME2)
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s is 0 or less.", #NAME); \
+    return(RVAL); \
+}
+
+#define PS_INT_CHECK_RANGE(NAME, LOWER, UPPER, RVAL) \
+if ((int)NAME < LOWER || (int)NAME > UPPER) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s, %d, is out of range.  Must be between %d and %d.", \
+            #NAME,(int)NAME,LOWER,UPPER); \
+    return RVAL; \
+}
+
+// Produce an error if (NAME1 > NAME2)
 #define PS_INT_COMPARE(NAME1, NAME2, RVAL) \
 if (NAME1 > NAME2) { \
-    psError(__func__,"Error: (%s > %s) (%d %d).", #NAME1, #NAME2, NAME1, NAME2); \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: (%s > %s) (%d %d).", \
+            #NAME1, #NAME2, NAME1, NAME2); \
     return(RVAL); \
 }
@@ -53,5 +65,7 @@
 #define PS_FLOAT_COMPARE(NAME1, NAME2, RVAL) \
 if (NAME1 > NAME2) { \
-    psError(__func__,"Error: (%s > %s) (%f %f)", #NAME1, #NAME2, NAME1, NAME2); \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: (%s > %s) (%f %f)", \
+            #NAME1, #NAME2, NAME1, NAME2); \
     return(RVAL); \
 }
@@ -59,5 +73,7 @@
 #define PS_FLOAT_CHECK_NON_EQUAL(NAME1, NAME2, RVAL) \
 if (fabs(NAME2 - NAME1) < FLT_EPSILON) { \
-    psError(__func__,"Error: %s and %s are equal.", #NAME1, #NAME2); \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s and %s are equal.", \
+            #NAME1, #NAME2); \
     return(RVAL); \
 }
@@ -67,26 +83,47 @@
 the wrong type.
 *****************************************************************************/
-#define PS_PTR_CHECK_NULL(NAME, RVAL) \
+#define PS_PTR_CHECK_NULL(NAME, RVAL) PS_PTR_CHECK_NULL_GENERAL(NAME, return RVAL)
+#define PS_PTR_CHECK_NULL_GENERAL(NAME, CLEANUP) \
 if (NAME == NULL) { \
-    psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \
-    return(RVAL); \
+    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
+            "Unallowable operation: %s is NULL.", \
+            #NAME); \
+    CLEANUP; \
 }
 
 #define PS_PTR_CHECK_TYPE(NAME, TYPE, RVAL) \
 if (NAME->type.type != TYPE) { \
-    psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \
-    return(RVAL); \
-}
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "Unallowable operation: %s has incorrect type.", \
+            #NAME); \
+    return(RVAL); \
+}
+
+#define PS_PTR_CHECK_DIMEN(NAME, DIMEN, RVAL) PS_PTR_CHECK_DIMEN_GENERAL(NAME, DIMEN, return RVAL)
+#define PS_PTR_CHECK_DIMEN_GENERAL(NAME, DIMEN, CLEANUP) \
+if (NAME->type.dimen != DIMEN) { \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "Unallowable operation: %s has incorrect dimensionality.", \
+            #NAME); \
+    CLEANUP; \
+}
+
 
 #define PS_PTR_CHECK_SIZE_EQUAL(PTR1, PTR2, RVAL) \
 if (PTR1->n != PTR2->n) { \
-    psError(__func__,"ptr %s has size %d, ptr %s has size %d.", #PTR1, PTR1->n, #PTR2, PTR2->n); \
-    return(RVAL); \
-}
-
-#define PS_PTR_CHECK_TYPE_EQUAL(PTR1, PTR2, RVAL) \
+    psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
+            "ptr %s has size %d, ptr %s has size %d.", \
+            #PTR1, PTR1->n, #PTR2, PTR2->n); \
+    return(RVAL); \
+}
+
+#define PS_PTR_CHECK_TYPE_EQUAL(PTR1, PTR2, RVAL) PS_PTR_CHECK_TYPE_EQUAL_GENERAL(PTR1, PTR2, return RVAL)
+
+#define PS_PTR_CHECK_TYPE_EQUAL_GENERAL(PTR1, PTR2, CLEANUP) \
 if (PTR1->type.type != PTR2->type.type) { \
-    psError(__func__,"ptr %s has type %d, ptr %s has type %d.", #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \
-    return(RVAL); \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "ptr %s has type %d, ptr %s has type %d.", \
+            #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \
+    CLEANUP; \
 }
 
@@ -95,13 +132,18 @@
     PS_VECTOR macros:
  *****************************************************************************/
-#define PS_VECTOR_CHECK_NULL(NAME, RVAL) \
+#define PS_VECTOR_CHECK_NULL(NAME, RVAL) PS_VECTOR_CHECK_NULL_GENERAL(NAME, return RVAL)
+#define PS_VECTOR_CHECK_NULL_GENERAL(NAME, CLEANUP) \
 if (NAME == NULL || NAME->data.V == NULL) { \
-    psError(__func__,"Unallowable operation: psVector %s or its data is NULL.", #NAME); \
-    return(RVAL); \
+    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
+            "Unallowable operation: psVector %s or its data is NULL.", \
+            #NAME); \
+    CLEANUP; \
 } \
 
 #define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) \
 if (NAME->n < 1) { \
-    psError(__func__,"Unallowable operation: psVector %s has no elements.", #NAME); \
+    psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
+            "Unallowable operation: psVector %s has no elements.", \
+            #NAME); \
     return(RVAL); \
 } \
@@ -109,5 +151,7 @@
 #define PS_VECTOR_CHECK_TYPE_F32_OR_F64(NAME, RVAL) \
 if ((NAME->type.type != PS_TYPE_F32) && (NAME->type.type != PS_TYPE_F64)) { \
-    psError(__func__, "psVector %s: bad type(%d)", #NAME, NAME->type.type); \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "psVector %s: bad type(%d)", \
+            #NAME, NAME->type.type); \
     return(RVAL); \
 } \
@@ -115,5 +159,7 @@
 #define PS_VECTOR_CHECK_TYPE(NAME, TYPE, RVAL) \
 if (NAME->type.type != TYPE) { \
-    psError(__func__,"Unallowable operation: psVector %s has incorrect type.", #NAME); \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "Unallowable operation: psVector %s has incorrect type.", \
+            #NAME); \
     return(RVAL); \
 }
@@ -121,5 +167,7 @@
 #define PS_VECTOR_CHECK_SIZE_EQUAL(VEC1, VEC2, RVAL) \
 if (VEC1->n != VEC2->n) { \
-    psError(__func__,"psVector %s has size %d, psVector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \
+    psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
+            "psVector %s has size %d, psVector %s has size %d.", \
+            #VEC1, VEC1->n, #VEC2, VEC2->n); \
     return(RVAL); \
 }
@@ -221,5 +269,7 @@
 #define PS_POLY_CHECK_NULL(NAME, RVAL) \
 if (NAME == NULL || NAME->coeff == NULL) { \
-    psError(__func__,"Unallowable operation: polynomial %s or its coeffs is NULL.", #NAME); \
+    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
+            "Unallowable operation: polynomial %s or its coeffs is NULL.", \
+            #NAME); \
     return(RVAL); \
 } \
@@ -227,5 +277,6 @@
 #define PS_POLY_CHECK_TYPE(NAME, TYPE, RVAL) \
 if (NAME->type != TYPE) { \
-    psError(__func__,"Unallowable operation: polynomial %s has wrong type.", #NAME); \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "Unallowable operation: polynomial %s has wrong type.", #NAME); \
     return(RVAL); \
 } \
@@ -234,20 +285,27 @@
     PS_IMAGE macros:
 *****************************************************************************/
-#define PS_IMAGE_CHECK_NULL(NAME, RVAL) \
+#define PS_IMAGE_CHECK_NULL(NAME, RVAL) PS_IMAGE_CHECK_NULL_GENERAL(NAME, return RVAL)
+#define PS_IMAGE_CHECK_NULL_GENERAL(NAME, CLEANUP) \
 if (NAME == NULL || NAME->data.V == NULL) { \
-    psError(__func__,"Unallowable operation: psImage %s or its data is NULL.", #NAME); \
-    return(RVAL); \
-}
-
-#define PS_IMAGE_CHECK_EMPTY(NAME, RVAL) \
+    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
+            "Unallowable operation: psImage %s or its data is NULL.", \
+            #NAME); \
+    CLEANUP; \
+}
+
+#define PS_IMAGE_CHECK_EMPTY(NAME, RVAL) PS_IMAGE_CHECK_EMPTY_GENERAL(NAME, return RVAL)
+#define PS_IMAGE_CHECK_EMPTY_GENERAL(NAME, CLEANUP) \
 if (NAME->numCols < 1 || NAME->numRows < 1) { \
-    psError(__func__,"Unallowable operation: psImage %s has zero rows or columns (%dx%d).", #NAME, \
-            NAME->numCols, NAME->numRows); \
-    return(RVAL); \
+    psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
+            "Unallowable operation: psImage %s has zero rows or columns (%dx%d).", \
+            #NAME, NAME->numCols, NAME->numRows); \
+    CLEANUP; \
 }
 
 #define PS_IMAGE_CHECK_TYPE(NAME, TYPE, RVAL) \
 if (NAME->type.type != TYPE) { \
-    psError(__func__,"Unallowable operation: psImage %s has incorrect type.", #NAME); \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "Unallowable operation: psImage %s has incorrect type.", \
+            #NAME); \
     return(RVAL); \
 }
@@ -260,5 +318,7 @@
 #define PS_READOUT_CHECK_NULL(NAME, RVAL) \
 if (NAME == NULL || NAME->image == NULL) { \
-    psError(__func__,"Unallowable operation: psReadout %s or its data is NULL.", #NAME); \
+    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
+            "Unallowable operation: psReadout %s or its data is NULL.", \
+            #NAME); \
     return(RVAL); \
 }
Index: /trunk/psLib/src/dataManip/psDataManipErrors.dat
===================================================================
--- /trunk/psLib/src/dataManip/psDataManipErrors.dat	(revision 2272)
+++ /trunk/psLib/src/dataManip/psDataManipErrors.dat	(revision 2273)
@@ -8,5 +8,5 @@
 ####################################################################
 #
-psVectorFFT_IMAGE_TYPE_UNSUPPORTED     Input psVector type, %s, is not supported. Valid data types are psF32 and psC32.
+psVectorFFT_TYPE_NOT_F32_C32           Input psVector type, %s, is not supported. Valid data types are psF32 and psC32.
 psVectorFFT_REVERSE_NOT_COMPLEX        Input psVector (%s) is not complex.  Reverse FFT operation requires a complex input.
 psVectorFFT_FORWARD_NOT_REAL           Input psVector (%s) is not real.  Forward FFT operation requires a real input.
@@ -18,2 +18,25 @@
 psVectorFFT_NONCOMPLEX_NOTSUPPORTED    Input psVector type, %s, is required to be either psC32 or psC64.
 psVectorFFT_DIRECTION_NOTSET           Must specify the direction as either PS_FFT_FORWARD or PS_FFT_REVERSE.
+#
+psStats_NOT_F32_F64                    Invalid data type, %s.  Only psF32 and psF64 data types are supported.
+psStats_VECTOR_TYPE_UNSUPPORTED        Input psVector type, %s, is not supported.
+psStats_YVAL_OUT_OF_RANGE              Specified yVal, %g, is not within y-range, %g to %g.
+psStats_ROBUST_QUARTILE_BINS_FAILED    Could not determine the robust lower/upper quartile bin numbers.
+psStats_STATS_FAILED                   Failed to calculate the specified statistic.
+#
+psFunctions_INVALID_POLYNOMIAL_TYPE    Unknown polynomial type 0x%x found.  Evaluation failed.
+psFunctions_TYPE_NOT_SUPPORTED         Input psVector type, %s, is not supported.
+psFunctions_NOT_ENOUGH_DATAPOINTS      Given vector does not have enough data points for %d-order interpolation.
+#
+psMatrix_COUNT_DIFFERS                 Number of elements inconsistent, %d vs %d.  Number of elements must match.
+psMatrix_IMAGE_SIZE_DIFFERS            Specified psImage dimensions differed, %dx%d vs %dx%d.
+psMatrix_TYPE_MISMATCH                 Specified data type, %s, is not supported.
+psMatrix_MIN_COMPLEX_SUPPORT           The minimum operation is not supported with complex data.
+psMatrix_MAX_COMPLEX_SUPPORT           The maximum operation is not supported with complex data.
+psMatrix_OPERATION_UNSUPPORTED         Specified operation, %s, is not supported.
+psMatrix_DIMEN_OTHER_FOUND             %s's dimensionality is PS_DIMEN_OTHER, which is  not allowed.
+psMatrix_OUTPUT_VECTOR_NOT_CREATED     Couldn't create a proper output psVector.
+psMatrix_OUTPUT_IMAGE_NOT_CREATED      Couldn't create a proper output psImage.
+psMatrix_DIMEN_INVALID                 Specified parameter, %s, has invalid dimensionality, %d.
+psMatrix_VECTOR_EMPTY                  Input psVector contains no elements.  No data to perform operation with.
+psMatrix_IMAGE_EMPTY                   Input psImage contains no pixels.  No data to perform operation with.
Index: /trunk/psLib/src/dataManip/psDataManipErrors.h
===================================================================
--- /trunk/psLib/src/dataManip/psDataManipErrors.h	(revision 2272)
+++ /trunk/psLib/src/dataManip/psDataManipErrors.h	(revision 2273)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-13 20:46:57 $
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:59 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -30,5 +30,5 @@
 
 //~Start #define PS_ERRORTEXT_$1 "$2"
-#define PS_ERRORTEXT_psVectorFFT_IMAGE_TYPE_UNSUPPORTED "Input psVector type, %s, is not supported. Valid data types are psF32 and psC32."
+#define PS_ERRORTEXT_psVectorFFT_TYPE_NOT_F32_C32 "Input psVector type, %s, is not supported. Valid data types are psF32 and psC32."
 #define PS_ERRORTEXT_psVectorFFT_REVERSE_NOT_COMPLEX "Input psVector (%s) is not complex.  Reverse FFT operation requires a complex input."
 #define PS_ERRORTEXT_psVectorFFT_FORWARD_NOT_REAL "Input psVector (%s) is not real.  Forward FFT operation requires a real input."
@@ -40,4 +40,24 @@
 #define PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED "Input psVector type, %s, is required to be either psC32 or psC64."
 #define PS_ERRORTEXT_psVectorFFT_DIRECTION_NOTSET "Must specify the direction as either PS_FFT_FORWARD or PS_FFT_REVERSE."
+#define PS_ERRORTEXT_psStats_NOT_F32_F64 "Invalid data type, %s.  Only psF32 and psF64 data types are supported."
+#define PS_ERRORTEXT_psStats_VECTOR_TYPE_UNSUPPORTED "Input psVector type, %s, is not supported."
+#define PS_ERRORTEXT_psStats_YVAL_OUT_OF_RANGE "Specified yVal, %g, is not within y-range, %g to %g."
+#define PS_ERRORTEXT_psStats_ROBUST_QUARTILE_BINS_FAILED "Could not determine the robust lower/upper quartile bin numbers."
+#define PS_ERRORTEXT_psStats_STATS_FAILED "Failed to calculate the specified statistic."
+#define PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE "Unknown polynomial type 0x%x found.  Evaluation failed."
+#define PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED "Input psVector type, %s, is not supported."
+#define PS_ERRORTEXT_psFunctions_NOT_ENOUGH_DATAPOINTS "Given vector does not have enough data points for %d-order interpolation."
+#define PS_ERRORTEXT_psMatrix_COUNT_DIFFERS "Number of elements inconsistent, %d vs %d.  Number of elements must match."
+#define PS_ERRORTEXT_psMatrix_IMAGE_SIZE_DIFFERS "Specified psImage dimensions differed, %dx%d vs %dx%d."
+#define PS_ERRORTEXT_psMatrix_TYPE_MISMATCH "Specified data type, %s, is not supported."
+#define PS_ERRORTEXT_psMatrix_MIN_COMPLEX_SUPPORT "The minimum operation is not supported with complex data."
+#define PS_ERRORTEXT_psMatrix_MAX_COMPLEX_SUPPORT "The maximum operation is not supported with complex data."
+#define PS_ERRORTEXT_psMatrix_OPERATION_UNSUPPORTED "Specified operation, %s, is not supported."
+#define PS_ERRORTEXT_psMatrix_DIMEN_OTHER_FOUND "%s's dimensionality is PS_DIMEN_OTHER, which is  not allowed."
+#define PS_ERRORTEXT_psMatrix_OUTPUT_VECTOR_NOT_CREATED "Couldn't create a proper output psVector."
+#define PS_ERRORTEXT_psMatrix_OUTPUT_IMAGE_NOT_CREATED "Couldn't create a proper output psImage."
+#define PS_ERRORTEXT_psMatrix_DIMEN_INVALID "Specified parameter, %s, has invalid dimensionality, %d."
+#define PS_ERRORTEXT_psMatrix_VECTOR_EMPTY "Input psVector contains no elements.  No data to perform operation with."
+#define PS_ERRORTEXT_psMatrix_IMAGE_EMPTY "Input psImage contains no pixels.  No data to perform operation with."
 //~End
 
Index: /trunk/psLib/src/dataManip/psFunctions.c
===================================================================
--- /trunk/psLib/src/dataManip/psFunctions.c	(revision 2272)
+++ /trunk/psLib/src/dataManip/psFunctions.c	(revision 2273)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.58 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-28 00:22:53 $
+ *  @version $Revision: 1.59 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:59 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -35,4 +35,7 @@
 #include "psFunctions.h"
 #include "psConstants.h"
+
+#include "psDataManipErrors.h"
+
 /*****************************************************************************/
 /* DEFINE STATEMENTS                                                         */
@@ -50,4 +53,7 @@
 static void dPolynomial3DFree(psDPolynomial3D* myPoly);
 static void dPolynomial4DFree(psDPolynomial4D* myPoly);
+static void spline1DFree(psSpline1D *tmpSpline);
+static psS32 vectorBinDisectF32(float *bins,psS32 numBins,float x);
+static psS32 vectorBinDisectS32(psS32 *bins,psS32 numBins,psS32 x);
 
 /*****************************************************************************/
@@ -67,6 +73,167 @@
 /*****************************************************************************/
 
+static void spline1DFree(psSpline1D *tmpSpline)
+{
+    psS32 i;
+
+    if (tmpSpline == NULL) {
+        return;
+    }
+
+    if (tmpSpline->spline != NULL) {
+        for (i=0;i<tmpSpline->n;i++) {
+            psFree((tmpSpline->spline)[i]);
+        }
+        psFree(tmpSpline->spline);
+    }
+
+    if (tmpSpline->p_psDeriv2 != NULL) {
+        psFree(tmpSpline->p_psDeriv2);
+    }
+    psFree(tmpSpline->domains);
+
+    return;
+}
+
+static void polynomial1DFree(psPolynomial1D* myPoly)
+{
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void polynomial2DFree(psPolynomial2D* myPoly)
+{
+    psS32 x = 0;
+
+    for (x = 0; x < myPoly->nX; x++) {
+        psFree(myPoly->coeff[x]);
+        psFree(myPoly->coeffErr[x]);
+        psFree(myPoly->mask[x]);
+    }
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void polynomial3DFree(psPolynomial3D* myPoly)
+{
+    psS32 x = 0;
+    psS32 y = 0;
+
+    for (x = 0; x < myPoly->nX; x++) {
+        for (y = 0; y < myPoly->nY; y++) {
+            psFree(myPoly->coeff[x][y]);
+            psFree(myPoly->coeffErr[x][y]);
+            psFree(myPoly->mask[x][y]);
+        }
+        psFree(myPoly->coeff[x]);
+        psFree(myPoly->coeffErr[x]);
+        psFree(myPoly->mask[x]);
+    }
+
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void polynomial4DFree(psPolynomial4D* myPoly)
+{
+    psS32 w = 0;
+    psS32 x = 0;
+    psS32 y = 0;
+
+    for (w = 0; w < myPoly->nW; w++) {
+        for (x = 0; x < myPoly->nX; x++) {
+            for (y = 0; y < myPoly->nY; y++) {
+                psFree(myPoly->coeff[w][x][y]);
+                psFree(myPoly->coeffErr[w][x][y]);
+                psFree(myPoly->mask[w][x][y]);
+            }
+            psFree(myPoly->coeff[w][x]);
+            psFree(myPoly->coeffErr[w][x]);
+            psFree(myPoly->mask[w][x]);
+        }
+        psFree(myPoly->coeff[w]);
+        psFree(myPoly->coeffErr[w]);
+        psFree(myPoly->mask[w]);
+    }
+
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void dPolynomial1DFree(psDPolynomial1D* myPoly)
+{
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void dPolynomial2DFree(psDPolynomial2D* myPoly)
+{
+    psS32 x = 0;
+
+    for (x = 0; x < myPoly->nX; x++) {
+        psFree(myPoly->coeff[x]);
+        psFree(myPoly->coeffErr[x]);
+        psFree(myPoly->mask[x]);
+    }
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void dPolynomial3DFree(psDPolynomial3D* myPoly)
+{
+    psS32 x = 0;
+    psS32 y = 0;
+
+    for (x = 0; x < myPoly->nX; x++) {
+        for (y = 0; y < myPoly->nY; y++) {
+            psFree(myPoly->coeff[x][y]);
+            psFree(myPoly->coeffErr[x][y]);
+            psFree(myPoly->mask[x][y]);
+        }
+        psFree(myPoly->coeff[x]);
+        psFree(myPoly->coeffErr[x]);
+        psFree(myPoly->mask[x]);
+    }
+
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void dPolynomial4DFree(psDPolynomial4D* myPoly)
+{
+    psS32 w = 0;
+    psS32 x = 0;
+    psS32 y = 0;
+
+    for (w = 0; w < myPoly->nW; w++) {
+        for (x = 0; x < myPoly->nX; x++) {
+            for (y = 0; y < myPoly->nY; y++) {
+                psFree(myPoly->coeff[w][x][y]);
+                psFree(myPoly->coeffErr[w][x][y]);
+                psFree(myPoly->mask[w][x][y]);
+            }
+            psFree(myPoly->coeff[w][x]);
+            psFree(myPoly->coeffErr[w][x]);
+            psFree(myPoly->mask[w][x]);
+        }
+        psFree(myPoly->coeff[w]);
+        psFree(myPoly->coeffErr[w]);
+        psFree(myPoly->mask[w]);
+    }
+
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
 /*****************************************************************************
-CreateChebyshevPolys(n): this routine takes as input the required order n,
+createChebyshevPolys(n): this routine takes as input the required order n,
 and returns as output as a pointer to an array of n psPolynomial1D
 structures, corresponding to the first n Chebyshev polynomials.
@@ -76,5 +243,5 @@
 outer coefficients of the Chebyshev polynomials.
  *****************************************************************************/
-static psPolynomial1D **CreateChebyshevPolys(psS32 maxChebyPoly)
+static psPolynomial1D **createChebyshevPolys(psS32 maxChebyPoly)
 {
     PS_INT_CHECK_NON_NEGATIVE(maxChebyPoly, NULL);
@@ -103,4 +270,655 @@
 
     return (chebPolys);
+}
+
+/*****************************************************************************
+    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
+ 
+    XXX: Should the "coeffErr[]" should be used as well?
+ *****************************************************************************/
+static float ordPolynomial1DEval(float x, const psPolynomial1D* myPoly)
+{
+    psS32 loop_x = 0;
+    float polySum = 0.0;
+    float xSum = 1.0;
+
+    psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4,
+            "---- Calling ordPolynomial1DEval(%f)\n", x);
+    psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4,
+            "Polynomial order is %d\n", myPoly->n);
+    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
+        psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4,
+                "Polynomial coeff[%d] is %f\n", loop_x, myPoly->coeff[loop_x]);
+    }
+
+    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
+        if (myPoly->mask[loop_x] == 0) {
+            psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 10,
+                    "polysum+= sum*coeff [%f+= (%f * %f)\n", polySum, xSum, myPoly->coeff[loop_x]);
+            polySum += xSum * myPoly->coeff[loop_x];
+            xSum *= x;
+        }
+    }
+
+    return(polySum);
+}
+
+// XXX: You can do this without having to psAlloc() vector d.
+// XXX: How does the mask vector effect Crenshaw's formula?
+static float chebPolynomial1DEval(float x, const psPolynomial1D* myPoly)
+{
+    psVector *d;
+    psS32 n;
+    psS32 i;
+    float tmp;
+
+    n = myPoly->n;
+    d = psVectorAlloc(n, PS_TYPE_F32);
+    d->data.F32[n-1] = myPoly->coeff[n-1];
+    d->data.F32[n-2] = (2.0 * x * d->data.F32[n-1]) + myPoly->coeff[n-2];
+    for (i=n-3;i>=1;i--) {
+        d->data.F32[i] = (2.0 * x * d->data.F32[i+1]) -
+                         (d->data.F32[i+2]) +
+                         (myPoly->coeff[i]);
+    }
+
+    tmp = (x * d->data.F32[1]) -
+          (d->data.F32[2]) +
+          (0.5 * myPoly->coeff[0]);
+
+    psFree(d);
+    return(tmp);
+    /*
+
+    psS32 n;
+    psS32 i;
+    float tmp;
+    psPolynomial1D **chebPolys = NULL;
+
+    n = myPoly->n;
+    chebPolys = createChebyshevPolys(n);
+
+    tmp = 0.0;
+    for (i=0;i<myPoly->n;i++) {
+        tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i]));
+        //            printf("HMMM: psPolynomial1DEval(%f, chebPolys[%d]) is %f\n", x, i, psPolynomial1DEval(x, chebPolys[i]));
+    }
+    tmp-= (myPoly->coeff[0]/2.0);
+
+
+    return(tmp);
+    */
+}
+
+static float ordPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
+{
+    PS_POLY_CHECK_NULL(myPoly, NAN);
+
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    float polySum = 0.0;
+    float xSum = 1.0;
+    float ySum = 1.0;
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        ySum = xSum;
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            if (myPoly->mask[loop_x][loop_y] == 0) {
+                polySum += ySum * myPoly->coeff[loop_x][loop_y];
+                ySum *= y;
+            }
+        }
+        xSum *= x;
+    }
+
+    return(polySum);
+}
+
+static float chebPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
+{
+    PS_POLY_CHECK_NULL(myPoly, NAN);
+
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 i = 0;
+    float polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nX;
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            if (myPoly->mask[loop_x][loop_y] == 0) {
+                polySum += myPoly->coeff[loop_x][loop_y] *
+                           psPolynomial1DEval(x, chebPolys[loop_x]) *
+                           psPolynomial1DEval(y, chebPolys[loop_y]);
+            }
+        }
+    }
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+static float ordPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    float polySum = 0.0;
+    float xSum = 1.0;
+    float ySum = 1.0;
+    float zSum = 1.0;
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        ySum = xSum;
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            zSum = ySum;
+            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
+                    polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];
+                    zSum *= z;
+                }
+            }
+            ySum *= y;
+        }
+        xSum *= x;
+    }
+
+    return(polySum);
+}
+
+static float chebPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    psS32 i = 0;
+    float polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nX;
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    if (myPoly->nZ > maxChebyPoly) {
+        maxChebyPoly = myPoly->nZ;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
+                    polySum += myPoly->coeff[loop_x][loop_y][loop_z] *
+                               psPolynomial1DEval(x, chebPolys[loop_x]) *
+                               psPolynomial1DEval(y, chebPolys[loop_y]) *
+                               psPolynomial1DEval(z, chebPolys[loop_z]);
+                }
+            }
+        }
+    }
+
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+static float ordPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
+{
+    psS32 loop_w = 0;
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    float polySum = 0.0;
+    float wSum = 1.0;
+    float xSum = 1.0;
+    float ySum = 1.0;
+    float zSum = 1.0;
+
+    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
+        xSum = wSum;
+        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+            ySum = xSum;
+            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+                zSum = ySum;
+                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
+                        polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];
+                        zSum *= z;
+                    }
+                }
+                ySum *= y;
+            }
+            xSum *= x;
+        }
+        wSum *= w;
+    }
+
+    return(polySum);
+}
+
+static float chebPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
+{
+    psS32 loop_w = 0;
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    psS32 i = 0;
+    float polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nW;
+    if (myPoly->nX > maxChebyPoly) {
+        maxChebyPoly = myPoly->nX;
+    }
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    if (myPoly->nZ > maxChebyPoly) {
+        maxChebyPoly = myPoly->nZ;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
+        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
+                        polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *
+                                   psPolynomial1DEval(w, chebPolys[loop_w]) *
+                                   psPolynomial1DEval(x, chebPolys[loop_x]) *
+                                   psPolynomial1DEval(y, chebPolys[loop_y]) *
+                                   psPolynomial1DEval(z, chebPolys[loop_z]);
+                    }
+                }
+            }
+        }
+    }
+
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+/*****************************************************************************
+    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
+ *****************************************************************************/
+static double dOrdPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
+{
+    psS32 loop_x = 0;
+    double polySum = 0.0;
+    double xSum = 1.0;
+
+    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
+        if (myPoly->mask[loop_x] == 0) {
+            polySum += xSum * myPoly->coeff[loop_x];
+            xSum *= x;
+        }
+    }
+
+    return(polySum);
+}
+
+// XXX: You can do this without having to psAlloc() vector d.
+// XXX: How does the mask vector effect Crenshaw's formula?
+static double dChebPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
+{
+    psVector *d;
+    psS32 n;
+    psS32 i;
+    double tmp;
+
+    n = myPoly->n;
+    d = psVectorAlloc(n, PS_TYPE_F64);
+    d->data.F64[n-1] = myPoly->coeff[n-1];
+    d->data.F64[n-2] = (2.0 * x * d->data.F64[n-1]) + myPoly->coeff[n-2];
+    for (i=n-3;i>=1;i--) {
+        d->data.F64[i] = (2.0 * x * d->data.F64[i+1]) -
+                         (d->data.F64[i+2]) +
+                         (myPoly->coeff[i]);
+    }
+
+    tmp = (x * d->data.F64[1]) -
+          (d->data.F64[2]) +
+          (0.5 * myPoly->coeff[0]);
+
+    psFree(d);
+    return(tmp);
+}
+
+static double dOrdPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    double polySum = 0.0;
+    double xSum = 1.0;
+    double ySum = 1.0;
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        ySum = xSum;
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            if (myPoly->mask[loop_x][loop_y] == 0) {
+                polySum += ySum * myPoly->coeff[loop_x][loop_y];
+                ySum *= y;
+            }
+        }
+        xSum *= x;
+    }
+
+    return(polySum);
+}
+
+static double dChebPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 i = 0;
+    double polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nX;
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            if (myPoly->mask[loop_x][loop_y] == 0) {
+                polySum += myPoly->coeff[loop_x][loop_y] *
+                           psPolynomial1DEval(x, chebPolys[loop_x]) *
+                           psPolynomial1DEval(y, chebPolys[loop_y]);
+            }
+        }
+    }
+
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+static double dOrdPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    double polySum = 0.0;
+    double xSum = 1.0;
+    double ySum = 1.0;
+    double zSum = 1.0;
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        ySum = xSum;
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            zSum = ySum;
+            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
+                    polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];
+                    zSum *= z;
+                }
+            }
+            ySum *= y;
+        }
+        xSum *= x;
+    }
+
+    return(polySum);
+}
+
+static double dChebPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    psS32 i = 0;
+    double polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nX;
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    if (myPoly->nZ > maxChebyPoly) {
+        maxChebyPoly = myPoly->nZ;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
+                    polySum += myPoly->coeff[loop_x][loop_y][loop_z] *
+                               psPolynomial1DEval(x, chebPolys[loop_x]) *
+                               psPolynomial1DEval(y, chebPolys[loop_y]) *
+                               psPolynomial1DEval(z, chebPolys[loop_z]);
+                }
+            }
+        }
+    }
+
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+static double dOrdPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
+{
+    psS32 loop_w = 0;
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    double polySum = 0.0;
+    double wSum = 1.0;
+    double xSum = 1.0;
+    double ySum = 1.0;
+    double zSum = 1.0;
+
+    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
+        xSum = wSum;
+        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+            ySum = xSum;
+            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+                zSum = ySum;
+                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
+                        polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];
+                        zSum *= z;
+                    }
+                }
+                ySum *= y;
+            }
+            xSum *= x;
+        }
+        wSum *= w;
+    }
+
+    return(polySum);
+}
+
+static double dChebPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
+{
+    psS32 loop_w = 0;
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    psS32 i = 0;
+    double polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nW;
+    if (myPoly->nX > maxChebyPoly) {
+        maxChebyPoly = myPoly->nX;
+    }
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    if (myPoly->nZ > maxChebyPoly) {
+        maxChebyPoly = myPoly->nZ;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
+        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
+                        polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *
+                                   psPolynomial1DEval(w, chebPolys[loop_w]) *
+                                   psPolynomial1DEval(x, chebPolys[loop_x]) *
+                                   psPolynomial1DEval(y, chebPolys[loop_y]) *
+                                   psPolynomial1DEval(z, chebPolys[loop_z]);
+                    }
+                }
+            }
+        }
+    }
+
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+
+/*****************************************************************************
+p_psInterpolate1D(): This routine will take as input n-element floating
+point arrays domain and range, and the x value, assumed to lie with the
+domain vector.  It produces as output the (n-1)-order LaGrange interpolated
+value of x.
+ 
+XXX: do we error check for non-distinct domain values?
+ *****************************************************************************/
+static float fullInterpolate1DF32(float *domain,
+                                  float *range,
+                                  psS32 n,
+                                  float x)
+{
+    PS_INT_CHECK_NON_NEGATIVE(n, NAN);
+    PS_PTR_CHECK_NULL(domain, NAN);
+    PS_PTR_CHECK_NULL(range, NAN);
+
+    psS32 i;
+    psS32 m;
+    static psVector *p = NULL;
+    p = psVectorRecycle(p, n, PS_TYPE_F32);
+    p_psMemSetPersistent(p, true);
+    p_psMemSetPersistent(p->data.F32, true);
+    /*
+        psVector *p = psVectorAlloc(n, PS_TYPE_F32);
+        float tmp;
+    */
+
+    psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 4,
+            "---- fullInterpolate1DF32() begin (%d-order at x=%f) (%d data points)----\n", n-1, x, n);
+
+    for (i=0;i<n;i++) {
+        psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6,
+                "domain/range is (%f %f)\n", domain[i], range[i]);
+    }
+
+    for (i=0;i<n;i++) {
+        p->data.F32[i] = range[i];
+        psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6,
+                "p->data.F32[%d] is %f\n", i, p->data.F32[i]);
+
+    }
+
+    // From NR, during each iteration of the m loop, we are computing the
+    // p_{i ... i+m} terms.
+    for (m=1;m<n;m++) {
+        for (i=0;i<n-m;i++) {
+            // From NR: we are computing P_{i ... i+m}
+            p->data.F32[i] = (((x-domain[i+m]) * p->data.F32[i]) +
+                              ((domain[i]-x) * p->data.F32[i+1])) /
+                             (domain[i] - domain[i+m]);
+            //printf("((%f-%f * %f) + (%f-%f * %f)) / (%f - %f)\n", x, domain[i+m], p->data.F32[i], domain[i], x, p->data.F32[i+1], domain[i], domain[i+m]);
+            psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6,
+                    "p->data.F32[%d] is %f\n", i, p->data.F32[i]);
+        }
+    }
+    psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 4,
+            "---- fullInterpolate1DF32() end ----\n");
+
+    /*
+        tmp = p->data.F32[0];
+        psFree(p);
+        return(tmp);
+    */
+    return(p->data.F32[0]);
+}
+
+
+/*****************************************************************************
+interpolate1DF32(): this is the base 1-D flat memory routine to perform
+LaGrange interpolation.
+ *****************************************************************************/
+static float interpolate1DF32(float *domain,
+                              float *range,
+                              psS32 n,
+                              psS32 order,
+                              float x)
+{
+    psS32 binNum;
+    psS32 numIntPoints = order+1;
+    psS32 origin;
+
+    psTrace(".psLib.dataManip.psFunctions.interpolate1DF32", 4,
+            "---- interpolate1DF32() begin ----\n");
+
+    binNum = vectorBinDisectF32(domain, n, x);
+
+    if (0 == numIntPoints%2) {
+        origin = binNum - ((numIntPoints/2) - 1);
+    } else {
+        origin = binNum - (numIntPoints/2);
+        if ((x-domain[binNum]) > (domain[binNum+1]-x)) {
+            // x is closer to binNum+1.
+            origin = 1 + (binNum - (numIntPoints/2));
+        }
+    }
+    if (origin < 0) {
+        origin = 0;
+    }
+    if ((origin + numIntPoints) > n) {
+        origin = n - numIntPoints;
+    }
+
+    psTrace(".psLib.dataManip.psFunctions.interpolate1DF32", 4,
+            "---- interpolate1DF32() end ----\n");
+    return(fullInterpolate1DF32(&domain[origin], &range[origin], order+1, x));
 }
 
@@ -336,152 +1154,4 @@
 }
 
-static void polynomial1DFree(psPolynomial1D* myPoly)
-{
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void polynomial2DFree(psPolynomial2D* myPoly)
-{
-    psS32 x = 0;
-
-    for (x = 0; x < myPoly->nX; x++) {
-        psFree(myPoly->coeff[x]);
-        psFree(myPoly->coeffErr[x]);
-        psFree(myPoly->mask[x]);
-    }
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void polynomial3DFree(psPolynomial3D* myPoly)
-{
-    psS32 x = 0;
-    psS32 y = 0;
-
-    for (x = 0; x < myPoly->nX; x++) {
-        for (y = 0; y < myPoly->nY; y++) {
-            psFree(myPoly->coeff[x][y]);
-            psFree(myPoly->coeffErr[x][y]);
-            psFree(myPoly->mask[x][y]);
-        }
-        psFree(myPoly->coeff[x]);
-        psFree(myPoly->coeffErr[x]);
-        psFree(myPoly->mask[x]);
-    }
-
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void polynomial4DFree(psPolynomial4D* myPoly)
-{
-    psS32 w = 0;
-    psS32 x = 0;
-    psS32 y = 0;
-
-    for (w = 0; w < myPoly->nW; w++) {
-        for (x = 0; x < myPoly->nX; x++) {
-            for (y = 0; y < myPoly->nY; y++) {
-                psFree(myPoly->coeff[w][x][y]);
-                psFree(myPoly->coeffErr[w][x][y]);
-                psFree(myPoly->mask[w][x][y]);
-            }
-            psFree(myPoly->coeff[w][x]);
-            psFree(myPoly->coeffErr[w][x]);
-            psFree(myPoly->mask[w][x]);
-        }
-        psFree(myPoly->coeff[w]);
-        psFree(myPoly->coeffErr[w]);
-        psFree(myPoly->mask[w]);
-    }
-
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-/*****************************************************************************
-    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
- 
-    XXX: Should the "coeffErr[]" should be used as well?
- *****************************************************************************/
-float p_psOrdPolynomial1DEval(float x, const psPolynomial1D* myPoly)
-{
-    psS32 loop_x = 0;
-    float polySum = 0.0;
-    float xSum = 1.0;
-
-    psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,
-            "---- Calling p_psOrdPolynomial1DEval(%f)\n", x);
-    psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,
-            "Polynomial order is %d\n", myPoly->n);
-    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
-        psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,
-                "Polynomial coeff[%d] is %f\n", loop_x, myPoly->coeff[loop_x]);
-    }
-
-    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
-        if (myPoly->mask[loop_x] == 0) {
-            psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 10,
-                    "polysum+= sum*coeff [%f+= (%f * %f)\n", polySum, xSum, myPoly->coeff[loop_x]);
-            polySum += xSum * myPoly->coeff[loop_x];
-            xSum *= x;
-        }
-    }
-
-    return(polySum);
-}
-
-// XXX: You can do this without having to psAlloc() vector d.
-// XXX: How does the mask vector effect Crenshaw's formula?
-float p_psChebPolynomial1DEval(float x, const psPolynomial1D* myPoly)
-{
-    psVector *d;
-    psS32 n;
-    psS32 i;
-    float tmp;
-
-    n = myPoly->n;
-    d = psVectorAlloc(n, PS_TYPE_F32);
-    d->data.F32[n-1] = myPoly->coeff[n-1];
-    d->data.F32[n-2] = (2.0 * x * d->data.F32[n-1]) + myPoly->coeff[n-2];
-    for (i=n-3;i>=1;i--) {
-        d->data.F32[i] = (2.0 * x * d->data.F32[i+1]) -
-                         (d->data.F32[i+2]) +
-                         (myPoly->coeff[i]);
-    }
-
-    tmp = (x * d->data.F32[1]) -
-          (d->data.F32[2]) +
-          (0.5 * myPoly->coeff[0]);
-
-    psFree(d);
-    return(tmp);
-    /*
-
-    psS32 n;
-    psS32 i;
-    float tmp;
-    psPolynomial1D **chebPolys = NULL;
-
-    n = myPoly->n;
-    chebPolys = CreateChebyshevPolys(n);
-
-    tmp = 0.0;
-    for (i=0;i<myPoly->n;i++) {
-        tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i]));
-        //            printf("HMMM: psPolynomial1DEval(%f, chebPolys[%d]) is %f\n", x, i, psPolynomial1DEval(x, chebPolys[i]));
-    }
-    tmp-= (myPoly->coeff[0]/2.0);
-
-
-    return(tmp);
-    */
-}
-
 float psPolynomial1DEval(float x, const psPolynomial1D* myPoly)
 {
@@ -489,9 +1159,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psOrdPolynomial1DEval(x, myPoly));
+        return(ordPolynomial1DEval(x, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psChebPolynomial1DEval(x, myPoly));
+        return(chebPolynomial1DEval(x, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -520,78 +1192,19 @@
 }
 
-
-float p_psOrdPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
+float psPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
 {
     PS_POLY_CHECK_NULL(myPoly, NAN);
 
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    float polySum = 0.0;
-    float xSum = 1.0;
-    float ySum = 1.0;
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        ySum = xSum;
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            if (myPoly->mask[loop_x][loop_y] == 0) {
-                polySum += ySum * myPoly->coeff[loop_x][loop_y];
-                ySum *= y;
-            }
-        }
-        xSum *= x;
-    }
-
-    return(polySum);
-}
-
-float p_psChebPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
-{
-    PS_POLY_CHECK_NULL(myPoly, NAN);
-
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 i = 0;
-    float polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nX;
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            if (myPoly->mask[loop_x][loop_y] == 0) {
-                polySum += myPoly->coeff[loop_x][loop_y] *
-                           psPolynomial1DEval(x, chebPolys[loop_x]) *
-                           psPolynomial1DEval(y, chebPolys[loop_y]);
-            }
-        }
-    }
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
-float psPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
-{
-    PS_POLY_CHECK_NULL(myPoly, NAN);
-
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psOrdPolynomial2DEval(x, y, myPoly));
+        return(ordPolynomial2DEval(x, y, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psChebPolynomial2DEval(x, y, myPoly));
+        return(chebPolynomial2DEval(x, y, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
 }
-
 
 psVector *psPolynomial2DEvalVector(const psVector *x,
@@ -632,75 +1245,4 @@
 }
 
-
-
-float p_psOrdPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    float polySum = 0.0;
-    float xSum = 1.0;
-    float ySum = 1.0;
-    float zSum = 1.0;
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        ySum = xSum;
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            zSum = ySum;
-            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
-                    polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];
-                    zSum *= z;
-                }
-            }
-            ySum *= y;
-        }
-        xSum *= x;
-    }
-
-    return(polySum);
-}
-
-float p_psChebPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    psS32 i = 0;
-    float polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nX;
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    if (myPoly->nZ > maxChebyPoly) {
-        maxChebyPoly = myPoly->nZ;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
-                    polySum += myPoly->coeff[loop_x][loop_y][loop_z] *
-                               psPolynomial1DEval(x, chebPolys[loop_x]) *
-                               psPolynomial1DEval(y, chebPolys[loop_y]) *
-                               psPolynomial1DEval(z, chebPolys[loop_z]);
-                }
-            }
-        }
-    }
-
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
 float psPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
 {
@@ -708,9 +1250,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psOrdPolynomial3DEval(x, y, z, myPoly));
+        return(ordPolynomial3DEval(x, y, z, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psChebPolynomial3DEval(x, y, z, myPoly));
+        return(chebPolynomial3DEval(x, y, z, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -765,91 +1309,4 @@
 }
 
-
-
-
-
-
-float p_psOrdPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
-{
-    psS32 loop_w = 0;
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    float polySum = 0.0;
-    float wSum = 1.0;
-    float xSum = 1.0;
-    float ySum = 1.0;
-    float zSum = 1.0;
-
-    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
-        xSum = wSum;
-        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-            ySum = xSum;
-            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-                zSum = ySum;
-                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
-                        polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];
-                        zSum *= z;
-                    }
-                }
-                ySum *= y;
-            }
-            xSum *= x;
-        }
-        wSum *= w;
-    }
-
-    return(polySum);
-}
-
-float p_psChebPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
-{
-    psS32 loop_w = 0;
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    psS32 i = 0;
-    float polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nW;
-    if (myPoly->nX > maxChebyPoly) {
-        maxChebyPoly = myPoly->nX;
-    }
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    if (myPoly->nZ > maxChebyPoly) {
-        maxChebyPoly = myPoly->nZ;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
-        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
-                        polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *
-                                   psPolynomial1DEval(w, chebPolys[loop_w]) *
-                                   psPolynomial1DEval(x, chebPolys[loop_x]) *
-                                   psPolynomial1DEval(y, chebPolys[loop_y]) *
-                                   psPolynomial1DEval(z, chebPolys[loop_z]);
-                    }
-                }
-            }
-        }
-    }
-
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
 float psPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
 {
@@ -857,9 +1314,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psOrdPolynomial4DEval(w,x,y,z, myPoly));
+        return(ordPolynomial4DEval(w,x,y,z, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psChebPolynomial4DEval(w,x,y,z, myPoly));
+        return(chebPolynomial4DEval(w,x,y,z, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -924,7 +1383,4 @@
     return(tmp);
 }
-
-
-
 
 
@@ -1092,118 +1548,4 @@
 }
 
-static void dPolynomial1DFree(psDPolynomial1D* myPoly)
-{
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void dPolynomial2DFree(psDPolynomial2D* myPoly)
-{
-    psS32 x = 0;
-
-    for (x = 0; x < myPoly->nX; x++) {
-        psFree(myPoly->coeff[x]);
-        psFree(myPoly->coeffErr[x]);
-        psFree(myPoly->mask[x]);
-    }
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void dPolynomial3DFree(psDPolynomial3D* myPoly)
-{
-    psS32 x = 0;
-    psS32 y = 0;
-
-    for (x = 0; x < myPoly->nX; x++) {
-        for (y = 0; y < myPoly->nY; y++) {
-            psFree(myPoly->coeff[x][y]);
-            psFree(myPoly->coeffErr[x][y]);
-            psFree(myPoly->mask[x][y]);
-        }
-        psFree(myPoly->coeff[x]);
-        psFree(myPoly->coeffErr[x]);
-        psFree(myPoly->mask[x]);
-    }
-
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void dPolynomial4DFree(psDPolynomial4D* myPoly)
-{
-    psS32 w = 0;
-    psS32 x = 0;
-    psS32 y = 0;
-
-    for (w = 0; w < myPoly->nW; w++) {
-        for (x = 0; x < myPoly->nX; x++) {
-            for (y = 0; y < myPoly->nY; y++) {
-                psFree(myPoly->coeff[w][x][y]);
-                psFree(myPoly->coeffErr[w][x][y]);
-                psFree(myPoly->mask[w][x][y]);
-            }
-            psFree(myPoly->coeff[w][x]);
-            psFree(myPoly->coeffErr[w][x]);
-            psFree(myPoly->mask[w][x]);
-        }
-        psFree(myPoly->coeff[w]);
-        psFree(myPoly->coeffErr[w]);
-        psFree(myPoly->mask[w]);
-    }
-
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-/*****************************************************************************
-    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
- *****************************************************************************/
-double p_psDOrdPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
-{
-    psS32 loop_x = 0;
-    double polySum = 0.0;
-    double xSum = 1.0;
-
-    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
-        if (myPoly->mask[loop_x] == 0) {
-            polySum += xSum * myPoly->coeff[loop_x];
-            xSum *= x;
-        }
-    }
-
-    return(polySum);
-}
-
-// XXX: You can do this without having to psAlloc() vector d.
-// XXX: How does the mask vector effect Crenshaw's formula?
-double p_psDChebPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
-{
-    psVector *d;
-    psS32 n;
-    psS32 i;
-    double tmp;
-
-    n = myPoly->n;
-    d = psVectorAlloc(n, PS_TYPE_F64);
-    d->data.F64[n-1] = myPoly->coeff[n-1];
-    d->data.F64[n-2] = (2.0 * x * d->data.F64[n-1]) + myPoly->coeff[n-2];
-    for (i=n-3;i>=1;i--) {
-        d->data.F64[i] = (2.0 * x * d->data.F64[i+1]) -
-                         (d->data.F64[i+2]) +
-                         (myPoly->coeff[i]);
-    }
-
-    tmp = (x * d->data.F64[1]) -
-          (d->data.F64[2]) +
-          (0.5 * myPoly->coeff[0]);
-
-    psFree(d);
-    return(tmp);
-}
 
 double psDPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
@@ -1212,9 +1554,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psDOrdPolynomial1DEval(x, myPoly));
+        return(dOrdPolynomial1DEval(x, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psDChebPolynomial1DEval(x, myPoly));
+        return(dChebPolynomial1DEval(x, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -1244,61 +1588,4 @@
 
 
-
-double p_psDOrdPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    double polySum = 0.0;
-    double xSum = 1.0;
-    double ySum = 1.0;
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        ySum = xSum;
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            if (myPoly->mask[loop_x][loop_y] == 0) {
-                polySum += ySum * myPoly->coeff[loop_x][loop_y];
-                ySum *= y;
-            }
-        }
-        xSum *= x;
-    }
-
-    return(polySum);
-}
-
-double p_psDChebPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 i = 0;
-    double polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nX;
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            if (myPoly->mask[loop_x][loop_y] == 0) {
-                polySum += myPoly->coeff[loop_x][loop_y] *
-                           psPolynomial1DEval(x, chebPolys[loop_x]) *
-                           psPolynomial1DEval(y, chebPolys[loop_y]);
-            }
-        }
-    }
-
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
 double psDPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
 {
@@ -1306,9 +1593,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psDOrdPolynomial2DEval(x, y, myPoly));
+        return(dOrdPolynomial2DEval(x, y, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psDChebPolynomial2DEval(x, y, myPoly));
+        return(dChebPolynomial2DEval(x, y, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -1353,74 +1642,4 @@
 
 
-
-double p_psDOrdPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    double polySum = 0.0;
-    double xSum = 1.0;
-    double ySum = 1.0;
-    double zSum = 1.0;
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        ySum = xSum;
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            zSum = ySum;
-            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
-                    polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];
-                    zSum *= z;
-                }
-            }
-            ySum *= y;
-        }
-        xSum *= x;
-    }
-
-    return(polySum);
-}
-
-double p_psDChebPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    psS32 i = 0;
-    double polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nX;
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    if (myPoly->nZ > maxChebyPoly) {
-        maxChebyPoly = myPoly->nZ;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
-                    polySum += myPoly->coeff[loop_x][loop_y][loop_z] *
-                               psPolynomial1DEval(x, chebPolys[loop_x]) *
-                               psPolynomial1DEval(y, chebPolys[loop_y]) *
-                               psPolynomial1DEval(z, chebPolys[loop_z]);
-                }
-            }
-        }
-    }
-
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
 double psDPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
 {
@@ -1428,9 +1647,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psDOrdPolynomial3DEval(x, y, z, myPoly));
+        return(dOrdPolynomial3DEval(x, y, z, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psDChebPolynomial3DEval(x, y, z, myPoly));
+        return(dChebPolynomial3DEval(x, y, z, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -1485,93 +1706,4 @@
 }
 
-
-
-
-
-
-
-
-double p_psDOrdPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
-{
-    psS32 loop_w = 0;
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    double polySum = 0.0;
-    double wSum = 1.0;
-    double xSum = 1.0;
-    double ySum = 1.0;
-    double zSum = 1.0;
-
-    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
-        xSum = wSum;
-        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-            ySum = xSum;
-            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-                zSum = ySum;
-                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
-                        polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];
-                        zSum *= z;
-                    }
-                }
-                ySum *= y;
-            }
-            xSum *= x;
-        }
-        wSum *= w;
-    }
-
-    return(polySum);
-}
-
-double p_psDChebPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
-{
-    psS32 loop_w = 0;
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    psS32 i = 0;
-    double polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nW;
-    if (myPoly->nX > maxChebyPoly) {
-        maxChebyPoly = myPoly->nX;
-    }
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    if (myPoly->nZ > maxChebyPoly) {
-        maxChebyPoly = myPoly->nZ;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
-        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
-                        polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *
-                                   psPolynomial1DEval(w, chebPolys[loop_w]) *
-                                   psPolynomial1DEval(x, chebPolys[loop_x]) *
-                                   psPolynomial1DEval(y, chebPolys[loop_y]) *
-                                   psPolynomial1DEval(z, chebPolys[loop_z]);
-                    }
-                }
-            }
-        }
-    }
-
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
 double psDPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
 {
@@ -1579,9 +1711,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psDOrdPolynomial4DEval(w,x,y,z, myPoly));
+        return(dOrdPolynomial4DEval(w,x,y,z, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psDChebPolynomial4DEval(w,x,y,z, myPoly));
+        return(dChebPolynomial4DEval(w,x,y,z, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -1699,31 +1833,8 @@
     (tmp->domains)[numSplines] = max;
 
+    p_psMemSetDeallocator(tmp,(psFreeFcn)spline1DFree);
     return(tmp);
 }
 
-// XXX: Have Robert put the dealocator in the memory file.
-psS32 p_psSpline1DFree(psSpline1D *tmpSpline)
-{
-    psS32 i;
-
-    if (tmpSpline == NULL) {
-        return(0);
-    }
-
-    if (tmpSpline->spline != NULL) {
-        for (i=0;i<tmpSpline->n;i++) {
-            psFree((tmpSpline->spline)[i]);
-        }
-        psFree(tmpSpline->spline);
-    }
-
-    if (tmpSpline->p_psDeriv2 != NULL) {
-        psFree(tmpSpline->p_psDeriv2);
-    }
-    psFree(tmpSpline->domains);
-    psFree(tmpSpline);
-
-    return(0);
-}
 
 /*****************************************************************************
@@ -1765,5 +1876,5 @@
 
 /*****************************************************************************
-p_psVectorBinDisectF32(): This is a private function which takes as input a
+vectorBinDisectF32(): This is a private function which takes as input a
 vector of floating point data as well as a single floating point values.
 The input vector values are assumed to be non-decreasing (v[i-1] <= v[j] for
@@ -1776,7 +1887,7 @@
 XXX: name since we don't take psVectors as input.
  *****************************************************************************/
-psS32 p_psVectorBinDisectF32(float *bins,
-                             psS32 numBins,
-                             float x)
+static psS32 vectorBinDisectF32(float *bins,
+                                psS32 numBins,
+                                float x)
 {
     psS32 min;
@@ -1784,10 +1895,10 @@
     psS32 mid;
 
-    psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4,
-            "---- Calling p_psVectorBinDisectF32(%f)\n", x);
+    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
+            "---- Calling vectorBinDisectF32(%f)\n", x);
 
     if (x < bins[0]) {
         psLogMsg(__func__, PS_LOG_WARN,
-                 "p_psVectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",
+                 "vectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",
                  x, bins[0], bins[numBins-1]);
         return(-2);
@@ -1796,5 +1907,5 @@
     if (x > bins[numBins-1]) {
         psLogMsg(__func__, PS_LOG_WARN,
-                 "p_psVectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",
+                 "vectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",
                  x, bins[0], bins[numBins-1]);
         return(-1);
@@ -1806,11 +1917,11 @@
 
     while (min != max) {
-        psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4,
+        psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
                 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n",
                 min, mid, max, x, bins[mid]);
 
         if (x == bins[mid]) {
-            psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4,
-                    "---- Exiting p_psVectorBinDisectF32(): bin %d\n", mid);
+            psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
+                    "---- Exiting vectorBinDisectF32(): bin %d\n", mid);
             return(mid);
         } else if (x < bins[mid]) {
@@ -1822,15 +1933,15 @@
     }
 
-    psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4,
-            "---- Exiting p_psVectorBinDisectF32(): bin %d\n", min);
+    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
+            "---- Exiting vectorBinDisectF32(): bin %d\n", min);
     return(min);
 }
 
 /*****************************************************************************
-p_psVectorBinDisectS32(): integer version of above.
+vectorBinDisectS32(): integer version of above.
  *****************************************************************************/
-psS32 p_psVectorBinDisectS32(psS32 *bins,
-                             psS32 numBins,
-                             psS32 x)
+static psS32 vectorBinDisectS32(psS32 *bins,
+                                psS32 numBins,
+                                psS32 x)
 {
     psS32 min;
@@ -1838,11 +1949,11 @@
     psS32 mid;
 
-    psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4,
-            "---- Calling p_psVectorBinDisectS32(%f)\n", x);
+    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
+            "---- Calling vectorBinDisectS32(%f)\n", x);
 
     if ((x < bins[0]) ||
             (x > bins[numBins-1])) {
         psLogMsg(__func__, PS_LOG_WARN,
-                 "p_psVectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).",
+                 "vectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).",
                  x, bins[0], bins[numBins-1]);
         return(-1);
@@ -1854,11 +1965,11 @@
 
     while (min != max) {
-        psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4,
+        psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
                 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n",
                 min, mid, max, x, bins[mid]);
 
         if (x == bins[mid]) {
-            psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4,
-                    "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min);
+            psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
+                    "---- Exiting vectorBinDisectS32(): bin %d\n", min);
             return(min);
         } else if (x < bins[mid]) {
@@ -1870,6 +1981,6 @@
     }
 
-    psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4,
-            "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min);
+    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
+            "---- Exiting vectorBinDisectS32(): bin %d\n", min);
     return(min);
 }
@@ -1884,120 +1995,16 @@
 
     if (x->type.type == PS_TYPE_S32) {
-        return(p_psVectorBinDisectS32(bins->data.S32, bins->n, x->data.S32));
+        return(vectorBinDisectS32(bins->data.S32, bins->n, x->data.S32));
     } else if (x->type.type == PS_TYPE_F32) {
-        return(p_psVectorBinDisectF32(bins->data.F32, bins->n, x->data.F32));
+        return(vectorBinDisectF32(bins->data.F32, bins->n, x->data.F32));
     } else {
-        psError(__func__, "Unallowable data type.");
+        char* strType;
+        PS_TYPE_NAME(strType,x->type.type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE,
+                PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED,
+                strType);
         return(-2);
     }
     return(-1);
-}
-
-/*****************************************************************************
-p_psInterpolate1D(): This routine will take as input n-element floating
-point arrays domain and range, and the x value, assumed to lie with the
-domain vector.  It produces as output the (n-1)-order LaGrange interpolated
-value of x.
- 
-XXX: do we error check for non-distinct domain values?
- *****************************************************************************/
-float p_ps1DFullInterpolateF32(float *domain,
-                               float *range,
-                               psS32 n,
-                               float x)
-{
-    PS_INT_CHECK_NON_NEGATIVE(n, NAN);
-    PS_PTR_CHECK_NULL(domain, NAN);
-    PS_PTR_CHECK_NULL(range, NAN);
-
-    psS32 i;
-    psS32 m;
-    static psVector *p = NULL;
-    p = psVectorRecycle(p, n, PS_TYPE_F32);
-    p_psMemSetPersistent(p, true);
-    p_psMemSetPersistent(p->data.F32, true);
-    /*
-        psVector *p = psVectorAlloc(n, PS_TYPE_F32);
-        float tmp;
-    */
-
-    psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 4,
-            "---- p_ps1DFullInterpolateF32() begin (%d-order at x=%f) (%d data points)----\n", n-1, x, n);
-
-    for (i=0;i<n;i++) {
-        psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,
-                "domain/range is (%f %f)\n", domain[i], range[i]);
-    }
-
-    for (i=0;i<n;i++) {
-        p->data.F32[i] = range[i];
-        psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,
-                "p->data.F32[%d] is %f\n", i, p->data.F32[i]);
-
-    }
-
-    // From NR, during each iteration of the m loop, we are computing the
-    // p_{i ... i+m} terms.
-    for (m=1;m<n;m++) {
-        for (i=0;i<n-m;i++) {
-            // From NR: we are computing P_{i ... i+m}
-            p->data.F32[i] = (((x-domain[i+m]) * p->data.F32[i]) +
-                              ((domain[i]-x) * p->data.F32[i+1])) /
-                             (domain[i] - domain[i+m]);
-            //printf("((%f-%f * %f) + (%f-%f * %f)) / (%f - %f)\n", x, domain[i+m], p->data.F32[i], domain[i], x, p->data.F32[i+1], domain[i], domain[i+m]);
-            psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,
-                    "p->data.F32[%d] is %f\n", i, p->data.F32[i]);
-        }
-    }
-    psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 4,
-            "---- p_ps1DFullInterpolateF32() end ----\n");
-
-    /*
-        tmp = p->data.F32[0];
-        psFree(p);
-        return(tmp);
-    */
-    return(p->data.F32[0]);
-}
-
-
-/*****************************************************************************
-p_ps1DInterpolateF32(): this is the base 1-D flat memory routine to perform
-LaGrange interpolation.
- *****************************************************************************/
-float p_ps1DInterpolateF32(float *domain,
-                           float *range,
-                           psS32 n,
-                           psS32 order,
-                           float x)
-{
-    psS32 binNum;
-    psS32 numIntPoints = order+1;
-    psS32 origin;
-
-    psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4,
-            "---- p_ps1DInterpolateF32() begin ----\n");
-
-    binNum = p_psVectorBinDisectF32(domain, n, x);
-
-    if (0 == numIntPoints%2) {
-        origin = binNum - ((numIntPoints/2) - 1);
-    } else {
-        origin = binNum - (numIntPoints/2);
-        if ((x-domain[binNum]) > (domain[binNum+1]-x)) {
-            // x is closer to binNum+1.
-            origin = 1 + (binNum - (numIntPoints/2));
-        }
-    }
-    if (origin < 0) {
-        origin = 0;
-    }
-    if ((origin + numIntPoints) > n) {
-        origin = n - numIntPoints;
-    }
-
-    psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4,
-            "---- p_ps1DInterpolateF32() end ----\n");
-    return(p_ps1DFullInterpolateF32(&domain[origin], &range[origin], order+1, x));
 }
 
@@ -2035,5 +2042,7 @@
 
     if (order > (domain->n - 1)) {
-        psError(__func__, "not enough data points for %d-order interpolation.\n", order);
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                PS_ERRORTEXT_psFunctions_NOT_ENOUGH_DATAPOINTS,
+                order);
         return(NULL);
     }
@@ -2042,9 +2051,9 @@
         psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4,
                 "---- p_psVectorInterpolate() end ----\n");
-        return(psScalarAlloc(p_ps1DInterpolateF32(domain->data.F32,
-                             range->data.F32,
-                             domain->n,
-                             order,
-                             x->data.F32), PS_TYPE_F32));
+        return(psScalarAlloc(interpolate1DF32(domain->data.F32,
+                                              range->data.F32,
+                                              domain->n,
+                                              order,
+                                              x->data.F32), PS_TYPE_F32));
     } else if (x->type.type == PS_TYPE_F64) {
         // XXX: use recycled vectors here.
@@ -2053,9 +2062,9 @@
 
         psScalar *tmpScalar = psScalarAlloc((double)
-                                            p_ps1DInterpolateF32(domain32->data.F32,
-                                                                 range32->data.F32,
-                                                                 domain32->n,
-                                                                 order,
-                                                                 (float) x->data.F64), PS_TYPE_F64);
+                                            interpolate1DF32(domain32->data.F32,
+                                                             range32->data.F32,
+                                                             domain32->n,
+                                                             order,
+                                                             (float) x->data.F64), PS_TYPE_F64);
         psFree(range32);
         psFree(domain32);
@@ -2067,6 +2076,9 @@
 
     } else {
-        // XXX psError: type not supported
-        psError(__func__, "type %d not supported\n", x->type.type);
+        char* strType;
+        PS_TYPE_NAME(strType,x->type.type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE,
+                PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED,
+                strType);
     }
 
@@ -2084,5 +2096,5 @@
 and an independent x value.  Each determines which spline that x corresponds
 to by doing a bracket disection on the domains of the spline data structure
-(p_psVectorBinDisectF32()).  Then it evaluates the spline at that x location
+(vectorBinDisectF32()).  Then it evaluates the spline at that x location
 by a call to the 1D polynomial functions.
  
@@ -2100,5 +2112,5 @@
 
     n = spline->n;
-    binNum = p_psVectorBinDisectF32(spline->domains, (spline->n)+1, x);
+    binNum = vectorBinDisectF32(spline->domains, (spline->n)+1, x);
     if (binNum < 0) {
         psLogMsg(__func__, PS_LOG_WARN,
@@ -2139,5 +2151,9 @@
         }
     } else {
-        psError(__func__, "Unknown data type.\n");
+        char* strType;
+        PS_TYPE_NAME(strType,x->type.type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE,
+                PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED,
+                strType);
         return(NULL);
     }
Index: /trunk/psLib/src/dataManip/psFunctions.h
===================================================================
--- /trunk/psLib/src/dataManip/psFunctions.h	(revision 2272)
+++ /trunk/psLib/src/dataManip/psFunctions.h	(revision 2273)
@@ -12,6 +12,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-11-03 03:30:30 $
+*  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:04:59 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -398,6 +398,4 @@
                             float max);
 
-psS32 p_psSpline1DFree(psSpline1D *tmpSpline);
-
 psSpline1D *psSpline1DAllocGeneric(const psVector *bounds,
                                    psS32 order);
Index: /trunk/psLib/src/dataManip/psMatrix.c
===================================================================
--- /trunk/psLib/src/dataManip/psMatrix.c	(revision 2272)
+++ /trunk/psLib/src/dataManip/psMatrix.c	(revision 2273)
@@ -20,6 +20,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 20:20:11 $
+ *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:59 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -40,53 +40,17 @@
 #include "psVector.h"
 #include "psMatrix.h"
-
-/** Preprocessor macro to generate error a NULL image */
-#define PS_VECTOR_CHECK_NULL(NAME, RETURN)                                                          \
-if (NAME == NULL || NAME->data.V == NULL) {                                                         \
-    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
-    return RETURN;                                                                                  \
-}
-
-/** Preprocessor macro to create vector based on another */
-#define PS_CHECK_ALLOC_VECTOR(NAME, SIZE, PS_TYPE)                                                  \
-if(NAME == NULL) {                                                                                  \
-    NAME = psVectorAlloc(SIZE, PS_TYPE);                                                            \
-}
-
-/** Preprocessor macro to generate error for zero length vector */
-#define PS_CHECK_SIZE_VECTOR(NAME, RETURN)                                                          \
-if (NAME->n < 1) {                                                                                  \
-    psError(__func__,"Invalid operation: %s has zero n value.", #NAME);                             \
-    return RETURN;                                                                                  \
-}
-
-/** Preprocessor macro to generate error a NULL image */
-#define PS_IMAGE_CHECK_NULL(NAME, RETURN)                                                           \
-if (NAME == NULL || NAME->data.V == NULL) {                                                         \
-    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
-    return RETURN;                                                                                  \
-}
-
-/** Preprocessor macro to create image based on another */
-#define PS_CHECK_ALLOC_IMAGE(NAME, NCOLS, NROWS, PS_TYPE)                                           \
-if(NAME == NULL) {                                                                                  \
-    NAME = psImageAlloc(NCOLS, NROWS, PS_TYPE);                                                     \
-}
-
-/** Preprocessor macro to generate error for zero length rows or columns */
-#define PS_CHECK_SIZE_IMAGE(NAME, RETURN)                                                           \
-if (NAME->numCols < 1 || NAME->numRows < 1) {                                                       \
-    psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME,              \
-            NAME->numCols, NAME->numRows);                                                          \
-    return RETURN;                                                                                  \
-}
+#include "psConstants.h"
+
+
 
 /** Preprocessor macro to generate error for image dimensionality not set to PS_DIMEN_IMAGE */
 #define PS_CHECK_DIMEN_AND_TYPE(NAME, PS_DIMEN, RETURN)                                             \
 if (NAME->type.dimen != PS_DIMEN) {                                                                 \
-    psError(__func__,"Invalid operation: %s incorrect dimensionality %d.", #NAME, PS_DIMEN);        \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true,                                                        \
+            "Invalid operation. %s has incorrect dimensionality %d.", #NAME, PS_DIMEN);             \
     return RETURN;                                                                                  \
 } else if(NAME->type.type != PS_TYPE_F64) {                                                         \
-    psError(__func__, "Invalid operation: %s not PS_TYPE_F64.", #NAME);                             \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true,                                                        \
+            "Invalid operation. %s not PS_TYPE_F64.", #NAME);                                       \
     return RETURN;                                                                                  \
 }
@@ -95,5 +59,6 @@
 #define PS_CHECK_POINTERS(NAME1, NAME2, RETURN)                                                     \
 if (NAME1 == NAME2) {                                                                               \
-    psError(__func__,"Invalid operation: Pointer to %s is same as %s.", #NAME1, #NAME2);            \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true,                                                       \
+            "Invalid operation: Pointer to %s is same as %s.", #NAME1, #NAME2);                     \
     return RETURN;                                                                                  \
 }
@@ -102,5 +67,6 @@
 #define PS_CHECK_SQUARE(NAME, RETURN)                                                               \
 if (NAME->numCols != NAME->numRows) {                                                               \
-    psError(__func__,"Invalid operation: %s not square array.", #NAME);                             \
+    psError(PS_ERR_BAD_PARAMETER_SIZE, true,                                                       \
+            "Invalid operation: %s not square array.", #NAME);                             \
     return RETURN;                                                                                  \
 }
@@ -126,15 +92,20 @@
     gsl_permutation perm;
 
+    #define psMatrixLUD_EXIT { \
+                               psFree(outImage); \
+                               return NULL; \
+                             }
+
     // Error checks
     PS_CHECK_POINTERS(inImage, outImage, outImage);
-    PS_IMAGE_CHECK_NULL(inImage, outImage);
     PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(inImage, outImage);
-    PS_CHECK_ALLOC_IMAGE(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
-    PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(outImage, outImage);
-    PS_CHECK_ALLOC_VECTOR(outPerm, inImage->numRows, inImage->type.type);
-    PS_VECTOR_CHECK_NULL(outPerm, outImage);
+
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage, psMatrixLUD_EXIT);
+    PS_VECTOR_CHECK_NULL_GENERAL(outPerm, psMatrixLUD_EXIT);
+
     PS_CHECK_DIMEN_AND_TYPE(outPerm, PS_DIMEN_VECTOR, outImage);
+
+    psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
+    psVectorRecycle(outPerm, inImage->numRows, inImage->type.type);
 
     // Initialize data
@@ -179,6 +150,5 @@
     PS_IMAGE_CHECK_NULL(inImage, outVector);
     PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outVector);
-    PS_CHECK_SIZE_IMAGE(inImage, outVector);
-    PS_CHECK_ALLOC_VECTOR(outVector, inImage->numRows, inImage->type.type);
+    PS_IMAGE_CHECK_EMPTY(inImage, outVector);
     PS_VECTOR_CHECK_NULL(outVector, outVector);
     PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_VECTOR, outVector);
@@ -188,4 +158,7 @@
     PS_CHECK_DIMEN_AND_TYPE(inPerm, PS_DIMEN_VECTOR, outVector);
 
+    psVectorRecycle(outVector, inImage->numRows, inImage->type.type);
+
+
     // Initialize data
     numRows = inImage->numRows;
@@ -226,15 +199,11 @@
 
     // Error checks
-    if (det == NULL) {
-        psError(__func__, "Invalid operation: determinant argument is NULL.");
-        return outImage;
-    }
+    PS_PTR_CHECK_NULL(det, outImage);
     PS_CHECK_POINTERS(inImage, outImage, outImage);
     PS_IMAGE_CHECK_NULL(inImage, outImage);
     PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(inImage, outImage);
-    PS_CHECK_ALLOC_IMAGE(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
-    PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(outImage, outImage);
+    PS_IMAGE_CHECK_EMPTY(inImage, outImage);
+
+    psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
 
     // Initialize data
@@ -282,5 +251,5 @@
     PS_IMAGE_CHECK_NULL(inImage, NULL);
     PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, NULL);
-    PS_CHECK_SIZE_IMAGE(inImage, NULL);
+    PS_IMAGE_CHECK_EMPTY(inImage, NULL);
 
     // Initialize data
@@ -325,11 +294,11 @@
     PS_IMAGE_CHECK_NULL(inImage1, outImage);
     PS_CHECK_DIMEN_AND_TYPE(inImage1, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(inImage1, outImage);
+    PS_IMAGE_CHECK_EMPTY(inImage1, outImage);
     PS_IMAGE_CHECK_NULL(inImage2, outImage);
     PS_CHECK_DIMEN_AND_TYPE(inImage2, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(inImage2, outImage);
-    PS_CHECK_ALLOC_IMAGE(outImage, inImage2->numCols, inImage2->numRows, inImage2->type.type);
+    PS_IMAGE_CHECK_EMPTY(inImage2, outImage);
     PS_CHECK_DIMEN_AND_TYPE(inImage1, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(outImage, outImage);
+
+    psImageRecycle(outImage, inImage2->numCols, inImage2->numRows, inImage2->type.type);
 
     // Initialize data
@@ -364,8 +333,7 @@
     PS_IMAGE_CHECK_NULL(inImage, outImage);
     PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(inImage, outImage);
-    PS_CHECK_ALLOC_IMAGE(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
-    PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(outImage, outImage);
+    PS_IMAGE_CHECK_EMPTY(inImage, outImage);
+
+    psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
 
     // Initialize data
@@ -403,8 +371,7 @@
     PS_IMAGE_CHECK_NULL(inImage, outImage);
     PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(inImage, outImage);
-    PS_CHECK_ALLOC_IMAGE(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
-    PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(outImage, outImage);
+    PS_IMAGE_CHECK_EMPTY(inImage, outImage);
+
+    psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
 
     // Initialize data
@@ -438,19 +405,25 @@
     psS32 size = 0;
 
-    // Error checks
-    PS_IMAGE_CHECK_NULL(inImage, outVector);
+    #define psMatrixToVector_EXIT { \
+                                    psFree(outVector); \
+                                    return NULL; \
+                                  }
+
+    // Error checks
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage, psMatrixToVector_EXIT);
     PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outVector);
-    PS_CHECK_SIZE_IMAGE(inImage, outVector);
+    PS_IMAGE_CHECK_EMPTY_GENERAL(inImage, psMatrixToVector_EXIT);
 
     if (inImage->numRows == 1) {
         // Create transposed row vector
-        PS_CHECK_ALLOC_VECTOR(outVector, inImage->numCols, inImage->type.type);
+        psVectorRecycle(outVector, inImage->numCols, inImage->type.type);
         outVector->type.dimen = PS_DIMEN_TRANSV;
     } else if (inImage->numCols == 1) {
         // Create non-transposed column vector
-        PS_CHECK_ALLOC_VECTOR(outVector, inImage->numRows, inImage->type.type);
+        psVectorRecycle(outVector, inImage->numRows, inImage->type.type);
     } else {
-        psError(__func__, "Image does not have dim with 1 col or 1 row: (%d x %d).", inImage->numRows,
-                inImage->numCols);
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                "Image does not have dim with 1 col or 1 row: (%d x %d).",
+                inImage->numRows, inImage->numCols);
         return outVector;
     }
@@ -467,5 +440,7 @@
 
         if (outVector->n != inImage->numRows) {
-            psError(__func__, "Image and vector sizes differ: (%d vs %d).", inImage->numRows, outVector->n);
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    "Image and vector sizes differ: (%d vs %d).",
+                    inImage->numRows, outVector->n);
             return outVector;
         }
@@ -481,5 +456,7 @@
 
         if (outVector->n != inImage->numCols) {
-            psError(__func__, "Image and vector sizes differ: (%d vs %d).", inImage->numCols, outVector->n);
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    "Image and vector sizes differ: (%d vs %d).",
+                    inImage->numCols, outVector->n);
             return outVector;
         }
@@ -502,12 +479,16 @@
     if (inVector->type.dimen == PS_DIMEN_VECTOR) {
         PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_VECTOR, outImage);
-        PS_CHECK_SIZE_VECTOR(inVector, outImage);
-        PS_CHECK_ALLOC_IMAGE(outImage, 1, inVector->n, PS_TYPE_F64)
+        PS_VECTOR_CHECK_EMPTY(inVector, outImage);
+        psImageRecycle(outImage, 1, inVector->n, PS_TYPE_F64);
         // More checks for PS_DIMEN_VECTOR
         if (outImage->numCols > 1) {
-            psError(__func__, "Image has more than 1 column: numCols = %d.", outImage->numCols);
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    "Image has more than 1 column: numCols = %d.",
+                    outImage->numCols);
             return outImage;
         } else if (outImage->numRows != inVector->n) {
-            psError(__func__, "Image and vector sizes differ: (%d vs %d).", outImage->numRows, inVector->n);
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    "Image and vector sizes differ: (%d vs %d).",
+                    outImage->numRows, inVector->n);
             return outImage;
         }
@@ -517,12 +498,16 @@
     } else if (inVector->type.dimen == PS_DIMEN_TRANSV) {
         PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_TRANSV, outImage);
-        PS_CHECK_SIZE_VECTOR(inVector, outImage);
-        PS_CHECK_ALLOC_IMAGE(outImage, inVector->n, 1, PS_TYPE_F64)
+        PS_VECTOR_CHECK_EMPTY(inVector, outImage);
+        psImageRecycle(outImage, inVector->n, 1, PS_TYPE_F64);
         // More checks for PS_DIMEN_TRANSV
         if (outImage->numRows > 1) {
-            psError(__func__, "Image has more than 1 row: numRows = %d.", outImage->numRows);
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    "Image has more than 1 row: numRows = %d.",
+                    outImage->numRows);
             return outImage;
         } else if (outImage->numCols != inVector->n) {
-            psError(__func__, "Image and vector sizes differ: (%d vs %d).", outImage->numCols, inVector->n);
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    "Image and vector sizes differ: (%d vs %d).",
+                    outImage->numCols, inVector->n);
             return outImage;
         }
Index: /trunk/psLib/src/dataManip/psMatrixVectorArithmetic.c
===================================================================
--- /trunk/psLib/src/dataManip/psMatrixVectorArithmetic.c	(revision 2272)
+++ /trunk/psLib/src/dataManip/psMatrixVectorArithmetic.c	(revision 2273)
@@ -29,6 +29,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:59 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -48,4 +48,6 @@
 #include "psScalar.h"
 #include "psLogMsg.h"
+#include "psConstants.h"
+#include "psDataManipErrors.h"
 
 /*****************************************************************************
@@ -58,19 +60,4 @@
 // Conversion for radians to degrees
 #define R2D 57.29577950924861   /* 180.0/PI */
-
-/* IEEE Standards on floating-point makes this function pointless, really.
-// Division with NAN checking
-static complex double psNanDiv(complex double a, complex double b)
-{
-    complex double out = 0 + 0i;
- 
-    out = a / b;
-    if (isnan(creal(out)) || isnan(cimag(out))) {
-        psError(__func__, ": Divide by zero");
-    }
- 
-    return out;
-}
-*/
 
 // Binary SCALAR_XXXX operations
@@ -142,7 +129,7 @@
 #define VECTOR_VECTOR(OUT,IN1,OP,IN2,TYPE)                                                                   \
 {                                                                                                            \
-    psS32 i = 0;                                                                                               \
-    psS32 n1 = 0;                                                                                              \
-    psS32 n2 = 0;                                                                                              \
+    psS32 i = 0;                                                                                             \
+    psS32 n1 = 0;                                                                                            \
+    psS32 n2 = 0;                                                                                            \
     ps##TYPE *o = NULL;                                                                                      \
     ps##TYPE *i1 = NULL;                                                                                     \
@@ -151,5 +138,7 @@
     n2  = ((psVector* )IN2)->n;                                                                              \
     if(n1 != n2) {                                                                                           \
-        psError(__func__, ": Inconsistent element count: %d vs %d", n1, n2);                                 \
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true,                                                             \
+                PS_ERRORTEXT_psMatrix_COUNT_DIFFERS,                                                         \
+                n1, n2);                                                                                     \
         if (OUT != IN1 && OUT != IN2) {                                                                      \
             psFree(OUT);                                                                                     \
@@ -167,9 +156,9 @@
 #define VECTOR_IMAGE(OUT,IN1,OP,IN2,TYPE)                                                                    \
 {                                                                                                            \
-    psS32 i = 0;                                                                                               \
-    psS32 j = 0;                                                                                               \
-    psS32 n1 = 0;                                                                                              \
-    psS32 numRows2 = 0;                                                                                        \
-    psS32 numCols2 = 0;                                                                                        \
+    psS32 i = 0;                                                                                             \
+    psS32 j = 0;                                                                                             \
+    psS32 n1 = 0;                                                                                            \
+    psS32 numRows2 = 0;                                                                                      \
+    psS32 numCols2 = 0;                                                                                      \
     psDimen dim1 = 0;                                                                                        \
     ps##TYPE *o = NULL;                                                                                      \
@@ -181,7 +170,9 @@
     numCols2 = ((psImage* )IN2)->numCols;                                                                    \
     \
-    if(dim1 == PS_DIMEN_VECTOR) { /* Regular vectors */                                                      \
+    if(dim1 == PS_DIMEN_VECTOR) { /* Regular vectors */                                             \
         if(n1!=numRows2) {                                                                                   \
-            psError(__func__, ": Inconsistent element count: %d vs %d", n1, numRows2);                       \
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,                                                         \
+                    PS_ERRORTEXT_psMatrix_COUNT_DIFFERS,                                                           \
+                    n1, numRows2);                                                                           \
             if (OUT != IN1 && OUT != IN2) {                                                                  \
                 psFree(OUT);                                                                                 \
@@ -200,5 +191,7 @@
     } else {  /* Transposed vectors */                                                                       \
         if(n1!=numCols2) {                                                                                   \
-            psError(__func__, ": Inconsistent element count: %d vs %d", n1, numCols2);                       \
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,                                                 \
+                    PS_ERRORTEXT_psMatrix_COUNT_DIFFERS,                                                     \
+                    n1, numCols2);                       \
             if (OUT != IN1 && OUT != IN2) {                                                                  \
                 psFree(OUT);                                                                                 \
@@ -256,7 +249,9 @@
     numCols1 = ((psImage* )IN1)->numCols;                                                                    \
     \
-    if(dim2 == PS_DIMEN_VECTOR) { /* Regular vectors */                                                      \
+    if(dim2 == PS_DIMEN_VECTOR) { /* Regular vectors */                                             \
         if(n2!=numRows1) {                                                                                   \
-            psError(__func__, ": Inconsistent element count: %d vs %d", n2, numRows1);                       \
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,                                                         \
+                    PS_ERRORTEXT_psMatrix_COUNT_DIFFERS,                                                     \
+                    n2, numRows1);                                                                           \
             if (OUT != IN1 && OUT != IN2) {                                                                  \
                 psFree(OUT);                                                                                 \
@@ -275,5 +270,7 @@
     } else {  /* Transposed vectors */                                                                       \
         if(n2!=numCols1) {                                                                                   \
-            psError(__func__, ": Inconsistent element count: %d vs %d", n2, numCols1);                       \
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,                                                         \
+                    PS_ERRORTEXT_psMatrix_COUNT_DIFFERS,                                                     \
+                    n2, numCols1);                                                                           \
             if (OUT != IN1) {                                                                                \
                 psFree(OUT);                                                                                 \
@@ -309,6 +306,7 @@
     numCols2 = ((psImage* )IN2)->numCols;                                                                    \
     if(numRows1!=numRows2 || numCols1!=numCols2) {                                                           \
-        psError(__func__, ": Inconsistent element count: numRows: %d vs %d numCols: %d vs %d", numRows1,     \
-                numRows2, numCols1, numCols2);                                                               \
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true,                                                             \
+                PS_ERRORTEXT_psMatrix_IMAGE_SIZE_DIFFERS,                                                     \
+                numCols1, numRows1, numCols2, numRows2);                                                     \
         if (OUT != IN1 && OUT != IN2) {                                                                      \
             psFree(OUT);                                                                                     \
@@ -366,5 +364,9 @@
     break;                                                                                                   \
 default:                                                                                                     \
-    psError(__func__, ": Invalid PS_TYPE: %d", IN1->type);                                                   \
+    /* char* strType; \
+    PS_TYPE_NAME(strType,IN1->type);                                                                         \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true,                                                                 \
+            PS_ERRORTEXT_psMatrix_TYPE_MISMATCH,                                                             \
+            strType);  */                                                                                      \
     if (OUT != IN1 && OUT != IN2) {                                                                          \
         psFree(OUT);                                                                                         \
@@ -391,5 +393,6 @@
 } else if(!strncmp(OP, "min", 3)) {                                                                          \
     if(PS_IS_PSELEMTYPE_COMPLEX(IN1->type)) {                                                                \
-        psError(__func__, ": Minimum operation not supported for complex numbers");                          \
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,                                                            \
+                PS_ERRORTEXT_psMatrix_MIN_COMPLEX_SUPPORT);                                                  \
         if (OUT != IN1 && OUT != IN2) {                                                                      \
             psFree(OUT);                                                                                     \
@@ -401,5 +404,6 @@
 } else if(!strncmp(OP, "max", 3)) {                                                                          \
     if(PS_IS_PSELEMTYPE_COMPLEX(IN1->type)) {                                                                \
-        psError(__func__, ": Maximum operation not supported for complex numbers");                          \
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,                                                            \
+                PS_ERRORTEXT_psMatrix_MAX_COMPLEX_SUPPORT);                                                  \
         if (OUT != IN1 && OUT != IN2) {                                                                      \
             psFree(OUT);                                                                                     \
@@ -410,5 +414,7 @@
     }                                                                                                        \
 } else {                                                                                                     \
-    psError(__func__, ": Invalid operation: %s", OP);                                                        \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true,                                                                \
+            PS_ERRORTEXT_psMatrix_OPERATION_UNSUPPORTED,                                                     \
+            OP);                                                                                             \
     if (OUT != IN1 && OUT != IN2) {                                                                          \
         psFree(OUT);                                                                                         \
@@ -419,67 +425,38 @@
 psPtr psBinaryOp(psPtr out, psPtr in1, char *op, psPtr in2)
 {
-    psDimen dim1 = 0;
-    psDimen dim2 = 0;
-    psElemType elType1 = 0;
-    psElemType elType2 = 0;
-    psType* psType1 = NULL;
-    psType* psType2 = NULL;
-
-    psType1 = (psType* ) in1;
-    if (psType1 == NULL) {
-        psError(__func__, ": Line %d - Null in1 argument", __LINE__);
-        if (out != in1 && out != in2) {
-            psFree(out);
-        }
-        return NULL;
-    }
-
-    psType2 = (psType* ) in2;
-    if (psType2 == NULL) {
-        psError(__func__, ": Line %d - Null in2 argument", __LINE__);
-        if (out != in1 && out != in2) {
-            psFree(out);
-        }
-        return NULL;
-    }
-
-    if (op == NULL) {
-        psError(__func__, ": Line %d - Null op argument", __LINE__);
-        if (out != in1 && out != in2) {
-            psFree(out);
-        }
-        return NULL;
-    }
-
-    dim1 = psType1->dimen;
-    dim2 = psType2->dimen;
-    elType1 = psType1->type;
-    elType2 = psType2->type;
-
-    if (elType1 != elType2) {
-        psError(__func__, ": Line %d - Element types for arguments inconsistent: (%d, %d)", __LINE__,
-                elType1, elType2);
-        if (out != in1 && out != in2) {
-            psFree(out);
-        }
-        return NULL;
-    }
-
-    if (dim1 == PS_DIMEN_OTHER || dim2 == PS_DIMEN_OTHER) {
-        psError(__func__, ": Line %d - PS_DIMEN_OTHER not allowed for arguments: (%d, %d)", __LINE__,
-                dim1, dim2);
-        if (out != in1 && out != in2) {
-            psFree(out);
-        }
-        return NULL;
-    }
+
+    psVector* input1 = (psVector* ) in1;
+    psVector* input2 = (psVector* ) in2;
+
+    #define psBinaryOp_EXIT { \
+                              if (out != in1 && out != in2) { \
+                              psFree(out); \
+                              } \
+                              return NULL; \
+                            }
+
+    PS_PTR_CHECK_NULL_GENERAL(input1, psBinaryOp_EXIT);
+    PS_PTR_CHECK_NULL_GENERAL(input2, psBinaryOp_EXIT);
+    PS_PTR_CHECK_NULL_GENERAL(op, psBinaryOp_EXIT);
+
+    PS_PTR_CHECK_TYPE_EQUAL_GENERAL(input1,input2, psBinaryOp_EXIT);
+
+    PS_PTR_CHECK_DIMEN_GENERAL(input1, PS_DIMEN_OTHER, psBinaryOp_EXIT);
+    PS_PTR_CHECK_DIMEN_GENERAL(input2, PS_DIMEN_OTHER, psBinaryOp_EXIT);
+
+    psType* psType1 = (psType*)in1;
+    psType* psType2 = (psType*)in2;
+    psDimen dim1 = psType1->dimen;
+    psDimen dim2 = psType2->dimen;
+    psElemType elType1 = psType1->type;
+    psElemType elType2 = psType2->type;
 
     if (dim1 == PS_DIMEN_VECTOR || dim1 == PS_DIMEN_TRANSV) {
         if (((psVector* ) in1)->n == 0) {
-            psLogMsg(__func__, PS_LOG_WARN, ": Line %d - Vector contains zero elements");
+            psLogMsg(__func__, PS_LOG_WARN, "Vector contains zero elements");
         }
     } else if (dim1 == PS_DIMEN_IMAGE) {
         if (((psImage* ) in1)->numCols == 0 || ((psImage* ) in1)->numRows == 0) {
-            psLogMsg(__func__, PS_LOG_WARN, ": Line %d - Image contains zero length row or cols");
+            psLogMsg(__func__, PS_LOG_WARN, "Image contains zero length row or cols");
         }
     }
@@ -487,9 +464,9 @@
     if (dim2 == PS_DIMEN_VECTOR || dim2 == PS_DIMEN_TRANSV) {
         if (((psVector* ) in2)->n == 0) {
-            psLogMsg(__func__, PS_LOG_WARN, ": Line %d - Vector contains zero elements");
+            psLogMsg(__func__, PS_LOG_WARN, "Vector contains zero elements");
         }
     } else if (dim2 == PS_DIMEN_IMAGE) {
         if (((psImage* ) in2)->numCols == 0 || ((psImage* ) in2)->numRows == 0) {
-            psLogMsg(__func__, PS_LOG_WARN, ": Line %d - Image contains zero length row or cols");
+            psLogMsg(__func__, PS_LOG_WARN, "Image contains zero length row or cols");
         }
     }
@@ -513,5 +490,6 @@
             out = psVectorRecycle(out,((psVector*)in2)->n,elType1);
             if (out == NULL) {
-                psError(__func__, "Couldn't create a proper output psVector.");
+                psError(PS_ERR_UNKNOWN, false,
+                        PS_ERRORTEXT_psMatrix_OUTPUT_VECTOR_NOT_CREATED);
                 return NULL;
             }
@@ -520,10 +498,14 @@
             out = psImageRecycle(out, ((psImage* ) in2)->numCols, ((psImage* ) in2)->numRows,elType1);
             if (out == NULL) {
-                psError(__func__, "Couldn't create a proper output psImage.");
+                psError(PS_ERR_UNKNOWN, false,
+                        PS_ERRORTEXT_psMatrix_OUTPUT_IMAGE_NOT_CREATED);
                 return NULL;
             }
             BINARY_OP(SCALAR, IMAGE, out, psType1, op, psType2);        // scalar op image
         } else {
-            psError(__func__, ": Line %d - Invalid dimensionality for in2 arg: %d", __LINE__, dim2);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psMatrix_DIMEN_INVALID,
+                    "in2",dim2);
+            psBinaryOp_EXIT;
         }
     } else if (dim1 == PS_DIMEN_VECTOR || dim1 == PS_DIMEN_TRANSV) {
@@ -531,5 +513,6 @@
             out = psVectorRecycle(out,((psVector*)in1)->n,elType1);
             if (out == NULL) {
-                psError(__func__, "Couldn't create a proper output psVector.");
+                psError(PS_ERR_UNKNOWN, false,
+                        PS_ERRORTEXT_psMatrix_OUTPUT_VECTOR_NOT_CREATED);
                 return NULL;
             }
@@ -538,5 +521,6 @@
             out = psVectorRecycle(out,((psVector*)in2)->n,elType2);
             if (out == NULL) {
-                psError(__func__, "Couldn't create a proper output psVector.");
+                psError(PS_ERR_UNKNOWN, false,
+                        PS_ERRORTEXT_psMatrix_OUTPUT_VECTOR_NOT_CREATED);
                 return NULL;
             }
@@ -545,15 +529,20 @@
             out = psImageRecycle(out, ((psImage* ) in2)->numCols, ((psImage* ) in2)->numRows, elType2);
             if (out == NULL) {
-                psError(__func__, "Couldn't create a proper output psImage.");
+                psError(PS_ERR_UNKNOWN, false,
+                        PS_ERRORTEXT_psMatrix_OUTPUT_IMAGE_NOT_CREATED);
                 return NULL;
             }
             BINARY_OP(VECTOR, IMAGE, out, psType1, op, psType2);        // vector op image
         } else {
-            psError(__func__, ": Line %d - Invalid dimensionality for in2 arg: %d", __LINE__, dim2);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psMatrix_DIMEN_INVALID,
+                    "in2",dim2);
+            psBinaryOp_EXIT;
         }
     } else if (dim1 == PS_DIMEN_IMAGE) {
         out = psImageRecycle(out, ((psImage*)in1)->numCols, ((psImage*)in1)->numRows, elType1);
         if (out == NULL) {
-            psError(__func__, "Couldn't create a proper output psImage.");
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psMatrix_OUTPUT_IMAGE_NOT_CREATED);
             return NULL;
         }
@@ -565,16 +554,14 @@
             BINARY_OP(IMAGE, IMAGE, out, psType1, op, psType2); // image op image
         } else {
-            if (out != in1 && out != in2) {
-                psFree(out);
-            }
-            psError(__func__, ": Line %d - Invalid dimensionality for in2 arg: %d", __LINE__, dim2);
-            return NULL;
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psMatrix_DIMEN_INVALID,
+                    "in2",dim2);
+            psBinaryOp_EXIT;
         }
     } else {
-        if (out != in1 && out != in2) {
-            psFree(out);
-        }
-        psError(__func__, ": Line %d - Invalid dimensionality for in1 arg: %d", __LINE__, dim1);
-        return NULL;
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psMatrix_DIMEN_INVALID,
+                "in1",dim1);
+        psBinaryOp_EXIT;
     }
 
@@ -605,7 +592,7 @@
 #define VECTOR(OUT,IN,OP,TYPE)                                                                               \
 {                                                                                                            \
-    psS32 i = 0;                                                                                               \
-    psS32 nIn = 0;                                                                                             \
-    psS32 nOut = 0;                                                                                            \
+    psS32 i = 0;                                                                                             \
+    psS32 nIn = 0;                                                                                           \
+    psS32 nOut = 0;                                                                                          \
     ps##TYPE *o = NULL;                                                                                      \
     ps##TYPE *i1 = NULL;                                                                                     \
@@ -613,5 +600,7 @@
     nOut = ((psVector* )OUT)->n;                                                                             \
     if(nIn != nOut) {                                                                                        \
-        psError(__func__, ": Inconsistent element count: %d vs %d", nIn, nOut);                              \
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true,                                                             \
+                PS_ERRORTEXT_psMatrix_COUNT_DIFFERS,                                                         \
+                nIn, nOut);                                                                                  \
         if (OUT != IN) {                                                                                     \
             psFree(OUT);                                                                                     \
@@ -629,10 +618,10 @@
 #define IMAGE(OUT,IN,OP,TYPE)                                                                                \
 {                                                                                                            \
-    psS32 i = 0;                                                                                               \
-    psS32 j = 0;                                                                                               \
-    psS32 numRowsIn = 0;                                                                                       \
-    psS32 numColsIn = 0;                                                                                       \
-    psS32 numRowsOut = 0;                                                                                      \
-    psS32 numColsOut = 0;                                                                                      \
+    psS32 i = 0;                                                                                             \
+    psS32 j = 0;                                                                                             \
+    psS32 numRowsIn = 0;                                                                                     \
+    psS32 numColsIn = 0;                                                                                     \
+    psS32 numRowsOut = 0;                                                                                    \
+    psS32 numColsOut = 0;                                                                                    \
     ps##TYPE *o = NULL;                                                                                      \
     ps##TYPE *i1 = NULL;                                                                                     \
@@ -642,6 +631,7 @@
     numColsOut = ((psImage* )OUT)->numCols;                                                                  \
     if(numRowsIn!=numRowsOut || numColsIn!=numColsOut) {                                                     \
-        psError(__func__, ": Inconsistent element count: numRows: %d vs %d numCols: %d vs %d", numRowsIn,    \
-                numRowsOut, numColsIn, numColsOut);                                                          \
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true,                                                             \
+                PS_ERRORTEXT_psMatrix_IMAGE_SIZE_DIFFERS,                                                    \
+                numColsIn, numRowsIn, numColsOut, numRowsOut);                                               \
         if (OUT != IN) {                                                                                     \
             psFree(OUT);                                                                                     \
@@ -697,10 +687,15 @@
     DIM(OUT,IN,OP,C32);                                                                                      \
     break;                                                                                                   \
-default:                                                                                                     \
-    psError(__func__, ": Invalid PS_TYPE: %d", IN->type);                                                    \
-    if (OUT != IN) {                                                                                         \
-        psFree(OUT);                                                                                         \
-    }                                                                                                        \
-    return NULL;                                                                                             \
+default: {                                                                                                     \
+        char* strType;                                                                                           \
+        PS_TYPE_NAME(strType, IN->type);                                                                         \
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,                                                                 \
+                PS_ERRORTEXT_psMatrix_TYPE_MISMATCH,                                                             \
+                strType);                                                                                        \
+        if (OUT != IN) {                                                                                         \
+            psFree(OUT);                                                                                         \
+        }                                                                                                        \
+        return NULL;                                                                                             \
+    } \
 }
 
@@ -815,32 +810,28 @@
     }                                                                                                        \
 } else {                                                                                                     \
-    psError(__func__, ": Invalid operation: %s", OP);                                                        \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true,                                                                \
+            PS_ERRORTEXT_psMatrix_OPERATION_UNSUPPORTED,                                                     \
+            OP);                                                                                             \
 }
 
 psPtr psUnaryOp(psPtr out, psPtr in, char *op)
 {
-    psDimen dimIn = 0;
-    psElemType elTypeIn = 0;
-    psType* psTypeIn = NULL;
-
-    psTypeIn = (psType* ) in;
-    if (psTypeIn == NULL) {
-        psError(__func__, ": Line %d - Null in argument", __LINE__);
-        if (out != in) {
-            psFree(out);
-        }
-        return NULL;
-    }
-
-    if (op == NULL) {
-        psError(__func__, ": Line %d - Null op argument", __LINE__);
-        if (out != in) {
-            psFree(out);
-        }
-        return NULL;
-    }
-
-    dimIn = psTypeIn->dimen;
-    elTypeIn = psTypeIn->type;
+    #define psUnaryOp_EXIT { \
+                             if (out != in) { \
+                             psFree(out); \
+                             } \
+                             if(psTypeIn->dimen==PS_DIMEN_SCALAR && in!=out) { \
+                             psFree(in); \
+                             } \
+                             return NULL; \
+                           }
+
+    psType* psTypeIn = (psType* ) in;
+
+    PS_PTR_CHECK_NULL_GENERAL(in, psUnaryOp_EXIT);
+    PS_PTR_CHECK_NULL_GENERAL(op, psUnaryOp_EXIT);
+
+    psDimen dimIn = psTypeIn->dimen;
+    psElemType elTypeIn = psTypeIn->type;
 
     switch (dimIn) {
@@ -857,9 +848,7 @@
     case PS_DIMEN_TRANSV:
         if (((psVector*)in)->n == 0) {
-            if (out != in) {
-                psFree(out);
-            }
-            psError(__func__, ": Line %d - Vector contains zero elements");
-            return NULL;
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    PS_ERRORTEXT_psMatrix_VECTOR_EMPTY);
+            psUnaryOp_EXIT;
         }
 
@@ -868,6 +857,7 @@
                               elTypeIn);
         if (out == NULL) {
-            psError(__func__, "Couldn't create a proper output psVector.");
-            return NULL;
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psMatrix_OUTPUT_VECTOR_NOT_CREATED);
+            psUnaryOp_EXIT;
         }
 
@@ -876,9 +866,7 @@
     case PS_DIMEN_IMAGE:
         if (((psImage* ) in)->numCols == 0 || ((psImage* ) in)->numRows == 0) {
-            if (out != in) {
-                psFree(out);
-            }
-            psError(__func__, ": Line %d - Image contains zero length row or cols");
-            return NULL;
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    PS_ERRORTEXT_psMatrix_IMAGE_EMPTY);
+            psUnaryOp_EXIT;
         }
 
@@ -888,6 +876,7 @@
                              elTypeIn);
         if (out == NULL) {
-            psError(__func__, "Couldn't create a proper output psImage.");
-            return NULL;
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psMatrix_OUTPUT_IMAGE_NOT_CREATED);
+            psUnaryOp_EXIT;
         }
 
@@ -898,6 +887,8 @@
             psFree(out);
         }
-        psError(__func__, ": Line %d - Invalid dimensionality for in arg: %d", __LINE__, dimIn);
-        return NULL;
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                PS_ERRORTEXT_psMatrix_DIMEN_INVALID,
+                "in", dimIn);
+        psUnaryOp_EXIT;
     }
 
Index: /trunk/psLib/src/dataManip/psMinimize.c
===================================================================
--- /trunk/psLib/src/dataManip/psMinimize.c	(revision 2272)
+++ /trunk/psLib/src/dataManip/psMinimize.c	(revision 2273)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-03 03:30:30 $
+ *  @version $Revision: 1.85 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:59 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -291,5 +291,6 @@
 
     if (y32->n != (1 + mySpline->n)) {
-        psError(__func__, "data size / spline size mismatch (%d %d)\n",
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                "data size / spline size mismatch (%d %d)\n",
                 y32->n, mySpline->n);
         return(NULL);
@@ -318,5 +319,6 @@
     // Check if these are cubic splines (n==4).  If not, psError.
     if (4 != (mySpline->spline[0])->n) {
-        psError(__func__, "Don't know how to generate %d-order splines.",
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                "Don't know how to generate %d-order splines.",
                 (mySpline->spline[0])->n-1);
         return(NULL);
@@ -952,5 +954,5 @@
         PS_VECTOR_GEN_X_INDEX_STATIC_F64(x64Static, y->n);
         if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-            p_psNormalizeVectorRange(x64Static, -1.0, 1.0);
+            psNormalizeVectorRange(x64Static, -1.0, 1.0);
         }
         x64 = x64Static;
@@ -968,5 +970,6 @@
         tmpPoly = VectorFitPolynomial1DOrd(myPoly, x64, y64, yErr64);
     } else {
-        psError(__func__, "unknown polynomial type.\n");
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "unknown polynomial type.\n");
         return(NULL);
     }
@@ -1365,5 +1368,6 @@
     bracket = p_psDetermineBracket2(params, line, paramMask, coords, func);
     if (bracket == NULL) {
-        psError(__func__, "(1) Could not bracket minimum.");
+        psError(PS_ERR_UNKNOWN, false,
+                "Could not bracket minimum.");
         return(NAN);
     }
@@ -1552,5 +1556,6 @@
                                   func);
                 if (isnan(mul)) {
-                    psError(__func__, "Could not perform line minimization (1).\n");
+                    psError(PS_ERR_UNKNOWN, false,
+                            "Could not perform line minimization");
                     psFree(v);
                     return(false);
@@ -1592,5 +1597,6 @@
         mul = p_psLineMin(&dummyMin, params, u, myParamMask, coords, func);
         if (isnan(mul)) {
-            psError(__func__, "Could not perform line minimization. (2)\n");
+            psError(PS_ERR_UNKNOWN, false,
+                    "Could not perform line minimization.");
             psFree(v);
             return(false);
Index: /trunk/psLib/src/dataManip/psStats.c
===================================================================
--- /trunk/psLib/src/dataManip/psStats.c	(revision 2272)
+++ /trunk/psLib/src/dataManip/psStats.c	(revision 2273)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-03 03:30:30 $
+ *  @version $Revision: 1.85 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:59 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -34,4 +34,6 @@
 #include "psFunctions.h"
 #include "psConstants.h"
+
+#include "psDataManipErrors.h"
 
 /*****************************************************************************/
@@ -735,13 +737,9 @@
 
     // Ensure that stats->clipIter is within the proper range.
-    if (!((PS_CLIPPED_NUM_ITER_LB <= stats->clipIter) && (stats->clipIter <= PS_CLIPPED_NUM_ITER_UB))) {
-        psError(__func__, "Unallowed value for clipIter (%d).\n", stats->clipIter);
-        return(-1);
-    }
+    PS_INT_CHECK_RANGE(stats->clipIter,PS_CLIPPED_NUM_ITER_LB,PS_CLIPPED_NUM_ITER_UB,-1);
+
     // Ensure that stats->clipSigma is within the proper range.
-    if (!((PS_CLIPPED_SIGMA_LB <= stats->clipSigma) && (stats->clipSigma <= PS_CLIPPED_SIGMA_UB))) {
-        psError(__func__, "Unallowed value for clipSigma (%f).\n", stats->clipSigma);
-        return(-1);
-    }
+    PS_INT_CHECK_RANGE(stats->clipSigma,PS_CLIPPED_SIGMA_LB,PS_CLIPPED_SIGMA_UB,-1);
+
     // We allocate a temporary mask vector since during the iterative
     // steps that follow, we will be masking off additional data points.
@@ -869,5 +867,9 @@
         p_psNormalizeVectorRangeF64(myData, low, high);
     } else {
-        psError(__func__, "Unalowable data type.\n");
+        char* strType;
+        PS_TYPE_NAME(strType,myData->type.type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psStats_NOT_F32_F64,
+                strType);
     }
 }
@@ -954,6 +956,7 @@
         // Ensure that yVal is within the range of the bins we are using.
         if (!((y->data.F64[0] <= yVal) && (yVal <= y->data.F64[2]))) {
-            printf("((%f), %f, %f)\n", yVal, y->data.F64[0], y->data.F64[2]);
-            psError(__func__, "yVal not within y-range\n");
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psStats_YVAL_OUT_OF_RANGE,
+                    (double)yVal,y->data.F64[2],y->data.F64[0]);
         }
         yErr->data.F64[0] = 1.0;
@@ -1113,9 +1116,11 @@
 
     if ((LQBinNum < 0) || (UQBinNum < 0)) {
-        psError(__func__, "Could not determine the robust lower/upper quartile bin numbers.");
+        psError(PS_ERR_UNKNOWN, true,
+                PS_ERRORTEXT_psStats_ROBUST_QUARTILE_BINS_FAILED);
         return(1);
     }
     if (medianBinNum < 0) {
-        psError(__func__, "Could not determine the robust lower/upper quartile bin numbers.");
+        psError(PS_ERR_UNKNOWN, true,
+                PS_ERRORTEXT_psStats_ROBUST_QUARTILE_BINS_FAILED);
         return(1);
     }
@@ -1174,5 +1179,5 @@
     psVector *y = psVectorAlloc(robustHistogramVector->n, PS_TYPE_F32);
 
-    p_psNormalizeVectorRange(robustHistogramVector, 0.0, 1.0);
+    psNormalizeVectorRange(robustHistogramVector, 0.0, 1.0);
     for (i=0;i<robustHistogramVector->n;i++) {
         myCoords->data[i] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32);
@@ -1536,5 +1541,9 @@
         // do nothing
     } else {
-        psError(__func__, "unsupported vector type 0x%x\n", in->type.type);
+        char* strType;
+        PS_TYPE_NAME(strType,in->type.type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psStats_VECTOR_TYPE_UNSUPPORTED,
+                strType);
     }
     return (tmp);
@@ -1603,5 +1612,6 @@
             (stats->options & PS_STAT_ROBUST_STDEV) || (stats->options & PS_STAT_ROBUST_QUARTILE)) {
         if (0 != p_psVectorRobustStats(inF32, mask, maskVal, stats)) {
-            psError(__func__, "p_psVectorRobustStats() failed.\n");
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psStats_STATS_FAILED);
         }
     }
@@ -1609,5 +1619,6 @@
     if ((stats->options & PS_STAT_CLIPPED_MEAN) || (stats->options & PS_STAT_CLIPPED_STDEV)) {
         if (0 != p_psVectorClippedStats(inF32, mask, maskVal, stats)) {
-            psError(__func__, "p_psVectorClippedStats() failed.\n");
+            psError(PS_ERR_UNKNOWN, false,
+                    "Failed to calculate statistics for input psVector.");
         }
     }
Index: /trunk/psLib/src/dataManip/psVectorFFT.c
===================================================================
--- /trunk/psLib/src/dataManip/psVectorFFT.c	(revision 2272)
+++ /trunk/psLib/src/dataManip/psVectorFFT.c	(revision 2273)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:59 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -63,7 +63,6 @@
                                  (fftwf_complex *) out->data.C32, FFTW_BACKWARD, P_FFTW_PLAN_RIGOR);
     } else {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorFFT",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psVectorFFT_DIRECTION_NOTSET);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psVectorFFT_DIRECTION_NOTSET);
         psFree(out);
         return NULL;
@@ -72,7 +71,6 @@
     /* check if a plan exists now */
     if (plan == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorFFT",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVectorFFT_FFTW_PLAN_NULL);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVectorFFT_FFTW_PLAN_NULL);
         psFree(out);
         return NULL;
@@ -144,8 +142,7 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorReal",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVectorFFT_TYPE_UNSUPPORTED,
-                   typeStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVectorFFT_TYPE_UNSUPPORTED,
+                typeStr);
         psFree(out);
         return NULL;
@@ -204,8 +201,7 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorImaginary",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVectorFFT_TYPE_UNSUPPORTED,
-                   typeStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVectorFFT_TYPE_UNSUPPORTED,
+                typeStr);
         psFree(out);
         return NULL;
@@ -237,8 +233,7 @@
         PS_TYPE_NAME(typeStrReal,type);
         PS_TYPE_NAME(typeStrImag,imag->type.type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorComplex",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVectorFFT_REAL_IMAG_TYPE_MISMATCH,
-                   typeStrReal,typeStrImag);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVectorFFT_REAL_IMAG_TYPE_MISMATCH,
+                typeStrReal,typeStrImag);
         psFree(out);
         return NULL;
@@ -272,8 +267,7 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorComplex",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVectorFFT_NONREAL_NOTSUPPORTED,
-                   typeStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVectorFFT_NONREAL_NOTSUPPORTED,
+                typeStr);
         psFree(out);
         return NULL;
@@ -333,8 +327,7 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorConjugate",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED,
-                   typeStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED,
+                typeStr);
         psFree(out);
         return NULL;
@@ -414,13 +407,12 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorPowerSpectrum",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED,
-                   typeStr);
-        psFree(out);
-        return NULL;
-    }
-
-    return out;
-
-}
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED,
+                typeStr);
+        psFree(out);
+        return NULL;
+    }
+
+    return out;
+
+}
Index: /trunk/psLib/src/fft/psImageFFT.c
===================================================================
--- /trunk/psLib/src/fft/psImageFFT.c	(revision 2272)
+++ /trunk/psLib/src/fft/psImageFFT.c	(revision 2273)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -43,21 +43,18 @@
     if ( ((direction & PS_FFT_FORWARD) != 0) ) {
         if ((direction & PS_FFT_REVERSE) != 0) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT",
-                       PS_ERR_BAD_PARAMETER_VALUE, true,
-                       PS_ERRORTEXT_psImageFFT_FORWARD_REVERSE);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psImageFFT_FORWARD_REVERSE);
             psFree(out);
             return NULL;
         }
         if ((direction & PS_FFT_REAL_RESULT) != 0) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT",
-                       PS_ERR_BAD_PARAMETER_VALUE, true,
-                       PS_ERRORTEXT_psImageFFT_REAL_FORWARD_NOTSUPPORTED);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psImageFFT_REAL_FORWARD_NOTSUPPORTED);
             psFree(out);
             return NULL;
         }
     } else if ((direction & PS_FFT_REVERSE) == 0) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImageFFT_NO_DIRECTION_OPTION);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImageFFT_NO_DIRECTION_OPTION);
         psFree(out);
         return NULL;
@@ -86,7 +83,6 @@
     /* check if a plan exists now -- if not, it is a real problem at this point */
     if (plan == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImageFFT_FFTW_PLAN_NULL);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImageFFT_FFTW_PLAN_NULL);
         psFree(out);
         return NULL;
@@ -163,8 +159,7 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReal",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                   typeStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                typeStr);
 
         psFree(out);
@@ -226,8 +221,7 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageImaginary",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                   typeStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                typeStr);
         psFree(out);
         return NULL;
@@ -257,8 +251,7 @@
         PS_TYPE_NAME(typeStrReal,type);
         PS_TYPE_NAME(typeStrImag,imag->type.type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImageFFT_REAL_IMAG_TYPE_MISMATCH,
-                   typeStrReal,typeStrImag);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImageFFT_REAL_IMAG_TYPE_MISMATCH,
+                typeStrReal,typeStrImag);
         psFree(out);
         return NULL;
@@ -266,8 +259,7 @@
 
     if (imag->numCols != numCols || imag->numRows != numRows) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImageFFT_REAL_IMAG_SIZE_MISMATCH,
-                   numCols, numRows, imag->numCols, imag->numRows);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImageFFT_REAL_IMAG_SIZE_MISMATCH,
+                numCols, numRows, imag->numCols, imag->numRows);
         psFree(out);
         return NULL;
@@ -308,8 +300,7 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImageFFT_NONREAL_NOTSUPPORTED,
-                   typeStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImageFFT_NONREAL_NOTSUPPORTED,
+                typeStr);
         psFree(out);
         return NULL;
@@ -369,8 +360,7 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConjugate",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED,
-                   typeStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED,
+                typeStr);
         psFree(out);
         return NULL;
@@ -434,13 +424,12 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePowerSpectrum",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED,
-                   typeStr);
-        psFree(out);
-        return NULL;
-    }
-
-    return out;
-
-}
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED,
+                typeStr);
+        psFree(out);
+        return NULL;
+    }
+
+    return out;
+
+}
Index: /trunk/psLib/src/fft/psVectorFFT.c
===================================================================
--- /trunk/psLib/src/fft/psVectorFFT.c	(revision 2272)
+++ /trunk/psLib/src/fft/psVectorFFT.c	(revision 2273)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:59 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -63,7 +63,6 @@
                                  (fftwf_complex *) out->data.C32, FFTW_BACKWARD, P_FFTW_PLAN_RIGOR);
     } else {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorFFT",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psVectorFFT_DIRECTION_NOTSET);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psVectorFFT_DIRECTION_NOTSET);
         psFree(out);
         return NULL;
@@ -72,7 +71,6 @@
     /* check if a plan exists now */
     if (plan == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorFFT",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVectorFFT_FFTW_PLAN_NULL);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVectorFFT_FFTW_PLAN_NULL);
         psFree(out);
         return NULL;
@@ -144,8 +142,7 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorReal",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVectorFFT_TYPE_UNSUPPORTED,
-                   typeStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVectorFFT_TYPE_UNSUPPORTED,
+                typeStr);
         psFree(out);
         return NULL;
@@ -204,8 +201,7 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorImaginary",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVectorFFT_TYPE_UNSUPPORTED,
-                   typeStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVectorFFT_TYPE_UNSUPPORTED,
+                typeStr);
         psFree(out);
         return NULL;
@@ -237,8 +233,7 @@
         PS_TYPE_NAME(typeStrReal,type);
         PS_TYPE_NAME(typeStrImag,imag->type.type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorComplex",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVectorFFT_REAL_IMAG_TYPE_MISMATCH,
-                   typeStrReal,typeStrImag);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVectorFFT_REAL_IMAG_TYPE_MISMATCH,
+                typeStrReal,typeStrImag);
         psFree(out);
         return NULL;
@@ -272,8 +267,7 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorComplex",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVectorFFT_NONREAL_NOTSUPPORTED,
-                   typeStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVectorFFT_NONREAL_NOTSUPPORTED,
+                typeStr);
         psFree(out);
         return NULL;
@@ -333,8 +327,7 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorConjugate",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED,
-                   typeStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED,
+                typeStr);
         psFree(out);
         return NULL;
@@ -414,13 +407,12 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorPowerSpectrum",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED,
-                   typeStr);
-        psFree(out);
-        return NULL;
-    }
-
-    return out;
-
-}
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVectorFFT_NONCOMPLEX_NOTSUPPORTED,
+                typeStr);
+        psFree(out);
+        return NULL;
+    }
+
+    return out;
+
+}
Index: /trunk/psLib/src/image/psImage.c
===================================================================
--- /trunk/psLib/src/image/psImage.c	(revision 2272)
+++ /trunk/psLib/src/image/psImage.c	(revision 2273)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -40,8 +40,7 @@
 
     if (area < 1) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageAlloc",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImage_AREA_NEGATIVE,
-                   numRows, numCols);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImage_AREA_NEGATIVE,
+                numRows, numCols);
         return NULL;
     }
@@ -119,7 +118,6 @@
     if (old->type.dimen != PS_DIMEN_IMAGE) {
         psFree(old);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRecycle",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImage_NOT_AN_IMAGE);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImage_NOT_AN_IMAGE);
         return NULL;
     }
@@ -175,7 +173,6 @@
 
     if (input == NULL || input->data.V == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         psFree(output);
         return NULL;
@@ -183,7 +180,6 @@
 
     if (input == output) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_INPLACE_NOTSUPPORTED);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_INPLACE_NOTSUPPORTED);
         psFree(output);
         return NULL;
@@ -191,7 +187,6 @@
 
     if (input->type.dimen != PS_DIMEN_IMAGE) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImage_NOT_AN_IMAGE);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImage_NOT_AN_IMAGE);
         psFree(output);
         return NULL;
@@ -205,8 +200,7 @@
 
     if (inDatatype == PS_TYPE_PTR || type == PS_TYPE_PTR) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                   PS_TYPE_PTR_NAME);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                PS_TYPE_PTR_NAME);
         psFree(output);
         return NULL;
@@ -319,8 +313,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                       typeStr);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                    typeStr);
             psFree(output);
 
@@ -372,7 +365,6 @@
 
     if (input == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePixelInterpolate",
-                   PS_ERR_BAD_PARAMETER_NULL,true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL,true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         return unexposedValue;
     }
@@ -400,8 +392,7 @@
         break;                                                       \
     default:                                                         \
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePixelInterpolate",    \
-                   PS_ERR_BAD_PARAMETER_VALUE,true,                  \
-                   PS_ERRORTEXT_psImage_INTERPOLATE_METHOD_INVALID,  \
-                   mode);                                            \
+        psError(PS_ERR_BAD_PARAMETER_VALUE,true,                     \
+                PS_ERRORTEXT_psImage_INTERPOLATE_METHOD_INVALID,     \
+                mode);                                               \
     }                                                                \
     break
@@ -423,8 +414,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,input->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePixelInterpolate",
-                       PS_ERR_BAD_PARAMETER_TYPE,true,
-                       PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                       typeStr);
+            psError(PS_ERR_BAD_PARAMETER_TYPE,true,
+                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                    typeStr);
         }
     }
Index: /trunk/psLib/src/image/psImageConvolve.c
===================================================================
--- /trunk/psLib/src/image/psImageConvolve.c	(revision 2272)
+++ /trunk/psLib/src/image/psImageConvolve.c	(revision 2273)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -110,7 +110,6 @@
     // got non-NULL vectors?
     if (tShifts == NULL || xShifts == NULL || yShifts == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psKernelGenerate",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImageConvolve_SHIFT_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImageConvolve_SHIFT_NULL);
         return NULL;
     }
@@ -125,8 +124,7 @@
         PS_TYPE_NAME(typeYStr,yShifts->type.type);
         PS_TYPE_NAME(typeTStr,tShifts->type.type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psKernelGenerate",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImageConvolve_SHIFT_TYPE_MISMATCH,
-                   typeTStr, typeXStr, typeYStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImageConvolve_SHIFT_TYPE_MISMATCH,
+                typeTStr, typeXStr, typeYStr);
         return NULL;
     }
@@ -218,8 +216,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,xShifts->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psKernelGenerate",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                       typeStr);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                    typeStr);
         }
     }
@@ -236,7 +233,6 @@
 
     if (kernel == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImageConvolve_KERNEL_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImageConvolve_KERNEL_NULL);
         psFree(out);
         return NULL;
@@ -297,8 +293,7 @@
                 char* typeStr;
                 PS_TYPE_NAME(typeStr,in->type.type);
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve",
-                           PS_ERR_BAD_PARAMETER_TYPE, true,
-                           PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                           typeStr);
+                psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                        PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                        typeStr);
                 psFree(out);
                 return NULL;
@@ -317,9 +312,8 @@
         psS32 kCols = kernel->image->numCols;
         if (kRows >= numRows || kCols >= numCols) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve",
-                       PS_ERR_BAD_PARAMETER_SIZE, true,
-                       PS_ERRORTEXT_psImageConvolve_KERNEL_TOO_LARGE,
-                       kCols,kRows,
-                       numCols, numRows);
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    PS_ERRORTEXT_psImageConvolve_KERNEL_TOO_LARGE,
+                    kCols,kRows,
+                    numCols, numRows);
             psFree(out);
             return NULL;
@@ -376,7 +370,6 @@
         psImage* kernelFourier = psImageFFT(NULL, paddedKernel, PS_FFT_FORWARD);
         if (kernelFourier == NULL) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve",
-                       PS_ERR_UNKNOWN, false,
-                       PS_ERRORTEXT_psImageConvolve_KERNEL_FFT_FAILED);
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psImageConvolve_KERNEL_FFT_FAILED);
             psFree(out);
             return NULL;
@@ -385,7 +378,6 @@
         psImage* inFourier = psImageFFT(NULL, paddedImage, PS_FFT_FORWARD);
         if (inFourier == NULL) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve",
-                       PS_ERR_UNKNOWN, false,
-                       PS_ERRORTEXT_psImageConvolve_FFT_FAILED);
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psImageConvolve_FFT_FAILED);
             psFree(out);
             return NULL;
@@ -398,7 +390,6 @@
                                          PS_FFT_REVERSE);
         if (complexOut == NULL) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve",
-                       PS_ERR_UNKNOWN, false,
-                       PS_ERRORTEXT_psImageConvolve_FFT_FAILED);
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psImageConvolve_FFT_FAILED);
             psFree(out);
             return NULL;
Index: /trunk/psLib/src/image/psImageExtraction.c
===================================================================
--- /trunk/psLib/src/image/psImageExtraction.c	(revision 2272)
+++ /trunk/psLib/src/image/psImageExtraction.c	(revision 2273)
@@ -9,6 +9,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -35,14 +35,12 @@
 
     if (image == NULL || image->data.V == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSubset",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         return NULL;
     }
 
     if (image->type.dimen != PS_DIMEN_IMAGE) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSubset",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImage_NOT_AN_IMAGE);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImage_NOT_AN_IMAGE);
         return NULL;
     }
@@ -61,9 +59,8 @@
             col1 > image->numCols ||
             row1 > image->numRows ) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSubset",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID,
-                   col0, col1-1, row0, row1-1,
-                   image->numCols-1, image->numRows-1);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID,
+                col0, col1-1, row0, row1-1,
+                image->numCols-1, image->numRows-1);
         return NULL;
     }
@@ -152,23 +149,20 @@
     // section should be of the form '[col0:col1,row0:row1]'
     if (section == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSubsection",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_SUBSECTION_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_SUBSECTION_NULL);
         return NULL;
     }
 
     if (sscanf(section,"[%d:%d,%d:%d]",&col0,&col1,&row0,&row1) < 4) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSubsection",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_SUBSECTION_INVALID,
-                   section);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_SUBSECTION_INVALID,
+                section);
         return NULL;
     }
 
     if (col0 > col1 || row0 > row1) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSubsection",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImage_SUBSET_RANGE_MALFORMED,
-                   col0,col1,row0,row1);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImage_SUBSET_RANGE_MALFORMED,
+                col0,col1,row0,row1);
         return NULL;
     }
@@ -180,7 +174,6 @@
 {
     if (image == NULL || image->data.V == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageTrim",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         return NULL;
     }
@@ -209,9 +202,8 @@
             col0 >= col1 ||
             row0 >= row1 ) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageTrim",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID,
-                   col0, col1-1, row0, row1-1,
-                   image->numCols-1, image->numRows-1);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID,
+                col0, col1-1, row0, row1-1,
+                image->numCols-1, image->numRows-1);
         psFree(image);
         return NULL;
@@ -267,7 +259,6 @@
 
     if (in == NULL || in->data.V == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSlice",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         psFree(out);
         return NULL;
@@ -288,9 +279,8 @@
             col0 >= col1 ||
             row0 >= row1) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSlice",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID,
-                   col0, col1, row0, row1,
-                   in->numCols, in->numRows);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID,
+                col0, col1, row0, row1,
+                in->numCols, in->numRows);
         psFree(out);
         return NULL;
@@ -307,9 +297,8 @@
     if (mask != NULL) {
         if (inRows != mask->numRows || inCols != mask->numCols) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSlice",
-                       PS_ERR_BAD_PARAMETER_VALUE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_MASK_SIZE,
-                       mask->numCols,mask->numRows,
-                       inCols, inRows);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_MASK_SIZE,
+                    mask->numCols,mask->numRows,
+                    inCols, inRows);
             psFree(out);
             return NULL;
@@ -318,8 +307,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,mask->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSlice",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
-                       typeStr, PS_TYPE_MASK_NAME);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
+                    typeStr, PS_TYPE_MASK_NAME);
             psFree(out);
             return NULL;
@@ -328,7 +316,6 @@
 
     if (stats == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSlice",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_STAT_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_STAT_NULL);
         psFree(out);
         return NULL;
@@ -338,7 +325,6 @@
     // single stats operation
     if (p_psGetStatValue(stats, &statVal) == false) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSlice",
-                   PS_ERR_BAD_PARAMETER_VALUE, false,
-                   PS_ERRORTEXT_psImage_BAD_STAT,stats->options);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                PS_ERRORTEXT_psImage_BAD_STAT,stats->options);
         psFree(out);
         return NULL;
@@ -423,8 +409,7 @@
                 char* typeStr;
                 PS_TYPE_NAME(typeStr,type);
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSlice",
-                           PS_ERR_BAD_PARAMETER_TYPE, true,
-                           PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                           typeStr);
+                psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                        PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                        typeStr);
                 psFree(out);
                 out = NULL;
@@ -485,8 +470,7 @@
         psFree(maskVec);
     } else { // don't know what the direction flag is
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSlice",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImage_SLICE_DIRECTION_INVALID,
-                   direction);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImage_SLICE_DIRECTION_INVALID,
+                direction);
         psFree(out);
         out = NULL;
@@ -512,7 +496,6 @@
 {
     if (in == NULL || in->data.V == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         psFree(out);
         return NULL;
@@ -522,8 +505,7 @@
 
     if (nSamples < 2) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImage_nSamples_TOOSMALL,
-                   nSamples);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImage_nSamples_TOOSMALL,
+                nSamples);
         psFree(out);
         return NULL;
@@ -534,9 +516,8 @@
             endCol < 0 || endCol >= numCols ||
             endRow < 0 || endRow >= numRows) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImage_LINE_NOT_IN_IMAGE,
-                   startCol,startRow,endCol,endRow,
-                   numCols-1,numRows-1);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImage_LINE_NOT_IN_IMAGE,
+                startCol,startRow,endCol,endRow,
+                numCols-1,numRows-1);
         psFree(out);
         return NULL;
@@ -544,8 +525,7 @@
 
     if (mode < PS_INTERPOLATE_FLAT || mode >= PS_INTERPOLATE_NUM_MODES) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageResample",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED,
-                   mode);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED,
+                mode);
         psFree(out);
         return NULL;
@@ -554,9 +534,8 @@
     if (mask != NULL) {
         if (numRows != mask->numRows || numCols != mask->numCols) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut",
-                       PS_ERR_BAD_PARAMETER_VALUE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_MASK_SIZE,
-                       mask->numCols,mask->numRows,
-                       numCols-1, numRows);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_MASK_SIZE,
+                    mask->numCols,mask->numRows,
+                    numCols-1, numRows);
             psFree(out);
             return NULL;
@@ -565,8 +544,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,mask->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
-                       typeStr, PS_TYPE_MASK_NAME);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
+                    typeStr, PS_TYPE_MASK_NAME);
             psFree(out);
             return NULL;
@@ -627,8 +605,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,in->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                       typeStr);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                    typeStr);
             psFree(out);
             out = NULL;
@@ -653,7 +630,6 @@
 
     if (in == NULL || in->data.V == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         psFree(out);
         return NULL;
@@ -664,9 +640,8 @@
     if (mask != NULL) {
         if (numRows != mask->numRows || numCols != mask->numCols) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut",
-                       PS_ERR_BAD_PARAMETER_SIZE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_MASK_SIZE,
-                       mask->numCols,mask->numRows,
-                       numCols, numRows);
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_MASK_SIZE,
+                    mask->numCols,mask->numRows,
+                    numCols, numRows);
             psFree(out);
             return NULL;
@@ -675,8 +650,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,mask->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
-                       typeStr, PS_TYPE_MASK_NAME);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
+                    typeStr, PS_TYPE_MASK_NAME);
             psFree(out);
             return NULL;
@@ -686,9 +660,8 @@
     if (centerCol < 0 || centerCol >= numCols ||
             centerRow < 0 || centerRow >= numRows) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImage_CENTER_NOT_IN_IMAGE,
-                   centerCol, centerRow,
-                   numCols-1, numRows-1);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImage_CENTER_NOT_IN_IMAGE,
+                centerCol, centerRow,
+                numCols-1, numRows-1);
         psFree(out);
         return NULL;
@@ -696,7 +669,6 @@
 
     if (radii == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_RADII_VECTOR_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_RADII_VECTOR_NULL);
         psFree(out);
         return NULL;
@@ -704,8 +676,7 @@
 
     if (radii->n < 2) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut",
-                   PS_ERR_BAD_PARAMETER_SIZE, true,
-                   PS_ERRORTEXT_psImage_RADII_VECTOR_TOOSMALL,
-                   radii->n);
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                PS_ERRORTEXT_psImage_RADII_VECTOR_TOOSMALL,
+                radii->n);
         psFree(out);
         return NULL;
@@ -713,7 +684,6 @@
 
     if (stats == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_STAT_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_STAT_NULL);
         psFree(out);
         return NULL;
@@ -723,8 +693,7 @@
     // single stats operation
     if (p_psGetStatValue(stats, &statVal) == false) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut",
-                   PS_ERR_BAD_PARAMETER_VALUE, false,
-                   PS_ERRORTEXT_psImage_BAD_STAT,
-                   stats->options);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                PS_ERRORTEXT_psImage_BAD_STAT,
+                stats->options);
         psFree(out);
         return NULL;
Index: /trunk/psLib/src/image/psImageFFT.c
===================================================================
--- /trunk/psLib/src/image/psImageFFT.c	(revision 2272)
+++ /trunk/psLib/src/image/psImageFFT.c	(revision 2273)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -43,21 +43,18 @@
     if ( ((direction & PS_FFT_FORWARD) != 0) ) {
         if ((direction & PS_FFT_REVERSE) != 0) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT",
-                       PS_ERR_BAD_PARAMETER_VALUE, true,
-                       PS_ERRORTEXT_psImageFFT_FORWARD_REVERSE);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psImageFFT_FORWARD_REVERSE);
             psFree(out);
             return NULL;
         }
         if ((direction & PS_FFT_REAL_RESULT) != 0) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT",
-                       PS_ERR_BAD_PARAMETER_VALUE, true,
-                       PS_ERRORTEXT_psImageFFT_REAL_FORWARD_NOTSUPPORTED);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psImageFFT_REAL_FORWARD_NOTSUPPORTED);
             psFree(out);
             return NULL;
         }
     } else if ((direction & PS_FFT_REVERSE) == 0) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImageFFT_NO_DIRECTION_OPTION);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImageFFT_NO_DIRECTION_OPTION);
         psFree(out);
         return NULL;
@@ -86,7 +83,6 @@
     /* check if a plan exists now -- if not, it is a real problem at this point */
     if (plan == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImageFFT_FFTW_PLAN_NULL);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImageFFT_FFTW_PLAN_NULL);
         psFree(out);
         return NULL;
@@ -163,8 +159,7 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReal",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                   typeStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                typeStr);
 
         psFree(out);
@@ -226,8 +221,7 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageImaginary",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                   typeStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                typeStr);
         psFree(out);
         return NULL;
@@ -257,8 +251,7 @@
         PS_TYPE_NAME(typeStrReal,type);
         PS_TYPE_NAME(typeStrImag,imag->type.type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImageFFT_REAL_IMAG_TYPE_MISMATCH,
-                   typeStrReal,typeStrImag);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImageFFT_REAL_IMAG_TYPE_MISMATCH,
+                typeStrReal,typeStrImag);
         psFree(out);
         return NULL;
@@ -266,8 +259,7 @@
 
     if (imag->numCols != numCols || imag->numRows != numRows) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImageFFT_REAL_IMAG_SIZE_MISMATCH,
-                   numCols, numRows, imag->numCols, imag->numRows);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImageFFT_REAL_IMAG_SIZE_MISMATCH,
+                numCols, numRows, imag->numCols, imag->numRows);
         psFree(out);
         return NULL;
@@ -308,8 +300,7 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImageFFT_NONREAL_NOTSUPPORTED,
-                   typeStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImageFFT_NONREAL_NOTSUPPORTED,
+                typeStr);
         psFree(out);
         return NULL;
@@ -369,8 +360,7 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConjugate",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED,
-                   typeStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED,
+                typeStr);
         psFree(out);
         return NULL;
@@ -434,13 +424,12 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePowerSpectrum",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED,
-                   typeStr);
-        psFree(out);
-        return NULL;
-    }
-
-    return out;
-
-}
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED,
+                typeStr);
+        psFree(out);
+        return NULL;
+    }
+
+    return out;
+
+}
Index: /trunk/psLib/src/image/psImageIO.c
===================================================================
--- /trunk/psLib/src/image/psImageIO.c	(revision 2272)
+++ /trunk/psLib/src/image/psImageIO.c	(revision 2273)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 19:35:58 $
+ *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -47,7 +47,6 @@
 
     if (filename == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImageIO_FILENAME_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImageIO_FILENAME_NULL);
         psFree(output);
         return NULL;
@@ -58,8 +57,7 @@
     if (fptr == NULL || status != 0) {
         fits_get_errstatus(status, fitsErr);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImageIO_FILENAME_INVALID,
-                   filename, fitsErr);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImageIO_FILENAME_INVALID,
+                filename, fitsErr);
         psFree(output);
         return NULL;
@@ -72,8 +70,7 @@
             status = 0;
             (void)fits_close_file(fptr, &status);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection",
-                       PS_ERR_LOCATION_INVALID, true,
-                       PS_ERRORTEXT_psImageIO_EXTNAME_INVALID,
-                       extname, filename, fitsErr);
+            psError(PS_ERR_LOCATION_INVALID, true,
+                    PS_ERRORTEXT_psImageIO_EXTNAME_INVALID,
+                    extname, filename, fitsErr);
             psFree(output);
             return NULL;
@@ -84,8 +81,7 @@
             status = 0;
             (void)fits_close_file(fptr, &status);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection",
-                       PS_ERR_LOCATION_INVALID, true,
-                       PS_ERRORTEXT_psImageIO_EXTNUM_INVALID,
-                       extnum, filename, fitsErr);
+            psError(PS_ERR_LOCATION_INVALID, true,
+                    PS_ERRORTEXT_psImageIO_EXTNUM_INVALID,
+                    extnum, filename, fitsErr);
             psFree(output);
             return NULL;
@@ -98,8 +94,7 @@
         status = 0;
         (void)fits_close_file(fptr, &status);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection",
-                   PS_ERR_IO, true,
-                   PS_ERRORTEXT_psImageIO_DATATYPE_UNKNOWN,
-                   filename, fitsErr);
+        psError(PS_ERR_IO, true,
+                PS_ERRORTEXT_psImageIO_DATATYPE_UNKNOWN,
+                filename, fitsErr);
         psFree(output);
         return NULL;
@@ -111,8 +106,7 @@
         status = 0;
         (void)fits_close_file(fptr, &status);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection",
-                   PS_ERR_IO, true,
-                   PS_ERRORTEXT_psImageIO_IMAGE_DIM_UNKNOWN,
-                   filename, fitsErr);
+        psError(PS_ERR_IO, true,
+                PS_ERRORTEXT_psImageIO_IMAGE_DIM_UNKNOWN,
+                filename, fitsErr);
         psFree(output);
         return NULL;
@@ -123,8 +117,7 @@
         status = 0;
         (void)fits_close_file(fptr, &status);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection",
-                   PS_ERR_IO, true,
-                   PS_ERRORTEXT_psImageIO_IMAGE_DIMENSION_UNSUPPORTED,
-                   nAxis);
+        psError(PS_ERR_IO, true,
+                PS_ERRORTEXT_psImageIO_IMAGE_DIMENSION_UNSUPPORTED,
+                nAxis);
         psFree(output);
         return NULL;
@@ -136,8 +129,7 @@
         status = 0;
         (void)fits_close_file(fptr, &status);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection",
-                   PS_ERR_IO, true,
-                   PS_ERRORTEXT_psImageIO_IMAGE_SIZE_UNKNOWN,
-                   filename, fitsErr);
+        psError(PS_ERR_IO, true,
+                PS_ERRORTEXT_psImageIO_IMAGE_SIZE_UNKNOWN,
+                filename, fitsErr);
         psFree(output);
         return NULL;
@@ -201,8 +193,7 @@
         break;
     default:
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection",
-                   PS_ERR_IO, true,
-                   PS_ERRORTEXT_psImageIO_FITS_TYPE_UNSUPPORTED,
-                   bitPix, filename);
+        psError(PS_ERR_IO, true,
+                PS_ERRORTEXT_psImageIO_FITS_TYPE_UNSUPPORTED,
+                bitPix, filename);
         psFree(output);
         return NULL;
@@ -215,8 +206,7 @@
         status = 0;
         (void)fits_close_file(fptr, &status);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReadSection",
-                   PS_ERR_IO, true,
-                   PS_ERRORTEXT_psImageIO_READ_FAILED,
-                   filename, fitsErr);
+        psError(PS_ERR_IO, true,
+                PS_ERRORTEXT_psImageIO_READ_FAILED,
+                filename, fitsErr);
         return NULL;
     }
@@ -253,7 +243,6 @@
     /* need a valid image to write */
     if (input == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         return false;
     }
@@ -301,8 +290,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,input->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImageIO_TYPE_UNSUPPORTED,
-                       typeStr);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImageIO_TYPE_UNSUPPORTED,
+                    typeStr);
             return false;
         }
@@ -315,8 +303,7 @@
         if (fptr == NULL || status != 0) {
             fits_get_errstatus(status, fitsErr);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection",
-                       PS_ERR_BAD_PARAMETER_VALUE, true,
-                       PS_ERRORTEXT_psImageIO_FILENAME_INVALID,
-                       filename, fitsErr);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psImageIO_FILENAME_INVALID,
+                    filename, fitsErr);
             return false;
         }
@@ -328,8 +315,7 @@
                 status = 0;
                 (void)fits_close_file(fptr, &status);
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection",
-                           PS_ERR_LOCATION_INVALID, true,
-                           PS_ERRORTEXT_psImageIO_EXTNAME_INVALID,
-                           extname, filename, fitsErr);
+                psError(PS_ERR_LOCATION_INVALID, true,
+                        PS_ERRORTEXT_psImageIO_EXTNAME_INVALID,
+                        extname, filename, fitsErr);
                 return false;
             }
@@ -341,8 +327,7 @@
                 status = 0;
                 (void)fits_close_file(fptr, &status);
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection",
-                           PS_ERR_LOCATION_INVALID, true,
-                           PS_ERRORTEXT_psImageIO_WRITE_EXTNUM_INVALID,
-                           extnum, numHDUs);
+                psError(PS_ERR_LOCATION_INVALID, true,
+                        PS_ERRORTEXT_psImageIO_WRITE_EXTNUM_INVALID,
+                        extnum, numHDUs);
                 return false;
             } else if (numHDUs == extnum) {
@@ -352,8 +337,7 @@
                 status = 0;
                 (void)fits_close_file(fptr, &status);
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection",
-                           PS_ERR_LOCATION_INVALID, true,
-                           PS_ERRORTEXT_psImageIO_EXTNUM_INVALID,
-                           extnum, filename, fitsErr);
+                psError(PS_ERR_LOCATION_INVALID, true,
+                        PS_ERRORTEXT_psImageIO_EXTNUM_INVALID,
+                        extnum, filename, fitsErr);
                 return false;
             }
@@ -368,8 +352,7 @@
         if (fptr == NULL || status != 0) {
             fits_get_errstatus(status, fitsErr);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection",
-                       PS_ERR_IO, true,
-                       PS_ERRORTEXT_psImageIO_FILENAME_CREATE_FAILED,
-                       filename, fitsErr);
+            psError(PS_ERR_IO, true,
+                    PS_ERRORTEXT_psImageIO_FILENAME_CREATE_FAILED,
+                    filename, fitsErr);
             return false;
         }
@@ -386,8 +369,7 @@
             status = 0;
             (void)fits_close_file(fptr, &status);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection",
-                       PS_ERR_IO, true,
-                       PS_ERRORTEXT_psImageIO_CREATE_HDU_FAILED,
-                       filename, fitsErr);
+            psError(PS_ERR_IO, true,
+                    PS_ERRORTEXT_psImageIO_CREATE_HDU_FAILED,
+                    filename, fitsErr);
             return false;
         }
@@ -403,8 +385,7 @@
                 status = 0;
                 (void)fits_close_file(fptr, &status);
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection",
-                           PS_ERR_IO, true,
-                           PS_ERRORTEXT_psImageIO_CREATE_EXTENSION_FAILED,
-                           filename, fitsErr);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psImageIO_CREATE_EXTENSION_FAILED,
+                        filename, fitsErr);
                 return false;
             }
@@ -424,8 +405,7 @@
         status = 0;
         (void)fits_close_file(fptr, &status);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageWriteSection",
-                   PS_ERR_IO, true,
-                   PS_ERRORTEXT_psImageIO_WRITE_FAILED,
-                   filename, fitsErr);
+        psError(PS_ERR_IO, true,
+                PS_ERRORTEXT_psImageIO_WRITE_FAILED,
+                filename, fitsErr);
         return false;
     }
Index: /trunk/psLib/src/image/psImageManip.c
===================================================================
--- /trunk/psLib/src/image/psImageManip.c	(revision 2272)
+++ /trunk/psLib/src/image/psImageManip.c	(revision 2273)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -43,8 +43,7 @@
 
     if (max < min) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImageManip_MAXMIN,
-                   (double)min,(double)max);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImageManip_MAXMIN,
+                (double)min,(double)max);
         return 0;
     }
@@ -58,16 +57,14 @@
     case PS_TYPE_##type: { \
             if (vmin < PS_MIN_##type || vmin > PS_MAX_##type) { \
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip", \
-                           PS_ERR_BAD_PARAMETER_VALUE, true, \
-                           PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \
-                           "vmin",vmin, PS_TYPE_##type##_NAME, \
-                           (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \
+                psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+                        PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \
+                        "vmin",vmin, PS_TYPE_##type##_NAME, \
+                        (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \
             } \
             if (vmax > PS_MAX_##type || vmax < PS_MIN_##type) { \
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip", \
-                           PS_ERR_BAD_PARAMETER_VALUE, true, \
-                           PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \
-                           "vmax",vmax, PS_TYPE_##type##_NAME, \
-                           (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \
+                psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+                        PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \
+                        "vmax",vmax, PS_TYPE_##type##_NAME, \
+                        (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \
             } \
             for (psU32 row = 0;row<numRows;row++) { \
@@ -89,16 +86,14 @@
     case PS_TYPE_##type: { \
             if (vmin < PS_MIN_##type || vmin > PS_MAX_##type) { \
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip", \
-                           PS_ERR_BAD_PARAMETER_VALUE, true, \
-                           PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \
-                           "vmin",vmin, PS_TYPE_##type##_NAME, \
-                           (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \
+                psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+                        PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \
+                        "vmin",vmin, PS_TYPE_##type##_NAME, \
+                        (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \
             } \
             if (vmax > PS_MAX_##type || vmax < PS_MIN_##type) { \
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip", \
-                           PS_ERR_BAD_PARAMETER_VALUE, true, \
-                           PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \
-                           "vmax",vmax, PS_TYPE_##type##_NAME, \
-                           (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \
+                psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+                        PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE, \
+                        "vmax",vmax, PS_TYPE_##type##_NAME, \
+                        (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \
             } \
             for (psU32 row = 0;row<numRows;row++) { \
@@ -133,8 +128,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,input->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClip",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                       typeStr);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                    typeStr);
         }
     }
@@ -179,8 +173,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,input->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipNaN",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                       typeStr);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                    typeStr);
         }
     }
@@ -204,14 +197,12 @@
 
     if (image == NULL || overlay == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         return 1;
     }
 
     if (op == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImageManip_OPERATION_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImageManip_OPERATION_NULL);
         return 1;
     }
@@ -224,8 +215,7 @@
         PS_TYPE_NAME(typeStr,type);
         PS_TYPE_NAME(typeStrOverlay,overlay->type.type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImageManip_OVERLAY_TYPE_MISMATCH,
-                   typeStrOverlay, typeStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImageManip_OVERLAY_TYPE_MISMATCH,
+                typeStrOverlay, typeStr);
         return 2;
     }
@@ -244,9 +234,8 @@
             imageColLimit > imageNumCols) {
 
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID,
-                   col0, imageColLimit, row0, imageRowLimit,
-                   imageNumCols, imageNumRows);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID,
+                col0, imageColLimit, row0, imageRowLimit,
+                imageNumCols, imageNumRows);
         return 3;
     }
@@ -277,8 +266,7 @@
                     break; \
                 default: \
-                    psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection", \
-                               PS_ERR_BAD_PARAMETER_VALUE, true, \
-                               PS_ERRORTEXT_psImageManip_OVERLAY_OPERATOR_INVALID, \
-                               op); \
+                    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+                            PS_ERRORTEXT_psImageManip_OVERLAY_OPERATOR_INVALID, \
+                            op); \
                     return 5; \
                 } \
@@ -303,8 +291,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageOverlaySection",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                       typeStr);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                    typeStr);
             return 6;
         }
@@ -329,22 +316,19 @@
 
     if (input == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         return 0;
     }
 
     if (realMax < realMin) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImageManip_MAXMIN_REAL,
-                   (double)realMin, (double)realMax);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImageManip_MAXMIN_REAL,
+                (double)realMin, (double)realMax);
         return 0;
     }
     if (imagMax < imagMin) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImageManip_MAXMIN_IMAG,
-                   (double)imagMin, (double)imagMax);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImageManip_MAXMIN_IMAG,
+                (double)imagMin, (double)imagMax);
         return 0;
     }
@@ -357,18 +341,16 @@
         if (realfcn(vmin) < PS_MIN_##type || imagfcn(vmin) < PS_MIN_##type || \
                 realfcn(vmin) > PS_MAX_##type || imagfcn(vmin) > PS_MAX_##type ) { \
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion", \
-                       PS_ERR_BAD_PARAMETER_VALUE, true, \
-                       PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \
-                       "vmin", creal(vmin), cimag(vmin), \
-                       PS_TYPE_##type##_NAME, PS_MIN_##type, PS_MAX_##type); \
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+                    PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \
+                    "vmin", creal(vmin), cimag(vmin), \
+                    PS_TYPE_##type##_NAME, PS_MIN_##type, PS_MAX_##type); \
             break; \
         } \
         if (realfcn(vmax) > PS_MAX_##type || imagfcn(vmax) > PS_MAX_##type || \
                 realfcn(vmax) < PS_MIN_##type || imagfcn(vmax) < PS_MIN_##type ) { \
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion", \
-                       PS_ERR_BAD_PARAMETER_VALUE, true, \
-                       PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \
-                       "vmax", creal(vmax), cimag(vmax), \
-                       PS_TYPE_##type##_NAME, PS_MIN_##type, PS_MAX_##type); \
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+                    PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \
+                    "vmax", creal(vmax), cimag(vmax), \
+                    PS_TYPE_##type##_NAME, PS_MIN_##type, PS_MAX_##type); \
             break; \
         } \
@@ -396,8 +378,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,input->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageClipComplexRegion",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                       typeStr);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                    typeStr);
         }
     }
@@ -424,7 +405,6 @@
 
     if (in == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         psFree(out);
         return NULL;
@@ -432,8 +412,7 @@
 
     if (scale < 1) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImageManip_SCALE_NOT_POSITIVE,
-                   scale);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImageManip_SCALE_NOT_POSITIVE,
+                scale);
         psFree(out);
         return NULL;
@@ -441,7 +420,6 @@
 
     if (stats == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_STAT_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_STAT_NULL);
         psFree(out);
         return NULL;
@@ -449,8 +427,7 @@
 
     if (p_psGetStatValue(stats, &statVal) == false) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImage_BAD_STAT,
-                   stats->options);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImage_BAD_STAT,
+                stats->options);
         psFree(out);
         return NULL;
@@ -463,8 +440,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,mask->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
-                       typeStr, PS_TYPE_MASK_NAME);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
+                    typeStr, PS_TYPE_MASK_NAME);
             psFree(out);
             psFree(vec);
@@ -536,8 +512,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,in->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRebin",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                       typeStr);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                    typeStr);
             psFree(out);
             out = NULL;
@@ -562,7 +537,6 @@
 
     if (in == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageResample",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         psFree(out);
         return NULL;
@@ -570,8 +544,7 @@
 
     if (scale < 1) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageResample",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImageManip_SCALE_NOT_POSITIVE,
-                   scale);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImageManip_SCALE_NOT_POSITIVE,
+                scale);
         psFree(out);
         return NULL;
@@ -579,8 +552,7 @@
 
     if (mode < PS_INTERPOLATE_FLAT || mode >= PS_INTERPOLATE_NUM_MODES) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageResample",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED,
-                   mode);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED,
+                mode);
         psFree(out);
         return NULL;
@@ -622,8 +594,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,in->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageResample",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                       typeStr);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                    typeStr);
             psFree(out);
             out = NULL;
@@ -644,7 +615,6 @@
 
     if (in == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRoll",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         psFree(out);
         return NULL;
@@ -694,7 +664,6 @@
 {
     if (in == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         psFree(out);
         return NULL;
@@ -741,8 +710,7 @@
                 char* typeStr;
                 PS_TYPE_NAME(typeStr,type);
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate",
-                           PS_ERR_BAD_PARAMETER_TYPE, true,
-                           PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                           typeStr);
+                psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                        PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                        typeStr);
                 psFree(out);
                 return NULL;
@@ -788,8 +756,7 @@
                 char* typeStr;
                 PS_TYPE_NAME(typeStr,type);
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate",
-                           PS_ERR_BAD_PARAMETER_TYPE, true,
-                           PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                           typeStr);
+                psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                        PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                        typeStr);
                 psFree(out);
                 return NULL;
@@ -834,8 +801,7 @@
                 char* typeStr;
                 PS_TYPE_NAME(typeStr,type);
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate",
-                           PS_ERR_BAD_PARAMETER_TYPE, true,
-                           PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                           typeStr);
+                psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                        PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                        typeStr);
                 psFree(out);
                 return NULL;
@@ -891,11 +857,10 @@
                     cimag(unexposedValue) < PS_MIN_##TYPE || \
                     cimag(unexposedValue) > PS_MAX_##TYPE) { \
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", \
-                           PS_ERR_BAD_PARAMETER_VALUE, true, \
-                           PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \
-                           "unexposedValue", \
-                           creal(unexposedValue),cimag(unexposedValue), \
-                           PS_TYPE_##TYPE##_NAME,  \
-                           (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \
+                psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+                        PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \
+                        "unexposedValue", \
+                        creal(unexposedValue),cimag(unexposedValue), \
+                        PS_TYPE_##TYPE##_NAME,  \
+                        (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \
                 psFree(out); \
                 out = NULL; \
@@ -959,8 +924,7 @@
                 char* typeStr; \
                 PS_TYPE_NAME(typeStr,type); \
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", \
-                           PS_ERR_BAD_PARAMETER_TYPE, true, \
-                           PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, \
-                           typeStr); \
+                psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+                        PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, \
+                        typeStr); \
                 psFree(out); \
                 out = NULL; \
@@ -973,8 +937,7 @@
             PSIMAGE_ROTATE_ARBITRARY_CASE(BILINEAR);
         default:
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate",
-                       PS_ERR_BAD_PARAMETER_VALUE, true,
-                       PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED,
-                       mode);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED,
+                    mode);
             psFree(out);
             out = NULL;
@@ -998,7 +961,6 @@
 
     if (in == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageShift",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         psFree(out);
         return NULL;
@@ -1018,11 +980,10 @@
             cimag(unexposedValue) < PS_MIN_##TYPE || \
             cimag(unexposedValue) > PS_MAX_##TYPE) { \
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageShift", \
-                   PS_ERR_BAD_PARAMETER_VALUE, true, \
-                   PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \
-                   "unexposedValue", \
-                   creal(unexposedValue),cimag(unexposedValue), \
-                   PS_TYPE_##TYPE##_NAME,  \
-                   (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+                PS_ERRORTEXT_psImageManip_CLIP_VALUE_INVALID, \
+                "unexposedValue", \
+                creal(unexposedValue),cimag(unexposedValue), \
+                PS_TYPE_##TYPE##_NAME,  \
+                (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \
         psFree(out); \
         out = NULL; \
@@ -1058,8 +1019,7 @@
             char* typeStr; \
             PS_TYPE_NAME(typeStr,type); \
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRotate", \
-                       PS_ERR_BAD_PARAMETER_TYPE, true, \
-                       PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, \
-                       typeStr); \
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, \
+                    typeStr); \
             psFree(out); \
             out = NULL; \
@@ -1073,8 +1033,7 @@
         PSIMAGE_SHIFT_ARBITRARY_CASE(BILINEAR);
     default:
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageShift",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED,
-                   mode);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED,
+                mode);
         psFree(out);
         out = NULL;
Index: /trunk/psLib/src/image/psImageStats.c
===================================================================
--- /trunk/psLib/src/image/psImageStats.c	(revision 2272)
+++ /trunk/psLib/src/image/psImageStats.c	(revision 2273)
@@ -1,17 +1,17 @@
 /** @file psImageStats.c
-*  \brief Routines for calculating statistics on images.
-*  @ingroup ImageStats
-*
-*  This file will hold the prototypes for procedures which calculate
-*  statistic on images, histograms on images, and fit/evaluate Chebyshev
-*  polynomials to images.
-*
-*  @author GLG, MHPCC
-*
-*  @version $Revision: 1.49 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-11-02 03:57:21 $
-*
-*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
-*/
+ *  \brief Routines for calculating statistics on images.
+ *  @ingroup ImageStats
+ *
+ *  This file will hold the prototypes for procedures which calculate
+ *  statistic on images, histograms on images, and fit/evaluate Chebyshev
+ *  polynomials to images.
+ *
+ *  @author GLG, MHPCC
+ *
+ *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
 
 #include <stdlib.h>
@@ -46,21 +46,18 @@
 
     if (stats == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageStats",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_STAT_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_STAT_NULL);
         return NULL;
     }
 
     if (in == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageStats",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         return NULL;
     }
 
     if (stats->options == 0) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageStats",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImage_NO_STAT_OPTIONS);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImage_NO_STAT_OPTIONS);
         return stats;
     }
@@ -76,8 +73,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,mask->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageStats",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
-                       typeStr, PS_TYPE_MASK_NAME);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
+                    typeStr, PS_TYPE_MASK_NAME);
             psFree(junkData);
             return NULL;
@@ -125,8 +121,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,mask->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageHistogram",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
-                       typeStr, PS_TYPE_MASK_NAME);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
+                    typeStr, PS_TYPE_MASK_NAME);
             psFree(out);
             psFree(junkData);
@@ -150,5 +145,5 @@
 
 /*****************************************************************************
-CalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the
+calcScaleFactorsEval(n): The Chebyshev polynomials are defined over the
 interval [-1.0 : 1.0].  Images typically have sizes of 512x512 or more.  In
 order to use Chebyshev polynomials, we must scale the coordinates from
@@ -156,7 +151,7 @@
 output a vector of evenly spaced floating point values between -1.0:1.0.
  *****************************************************************************/
-double *CalcScaleFactors(psS32 n)
-{
-    PS_INT_CHEC_NON_NEGATIVE(n, NULL);
+double* calcScaleFactors(psS32 n)
+{
+    PS_INT_CHECK_NON_NEGATIVE(n, NULL);
     psS32 i = 0;
     double tmp = 0.0;
@@ -172,9 +167,9 @@
 }
 
-psVector *VecCalcScaleFactors(psVector *scalingFactors, psS32 n)
+psVector *VeccalcScaleFactors(psVector *scalingFactors, psS32 n)
 {
     PS_VECTOR_CHECK_NULL(scalingFactors, NULL);
     PS_VECTOR_CHECK_TYPE(scalingFactors, PS_TYPE_F64, NULL);
-    PS_INT_CHEC_NON_NEGATIVE(n, NULL);
+    PS_INT_CHECK_NON_NEGATIVE(n, NULL);
     psS32 i = 0;
     double tmp = 0.0;
@@ -243,5 +238,6 @@
             (input->type.type != PS_TYPE_F32) &&
             (input->type.type != PS_TYPE_F64)) {
-        psError(__func__, "Unalowwable image type.\n");
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                "Unallowable image type.\n");
     }
     PS_POLY_CHECK_NULL(coeffs, NULL);
@@ -259,14 +255,12 @@
     // Check for null inputs
     if (input == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFitPolynomial",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         return NULL;
     }
 
     if (coeffs == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFitPolynomial",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_COEFF_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_COEFF_NULL);
         return NULL;
     }
@@ -283,6 +277,6 @@
     // We scale the pixel positions to values
     // between -1.0 and 1.0
-    rScalingFactors = CalcScaleFactors(input->numRows);
-    cScalingFactors = CalcScaleFactors(input->numCols);
+    rScalingFactors = calcScaleFactors(input->numRows);
+    cScalingFactors = calcScaleFactors(input->numCols);
 
     // Determine how many Chebyshev polynomials
@@ -363,5 +357,6 @@
             (input->type.type != PS_TYPE_F32) &&
             (input->type.type != PS_TYPE_F64)) {
-        psError(__func__, "Unalowwable image type.\n");
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                "Unallowable image type.\n");
     }
     PS_POLY_CHECK_NULL(coeffs, NULL);
@@ -376,11 +371,23 @@
     double *cScalingFactors = NULL;
     double *rScalingFactors = NULL;
-    double polySum = 0.0;
-
+    float polySum = 0.0;
+
+    // Check for null inputs
+    if (input == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
+        return NULL;
+    }
+
+    if (coeffs == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_COEFF_NULL);
+        return NULL;
+    }
 
     // We scale the pixel positions to values between -1.0 and 1.0
     // Use static data structures here.
-    rScalingFactors = CalcScaleFactors(input->numRows);
-    cScalingFactors = CalcScaleFactors(input->numCols);
+    rScalingFactors = calcScaleFactors(input->numRows);
+    cScalingFactors = calcScaleFactors(input->numCols);
 
     // Determine how many Chebyshev polynomials
Index: /trunk/psLib/src/imageops/psImageConvolve.c
===================================================================
--- /trunk/psLib/src/imageops/psImageConvolve.c	(revision 2272)
+++ /trunk/psLib/src/imageops/psImageConvolve.c	(revision 2273)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -110,7 +110,6 @@
     // got non-NULL vectors?
     if (tShifts == NULL || xShifts == NULL || yShifts == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psKernelGenerate",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImageConvolve_SHIFT_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImageConvolve_SHIFT_NULL);
         return NULL;
     }
@@ -125,8 +124,7 @@
         PS_TYPE_NAME(typeYStr,yShifts->type.type);
         PS_TYPE_NAME(typeTStr,tShifts->type.type);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psKernelGenerate",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImageConvolve_SHIFT_TYPE_MISMATCH,
-                   typeTStr, typeXStr, typeYStr);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImageConvolve_SHIFT_TYPE_MISMATCH,
+                typeTStr, typeXStr, typeYStr);
         return NULL;
     }
@@ -218,8 +216,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,xShifts->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psKernelGenerate",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                       typeStr);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                    typeStr);
         }
     }
@@ -236,7 +233,6 @@
 
     if (kernel == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImageConvolve_KERNEL_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImageConvolve_KERNEL_NULL);
         psFree(out);
         return NULL;
@@ -297,8 +293,7 @@
                 char* typeStr;
                 PS_TYPE_NAME(typeStr,in->type.type);
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve",
-                           PS_ERR_BAD_PARAMETER_TYPE, true,
-                           PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                           typeStr);
+                psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                        PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                        typeStr);
                 psFree(out);
                 return NULL;
@@ -317,9 +312,8 @@
         psS32 kCols = kernel->image->numCols;
         if (kRows >= numRows || kCols >= numCols) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve",
-                       PS_ERR_BAD_PARAMETER_SIZE, true,
-                       PS_ERRORTEXT_psImageConvolve_KERNEL_TOO_LARGE,
-                       kCols,kRows,
-                       numCols, numRows);
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    PS_ERRORTEXT_psImageConvolve_KERNEL_TOO_LARGE,
+                    kCols,kRows,
+                    numCols, numRows);
             psFree(out);
             return NULL;
@@ -376,7 +370,6 @@
         psImage* kernelFourier = psImageFFT(NULL, paddedKernel, PS_FFT_FORWARD);
         if (kernelFourier == NULL) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve",
-                       PS_ERR_UNKNOWN, false,
-                       PS_ERRORTEXT_psImageConvolve_KERNEL_FFT_FAILED);
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psImageConvolve_KERNEL_FFT_FAILED);
             psFree(out);
             return NULL;
@@ -385,7 +378,6 @@
         psImage* inFourier = psImageFFT(NULL, paddedImage, PS_FFT_FORWARD);
         if (inFourier == NULL) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve",
-                       PS_ERR_UNKNOWN, false,
-                       PS_ERRORTEXT_psImageConvolve_FFT_FAILED);
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psImageConvolve_FFT_FAILED);
             psFree(out);
             return NULL;
@@ -398,7 +390,6 @@
                                          PS_FFT_REVERSE);
         if (complexOut == NULL) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve",
-                       PS_ERR_UNKNOWN, false,
-                       PS_ERRORTEXT_psImageConvolve_FFT_FAILED);
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psImageConvolve_FFT_FAILED);
             psFree(out);
             return NULL;
Index: /trunk/psLib/src/imageops/psImageStats.c
===================================================================
--- /trunk/psLib/src/imageops/psImageStats.c	(revision 2272)
+++ /trunk/psLib/src/imageops/psImageStats.c	(revision 2273)
@@ -1,17 +1,17 @@
 /** @file psImageStats.c
-*  \brief Routines for calculating statistics on images.
-*  @ingroup ImageStats
-*
-*  This file will hold the prototypes for procedures which calculate
-*  statistic on images, histograms on images, and fit/evaluate Chebyshev
-*  polynomials to images.
-*
-*  @author GLG, MHPCC
-*
-*  @version $Revision: 1.49 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-11-02 03:57:21 $
-*
-*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
-*/
+ *  \brief Routines for calculating statistics on images.
+ *  @ingroup ImageStats
+ *
+ *  This file will hold the prototypes for procedures which calculate
+ *  statistic on images, histograms on images, and fit/evaluate Chebyshev
+ *  polynomials to images.
+ *
+ *  @author GLG, MHPCC
+ *
+ *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
 
 #include <stdlib.h>
@@ -46,21 +46,18 @@
 
     if (stats == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageStats",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_STAT_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_STAT_NULL);
         return NULL;
     }
 
     if (in == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageStats",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         return NULL;
     }
 
     if (stats->options == 0) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageStats",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImage_NO_STAT_OPTIONS);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImage_NO_STAT_OPTIONS);
         return stats;
     }
@@ -76,8 +73,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,mask->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageStats",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
-                       typeStr, PS_TYPE_MASK_NAME);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
+                    typeStr, PS_TYPE_MASK_NAME);
             psFree(junkData);
             return NULL;
@@ -125,8 +121,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,mask->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageHistogram",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
-                       typeStr, PS_TYPE_MASK_NAME);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
+                    typeStr, PS_TYPE_MASK_NAME);
             psFree(out);
             psFree(junkData);
@@ -150,5 +145,5 @@
 
 /*****************************************************************************
-CalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the
+calcScaleFactorsEval(n): The Chebyshev polynomials are defined over the
 interval [-1.0 : 1.0].  Images typically have sizes of 512x512 or more.  In
 order to use Chebyshev polynomials, we must scale the coordinates from
@@ -156,7 +151,7 @@
 output a vector of evenly spaced floating point values between -1.0:1.0.
  *****************************************************************************/
-double *CalcScaleFactors(psS32 n)
-{
-    PS_INT_CHEC_NON_NEGATIVE(n, NULL);
+double* calcScaleFactors(psS32 n)
+{
+    PS_INT_CHECK_NON_NEGATIVE(n, NULL);
     psS32 i = 0;
     double tmp = 0.0;
@@ -172,9 +167,9 @@
 }
 
-psVector *VecCalcScaleFactors(psVector *scalingFactors, psS32 n)
+psVector *VeccalcScaleFactors(psVector *scalingFactors, psS32 n)
 {
     PS_VECTOR_CHECK_NULL(scalingFactors, NULL);
     PS_VECTOR_CHECK_TYPE(scalingFactors, PS_TYPE_F64, NULL);
-    PS_INT_CHEC_NON_NEGATIVE(n, NULL);
+    PS_INT_CHECK_NON_NEGATIVE(n, NULL);
     psS32 i = 0;
     double tmp = 0.0;
@@ -243,5 +238,6 @@
             (input->type.type != PS_TYPE_F32) &&
             (input->type.type != PS_TYPE_F64)) {
-        psError(__func__, "Unalowwable image type.\n");
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                "Unallowable image type.\n");
     }
     PS_POLY_CHECK_NULL(coeffs, NULL);
@@ -259,14 +255,12 @@
     // Check for null inputs
     if (input == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFitPolynomial",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         return NULL;
     }
 
     if (coeffs == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFitPolynomial",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_COEFF_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_COEFF_NULL);
         return NULL;
     }
@@ -283,6 +277,6 @@
     // We scale the pixel positions to values
     // between -1.0 and 1.0
-    rScalingFactors = CalcScaleFactors(input->numRows);
-    cScalingFactors = CalcScaleFactors(input->numCols);
+    rScalingFactors = calcScaleFactors(input->numRows);
+    cScalingFactors = calcScaleFactors(input->numCols);
 
     // Determine how many Chebyshev polynomials
@@ -363,5 +357,6 @@
             (input->type.type != PS_TYPE_F32) &&
             (input->type.type != PS_TYPE_F64)) {
-        psError(__func__, "Unalowwable image type.\n");
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                "Unallowable image type.\n");
     }
     PS_POLY_CHECK_NULL(coeffs, NULL);
@@ -376,11 +371,23 @@
     double *cScalingFactors = NULL;
     double *rScalingFactors = NULL;
-    double polySum = 0.0;
-
+    float polySum = 0.0;
+
+    // Check for null inputs
+    if (input == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
+        return NULL;
+    }
+
+    if (coeffs == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_COEFF_NULL);
+        return NULL;
+    }
 
     // We scale the pixel positions to values between -1.0 and 1.0
     // Use static data structures here.
-    rScalingFactors = CalcScaleFactors(input->numRows);
-    cScalingFactors = CalcScaleFactors(input->numCols);
+    rScalingFactors = calcScaleFactors(input->numRows);
+    cScalingFactors = calcScaleFactors(input->numCols);
 
     // Determine how many Chebyshev polynomials
Index: /trunk/psLib/src/math/psConstants.h
===================================================================
--- /trunk/psLib/src/math/psConstants.h	(revision 2272)
+++ /trunk/psLib/src/math/psConstants.h	(revision 2273)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-03 22:58:53 $
+ *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -32,5 +32,6 @@
 #define PS_INT_CHECK_NON_NEGATIVE(NAME, RVAL) \
 if (NAME < 0) { \
-    psError(__func__,"Error: %s is less than 0.", #NAME); \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s is less than 0.", #NAME); \
     return(RVAL); \
 }
@@ -38,12 +39,23 @@
 #define PS_INT_CHECK_POSITIVE(NAME, RVAL) \
 if (NAME < 1) { \
-    psError(__func__,"Error: %s is 0 or less.", #NAME); \
-    return(RVAL); \
-}
-
-// Produce an error if ((NAME1 > NAME2)
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s is 0 or less.", #NAME); \
+    return(RVAL); \
+}
+
+#define PS_INT_CHECK_RANGE(NAME, LOWER, UPPER, RVAL) \
+if ((int)NAME < LOWER || (int)NAME > UPPER) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s, %d, is out of range.  Must be between %d and %d.", \
+            #NAME,(int)NAME,LOWER,UPPER); \
+    return RVAL; \
+}
+
+// Produce an error if (NAME1 > NAME2)
 #define PS_INT_COMPARE(NAME1, NAME2, RVAL) \
 if (NAME1 > NAME2) { \
-    psError(__func__,"Error: (%s > %s) (%d %d).", #NAME1, #NAME2, NAME1, NAME2); \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: (%s > %s) (%d %d).", \
+            #NAME1, #NAME2, NAME1, NAME2); \
     return(RVAL); \
 }
@@ -53,5 +65,7 @@
 #define PS_FLOAT_COMPARE(NAME1, NAME2, RVAL) \
 if (NAME1 > NAME2) { \
-    psError(__func__,"Error: (%s > %s) (%f %f)", #NAME1, #NAME2, NAME1, NAME2); \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: (%s > %s) (%f %f)", \
+            #NAME1, #NAME2, NAME1, NAME2); \
     return(RVAL); \
 }
@@ -59,5 +73,7 @@
 #define PS_FLOAT_CHECK_NON_EQUAL(NAME1, NAME2, RVAL) \
 if (fabs(NAME2 - NAME1) < FLT_EPSILON) { \
-    psError(__func__,"Error: %s and %s are equal.", #NAME1, #NAME2); \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s and %s are equal.", \
+            #NAME1, #NAME2); \
     return(RVAL); \
 }
@@ -67,26 +83,47 @@
 the wrong type.
 *****************************************************************************/
-#define PS_PTR_CHECK_NULL(NAME, RVAL) \
+#define PS_PTR_CHECK_NULL(NAME, RVAL) PS_PTR_CHECK_NULL_GENERAL(NAME, return RVAL)
+#define PS_PTR_CHECK_NULL_GENERAL(NAME, CLEANUP) \
 if (NAME == NULL) { \
-    psError(__func__,"Unallowable operation: %s is NULL.", #NAME); \
-    return(RVAL); \
+    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
+            "Unallowable operation: %s is NULL.", \
+            #NAME); \
+    CLEANUP; \
 }
 
 #define PS_PTR_CHECK_TYPE(NAME, TYPE, RVAL) \
 if (NAME->type.type != TYPE) { \
-    psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \
-    return(RVAL); \
-}
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "Unallowable operation: %s has incorrect type.", \
+            #NAME); \
+    return(RVAL); \
+}
+
+#define PS_PTR_CHECK_DIMEN(NAME, DIMEN, RVAL) PS_PTR_CHECK_DIMEN_GENERAL(NAME, DIMEN, return RVAL)
+#define PS_PTR_CHECK_DIMEN_GENERAL(NAME, DIMEN, CLEANUP) \
+if (NAME->type.dimen != DIMEN) { \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "Unallowable operation: %s has incorrect dimensionality.", \
+            #NAME); \
+    CLEANUP; \
+}
+
 
 #define PS_PTR_CHECK_SIZE_EQUAL(PTR1, PTR2, RVAL) \
 if (PTR1->n != PTR2->n) { \
-    psError(__func__,"ptr %s has size %d, ptr %s has size %d.", #PTR1, PTR1->n, #PTR2, PTR2->n); \
-    return(RVAL); \
-}
-
-#define PS_PTR_CHECK_TYPE_EQUAL(PTR1, PTR2, RVAL) \
+    psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
+            "ptr %s has size %d, ptr %s has size %d.", \
+            #PTR1, PTR1->n, #PTR2, PTR2->n); \
+    return(RVAL); \
+}
+
+#define PS_PTR_CHECK_TYPE_EQUAL(PTR1, PTR2, RVAL) PS_PTR_CHECK_TYPE_EQUAL_GENERAL(PTR1, PTR2, return RVAL)
+
+#define PS_PTR_CHECK_TYPE_EQUAL_GENERAL(PTR1, PTR2, CLEANUP) \
 if (PTR1->type.type != PTR2->type.type) { \
-    psError(__func__,"ptr %s has type %d, ptr %s has type %d.", #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \
-    return(RVAL); \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "ptr %s has type %d, ptr %s has type %d.", \
+            #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \
+    CLEANUP; \
 }
 
@@ -95,13 +132,18 @@
     PS_VECTOR macros:
  *****************************************************************************/
-#define PS_VECTOR_CHECK_NULL(NAME, RVAL) \
+#define PS_VECTOR_CHECK_NULL(NAME, RVAL) PS_VECTOR_CHECK_NULL_GENERAL(NAME, return RVAL)
+#define PS_VECTOR_CHECK_NULL_GENERAL(NAME, CLEANUP) \
 if (NAME == NULL || NAME->data.V == NULL) { \
-    psError(__func__,"Unallowable operation: psVector %s or its data is NULL.", #NAME); \
-    return(RVAL); \
+    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
+            "Unallowable operation: psVector %s or its data is NULL.", \
+            #NAME); \
+    CLEANUP; \
 } \
 
 #define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) \
 if (NAME->n < 1) { \
-    psError(__func__,"Unallowable operation: psVector %s has no elements.", #NAME); \
+    psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
+            "Unallowable operation: psVector %s has no elements.", \
+            #NAME); \
     return(RVAL); \
 } \
@@ -109,5 +151,7 @@
 #define PS_VECTOR_CHECK_TYPE_F32_OR_F64(NAME, RVAL) \
 if ((NAME->type.type != PS_TYPE_F32) && (NAME->type.type != PS_TYPE_F64)) { \
-    psError(__func__, "psVector %s: bad type(%d)", #NAME, NAME->type.type); \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "psVector %s: bad type(%d)", \
+            #NAME, NAME->type.type); \
     return(RVAL); \
 } \
@@ -115,5 +159,7 @@
 #define PS_VECTOR_CHECK_TYPE(NAME, TYPE, RVAL) \
 if (NAME->type.type != TYPE) { \
-    psError(__func__,"Unallowable operation: psVector %s has incorrect type.", #NAME); \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "Unallowable operation: psVector %s has incorrect type.", \
+            #NAME); \
     return(RVAL); \
 }
@@ -121,5 +167,7 @@
 #define PS_VECTOR_CHECK_SIZE_EQUAL(VEC1, VEC2, RVAL) \
 if (VEC1->n != VEC2->n) { \
-    psError(__func__,"psVector %s has size %d, psVector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \
+    psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
+            "psVector %s has size %d, psVector %s has size %d.", \
+            #VEC1, VEC1->n, #VEC2, VEC2->n); \
     return(RVAL); \
 }
@@ -221,5 +269,7 @@
 #define PS_POLY_CHECK_NULL(NAME, RVAL) \
 if (NAME == NULL || NAME->coeff == NULL) { \
-    psError(__func__,"Unallowable operation: polynomial %s or its coeffs is NULL.", #NAME); \
+    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
+            "Unallowable operation: polynomial %s or its coeffs is NULL.", \
+            #NAME); \
     return(RVAL); \
 } \
@@ -227,5 +277,6 @@
 #define PS_POLY_CHECK_TYPE(NAME, TYPE, RVAL) \
 if (NAME->type != TYPE) { \
-    psError(__func__,"Unallowable operation: polynomial %s has wrong type.", #NAME); \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "Unallowable operation: polynomial %s has wrong type.", #NAME); \
     return(RVAL); \
 } \
@@ -234,20 +285,27 @@
     PS_IMAGE macros:
 *****************************************************************************/
-#define PS_IMAGE_CHECK_NULL(NAME, RVAL) \
+#define PS_IMAGE_CHECK_NULL(NAME, RVAL) PS_IMAGE_CHECK_NULL_GENERAL(NAME, return RVAL)
+#define PS_IMAGE_CHECK_NULL_GENERAL(NAME, CLEANUP) \
 if (NAME == NULL || NAME->data.V == NULL) { \
-    psError(__func__,"Unallowable operation: psImage %s or its data is NULL.", #NAME); \
-    return(RVAL); \
-}
-
-#define PS_IMAGE_CHECK_EMPTY(NAME, RVAL) \
+    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
+            "Unallowable operation: psImage %s or its data is NULL.", \
+            #NAME); \
+    CLEANUP; \
+}
+
+#define PS_IMAGE_CHECK_EMPTY(NAME, RVAL) PS_IMAGE_CHECK_EMPTY_GENERAL(NAME, return RVAL)
+#define PS_IMAGE_CHECK_EMPTY_GENERAL(NAME, CLEANUP) \
 if (NAME->numCols < 1 || NAME->numRows < 1) { \
-    psError(__func__,"Unallowable operation: psImage %s has zero rows or columns (%dx%d).", #NAME, \
-            NAME->numCols, NAME->numRows); \
-    return(RVAL); \
+    psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
+            "Unallowable operation: psImage %s has zero rows or columns (%dx%d).", \
+            #NAME, NAME->numCols, NAME->numRows); \
+    CLEANUP; \
 }
 
 #define PS_IMAGE_CHECK_TYPE(NAME, TYPE, RVAL) \
 if (NAME->type.type != TYPE) { \
-    psError(__func__,"Unallowable operation: psImage %s has incorrect type.", #NAME); \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "Unallowable operation: psImage %s has incorrect type.", \
+            #NAME); \
     return(RVAL); \
 }
@@ -260,5 +318,7 @@
 #define PS_READOUT_CHECK_NULL(NAME, RVAL) \
 if (NAME == NULL || NAME->image == NULL) { \
-    psError(__func__,"Unallowable operation: psReadout %s or its data is NULL.", #NAME); \
+    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
+            "Unallowable operation: psReadout %s or its data is NULL.", \
+            #NAME); \
     return(RVAL); \
 }
Index: /trunk/psLib/src/math/psMatrix.c
===================================================================
--- /trunk/psLib/src/math/psMatrix.c	(revision 2272)
+++ /trunk/psLib/src/math/psMatrix.c	(revision 2273)
@@ -20,6 +20,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 20:20:11 $
+ *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:59 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -40,53 +40,17 @@
 #include "psVector.h"
 #include "psMatrix.h"
-
-/** Preprocessor macro to generate error a NULL image */
-#define PS_VECTOR_CHECK_NULL(NAME, RETURN)                                                          \
-if (NAME == NULL || NAME->data.V == NULL) {                                                         \
-    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
-    return RETURN;                                                                                  \
-}
-
-/** Preprocessor macro to create vector based on another */
-#define PS_CHECK_ALLOC_VECTOR(NAME, SIZE, PS_TYPE)                                                  \
-if(NAME == NULL) {                                                                                  \
-    NAME = psVectorAlloc(SIZE, PS_TYPE);                                                            \
-}
-
-/** Preprocessor macro to generate error for zero length vector */
-#define PS_CHECK_SIZE_VECTOR(NAME, RETURN)                                                          \
-if (NAME->n < 1) {                                                                                  \
-    psError(__func__,"Invalid operation: %s has zero n value.", #NAME);                             \
-    return RETURN;                                                                                  \
-}
-
-/** Preprocessor macro to generate error a NULL image */
-#define PS_IMAGE_CHECK_NULL(NAME, RETURN)                                                           \
-if (NAME == NULL || NAME->data.V == NULL) {                                                         \
-    psError(__func__,"Invalid operation: %s or its data is NULL.", #NAME);                          \
-    return RETURN;                                                                                  \
-}
-
-/** Preprocessor macro to create image based on another */
-#define PS_CHECK_ALLOC_IMAGE(NAME, NCOLS, NROWS, PS_TYPE)                                           \
-if(NAME == NULL) {                                                                                  \
-    NAME = psImageAlloc(NCOLS, NROWS, PS_TYPE);                                                     \
-}
-
-/** Preprocessor macro to generate error for zero length rows or columns */
-#define PS_CHECK_SIZE_IMAGE(NAME, RETURN)                                                           \
-if (NAME->numCols < 1 || NAME->numRows < 1) {                                                       \
-    psError(__func__,"Invalid operation: %s has zero rows or columns (%dx%d).", #NAME,              \
-            NAME->numCols, NAME->numRows);                                                          \
-    return RETURN;                                                                                  \
-}
+#include "psConstants.h"
+
+
 
 /** Preprocessor macro to generate error for image dimensionality not set to PS_DIMEN_IMAGE */
 #define PS_CHECK_DIMEN_AND_TYPE(NAME, PS_DIMEN, RETURN)                                             \
 if (NAME->type.dimen != PS_DIMEN) {                                                                 \
-    psError(__func__,"Invalid operation: %s incorrect dimensionality %d.", #NAME, PS_DIMEN);        \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true,                                                        \
+            "Invalid operation. %s has incorrect dimensionality %d.", #NAME, PS_DIMEN);             \
     return RETURN;                                                                                  \
 } else if(NAME->type.type != PS_TYPE_F64) {                                                         \
-    psError(__func__, "Invalid operation: %s not PS_TYPE_F64.", #NAME);                             \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true,                                                        \
+            "Invalid operation. %s not PS_TYPE_F64.", #NAME);                                       \
     return RETURN;                                                                                  \
 }
@@ -95,5 +59,6 @@
 #define PS_CHECK_POINTERS(NAME1, NAME2, RETURN)                                                     \
 if (NAME1 == NAME2) {                                                                               \
-    psError(__func__,"Invalid operation: Pointer to %s is same as %s.", #NAME1, #NAME2);            \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true,                                                       \
+            "Invalid operation: Pointer to %s is same as %s.", #NAME1, #NAME2);                     \
     return RETURN;                                                                                  \
 }
@@ -102,5 +67,6 @@
 #define PS_CHECK_SQUARE(NAME, RETURN)                                                               \
 if (NAME->numCols != NAME->numRows) {                                                               \
-    psError(__func__,"Invalid operation: %s not square array.", #NAME);                             \
+    psError(PS_ERR_BAD_PARAMETER_SIZE, true,                                                       \
+            "Invalid operation: %s not square array.", #NAME);                             \
     return RETURN;                                                                                  \
 }
@@ -126,15 +92,20 @@
     gsl_permutation perm;
 
+    #define psMatrixLUD_EXIT { \
+                               psFree(outImage); \
+                               return NULL; \
+                             }
+
     // Error checks
     PS_CHECK_POINTERS(inImage, outImage, outImage);
-    PS_IMAGE_CHECK_NULL(inImage, outImage);
     PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(inImage, outImage);
-    PS_CHECK_ALLOC_IMAGE(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
-    PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(outImage, outImage);
-    PS_CHECK_ALLOC_VECTOR(outPerm, inImage->numRows, inImage->type.type);
-    PS_VECTOR_CHECK_NULL(outPerm, outImage);
+
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage, psMatrixLUD_EXIT);
+    PS_VECTOR_CHECK_NULL_GENERAL(outPerm, psMatrixLUD_EXIT);
+
     PS_CHECK_DIMEN_AND_TYPE(outPerm, PS_DIMEN_VECTOR, outImage);
+
+    psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
+    psVectorRecycle(outPerm, inImage->numRows, inImage->type.type);
 
     // Initialize data
@@ -179,6 +150,5 @@
     PS_IMAGE_CHECK_NULL(inImage, outVector);
     PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outVector);
-    PS_CHECK_SIZE_IMAGE(inImage, outVector);
-    PS_CHECK_ALLOC_VECTOR(outVector, inImage->numRows, inImage->type.type);
+    PS_IMAGE_CHECK_EMPTY(inImage, outVector);
     PS_VECTOR_CHECK_NULL(outVector, outVector);
     PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_VECTOR, outVector);
@@ -188,4 +158,7 @@
     PS_CHECK_DIMEN_AND_TYPE(inPerm, PS_DIMEN_VECTOR, outVector);
 
+    psVectorRecycle(outVector, inImage->numRows, inImage->type.type);
+
+
     // Initialize data
     numRows = inImage->numRows;
@@ -226,15 +199,11 @@
 
     // Error checks
-    if (det == NULL) {
-        psError(__func__, "Invalid operation: determinant argument is NULL.");
-        return outImage;
-    }
+    PS_PTR_CHECK_NULL(det, outImage);
     PS_CHECK_POINTERS(inImage, outImage, outImage);
     PS_IMAGE_CHECK_NULL(inImage, outImage);
     PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(inImage, outImage);
-    PS_CHECK_ALLOC_IMAGE(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
-    PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(outImage, outImage);
+    PS_IMAGE_CHECK_EMPTY(inImage, outImage);
+
+    psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
 
     // Initialize data
@@ -282,5 +251,5 @@
     PS_IMAGE_CHECK_NULL(inImage, NULL);
     PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, NULL);
-    PS_CHECK_SIZE_IMAGE(inImage, NULL);
+    PS_IMAGE_CHECK_EMPTY(inImage, NULL);
 
     // Initialize data
@@ -325,11 +294,11 @@
     PS_IMAGE_CHECK_NULL(inImage1, outImage);
     PS_CHECK_DIMEN_AND_TYPE(inImage1, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(inImage1, outImage);
+    PS_IMAGE_CHECK_EMPTY(inImage1, outImage);
     PS_IMAGE_CHECK_NULL(inImage2, outImage);
     PS_CHECK_DIMEN_AND_TYPE(inImage2, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(inImage2, outImage);
-    PS_CHECK_ALLOC_IMAGE(outImage, inImage2->numCols, inImage2->numRows, inImage2->type.type);
+    PS_IMAGE_CHECK_EMPTY(inImage2, outImage);
     PS_CHECK_DIMEN_AND_TYPE(inImage1, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(outImage, outImage);
+
+    psImageRecycle(outImage, inImage2->numCols, inImage2->numRows, inImage2->type.type);
 
     // Initialize data
@@ -364,8 +333,7 @@
     PS_IMAGE_CHECK_NULL(inImage, outImage);
     PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(inImage, outImage);
-    PS_CHECK_ALLOC_IMAGE(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
-    PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(outImage, outImage);
+    PS_IMAGE_CHECK_EMPTY(inImage, outImage);
+
+    psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
 
     // Initialize data
@@ -403,8 +371,7 @@
     PS_IMAGE_CHECK_NULL(inImage, outImage);
     PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(inImage, outImage);
-    PS_CHECK_ALLOC_IMAGE(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
-    PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage);
-    PS_CHECK_SIZE_IMAGE(outImage, outImage);
+    PS_IMAGE_CHECK_EMPTY(inImage, outImage);
+
+    psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
 
     // Initialize data
@@ -438,19 +405,25 @@
     psS32 size = 0;
 
-    // Error checks
-    PS_IMAGE_CHECK_NULL(inImage, outVector);
+    #define psMatrixToVector_EXIT { \
+                                    psFree(outVector); \
+                                    return NULL; \
+                                  }
+
+    // Error checks
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage, psMatrixToVector_EXIT);
     PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outVector);
-    PS_CHECK_SIZE_IMAGE(inImage, outVector);
+    PS_IMAGE_CHECK_EMPTY_GENERAL(inImage, psMatrixToVector_EXIT);
 
     if (inImage->numRows == 1) {
         // Create transposed row vector
-        PS_CHECK_ALLOC_VECTOR(outVector, inImage->numCols, inImage->type.type);
+        psVectorRecycle(outVector, inImage->numCols, inImage->type.type);
         outVector->type.dimen = PS_DIMEN_TRANSV;
     } else if (inImage->numCols == 1) {
         // Create non-transposed column vector
-        PS_CHECK_ALLOC_VECTOR(outVector, inImage->numRows, inImage->type.type);
+        psVectorRecycle(outVector, inImage->numRows, inImage->type.type);
     } else {
-        psError(__func__, "Image does not have dim with 1 col or 1 row: (%d x %d).", inImage->numRows,
-                inImage->numCols);
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                "Image does not have dim with 1 col or 1 row: (%d x %d).",
+                inImage->numRows, inImage->numCols);
         return outVector;
     }
@@ -467,5 +440,7 @@
 
         if (outVector->n != inImage->numRows) {
-            psError(__func__, "Image and vector sizes differ: (%d vs %d).", inImage->numRows, outVector->n);
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    "Image and vector sizes differ: (%d vs %d).",
+                    inImage->numRows, outVector->n);
             return outVector;
         }
@@ -481,5 +456,7 @@
 
         if (outVector->n != inImage->numCols) {
-            psError(__func__, "Image and vector sizes differ: (%d vs %d).", inImage->numCols, outVector->n);
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    "Image and vector sizes differ: (%d vs %d).",
+                    inImage->numCols, outVector->n);
             return outVector;
         }
@@ -502,12 +479,16 @@
     if (inVector->type.dimen == PS_DIMEN_VECTOR) {
         PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_VECTOR, outImage);
-        PS_CHECK_SIZE_VECTOR(inVector, outImage);
-        PS_CHECK_ALLOC_IMAGE(outImage, 1, inVector->n, PS_TYPE_F64)
+        PS_VECTOR_CHECK_EMPTY(inVector, outImage);
+        psImageRecycle(outImage, 1, inVector->n, PS_TYPE_F64);
         // More checks for PS_DIMEN_VECTOR
         if (outImage->numCols > 1) {
-            psError(__func__, "Image has more than 1 column: numCols = %d.", outImage->numCols);
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    "Image has more than 1 column: numCols = %d.",
+                    outImage->numCols);
             return outImage;
         } else if (outImage->numRows != inVector->n) {
-            psError(__func__, "Image and vector sizes differ: (%d vs %d).", outImage->numRows, inVector->n);
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    "Image and vector sizes differ: (%d vs %d).",
+                    outImage->numRows, inVector->n);
             return outImage;
         }
@@ -517,12 +498,16 @@
     } else if (inVector->type.dimen == PS_DIMEN_TRANSV) {
         PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_TRANSV, outImage);
-        PS_CHECK_SIZE_VECTOR(inVector, outImage);
-        PS_CHECK_ALLOC_IMAGE(outImage, inVector->n, 1, PS_TYPE_F64)
+        PS_VECTOR_CHECK_EMPTY(inVector, outImage);
+        psImageRecycle(outImage, inVector->n, 1, PS_TYPE_F64);
         // More checks for PS_DIMEN_TRANSV
         if (outImage->numRows > 1) {
-            psError(__func__, "Image has more than 1 row: numRows = %d.", outImage->numRows);
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    "Image has more than 1 row: numRows = %d.",
+                    outImage->numRows);
             return outImage;
         } else if (outImage->numCols != inVector->n) {
-            psError(__func__, "Image and vector sizes differ: (%d vs %d).", outImage->numCols, inVector->n);
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    "Image and vector sizes differ: (%d vs %d).",
+                    outImage->numCols, inVector->n);
             return outImage;
         }
Index: /trunk/psLib/src/math/psMinimize.c
===================================================================
--- /trunk/psLib/src/math/psMinimize.c	(revision 2272)
+++ /trunk/psLib/src/math/psMinimize.c	(revision 2273)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-03 03:30:30 $
+ *  @version $Revision: 1.85 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:59 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -291,5 +291,6 @@
 
     if (y32->n != (1 + mySpline->n)) {
-        psError(__func__, "data size / spline size mismatch (%d %d)\n",
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                "data size / spline size mismatch (%d %d)\n",
                 y32->n, mySpline->n);
         return(NULL);
@@ -318,5 +319,6 @@
     // Check if these are cubic splines (n==4).  If not, psError.
     if (4 != (mySpline->spline[0])->n) {
-        psError(__func__, "Don't know how to generate %d-order splines.",
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                "Don't know how to generate %d-order splines.",
                 (mySpline->spline[0])->n-1);
         return(NULL);
@@ -952,5 +954,5 @@
         PS_VECTOR_GEN_X_INDEX_STATIC_F64(x64Static, y->n);
         if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-            p_psNormalizeVectorRange(x64Static, -1.0, 1.0);
+            psNormalizeVectorRange(x64Static, -1.0, 1.0);
         }
         x64 = x64Static;
@@ -968,5 +970,6 @@
         tmpPoly = VectorFitPolynomial1DOrd(myPoly, x64, y64, yErr64);
     } else {
-        psError(__func__, "unknown polynomial type.\n");
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "unknown polynomial type.\n");
         return(NULL);
     }
@@ -1365,5 +1368,6 @@
     bracket = p_psDetermineBracket2(params, line, paramMask, coords, func);
     if (bracket == NULL) {
-        psError(__func__, "(1) Could not bracket minimum.");
+        psError(PS_ERR_UNKNOWN, false,
+                "Could not bracket minimum.");
         return(NAN);
     }
@@ -1552,5 +1556,6 @@
                                   func);
                 if (isnan(mul)) {
-                    psError(__func__, "Could not perform line minimization (1).\n");
+                    psError(PS_ERR_UNKNOWN, false,
+                            "Could not perform line minimization");
                     psFree(v);
                     return(false);
@@ -1592,5 +1597,6 @@
         mul = p_psLineMin(&dummyMin, params, u, myParamMask, coords, func);
         if (isnan(mul)) {
-            psError(__func__, "Could not perform line minimization. (2)\n");
+            psError(PS_ERR_UNKNOWN, false,
+                    "Could not perform line minimization.");
             psFree(v);
             return(false);
Index: /trunk/psLib/src/math/psPolynomial.c
===================================================================
--- /trunk/psLib/src/math/psPolynomial.c	(revision 2272)
+++ /trunk/psLib/src/math/psPolynomial.c	(revision 2273)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.58 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-28 00:22:53 $
+ *  @version $Revision: 1.59 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:59 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -35,4 +35,7 @@
 #include "psFunctions.h"
 #include "psConstants.h"
+
+#include "psDataManipErrors.h"
+
 /*****************************************************************************/
 /* DEFINE STATEMENTS                                                         */
@@ -50,4 +53,7 @@
 static void dPolynomial3DFree(psDPolynomial3D* myPoly);
 static void dPolynomial4DFree(psDPolynomial4D* myPoly);
+static void spline1DFree(psSpline1D *tmpSpline);
+static psS32 vectorBinDisectF32(float *bins,psS32 numBins,float x);
+static psS32 vectorBinDisectS32(psS32 *bins,psS32 numBins,psS32 x);
 
 /*****************************************************************************/
@@ -67,6 +73,167 @@
 /*****************************************************************************/
 
+static void spline1DFree(psSpline1D *tmpSpline)
+{
+    psS32 i;
+
+    if (tmpSpline == NULL) {
+        return;
+    }
+
+    if (tmpSpline->spline != NULL) {
+        for (i=0;i<tmpSpline->n;i++) {
+            psFree((tmpSpline->spline)[i]);
+        }
+        psFree(tmpSpline->spline);
+    }
+
+    if (tmpSpline->p_psDeriv2 != NULL) {
+        psFree(tmpSpline->p_psDeriv2);
+    }
+    psFree(tmpSpline->domains);
+
+    return;
+}
+
+static void polynomial1DFree(psPolynomial1D* myPoly)
+{
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void polynomial2DFree(psPolynomial2D* myPoly)
+{
+    psS32 x = 0;
+
+    for (x = 0; x < myPoly->nX; x++) {
+        psFree(myPoly->coeff[x]);
+        psFree(myPoly->coeffErr[x]);
+        psFree(myPoly->mask[x]);
+    }
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void polynomial3DFree(psPolynomial3D* myPoly)
+{
+    psS32 x = 0;
+    psS32 y = 0;
+
+    for (x = 0; x < myPoly->nX; x++) {
+        for (y = 0; y < myPoly->nY; y++) {
+            psFree(myPoly->coeff[x][y]);
+            psFree(myPoly->coeffErr[x][y]);
+            psFree(myPoly->mask[x][y]);
+        }
+        psFree(myPoly->coeff[x]);
+        psFree(myPoly->coeffErr[x]);
+        psFree(myPoly->mask[x]);
+    }
+
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void polynomial4DFree(psPolynomial4D* myPoly)
+{
+    psS32 w = 0;
+    psS32 x = 0;
+    psS32 y = 0;
+
+    for (w = 0; w < myPoly->nW; w++) {
+        for (x = 0; x < myPoly->nX; x++) {
+            for (y = 0; y < myPoly->nY; y++) {
+                psFree(myPoly->coeff[w][x][y]);
+                psFree(myPoly->coeffErr[w][x][y]);
+                psFree(myPoly->mask[w][x][y]);
+            }
+            psFree(myPoly->coeff[w][x]);
+            psFree(myPoly->coeffErr[w][x]);
+            psFree(myPoly->mask[w][x]);
+        }
+        psFree(myPoly->coeff[w]);
+        psFree(myPoly->coeffErr[w]);
+        psFree(myPoly->mask[w]);
+    }
+
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void dPolynomial1DFree(psDPolynomial1D* myPoly)
+{
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void dPolynomial2DFree(psDPolynomial2D* myPoly)
+{
+    psS32 x = 0;
+
+    for (x = 0; x < myPoly->nX; x++) {
+        psFree(myPoly->coeff[x]);
+        psFree(myPoly->coeffErr[x]);
+        psFree(myPoly->mask[x]);
+    }
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void dPolynomial3DFree(psDPolynomial3D* myPoly)
+{
+    psS32 x = 0;
+    psS32 y = 0;
+
+    for (x = 0; x < myPoly->nX; x++) {
+        for (y = 0; y < myPoly->nY; y++) {
+            psFree(myPoly->coeff[x][y]);
+            psFree(myPoly->coeffErr[x][y]);
+            psFree(myPoly->mask[x][y]);
+        }
+        psFree(myPoly->coeff[x]);
+        psFree(myPoly->coeffErr[x]);
+        psFree(myPoly->mask[x]);
+    }
+
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void dPolynomial4DFree(psDPolynomial4D* myPoly)
+{
+    psS32 w = 0;
+    psS32 x = 0;
+    psS32 y = 0;
+
+    for (w = 0; w < myPoly->nW; w++) {
+        for (x = 0; x < myPoly->nX; x++) {
+            for (y = 0; y < myPoly->nY; y++) {
+                psFree(myPoly->coeff[w][x][y]);
+                psFree(myPoly->coeffErr[w][x][y]);
+                psFree(myPoly->mask[w][x][y]);
+            }
+            psFree(myPoly->coeff[w][x]);
+            psFree(myPoly->coeffErr[w][x]);
+            psFree(myPoly->mask[w][x]);
+        }
+        psFree(myPoly->coeff[w]);
+        psFree(myPoly->coeffErr[w]);
+        psFree(myPoly->mask[w]);
+    }
+
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
 /*****************************************************************************
-CreateChebyshevPolys(n): this routine takes as input the required order n,
+createChebyshevPolys(n): this routine takes as input the required order n,
 and returns as output as a pointer to an array of n psPolynomial1D
 structures, corresponding to the first n Chebyshev polynomials.
@@ -76,5 +243,5 @@
 outer coefficients of the Chebyshev polynomials.
  *****************************************************************************/
-static psPolynomial1D **CreateChebyshevPolys(psS32 maxChebyPoly)
+static psPolynomial1D **createChebyshevPolys(psS32 maxChebyPoly)
 {
     PS_INT_CHECK_NON_NEGATIVE(maxChebyPoly, NULL);
@@ -103,4 +270,655 @@
 
     return (chebPolys);
+}
+
+/*****************************************************************************
+    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
+ 
+    XXX: Should the "coeffErr[]" should be used as well?
+ *****************************************************************************/
+static float ordPolynomial1DEval(float x, const psPolynomial1D* myPoly)
+{
+    psS32 loop_x = 0;
+    float polySum = 0.0;
+    float xSum = 1.0;
+
+    psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4,
+            "---- Calling ordPolynomial1DEval(%f)\n", x);
+    psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4,
+            "Polynomial order is %d\n", myPoly->n);
+    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
+        psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4,
+                "Polynomial coeff[%d] is %f\n", loop_x, myPoly->coeff[loop_x]);
+    }
+
+    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
+        if (myPoly->mask[loop_x] == 0) {
+            psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 10,
+                    "polysum+= sum*coeff [%f+= (%f * %f)\n", polySum, xSum, myPoly->coeff[loop_x]);
+            polySum += xSum * myPoly->coeff[loop_x];
+            xSum *= x;
+        }
+    }
+
+    return(polySum);
+}
+
+// XXX: You can do this without having to psAlloc() vector d.
+// XXX: How does the mask vector effect Crenshaw's formula?
+static float chebPolynomial1DEval(float x, const psPolynomial1D* myPoly)
+{
+    psVector *d;
+    psS32 n;
+    psS32 i;
+    float tmp;
+
+    n = myPoly->n;
+    d = psVectorAlloc(n, PS_TYPE_F32);
+    d->data.F32[n-1] = myPoly->coeff[n-1];
+    d->data.F32[n-2] = (2.0 * x * d->data.F32[n-1]) + myPoly->coeff[n-2];
+    for (i=n-3;i>=1;i--) {
+        d->data.F32[i] = (2.0 * x * d->data.F32[i+1]) -
+                         (d->data.F32[i+2]) +
+                         (myPoly->coeff[i]);
+    }
+
+    tmp = (x * d->data.F32[1]) -
+          (d->data.F32[2]) +
+          (0.5 * myPoly->coeff[0]);
+
+    psFree(d);
+    return(tmp);
+    /*
+
+    psS32 n;
+    psS32 i;
+    float tmp;
+    psPolynomial1D **chebPolys = NULL;
+
+    n = myPoly->n;
+    chebPolys = createChebyshevPolys(n);
+
+    tmp = 0.0;
+    for (i=0;i<myPoly->n;i++) {
+        tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i]));
+        //            printf("HMMM: psPolynomial1DEval(%f, chebPolys[%d]) is %f\n", x, i, psPolynomial1DEval(x, chebPolys[i]));
+    }
+    tmp-= (myPoly->coeff[0]/2.0);
+
+
+    return(tmp);
+    */
+}
+
+static float ordPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
+{
+    PS_POLY_CHECK_NULL(myPoly, NAN);
+
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    float polySum = 0.0;
+    float xSum = 1.0;
+    float ySum = 1.0;
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        ySum = xSum;
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            if (myPoly->mask[loop_x][loop_y] == 0) {
+                polySum += ySum * myPoly->coeff[loop_x][loop_y];
+                ySum *= y;
+            }
+        }
+        xSum *= x;
+    }
+
+    return(polySum);
+}
+
+static float chebPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
+{
+    PS_POLY_CHECK_NULL(myPoly, NAN);
+
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 i = 0;
+    float polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nX;
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            if (myPoly->mask[loop_x][loop_y] == 0) {
+                polySum += myPoly->coeff[loop_x][loop_y] *
+                           psPolynomial1DEval(x, chebPolys[loop_x]) *
+                           psPolynomial1DEval(y, chebPolys[loop_y]);
+            }
+        }
+    }
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+static float ordPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    float polySum = 0.0;
+    float xSum = 1.0;
+    float ySum = 1.0;
+    float zSum = 1.0;
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        ySum = xSum;
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            zSum = ySum;
+            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
+                    polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];
+                    zSum *= z;
+                }
+            }
+            ySum *= y;
+        }
+        xSum *= x;
+    }
+
+    return(polySum);
+}
+
+static float chebPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    psS32 i = 0;
+    float polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nX;
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    if (myPoly->nZ > maxChebyPoly) {
+        maxChebyPoly = myPoly->nZ;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
+                    polySum += myPoly->coeff[loop_x][loop_y][loop_z] *
+                               psPolynomial1DEval(x, chebPolys[loop_x]) *
+                               psPolynomial1DEval(y, chebPolys[loop_y]) *
+                               psPolynomial1DEval(z, chebPolys[loop_z]);
+                }
+            }
+        }
+    }
+
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+static float ordPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
+{
+    psS32 loop_w = 0;
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    float polySum = 0.0;
+    float wSum = 1.0;
+    float xSum = 1.0;
+    float ySum = 1.0;
+    float zSum = 1.0;
+
+    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
+        xSum = wSum;
+        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+            ySum = xSum;
+            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+                zSum = ySum;
+                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
+                        polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];
+                        zSum *= z;
+                    }
+                }
+                ySum *= y;
+            }
+            xSum *= x;
+        }
+        wSum *= w;
+    }
+
+    return(polySum);
+}
+
+static float chebPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
+{
+    psS32 loop_w = 0;
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    psS32 i = 0;
+    float polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nW;
+    if (myPoly->nX > maxChebyPoly) {
+        maxChebyPoly = myPoly->nX;
+    }
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    if (myPoly->nZ > maxChebyPoly) {
+        maxChebyPoly = myPoly->nZ;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
+        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
+                        polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *
+                                   psPolynomial1DEval(w, chebPolys[loop_w]) *
+                                   psPolynomial1DEval(x, chebPolys[loop_x]) *
+                                   psPolynomial1DEval(y, chebPolys[loop_y]) *
+                                   psPolynomial1DEval(z, chebPolys[loop_z]);
+                    }
+                }
+            }
+        }
+    }
+
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+/*****************************************************************************
+    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
+ *****************************************************************************/
+static double dOrdPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
+{
+    psS32 loop_x = 0;
+    double polySum = 0.0;
+    double xSum = 1.0;
+
+    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
+        if (myPoly->mask[loop_x] == 0) {
+            polySum += xSum * myPoly->coeff[loop_x];
+            xSum *= x;
+        }
+    }
+
+    return(polySum);
+}
+
+// XXX: You can do this without having to psAlloc() vector d.
+// XXX: How does the mask vector effect Crenshaw's formula?
+static double dChebPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
+{
+    psVector *d;
+    psS32 n;
+    psS32 i;
+    double tmp;
+
+    n = myPoly->n;
+    d = psVectorAlloc(n, PS_TYPE_F64);
+    d->data.F64[n-1] = myPoly->coeff[n-1];
+    d->data.F64[n-2] = (2.0 * x * d->data.F64[n-1]) + myPoly->coeff[n-2];
+    for (i=n-3;i>=1;i--) {
+        d->data.F64[i] = (2.0 * x * d->data.F64[i+1]) -
+                         (d->data.F64[i+2]) +
+                         (myPoly->coeff[i]);
+    }
+
+    tmp = (x * d->data.F64[1]) -
+          (d->data.F64[2]) +
+          (0.5 * myPoly->coeff[0]);
+
+    psFree(d);
+    return(tmp);
+}
+
+static double dOrdPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    double polySum = 0.0;
+    double xSum = 1.0;
+    double ySum = 1.0;
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        ySum = xSum;
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            if (myPoly->mask[loop_x][loop_y] == 0) {
+                polySum += ySum * myPoly->coeff[loop_x][loop_y];
+                ySum *= y;
+            }
+        }
+        xSum *= x;
+    }
+
+    return(polySum);
+}
+
+static double dChebPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 i = 0;
+    double polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nX;
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            if (myPoly->mask[loop_x][loop_y] == 0) {
+                polySum += myPoly->coeff[loop_x][loop_y] *
+                           psPolynomial1DEval(x, chebPolys[loop_x]) *
+                           psPolynomial1DEval(y, chebPolys[loop_y]);
+            }
+        }
+    }
+
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+static double dOrdPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    double polySum = 0.0;
+    double xSum = 1.0;
+    double ySum = 1.0;
+    double zSum = 1.0;
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        ySum = xSum;
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            zSum = ySum;
+            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
+                    polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];
+                    zSum *= z;
+                }
+            }
+            ySum *= y;
+        }
+        xSum *= x;
+    }
+
+    return(polySum);
+}
+
+static double dChebPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    psS32 i = 0;
+    double polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nX;
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    if (myPoly->nZ > maxChebyPoly) {
+        maxChebyPoly = myPoly->nZ;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
+                    polySum += myPoly->coeff[loop_x][loop_y][loop_z] *
+                               psPolynomial1DEval(x, chebPolys[loop_x]) *
+                               psPolynomial1DEval(y, chebPolys[loop_y]) *
+                               psPolynomial1DEval(z, chebPolys[loop_z]);
+                }
+            }
+        }
+    }
+
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+static double dOrdPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
+{
+    psS32 loop_w = 0;
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    double polySum = 0.0;
+    double wSum = 1.0;
+    double xSum = 1.0;
+    double ySum = 1.0;
+    double zSum = 1.0;
+
+    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
+        xSum = wSum;
+        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+            ySum = xSum;
+            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+                zSum = ySum;
+                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
+                        polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];
+                        zSum *= z;
+                    }
+                }
+                ySum *= y;
+            }
+            xSum *= x;
+        }
+        wSum *= w;
+    }
+
+    return(polySum);
+}
+
+static double dChebPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
+{
+    psS32 loop_w = 0;
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    psS32 i = 0;
+    double polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nW;
+    if (myPoly->nX > maxChebyPoly) {
+        maxChebyPoly = myPoly->nX;
+    }
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    if (myPoly->nZ > maxChebyPoly) {
+        maxChebyPoly = myPoly->nZ;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
+        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
+                        polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *
+                                   psPolynomial1DEval(w, chebPolys[loop_w]) *
+                                   psPolynomial1DEval(x, chebPolys[loop_x]) *
+                                   psPolynomial1DEval(y, chebPolys[loop_y]) *
+                                   psPolynomial1DEval(z, chebPolys[loop_z]);
+                    }
+                }
+            }
+        }
+    }
+
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+
+/*****************************************************************************
+p_psInterpolate1D(): This routine will take as input n-element floating
+point arrays domain and range, and the x value, assumed to lie with the
+domain vector.  It produces as output the (n-1)-order LaGrange interpolated
+value of x.
+ 
+XXX: do we error check for non-distinct domain values?
+ *****************************************************************************/
+static float fullInterpolate1DF32(float *domain,
+                                  float *range,
+                                  psS32 n,
+                                  float x)
+{
+    PS_INT_CHECK_NON_NEGATIVE(n, NAN);
+    PS_PTR_CHECK_NULL(domain, NAN);
+    PS_PTR_CHECK_NULL(range, NAN);
+
+    psS32 i;
+    psS32 m;
+    static psVector *p = NULL;
+    p = psVectorRecycle(p, n, PS_TYPE_F32);
+    p_psMemSetPersistent(p, true);
+    p_psMemSetPersistent(p->data.F32, true);
+    /*
+        psVector *p = psVectorAlloc(n, PS_TYPE_F32);
+        float tmp;
+    */
+
+    psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 4,
+            "---- fullInterpolate1DF32() begin (%d-order at x=%f) (%d data points)----\n", n-1, x, n);
+
+    for (i=0;i<n;i++) {
+        psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6,
+                "domain/range is (%f %f)\n", domain[i], range[i]);
+    }
+
+    for (i=0;i<n;i++) {
+        p->data.F32[i] = range[i];
+        psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6,
+                "p->data.F32[%d] is %f\n", i, p->data.F32[i]);
+
+    }
+
+    // From NR, during each iteration of the m loop, we are computing the
+    // p_{i ... i+m} terms.
+    for (m=1;m<n;m++) {
+        for (i=0;i<n-m;i++) {
+            // From NR: we are computing P_{i ... i+m}
+            p->data.F32[i] = (((x-domain[i+m]) * p->data.F32[i]) +
+                              ((domain[i]-x) * p->data.F32[i+1])) /
+                             (domain[i] - domain[i+m]);
+            //printf("((%f-%f * %f) + (%f-%f * %f)) / (%f - %f)\n", x, domain[i+m], p->data.F32[i], domain[i], x, p->data.F32[i+1], domain[i], domain[i+m]);
+            psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6,
+                    "p->data.F32[%d] is %f\n", i, p->data.F32[i]);
+        }
+    }
+    psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 4,
+            "---- fullInterpolate1DF32() end ----\n");
+
+    /*
+        tmp = p->data.F32[0];
+        psFree(p);
+        return(tmp);
+    */
+    return(p->data.F32[0]);
+}
+
+
+/*****************************************************************************
+interpolate1DF32(): this is the base 1-D flat memory routine to perform
+LaGrange interpolation.
+ *****************************************************************************/
+static float interpolate1DF32(float *domain,
+                              float *range,
+                              psS32 n,
+                              psS32 order,
+                              float x)
+{
+    psS32 binNum;
+    psS32 numIntPoints = order+1;
+    psS32 origin;
+
+    psTrace(".psLib.dataManip.psFunctions.interpolate1DF32", 4,
+            "---- interpolate1DF32() begin ----\n");
+
+    binNum = vectorBinDisectF32(domain, n, x);
+
+    if (0 == numIntPoints%2) {
+        origin = binNum - ((numIntPoints/2) - 1);
+    } else {
+        origin = binNum - (numIntPoints/2);
+        if ((x-domain[binNum]) > (domain[binNum+1]-x)) {
+            // x is closer to binNum+1.
+            origin = 1 + (binNum - (numIntPoints/2));
+        }
+    }
+    if (origin < 0) {
+        origin = 0;
+    }
+    if ((origin + numIntPoints) > n) {
+        origin = n - numIntPoints;
+    }
+
+    psTrace(".psLib.dataManip.psFunctions.interpolate1DF32", 4,
+            "---- interpolate1DF32() end ----\n");
+    return(fullInterpolate1DF32(&domain[origin], &range[origin], order+1, x));
 }
 
@@ -336,152 +1154,4 @@
 }
 
-static void polynomial1DFree(psPolynomial1D* myPoly)
-{
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void polynomial2DFree(psPolynomial2D* myPoly)
-{
-    psS32 x = 0;
-
-    for (x = 0; x < myPoly->nX; x++) {
-        psFree(myPoly->coeff[x]);
-        psFree(myPoly->coeffErr[x]);
-        psFree(myPoly->mask[x]);
-    }
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void polynomial3DFree(psPolynomial3D* myPoly)
-{
-    psS32 x = 0;
-    psS32 y = 0;
-
-    for (x = 0; x < myPoly->nX; x++) {
-        for (y = 0; y < myPoly->nY; y++) {
-            psFree(myPoly->coeff[x][y]);
-            psFree(myPoly->coeffErr[x][y]);
-            psFree(myPoly->mask[x][y]);
-        }
-        psFree(myPoly->coeff[x]);
-        psFree(myPoly->coeffErr[x]);
-        psFree(myPoly->mask[x]);
-    }
-
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void polynomial4DFree(psPolynomial4D* myPoly)
-{
-    psS32 w = 0;
-    psS32 x = 0;
-    psS32 y = 0;
-
-    for (w = 0; w < myPoly->nW; w++) {
-        for (x = 0; x < myPoly->nX; x++) {
-            for (y = 0; y < myPoly->nY; y++) {
-                psFree(myPoly->coeff[w][x][y]);
-                psFree(myPoly->coeffErr[w][x][y]);
-                psFree(myPoly->mask[w][x][y]);
-            }
-            psFree(myPoly->coeff[w][x]);
-            psFree(myPoly->coeffErr[w][x]);
-            psFree(myPoly->mask[w][x]);
-        }
-        psFree(myPoly->coeff[w]);
-        psFree(myPoly->coeffErr[w]);
-        psFree(myPoly->mask[w]);
-    }
-
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-/*****************************************************************************
-    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
- 
-    XXX: Should the "coeffErr[]" should be used as well?
- *****************************************************************************/
-float p_psOrdPolynomial1DEval(float x, const psPolynomial1D* myPoly)
-{
-    psS32 loop_x = 0;
-    float polySum = 0.0;
-    float xSum = 1.0;
-
-    psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,
-            "---- Calling p_psOrdPolynomial1DEval(%f)\n", x);
-    psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,
-            "Polynomial order is %d\n", myPoly->n);
-    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
-        psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,
-                "Polynomial coeff[%d] is %f\n", loop_x, myPoly->coeff[loop_x]);
-    }
-
-    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
-        if (myPoly->mask[loop_x] == 0) {
-            psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 10,
-                    "polysum+= sum*coeff [%f+= (%f * %f)\n", polySum, xSum, myPoly->coeff[loop_x]);
-            polySum += xSum * myPoly->coeff[loop_x];
-            xSum *= x;
-        }
-    }
-
-    return(polySum);
-}
-
-// XXX: You can do this without having to psAlloc() vector d.
-// XXX: How does the mask vector effect Crenshaw's formula?
-float p_psChebPolynomial1DEval(float x, const psPolynomial1D* myPoly)
-{
-    psVector *d;
-    psS32 n;
-    psS32 i;
-    float tmp;
-
-    n = myPoly->n;
-    d = psVectorAlloc(n, PS_TYPE_F32);
-    d->data.F32[n-1] = myPoly->coeff[n-1];
-    d->data.F32[n-2] = (2.0 * x * d->data.F32[n-1]) + myPoly->coeff[n-2];
-    for (i=n-3;i>=1;i--) {
-        d->data.F32[i] = (2.0 * x * d->data.F32[i+1]) -
-                         (d->data.F32[i+2]) +
-                         (myPoly->coeff[i]);
-    }
-
-    tmp = (x * d->data.F32[1]) -
-          (d->data.F32[2]) +
-          (0.5 * myPoly->coeff[0]);
-
-    psFree(d);
-    return(tmp);
-    /*
-
-    psS32 n;
-    psS32 i;
-    float tmp;
-    psPolynomial1D **chebPolys = NULL;
-
-    n = myPoly->n;
-    chebPolys = CreateChebyshevPolys(n);
-
-    tmp = 0.0;
-    for (i=0;i<myPoly->n;i++) {
-        tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i]));
-        //            printf("HMMM: psPolynomial1DEval(%f, chebPolys[%d]) is %f\n", x, i, psPolynomial1DEval(x, chebPolys[i]));
-    }
-    tmp-= (myPoly->coeff[0]/2.0);
-
-
-    return(tmp);
-    */
-}
-
 float psPolynomial1DEval(float x, const psPolynomial1D* myPoly)
 {
@@ -489,9 +1159,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psOrdPolynomial1DEval(x, myPoly));
+        return(ordPolynomial1DEval(x, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psChebPolynomial1DEval(x, myPoly));
+        return(chebPolynomial1DEval(x, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -520,78 +1192,19 @@
 }
 
-
-float p_psOrdPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
+float psPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
 {
     PS_POLY_CHECK_NULL(myPoly, NAN);
 
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    float polySum = 0.0;
-    float xSum = 1.0;
-    float ySum = 1.0;
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        ySum = xSum;
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            if (myPoly->mask[loop_x][loop_y] == 0) {
-                polySum += ySum * myPoly->coeff[loop_x][loop_y];
-                ySum *= y;
-            }
-        }
-        xSum *= x;
-    }
-
-    return(polySum);
-}
-
-float p_psChebPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
-{
-    PS_POLY_CHECK_NULL(myPoly, NAN);
-
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 i = 0;
-    float polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nX;
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            if (myPoly->mask[loop_x][loop_y] == 0) {
-                polySum += myPoly->coeff[loop_x][loop_y] *
-                           psPolynomial1DEval(x, chebPolys[loop_x]) *
-                           psPolynomial1DEval(y, chebPolys[loop_y]);
-            }
-        }
-    }
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
-float psPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
-{
-    PS_POLY_CHECK_NULL(myPoly, NAN);
-
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psOrdPolynomial2DEval(x, y, myPoly));
+        return(ordPolynomial2DEval(x, y, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psChebPolynomial2DEval(x, y, myPoly));
+        return(chebPolynomial2DEval(x, y, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
 }
-
 
 psVector *psPolynomial2DEvalVector(const psVector *x,
@@ -632,75 +1245,4 @@
 }
 
-
-
-float p_psOrdPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    float polySum = 0.0;
-    float xSum = 1.0;
-    float ySum = 1.0;
-    float zSum = 1.0;
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        ySum = xSum;
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            zSum = ySum;
-            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
-                    polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];
-                    zSum *= z;
-                }
-            }
-            ySum *= y;
-        }
-        xSum *= x;
-    }
-
-    return(polySum);
-}
-
-float p_psChebPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    psS32 i = 0;
-    float polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nX;
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    if (myPoly->nZ > maxChebyPoly) {
-        maxChebyPoly = myPoly->nZ;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
-                    polySum += myPoly->coeff[loop_x][loop_y][loop_z] *
-                               psPolynomial1DEval(x, chebPolys[loop_x]) *
-                               psPolynomial1DEval(y, chebPolys[loop_y]) *
-                               psPolynomial1DEval(z, chebPolys[loop_z]);
-                }
-            }
-        }
-    }
-
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
 float psPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
 {
@@ -708,9 +1250,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psOrdPolynomial3DEval(x, y, z, myPoly));
+        return(ordPolynomial3DEval(x, y, z, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psChebPolynomial3DEval(x, y, z, myPoly));
+        return(chebPolynomial3DEval(x, y, z, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -765,91 +1309,4 @@
 }
 
-
-
-
-
-
-float p_psOrdPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
-{
-    psS32 loop_w = 0;
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    float polySum = 0.0;
-    float wSum = 1.0;
-    float xSum = 1.0;
-    float ySum = 1.0;
-    float zSum = 1.0;
-
-    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
-        xSum = wSum;
-        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-            ySum = xSum;
-            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-                zSum = ySum;
-                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
-                        polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];
-                        zSum *= z;
-                    }
-                }
-                ySum *= y;
-            }
-            xSum *= x;
-        }
-        wSum *= w;
-    }
-
-    return(polySum);
-}
-
-float p_psChebPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
-{
-    psS32 loop_w = 0;
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    psS32 i = 0;
-    float polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nW;
-    if (myPoly->nX > maxChebyPoly) {
-        maxChebyPoly = myPoly->nX;
-    }
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    if (myPoly->nZ > maxChebyPoly) {
-        maxChebyPoly = myPoly->nZ;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
-        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
-                        polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *
-                                   psPolynomial1DEval(w, chebPolys[loop_w]) *
-                                   psPolynomial1DEval(x, chebPolys[loop_x]) *
-                                   psPolynomial1DEval(y, chebPolys[loop_y]) *
-                                   psPolynomial1DEval(z, chebPolys[loop_z]);
-                    }
-                }
-            }
-        }
-    }
-
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
 float psPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
 {
@@ -857,9 +1314,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psOrdPolynomial4DEval(w,x,y,z, myPoly));
+        return(ordPolynomial4DEval(w,x,y,z, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psChebPolynomial4DEval(w,x,y,z, myPoly));
+        return(chebPolynomial4DEval(w,x,y,z, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -924,7 +1383,4 @@
     return(tmp);
 }
-
-
-
 
 
@@ -1092,118 +1548,4 @@
 }
 
-static void dPolynomial1DFree(psDPolynomial1D* myPoly)
-{
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void dPolynomial2DFree(psDPolynomial2D* myPoly)
-{
-    psS32 x = 0;
-
-    for (x = 0; x < myPoly->nX; x++) {
-        psFree(myPoly->coeff[x]);
-        psFree(myPoly->coeffErr[x]);
-        psFree(myPoly->mask[x]);
-    }
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void dPolynomial3DFree(psDPolynomial3D* myPoly)
-{
-    psS32 x = 0;
-    psS32 y = 0;
-
-    for (x = 0; x < myPoly->nX; x++) {
-        for (y = 0; y < myPoly->nY; y++) {
-            psFree(myPoly->coeff[x][y]);
-            psFree(myPoly->coeffErr[x][y]);
-            psFree(myPoly->mask[x][y]);
-        }
-        psFree(myPoly->coeff[x]);
-        psFree(myPoly->coeffErr[x]);
-        psFree(myPoly->mask[x]);
-    }
-
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void dPolynomial4DFree(psDPolynomial4D* myPoly)
-{
-    psS32 w = 0;
-    psS32 x = 0;
-    psS32 y = 0;
-
-    for (w = 0; w < myPoly->nW; w++) {
-        for (x = 0; x < myPoly->nX; x++) {
-            for (y = 0; y < myPoly->nY; y++) {
-                psFree(myPoly->coeff[w][x][y]);
-                psFree(myPoly->coeffErr[w][x][y]);
-                psFree(myPoly->mask[w][x][y]);
-            }
-            psFree(myPoly->coeff[w][x]);
-            psFree(myPoly->coeffErr[w][x]);
-            psFree(myPoly->mask[w][x]);
-        }
-        psFree(myPoly->coeff[w]);
-        psFree(myPoly->coeffErr[w]);
-        psFree(myPoly->mask[w]);
-    }
-
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-/*****************************************************************************
-    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
- *****************************************************************************/
-double p_psDOrdPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
-{
-    psS32 loop_x = 0;
-    double polySum = 0.0;
-    double xSum = 1.0;
-
-    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
-        if (myPoly->mask[loop_x] == 0) {
-            polySum += xSum * myPoly->coeff[loop_x];
-            xSum *= x;
-        }
-    }
-
-    return(polySum);
-}
-
-// XXX: You can do this without having to psAlloc() vector d.
-// XXX: How does the mask vector effect Crenshaw's formula?
-double p_psDChebPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
-{
-    psVector *d;
-    psS32 n;
-    psS32 i;
-    double tmp;
-
-    n = myPoly->n;
-    d = psVectorAlloc(n, PS_TYPE_F64);
-    d->data.F64[n-1] = myPoly->coeff[n-1];
-    d->data.F64[n-2] = (2.0 * x * d->data.F64[n-1]) + myPoly->coeff[n-2];
-    for (i=n-3;i>=1;i--) {
-        d->data.F64[i] = (2.0 * x * d->data.F64[i+1]) -
-                         (d->data.F64[i+2]) +
-                         (myPoly->coeff[i]);
-    }
-
-    tmp = (x * d->data.F64[1]) -
-          (d->data.F64[2]) +
-          (0.5 * myPoly->coeff[0]);
-
-    psFree(d);
-    return(tmp);
-}
 
 double psDPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
@@ -1212,9 +1554,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psDOrdPolynomial1DEval(x, myPoly));
+        return(dOrdPolynomial1DEval(x, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psDChebPolynomial1DEval(x, myPoly));
+        return(dChebPolynomial1DEval(x, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -1244,61 +1588,4 @@
 
 
-
-double p_psDOrdPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    double polySum = 0.0;
-    double xSum = 1.0;
-    double ySum = 1.0;
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        ySum = xSum;
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            if (myPoly->mask[loop_x][loop_y] == 0) {
-                polySum += ySum * myPoly->coeff[loop_x][loop_y];
-                ySum *= y;
-            }
-        }
-        xSum *= x;
-    }
-
-    return(polySum);
-}
-
-double p_psDChebPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 i = 0;
-    double polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nX;
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            if (myPoly->mask[loop_x][loop_y] == 0) {
-                polySum += myPoly->coeff[loop_x][loop_y] *
-                           psPolynomial1DEval(x, chebPolys[loop_x]) *
-                           psPolynomial1DEval(y, chebPolys[loop_y]);
-            }
-        }
-    }
-
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
 double psDPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
 {
@@ -1306,9 +1593,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psDOrdPolynomial2DEval(x, y, myPoly));
+        return(dOrdPolynomial2DEval(x, y, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psDChebPolynomial2DEval(x, y, myPoly));
+        return(dChebPolynomial2DEval(x, y, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -1353,74 +1642,4 @@
 
 
-
-double p_psDOrdPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    double polySum = 0.0;
-    double xSum = 1.0;
-    double ySum = 1.0;
-    double zSum = 1.0;
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        ySum = xSum;
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            zSum = ySum;
-            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
-                    polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];
-                    zSum *= z;
-                }
-            }
-            ySum *= y;
-        }
-        xSum *= x;
-    }
-
-    return(polySum);
-}
-
-double p_psDChebPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    psS32 i = 0;
-    double polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nX;
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    if (myPoly->nZ > maxChebyPoly) {
-        maxChebyPoly = myPoly->nZ;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
-                    polySum += myPoly->coeff[loop_x][loop_y][loop_z] *
-                               psPolynomial1DEval(x, chebPolys[loop_x]) *
-                               psPolynomial1DEval(y, chebPolys[loop_y]) *
-                               psPolynomial1DEval(z, chebPolys[loop_z]);
-                }
-            }
-        }
-    }
-
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
 double psDPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
 {
@@ -1428,9 +1647,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psDOrdPolynomial3DEval(x, y, z, myPoly));
+        return(dOrdPolynomial3DEval(x, y, z, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psDChebPolynomial3DEval(x, y, z, myPoly));
+        return(dChebPolynomial3DEval(x, y, z, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -1485,93 +1706,4 @@
 }
 
-
-
-
-
-
-
-
-double p_psDOrdPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
-{
-    psS32 loop_w = 0;
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    double polySum = 0.0;
-    double wSum = 1.0;
-    double xSum = 1.0;
-    double ySum = 1.0;
-    double zSum = 1.0;
-
-    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
-        xSum = wSum;
-        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-            ySum = xSum;
-            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-                zSum = ySum;
-                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
-                        polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];
-                        zSum *= z;
-                    }
-                }
-                ySum *= y;
-            }
-            xSum *= x;
-        }
-        wSum *= w;
-    }
-
-    return(polySum);
-}
-
-double p_psDChebPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
-{
-    psS32 loop_w = 0;
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    psS32 i = 0;
-    double polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nW;
-    if (myPoly->nX > maxChebyPoly) {
-        maxChebyPoly = myPoly->nX;
-    }
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    if (myPoly->nZ > maxChebyPoly) {
-        maxChebyPoly = myPoly->nZ;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
-        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
-                        polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *
-                                   psPolynomial1DEval(w, chebPolys[loop_w]) *
-                                   psPolynomial1DEval(x, chebPolys[loop_x]) *
-                                   psPolynomial1DEval(y, chebPolys[loop_y]) *
-                                   psPolynomial1DEval(z, chebPolys[loop_z]);
-                    }
-                }
-            }
-        }
-    }
-
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
 double psDPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
 {
@@ -1579,9 +1711,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psDOrdPolynomial4DEval(w,x,y,z, myPoly));
+        return(dOrdPolynomial4DEval(w,x,y,z, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psDChebPolynomial4DEval(w,x,y,z, myPoly));
+        return(dChebPolynomial4DEval(w,x,y,z, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -1699,31 +1833,8 @@
     (tmp->domains)[numSplines] = max;
 
+    p_psMemSetDeallocator(tmp,(psFreeFcn)spline1DFree);
     return(tmp);
 }
 
-// XXX: Have Robert put the dealocator in the memory file.
-psS32 p_psSpline1DFree(psSpline1D *tmpSpline)
-{
-    psS32 i;
-
-    if (tmpSpline == NULL) {
-        return(0);
-    }
-
-    if (tmpSpline->spline != NULL) {
-        for (i=0;i<tmpSpline->n;i++) {
-            psFree((tmpSpline->spline)[i]);
-        }
-        psFree(tmpSpline->spline);
-    }
-
-    if (tmpSpline->p_psDeriv2 != NULL) {
-        psFree(tmpSpline->p_psDeriv2);
-    }
-    psFree(tmpSpline->domains);
-    psFree(tmpSpline);
-
-    return(0);
-}
 
 /*****************************************************************************
@@ -1765,5 +1876,5 @@
 
 /*****************************************************************************
-p_psVectorBinDisectF32(): This is a private function which takes as input a
+vectorBinDisectF32(): This is a private function which takes as input a
 vector of floating point data as well as a single floating point values.
 The input vector values are assumed to be non-decreasing (v[i-1] <= v[j] for
@@ -1776,7 +1887,7 @@
 XXX: name since we don't take psVectors as input.
  *****************************************************************************/
-psS32 p_psVectorBinDisectF32(float *bins,
-                             psS32 numBins,
-                             float x)
+static psS32 vectorBinDisectF32(float *bins,
+                                psS32 numBins,
+                                float x)
 {
     psS32 min;
@@ -1784,10 +1895,10 @@
     psS32 mid;
 
-    psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4,
-            "---- Calling p_psVectorBinDisectF32(%f)\n", x);
+    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
+            "---- Calling vectorBinDisectF32(%f)\n", x);
 
     if (x < bins[0]) {
         psLogMsg(__func__, PS_LOG_WARN,
-                 "p_psVectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",
+                 "vectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",
                  x, bins[0], bins[numBins-1]);
         return(-2);
@@ -1796,5 +1907,5 @@
     if (x > bins[numBins-1]) {
         psLogMsg(__func__, PS_LOG_WARN,
-                 "p_psVectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",
+                 "vectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",
                  x, bins[0], bins[numBins-1]);
         return(-1);
@@ -1806,11 +1917,11 @@
 
     while (min != max) {
-        psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4,
+        psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
                 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n",
                 min, mid, max, x, bins[mid]);
 
         if (x == bins[mid]) {
-            psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4,
-                    "---- Exiting p_psVectorBinDisectF32(): bin %d\n", mid);
+            psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
+                    "---- Exiting vectorBinDisectF32(): bin %d\n", mid);
             return(mid);
         } else if (x < bins[mid]) {
@@ -1822,15 +1933,15 @@
     }
 
-    psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4,
-            "---- Exiting p_psVectorBinDisectF32(): bin %d\n", min);
+    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
+            "---- Exiting vectorBinDisectF32(): bin %d\n", min);
     return(min);
 }
 
 /*****************************************************************************
-p_psVectorBinDisectS32(): integer version of above.
+vectorBinDisectS32(): integer version of above.
  *****************************************************************************/
-psS32 p_psVectorBinDisectS32(psS32 *bins,
-                             psS32 numBins,
-                             psS32 x)
+static psS32 vectorBinDisectS32(psS32 *bins,
+                                psS32 numBins,
+                                psS32 x)
 {
     psS32 min;
@@ -1838,11 +1949,11 @@
     psS32 mid;
 
-    psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4,
-            "---- Calling p_psVectorBinDisectS32(%f)\n", x);
+    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
+            "---- Calling vectorBinDisectS32(%f)\n", x);
 
     if ((x < bins[0]) ||
             (x > bins[numBins-1])) {
         psLogMsg(__func__, PS_LOG_WARN,
-                 "p_psVectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).",
+                 "vectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).",
                  x, bins[0], bins[numBins-1]);
         return(-1);
@@ -1854,11 +1965,11 @@
 
     while (min != max) {
-        psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4,
+        psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
                 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n",
                 min, mid, max, x, bins[mid]);
 
         if (x == bins[mid]) {
-            psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4,
-                    "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min);
+            psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
+                    "---- Exiting vectorBinDisectS32(): bin %d\n", min);
             return(min);
         } else if (x < bins[mid]) {
@@ -1870,6 +1981,6 @@
     }
 
-    psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4,
-            "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min);
+    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
+            "---- Exiting vectorBinDisectS32(): bin %d\n", min);
     return(min);
 }
@@ -1884,120 +1995,16 @@
 
     if (x->type.type == PS_TYPE_S32) {
-        return(p_psVectorBinDisectS32(bins->data.S32, bins->n, x->data.S32));
+        return(vectorBinDisectS32(bins->data.S32, bins->n, x->data.S32));
     } else if (x->type.type == PS_TYPE_F32) {
-        return(p_psVectorBinDisectF32(bins->data.F32, bins->n, x->data.F32));
+        return(vectorBinDisectF32(bins->data.F32, bins->n, x->data.F32));
     } else {
-        psError(__func__, "Unallowable data type.");
+        char* strType;
+        PS_TYPE_NAME(strType,x->type.type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE,
+                PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED,
+                strType);
         return(-2);
     }
     return(-1);
-}
-
-/*****************************************************************************
-p_psInterpolate1D(): This routine will take as input n-element floating
-point arrays domain and range, and the x value, assumed to lie with the
-domain vector.  It produces as output the (n-1)-order LaGrange interpolated
-value of x.
- 
-XXX: do we error check for non-distinct domain values?
- *****************************************************************************/
-float p_ps1DFullInterpolateF32(float *domain,
-                               float *range,
-                               psS32 n,
-                               float x)
-{
-    PS_INT_CHECK_NON_NEGATIVE(n, NAN);
-    PS_PTR_CHECK_NULL(domain, NAN);
-    PS_PTR_CHECK_NULL(range, NAN);
-
-    psS32 i;
-    psS32 m;
-    static psVector *p = NULL;
-    p = psVectorRecycle(p, n, PS_TYPE_F32);
-    p_psMemSetPersistent(p, true);
-    p_psMemSetPersistent(p->data.F32, true);
-    /*
-        psVector *p = psVectorAlloc(n, PS_TYPE_F32);
-        float tmp;
-    */
-
-    psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 4,
-            "---- p_ps1DFullInterpolateF32() begin (%d-order at x=%f) (%d data points)----\n", n-1, x, n);
-
-    for (i=0;i<n;i++) {
-        psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,
-                "domain/range is (%f %f)\n", domain[i], range[i]);
-    }
-
-    for (i=0;i<n;i++) {
-        p->data.F32[i] = range[i];
-        psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,
-                "p->data.F32[%d] is %f\n", i, p->data.F32[i]);
-
-    }
-
-    // From NR, during each iteration of the m loop, we are computing the
-    // p_{i ... i+m} terms.
-    for (m=1;m<n;m++) {
-        for (i=0;i<n-m;i++) {
-            // From NR: we are computing P_{i ... i+m}
-            p->data.F32[i] = (((x-domain[i+m]) * p->data.F32[i]) +
-                              ((domain[i]-x) * p->data.F32[i+1])) /
-                             (domain[i] - domain[i+m]);
-            //printf("((%f-%f * %f) + (%f-%f * %f)) / (%f - %f)\n", x, domain[i+m], p->data.F32[i], domain[i], x, p->data.F32[i+1], domain[i], domain[i+m]);
-            psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,
-                    "p->data.F32[%d] is %f\n", i, p->data.F32[i]);
-        }
-    }
-    psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 4,
-            "---- p_ps1DFullInterpolateF32() end ----\n");
-
-    /*
-        tmp = p->data.F32[0];
-        psFree(p);
-        return(tmp);
-    */
-    return(p->data.F32[0]);
-}
-
-
-/*****************************************************************************
-p_ps1DInterpolateF32(): this is the base 1-D flat memory routine to perform
-LaGrange interpolation.
- *****************************************************************************/
-float p_ps1DInterpolateF32(float *domain,
-                           float *range,
-                           psS32 n,
-                           psS32 order,
-                           float x)
-{
-    psS32 binNum;
-    psS32 numIntPoints = order+1;
-    psS32 origin;
-
-    psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4,
-            "---- p_ps1DInterpolateF32() begin ----\n");
-
-    binNum = p_psVectorBinDisectF32(domain, n, x);
-
-    if (0 == numIntPoints%2) {
-        origin = binNum - ((numIntPoints/2) - 1);
-    } else {
-        origin = binNum - (numIntPoints/2);
-        if ((x-domain[binNum]) > (domain[binNum+1]-x)) {
-            // x is closer to binNum+1.
-            origin = 1 + (binNum - (numIntPoints/2));
-        }
-    }
-    if (origin < 0) {
-        origin = 0;
-    }
-    if ((origin + numIntPoints) > n) {
-        origin = n - numIntPoints;
-    }
-
-    psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4,
-            "---- p_ps1DInterpolateF32() end ----\n");
-    return(p_ps1DFullInterpolateF32(&domain[origin], &range[origin], order+1, x));
 }
 
@@ -2035,5 +2042,7 @@
 
     if (order > (domain->n - 1)) {
-        psError(__func__, "not enough data points for %d-order interpolation.\n", order);
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                PS_ERRORTEXT_psFunctions_NOT_ENOUGH_DATAPOINTS,
+                order);
         return(NULL);
     }
@@ -2042,9 +2051,9 @@
         psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4,
                 "---- p_psVectorInterpolate() end ----\n");
-        return(psScalarAlloc(p_ps1DInterpolateF32(domain->data.F32,
-                             range->data.F32,
-                             domain->n,
-                             order,
-                             x->data.F32), PS_TYPE_F32));
+        return(psScalarAlloc(interpolate1DF32(domain->data.F32,
+                                              range->data.F32,
+                                              domain->n,
+                                              order,
+                                              x->data.F32), PS_TYPE_F32));
     } else if (x->type.type == PS_TYPE_F64) {
         // XXX: use recycled vectors here.
@@ -2053,9 +2062,9 @@
 
         psScalar *tmpScalar = psScalarAlloc((double)
-                                            p_ps1DInterpolateF32(domain32->data.F32,
-                                                                 range32->data.F32,
-                                                                 domain32->n,
-                                                                 order,
-                                                                 (float) x->data.F64), PS_TYPE_F64);
+                                            interpolate1DF32(domain32->data.F32,
+                                                             range32->data.F32,
+                                                             domain32->n,
+                                                             order,
+                                                             (float) x->data.F64), PS_TYPE_F64);
         psFree(range32);
         psFree(domain32);
@@ -2067,6 +2076,9 @@
 
     } else {
-        // XXX psError: type not supported
-        psError(__func__, "type %d not supported\n", x->type.type);
+        char* strType;
+        PS_TYPE_NAME(strType,x->type.type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE,
+                PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED,
+                strType);
     }
 
@@ -2084,5 +2096,5 @@
 and an independent x value.  Each determines which spline that x corresponds
 to by doing a bracket disection on the domains of the spline data structure
-(p_psVectorBinDisectF32()).  Then it evaluates the spline at that x location
+(vectorBinDisectF32()).  Then it evaluates the spline at that x location
 by a call to the 1D polynomial functions.
  
@@ -2100,5 +2112,5 @@
 
     n = spline->n;
-    binNum = p_psVectorBinDisectF32(spline->domains, (spline->n)+1, x);
+    binNum = vectorBinDisectF32(spline->domains, (spline->n)+1, x);
     if (binNum < 0) {
         psLogMsg(__func__, PS_LOG_WARN,
@@ -2139,5 +2151,9 @@
         }
     } else {
-        psError(__func__, "Unknown data type.\n");
+        char* strType;
+        PS_TYPE_NAME(strType,x->type.type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE,
+                PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED,
+                strType);
         return(NULL);
     }
Index: /trunk/psLib/src/math/psPolynomial.h
===================================================================
--- /trunk/psLib/src/math/psPolynomial.h	(revision 2272)
+++ /trunk/psLib/src/math/psPolynomial.h	(revision 2273)
@@ -12,6 +12,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-11-03 03:30:30 $
+*  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:04:59 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -398,6 +398,4 @@
                             float max);
 
-psS32 p_psSpline1DFree(psSpline1D *tmpSpline);
-
 psSpline1D *psSpline1DAllocGeneric(const psVector *bounds,
                                    psS32 order);
Index: /trunk/psLib/src/math/psSpline.c
===================================================================
--- /trunk/psLib/src/math/psSpline.c	(revision 2272)
+++ /trunk/psLib/src/math/psSpline.c	(revision 2273)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.58 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-28 00:22:53 $
+ *  @version $Revision: 1.59 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:59 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -35,4 +35,7 @@
 #include "psFunctions.h"
 #include "psConstants.h"
+
+#include "psDataManipErrors.h"
+
 /*****************************************************************************/
 /* DEFINE STATEMENTS                                                         */
@@ -50,4 +53,7 @@
 static void dPolynomial3DFree(psDPolynomial3D* myPoly);
 static void dPolynomial4DFree(psDPolynomial4D* myPoly);
+static void spline1DFree(psSpline1D *tmpSpline);
+static psS32 vectorBinDisectF32(float *bins,psS32 numBins,float x);
+static psS32 vectorBinDisectS32(psS32 *bins,psS32 numBins,psS32 x);
 
 /*****************************************************************************/
@@ -67,6 +73,167 @@
 /*****************************************************************************/
 
+static void spline1DFree(psSpline1D *tmpSpline)
+{
+    psS32 i;
+
+    if (tmpSpline == NULL) {
+        return;
+    }
+
+    if (tmpSpline->spline != NULL) {
+        for (i=0;i<tmpSpline->n;i++) {
+            psFree((tmpSpline->spline)[i]);
+        }
+        psFree(tmpSpline->spline);
+    }
+
+    if (tmpSpline->p_psDeriv2 != NULL) {
+        psFree(tmpSpline->p_psDeriv2);
+    }
+    psFree(tmpSpline->domains);
+
+    return;
+}
+
+static void polynomial1DFree(psPolynomial1D* myPoly)
+{
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void polynomial2DFree(psPolynomial2D* myPoly)
+{
+    psS32 x = 0;
+
+    for (x = 0; x < myPoly->nX; x++) {
+        psFree(myPoly->coeff[x]);
+        psFree(myPoly->coeffErr[x]);
+        psFree(myPoly->mask[x]);
+    }
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void polynomial3DFree(psPolynomial3D* myPoly)
+{
+    psS32 x = 0;
+    psS32 y = 0;
+
+    for (x = 0; x < myPoly->nX; x++) {
+        for (y = 0; y < myPoly->nY; y++) {
+            psFree(myPoly->coeff[x][y]);
+            psFree(myPoly->coeffErr[x][y]);
+            psFree(myPoly->mask[x][y]);
+        }
+        psFree(myPoly->coeff[x]);
+        psFree(myPoly->coeffErr[x]);
+        psFree(myPoly->mask[x]);
+    }
+
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void polynomial4DFree(psPolynomial4D* myPoly)
+{
+    psS32 w = 0;
+    psS32 x = 0;
+    psS32 y = 0;
+
+    for (w = 0; w < myPoly->nW; w++) {
+        for (x = 0; x < myPoly->nX; x++) {
+            for (y = 0; y < myPoly->nY; y++) {
+                psFree(myPoly->coeff[w][x][y]);
+                psFree(myPoly->coeffErr[w][x][y]);
+                psFree(myPoly->mask[w][x][y]);
+            }
+            psFree(myPoly->coeff[w][x]);
+            psFree(myPoly->coeffErr[w][x]);
+            psFree(myPoly->mask[w][x]);
+        }
+        psFree(myPoly->coeff[w]);
+        psFree(myPoly->coeffErr[w]);
+        psFree(myPoly->mask[w]);
+    }
+
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void dPolynomial1DFree(psDPolynomial1D* myPoly)
+{
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void dPolynomial2DFree(psDPolynomial2D* myPoly)
+{
+    psS32 x = 0;
+
+    for (x = 0; x < myPoly->nX; x++) {
+        psFree(myPoly->coeff[x]);
+        psFree(myPoly->coeffErr[x]);
+        psFree(myPoly->mask[x]);
+    }
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void dPolynomial3DFree(psDPolynomial3D* myPoly)
+{
+    psS32 x = 0;
+    psS32 y = 0;
+
+    for (x = 0; x < myPoly->nX; x++) {
+        for (y = 0; y < myPoly->nY; y++) {
+            psFree(myPoly->coeff[x][y]);
+            psFree(myPoly->coeffErr[x][y]);
+            psFree(myPoly->mask[x][y]);
+        }
+        psFree(myPoly->coeff[x]);
+        psFree(myPoly->coeffErr[x]);
+        psFree(myPoly->mask[x]);
+    }
+
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
+static void dPolynomial4DFree(psDPolynomial4D* myPoly)
+{
+    psS32 w = 0;
+    psS32 x = 0;
+    psS32 y = 0;
+
+    for (w = 0; w < myPoly->nW; w++) {
+        for (x = 0; x < myPoly->nX; x++) {
+            for (y = 0; y < myPoly->nY; y++) {
+                psFree(myPoly->coeff[w][x][y]);
+                psFree(myPoly->coeffErr[w][x][y]);
+                psFree(myPoly->mask[w][x][y]);
+            }
+            psFree(myPoly->coeff[w][x]);
+            psFree(myPoly->coeffErr[w][x]);
+            psFree(myPoly->mask[w][x]);
+        }
+        psFree(myPoly->coeff[w]);
+        psFree(myPoly->coeffErr[w]);
+        psFree(myPoly->mask[w]);
+    }
+
+    psFree(myPoly->coeff);
+    psFree(myPoly->coeffErr);
+    psFree(myPoly->mask);
+}
+
 /*****************************************************************************
-CreateChebyshevPolys(n): this routine takes as input the required order n,
+createChebyshevPolys(n): this routine takes as input the required order n,
 and returns as output as a pointer to an array of n psPolynomial1D
 structures, corresponding to the first n Chebyshev polynomials.
@@ -76,5 +243,5 @@
 outer coefficients of the Chebyshev polynomials.
  *****************************************************************************/
-static psPolynomial1D **CreateChebyshevPolys(psS32 maxChebyPoly)
+static psPolynomial1D **createChebyshevPolys(psS32 maxChebyPoly)
 {
     PS_INT_CHECK_NON_NEGATIVE(maxChebyPoly, NULL);
@@ -103,4 +270,655 @@
 
     return (chebPolys);
+}
+
+/*****************************************************************************
+    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
+ 
+    XXX: Should the "coeffErr[]" should be used as well?
+ *****************************************************************************/
+static float ordPolynomial1DEval(float x, const psPolynomial1D* myPoly)
+{
+    psS32 loop_x = 0;
+    float polySum = 0.0;
+    float xSum = 1.0;
+
+    psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4,
+            "---- Calling ordPolynomial1DEval(%f)\n", x);
+    psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4,
+            "Polynomial order is %d\n", myPoly->n);
+    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
+        psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 4,
+                "Polynomial coeff[%d] is %f\n", loop_x, myPoly->coeff[loop_x]);
+    }
+
+    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
+        if (myPoly->mask[loop_x] == 0) {
+            psTrace(".psLib.dataManip.psFunctions.ordPolynomial1DEval", 10,
+                    "polysum+= sum*coeff [%f+= (%f * %f)\n", polySum, xSum, myPoly->coeff[loop_x]);
+            polySum += xSum * myPoly->coeff[loop_x];
+            xSum *= x;
+        }
+    }
+
+    return(polySum);
+}
+
+// XXX: You can do this without having to psAlloc() vector d.
+// XXX: How does the mask vector effect Crenshaw's formula?
+static float chebPolynomial1DEval(float x, const psPolynomial1D* myPoly)
+{
+    psVector *d;
+    psS32 n;
+    psS32 i;
+    float tmp;
+
+    n = myPoly->n;
+    d = psVectorAlloc(n, PS_TYPE_F32);
+    d->data.F32[n-1] = myPoly->coeff[n-1];
+    d->data.F32[n-2] = (2.0 * x * d->data.F32[n-1]) + myPoly->coeff[n-2];
+    for (i=n-3;i>=1;i--) {
+        d->data.F32[i] = (2.0 * x * d->data.F32[i+1]) -
+                         (d->data.F32[i+2]) +
+                         (myPoly->coeff[i]);
+    }
+
+    tmp = (x * d->data.F32[1]) -
+          (d->data.F32[2]) +
+          (0.5 * myPoly->coeff[0]);
+
+    psFree(d);
+    return(tmp);
+    /*
+
+    psS32 n;
+    psS32 i;
+    float tmp;
+    psPolynomial1D **chebPolys = NULL;
+
+    n = myPoly->n;
+    chebPolys = createChebyshevPolys(n);
+
+    tmp = 0.0;
+    for (i=0;i<myPoly->n;i++) {
+        tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i]));
+        //            printf("HMMM: psPolynomial1DEval(%f, chebPolys[%d]) is %f\n", x, i, psPolynomial1DEval(x, chebPolys[i]));
+    }
+    tmp-= (myPoly->coeff[0]/2.0);
+
+
+    return(tmp);
+    */
+}
+
+static float ordPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
+{
+    PS_POLY_CHECK_NULL(myPoly, NAN);
+
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    float polySum = 0.0;
+    float xSum = 1.0;
+    float ySum = 1.0;
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        ySum = xSum;
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            if (myPoly->mask[loop_x][loop_y] == 0) {
+                polySum += ySum * myPoly->coeff[loop_x][loop_y];
+                ySum *= y;
+            }
+        }
+        xSum *= x;
+    }
+
+    return(polySum);
+}
+
+static float chebPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
+{
+    PS_POLY_CHECK_NULL(myPoly, NAN);
+
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 i = 0;
+    float polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nX;
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            if (myPoly->mask[loop_x][loop_y] == 0) {
+                polySum += myPoly->coeff[loop_x][loop_y] *
+                           psPolynomial1DEval(x, chebPolys[loop_x]) *
+                           psPolynomial1DEval(y, chebPolys[loop_y]);
+            }
+        }
+    }
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+static float ordPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    float polySum = 0.0;
+    float xSum = 1.0;
+    float ySum = 1.0;
+    float zSum = 1.0;
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        ySum = xSum;
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            zSum = ySum;
+            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
+                    polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];
+                    zSum *= z;
+                }
+            }
+            ySum *= y;
+        }
+        xSum *= x;
+    }
+
+    return(polySum);
+}
+
+static float chebPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    psS32 i = 0;
+    float polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nX;
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    if (myPoly->nZ > maxChebyPoly) {
+        maxChebyPoly = myPoly->nZ;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
+                    polySum += myPoly->coeff[loop_x][loop_y][loop_z] *
+                               psPolynomial1DEval(x, chebPolys[loop_x]) *
+                               psPolynomial1DEval(y, chebPolys[loop_y]) *
+                               psPolynomial1DEval(z, chebPolys[loop_z]);
+                }
+            }
+        }
+    }
+
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+static float ordPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
+{
+    psS32 loop_w = 0;
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    float polySum = 0.0;
+    float wSum = 1.0;
+    float xSum = 1.0;
+    float ySum = 1.0;
+    float zSum = 1.0;
+
+    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
+        xSum = wSum;
+        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+            ySum = xSum;
+            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+                zSum = ySum;
+                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
+                        polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];
+                        zSum *= z;
+                    }
+                }
+                ySum *= y;
+            }
+            xSum *= x;
+        }
+        wSum *= w;
+    }
+
+    return(polySum);
+}
+
+static float chebPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
+{
+    psS32 loop_w = 0;
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    psS32 i = 0;
+    float polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nW;
+    if (myPoly->nX > maxChebyPoly) {
+        maxChebyPoly = myPoly->nX;
+    }
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    if (myPoly->nZ > maxChebyPoly) {
+        maxChebyPoly = myPoly->nZ;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
+        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
+                        polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *
+                                   psPolynomial1DEval(w, chebPolys[loop_w]) *
+                                   psPolynomial1DEval(x, chebPolys[loop_x]) *
+                                   psPolynomial1DEval(y, chebPolys[loop_y]) *
+                                   psPolynomial1DEval(z, chebPolys[loop_z]);
+                    }
+                }
+            }
+        }
+    }
+
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+/*****************************************************************************
+    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
+ *****************************************************************************/
+static double dOrdPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
+{
+    psS32 loop_x = 0;
+    double polySum = 0.0;
+    double xSum = 1.0;
+
+    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
+        if (myPoly->mask[loop_x] == 0) {
+            polySum += xSum * myPoly->coeff[loop_x];
+            xSum *= x;
+        }
+    }
+
+    return(polySum);
+}
+
+// XXX: You can do this without having to psAlloc() vector d.
+// XXX: How does the mask vector effect Crenshaw's formula?
+static double dChebPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
+{
+    psVector *d;
+    psS32 n;
+    psS32 i;
+    double tmp;
+
+    n = myPoly->n;
+    d = psVectorAlloc(n, PS_TYPE_F64);
+    d->data.F64[n-1] = myPoly->coeff[n-1];
+    d->data.F64[n-2] = (2.0 * x * d->data.F64[n-1]) + myPoly->coeff[n-2];
+    for (i=n-3;i>=1;i--) {
+        d->data.F64[i] = (2.0 * x * d->data.F64[i+1]) -
+                         (d->data.F64[i+2]) +
+                         (myPoly->coeff[i]);
+    }
+
+    tmp = (x * d->data.F64[1]) -
+          (d->data.F64[2]) +
+          (0.5 * myPoly->coeff[0]);
+
+    psFree(d);
+    return(tmp);
+}
+
+static double dOrdPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    double polySum = 0.0;
+    double xSum = 1.0;
+    double ySum = 1.0;
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        ySum = xSum;
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            if (myPoly->mask[loop_x][loop_y] == 0) {
+                polySum += ySum * myPoly->coeff[loop_x][loop_y];
+                ySum *= y;
+            }
+        }
+        xSum *= x;
+    }
+
+    return(polySum);
+}
+
+static double dChebPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 i = 0;
+    double polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nX;
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            if (myPoly->mask[loop_x][loop_y] == 0) {
+                polySum += myPoly->coeff[loop_x][loop_y] *
+                           psPolynomial1DEval(x, chebPolys[loop_x]) *
+                           psPolynomial1DEval(y, chebPolys[loop_y]);
+            }
+        }
+    }
+
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+static double dOrdPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    double polySum = 0.0;
+    double xSum = 1.0;
+    double ySum = 1.0;
+    double zSum = 1.0;
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        ySum = xSum;
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            zSum = ySum;
+            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
+                    polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];
+                    zSum *= z;
+                }
+            }
+            ySum *= y;
+        }
+        xSum *= x;
+    }
+
+    return(polySum);
+}
+
+static double dChebPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
+{
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    psS32 i = 0;
+    double polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nX;
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    if (myPoly->nZ > maxChebyPoly) {
+        maxChebyPoly = myPoly->nZ;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
+                    polySum += myPoly->coeff[loop_x][loop_y][loop_z] *
+                               psPolynomial1DEval(x, chebPolys[loop_x]) *
+                               psPolynomial1DEval(y, chebPolys[loop_y]) *
+                               psPolynomial1DEval(z, chebPolys[loop_z]);
+                }
+            }
+        }
+    }
+
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+static double dOrdPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
+{
+    psS32 loop_w = 0;
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    double polySum = 0.0;
+    double wSum = 1.0;
+    double xSum = 1.0;
+    double ySum = 1.0;
+    double zSum = 1.0;
+
+    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
+        xSum = wSum;
+        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+            ySum = xSum;
+            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+                zSum = ySum;
+                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
+                        polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];
+                        zSum *= z;
+                    }
+                }
+                ySum *= y;
+            }
+            xSum *= x;
+        }
+        wSum *= w;
+    }
+
+    return(polySum);
+}
+
+static double dChebPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
+{
+    psS32 loop_w = 0;
+    psS32 loop_x = 0;
+    psS32 loop_y = 0;
+    psS32 loop_z = 0;
+    psS32 i = 0;
+    double polySum = 0.0;
+    psPolynomial1D* *chebPolys = NULL;
+    psS32 maxChebyPoly = 0;
+
+    // Determine how many Chebyshev polynomials
+    // are needed, then create them.
+    maxChebyPoly = myPoly->nW;
+    if (myPoly->nX > maxChebyPoly) {
+        maxChebyPoly = myPoly->nX;
+    }
+    if (myPoly->nY > maxChebyPoly) {
+        maxChebyPoly = myPoly->nY;
+    }
+    if (myPoly->nZ > maxChebyPoly) {
+        maxChebyPoly = myPoly->nZ;
+    }
+    chebPolys = createChebyshevPolys(maxChebyPoly);
+
+    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
+        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
+            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
+                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
+                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
+                        polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *
+                                   psPolynomial1DEval(w, chebPolys[loop_w]) *
+                                   psPolynomial1DEval(x, chebPolys[loop_x]) *
+                                   psPolynomial1DEval(y, chebPolys[loop_y]) *
+                                   psPolynomial1DEval(z, chebPolys[loop_z]);
+                    }
+                }
+            }
+        }
+    }
+
+    for (i=0;i<maxChebyPoly;i++) {
+        psFree(chebPolys[i]);
+    }
+    psFree(chebPolys);
+    return(polySum);
+}
+
+
+/*****************************************************************************
+p_psInterpolate1D(): This routine will take as input n-element floating
+point arrays domain and range, and the x value, assumed to lie with the
+domain vector.  It produces as output the (n-1)-order LaGrange interpolated
+value of x.
+ 
+XXX: do we error check for non-distinct domain values?
+ *****************************************************************************/
+static float fullInterpolate1DF32(float *domain,
+                                  float *range,
+                                  psS32 n,
+                                  float x)
+{
+    PS_INT_CHECK_NON_NEGATIVE(n, NAN);
+    PS_PTR_CHECK_NULL(domain, NAN);
+    PS_PTR_CHECK_NULL(range, NAN);
+
+    psS32 i;
+    psS32 m;
+    static psVector *p = NULL;
+    p = psVectorRecycle(p, n, PS_TYPE_F32);
+    p_psMemSetPersistent(p, true);
+    p_psMemSetPersistent(p->data.F32, true);
+    /*
+        psVector *p = psVectorAlloc(n, PS_TYPE_F32);
+        float tmp;
+    */
+
+    psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 4,
+            "---- fullInterpolate1DF32() begin (%d-order at x=%f) (%d data points)----\n", n-1, x, n);
+
+    for (i=0;i<n;i++) {
+        psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6,
+                "domain/range is (%f %f)\n", domain[i], range[i]);
+    }
+
+    for (i=0;i<n;i++) {
+        p->data.F32[i] = range[i];
+        psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6,
+                "p->data.F32[%d] is %f\n", i, p->data.F32[i]);
+
+    }
+
+    // From NR, during each iteration of the m loop, we are computing the
+    // p_{i ... i+m} terms.
+    for (m=1;m<n;m++) {
+        for (i=0;i<n-m;i++) {
+            // From NR: we are computing P_{i ... i+m}
+            p->data.F32[i] = (((x-domain[i+m]) * p->data.F32[i]) +
+                              ((domain[i]-x) * p->data.F32[i+1])) /
+                             (domain[i] - domain[i+m]);
+            //printf("((%f-%f * %f) + (%f-%f * %f)) / (%f - %f)\n", x, domain[i+m], p->data.F32[i], domain[i], x, p->data.F32[i+1], domain[i], domain[i+m]);
+            psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 6,
+                    "p->data.F32[%d] is %f\n", i, p->data.F32[i]);
+        }
+    }
+    psTrace(".psLib.dataManip.psFunctions.fullInterpolate1DF32", 4,
+            "---- fullInterpolate1DF32() end ----\n");
+
+    /*
+        tmp = p->data.F32[0];
+        psFree(p);
+        return(tmp);
+    */
+    return(p->data.F32[0]);
+}
+
+
+/*****************************************************************************
+interpolate1DF32(): this is the base 1-D flat memory routine to perform
+LaGrange interpolation.
+ *****************************************************************************/
+static float interpolate1DF32(float *domain,
+                              float *range,
+                              psS32 n,
+                              psS32 order,
+                              float x)
+{
+    psS32 binNum;
+    psS32 numIntPoints = order+1;
+    psS32 origin;
+
+    psTrace(".psLib.dataManip.psFunctions.interpolate1DF32", 4,
+            "---- interpolate1DF32() begin ----\n");
+
+    binNum = vectorBinDisectF32(domain, n, x);
+
+    if (0 == numIntPoints%2) {
+        origin = binNum - ((numIntPoints/2) - 1);
+    } else {
+        origin = binNum - (numIntPoints/2);
+        if ((x-domain[binNum]) > (domain[binNum+1]-x)) {
+            // x is closer to binNum+1.
+            origin = 1 + (binNum - (numIntPoints/2));
+        }
+    }
+    if (origin < 0) {
+        origin = 0;
+    }
+    if ((origin + numIntPoints) > n) {
+        origin = n - numIntPoints;
+    }
+
+    psTrace(".psLib.dataManip.psFunctions.interpolate1DF32", 4,
+            "---- interpolate1DF32() end ----\n");
+    return(fullInterpolate1DF32(&domain[origin], &range[origin], order+1, x));
 }
 
@@ -336,152 +1154,4 @@
 }
 
-static void polynomial1DFree(psPolynomial1D* myPoly)
-{
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void polynomial2DFree(psPolynomial2D* myPoly)
-{
-    psS32 x = 0;
-
-    for (x = 0; x < myPoly->nX; x++) {
-        psFree(myPoly->coeff[x]);
-        psFree(myPoly->coeffErr[x]);
-        psFree(myPoly->mask[x]);
-    }
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void polynomial3DFree(psPolynomial3D* myPoly)
-{
-    psS32 x = 0;
-    psS32 y = 0;
-
-    for (x = 0; x < myPoly->nX; x++) {
-        for (y = 0; y < myPoly->nY; y++) {
-            psFree(myPoly->coeff[x][y]);
-            psFree(myPoly->coeffErr[x][y]);
-            psFree(myPoly->mask[x][y]);
-        }
-        psFree(myPoly->coeff[x]);
-        psFree(myPoly->coeffErr[x]);
-        psFree(myPoly->mask[x]);
-    }
-
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void polynomial4DFree(psPolynomial4D* myPoly)
-{
-    psS32 w = 0;
-    psS32 x = 0;
-    psS32 y = 0;
-
-    for (w = 0; w < myPoly->nW; w++) {
-        for (x = 0; x < myPoly->nX; x++) {
-            for (y = 0; y < myPoly->nY; y++) {
-                psFree(myPoly->coeff[w][x][y]);
-                psFree(myPoly->coeffErr[w][x][y]);
-                psFree(myPoly->mask[w][x][y]);
-            }
-            psFree(myPoly->coeff[w][x]);
-            psFree(myPoly->coeffErr[w][x]);
-            psFree(myPoly->mask[w][x]);
-        }
-        psFree(myPoly->coeff[w]);
-        psFree(myPoly->coeffErr[w]);
-        psFree(myPoly->mask[w]);
-    }
-
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-/*****************************************************************************
-    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
- 
-    XXX: Should the "coeffErr[]" should be used as well?
- *****************************************************************************/
-float p_psOrdPolynomial1DEval(float x, const psPolynomial1D* myPoly)
-{
-    psS32 loop_x = 0;
-    float polySum = 0.0;
-    float xSum = 1.0;
-
-    psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,
-            "---- Calling p_psOrdPolynomial1DEval(%f)\n", x);
-    psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,
-            "Polynomial order is %d\n", myPoly->n);
-    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
-        psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 4,
-                "Polynomial coeff[%d] is %f\n", loop_x, myPoly->coeff[loop_x]);
-    }
-
-    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
-        if (myPoly->mask[loop_x] == 0) {
-            psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 10,
-                    "polysum+= sum*coeff [%f+= (%f * %f)\n", polySum, xSum, myPoly->coeff[loop_x]);
-            polySum += xSum * myPoly->coeff[loop_x];
-            xSum *= x;
-        }
-    }
-
-    return(polySum);
-}
-
-// XXX: You can do this without having to psAlloc() vector d.
-// XXX: How does the mask vector effect Crenshaw's formula?
-float p_psChebPolynomial1DEval(float x, const psPolynomial1D* myPoly)
-{
-    psVector *d;
-    psS32 n;
-    psS32 i;
-    float tmp;
-
-    n = myPoly->n;
-    d = psVectorAlloc(n, PS_TYPE_F32);
-    d->data.F32[n-1] = myPoly->coeff[n-1];
-    d->data.F32[n-2] = (2.0 * x * d->data.F32[n-1]) + myPoly->coeff[n-2];
-    for (i=n-3;i>=1;i--) {
-        d->data.F32[i] = (2.0 * x * d->data.F32[i+1]) -
-                         (d->data.F32[i+2]) +
-                         (myPoly->coeff[i]);
-    }
-
-    tmp = (x * d->data.F32[1]) -
-          (d->data.F32[2]) +
-          (0.5 * myPoly->coeff[0]);
-
-    psFree(d);
-    return(tmp);
-    /*
-
-    psS32 n;
-    psS32 i;
-    float tmp;
-    psPolynomial1D **chebPolys = NULL;
-
-    n = myPoly->n;
-    chebPolys = CreateChebyshevPolys(n);
-
-    tmp = 0.0;
-    for (i=0;i<myPoly->n;i++) {
-        tmp+= (myPoly->coeff[i] * psPolynomial1DEval(x, chebPolys[i]));
-        //            printf("HMMM: psPolynomial1DEval(%f, chebPolys[%d]) is %f\n", x, i, psPolynomial1DEval(x, chebPolys[i]));
-    }
-    tmp-= (myPoly->coeff[0]/2.0);
-
-
-    return(tmp);
-    */
-}
-
 float psPolynomial1DEval(float x, const psPolynomial1D* myPoly)
 {
@@ -489,9 +1159,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psOrdPolynomial1DEval(x, myPoly));
+        return(ordPolynomial1DEval(x, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psChebPolynomial1DEval(x, myPoly));
+        return(chebPolynomial1DEval(x, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -520,78 +1192,19 @@
 }
 
-
-float p_psOrdPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
+float psPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
 {
     PS_POLY_CHECK_NULL(myPoly, NAN);
 
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    float polySum = 0.0;
-    float xSum = 1.0;
-    float ySum = 1.0;
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        ySum = xSum;
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            if (myPoly->mask[loop_x][loop_y] == 0) {
-                polySum += ySum * myPoly->coeff[loop_x][loop_y];
-                ySum *= y;
-            }
-        }
-        xSum *= x;
-    }
-
-    return(polySum);
-}
-
-float p_psChebPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
-{
-    PS_POLY_CHECK_NULL(myPoly, NAN);
-
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 i = 0;
-    float polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nX;
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            if (myPoly->mask[loop_x][loop_y] == 0) {
-                polySum += myPoly->coeff[loop_x][loop_y] *
-                           psPolynomial1DEval(x, chebPolys[loop_x]) *
-                           psPolynomial1DEval(y, chebPolys[loop_y]);
-            }
-        }
-    }
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
-float psPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
-{
-    PS_POLY_CHECK_NULL(myPoly, NAN);
-
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psOrdPolynomial2DEval(x, y, myPoly));
+        return(ordPolynomial2DEval(x, y, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psChebPolynomial2DEval(x, y, myPoly));
+        return(chebPolynomial2DEval(x, y, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
 }
-
 
 psVector *psPolynomial2DEvalVector(const psVector *x,
@@ -632,75 +1245,4 @@
 }
 
-
-
-float p_psOrdPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    float polySum = 0.0;
-    float xSum = 1.0;
-    float ySum = 1.0;
-    float zSum = 1.0;
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        ySum = xSum;
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            zSum = ySum;
-            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
-                    polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];
-                    zSum *= z;
-                }
-            }
-            ySum *= y;
-        }
-        xSum *= x;
-    }
-
-    return(polySum);
-}
-
-float p_psChebPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    psS32 i = 0;
-    float polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nX;
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    if (myPoly->nZ > maxChebyPoly) {
-        maxChebyPoly = myPoly->nZ;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
-                    polySum += myPoly->coeff[loop_x][loop_y][loop_z] *
-                               psPolynomial1DEval(x, chebPolys[loop_x]) *
-                               psPolynomial1DEval(y, chebPolys[loop_y]) *
-                               psPolynomial1DEval(z, chebPolys[loop_z]);
-                }
-            }
-        }
-    }
-
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
 float psPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
 {
@@ -708,9 +1250,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psOrdPolynomial3DEval(x, y, z, myPoly));
+        return(ordPolynomial3DEval(x, y, z, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psChebPolynomial3DEval(x, y, z, myPoly));
+        return(chebPolynomial3DEval(x, y, z, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -765,91 +1309,4 @@
 }
 
-
-
-
-
-
-float p_psOrdPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
-{
-    psS32 loop_w = 0;
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    float polySum = 0.0;
-    float wSum = 1.0;
-    float xSum = 1.0;
-    float ySum = 1.0;
-    float zSum = 1.0;
-
-    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
-        xSum = wSum;
-        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-            ySum = xSum;
-            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-                zSum = ySum;
-                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
-                        polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];
-                        zSum *= z;
-                    }
-                }
-                ySum *= y;
-            }
-            xSum *= x;
-        }
-        wSum *= w;
-    }
-
-    return(polySum);
-}
-
-float p_psChebPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
-{
-    psS32 loop_w = 0;
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    psS32 i = 0;
-    float polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nW;
-    if (myPoly->nX > maxChebyPoly) {
-        maxChebyPoly = myPoly->nX;
-    }
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    if (myPoly->nZ > maxChebyPoly) {
-        maxChebyPoly = myPoly->nZ;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
-        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
-                        polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *
-                                   psPolynomial1DEval(w, chebPolys[loop_w]) *
-                                   psPolynomial1DEval(x, chebPolys[loop_x]) *
-                                   psPolynomial1DEval(y, chebPolys[loop_y]) *
-                                   psPolynomial1DEval(z, chebPolys[loop_z]);
-                    }
-                }
-            }
-        }
-    }
-
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
 float psPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
 {
@@ -857,9 +1314,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psOrdPolynomial4DEval(w,x,y,z, myPoly));
+        return(ordPolynomial4DEval(w,x,y,z, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psChebPolynomial4DEval(w,x,y,z, myPoly));
+        return(chebPolynomial4DEval(w,x,y,z, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -924,7 +1383,4 @@
     return(tmp);
 }
-
-
-
 
 
@@ -1092,118 +1548,4 @@
 }
 
-static void dPolynomial1DFree(psDPolynomial1D* myPoly)
-{
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void dPolynomial2DFree(psDPolynomial2D* myPoly)
-{
-    psS32 x = 0;
-
-    for (x = 0; x < myPoly->nX; x++) {
-        psFree(myPoly->coeff[x]);
-        psFree(myPoly->coeffErr[x]);
-        psFree(myPoly->mask[x]);
-    }
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void dPolynomial3DFree(psDPolynomial3D* myPoly)
-{
-    psS32 x = 0;
-    psS32 y = 0;
-
-    for (x = 0; x < myPoly->nX; x++) {
-        for (y = 0; y < myPoly->nY; y++) {
-            psFree(myPoly->coeff[x][y]);
-            psFree(myPoly->coeffErr[x][y]);
-            psFree(myPoly->mask[x][y]);
-        }
-        psFree(myPoly->coeff[x]);
-        psFree(myPoly->coeffErr[x]);
-        psFree(myPoly->mask[x]);
-    }
-
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-static void dPolynomial4DFree(psDPolynomial4D* myPoly)
-{
-    psS32 w = 0;
-    psS32 x = 0;
-    psS32 y = 0;
-
-    for (w = 0; w < myPoly->nW; w++) {
-        for (x = 0; x < myPoly->nX; x++) {
-            for (y = 0; y < myPoly->nY; y++) {
-                psFree(myPoly->coeff[w][x][y]);
-                psFree(myPoly->coeffErr[w][x][y]);
-                psFree(myPoly->mask[w][x][y]);
-            }
-            psFree(myPoly->coeff[w][x]);
-            psFree(myPoly->coeffErr[w][x]);
-            psFree(myPoly->mask[w][x]);
-        }
-        psFree(myPoly->coeff[w]);
-        psFree(myPoly->coeffErr[w]);
-        psFree(myPoly->mask[w]);
-    }
-
-    psFree(myPoly->coeff);
-    psFree(myPoly->coeffErr);
-    psFree(myPoly->mask);
-}
-
-/*****************************************************************************
-    Polynomial coefficients will be accessed in [w][x][y][z] fashion.
- *****************************************************************************/
-double p_psDOrdPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
-{
-    psS32 loop_x = 0;
-    double polySum = 0.0;
-    double xSum = 1.0;
-
-    for (loop_x = 0; loop_x < myPoly->n; loop_x++) {
-        if (myPoly->mask[loop_x] == 0) {
-            polySum += xSum * myPoly->coeff[loop_x];
-            xSum *= x;
-        }
-    }
-
-    return(polySum);
-}
-
-// XXX: You can do this without having to psAlloc() vector d.
-// XXX: How does the mask vector effect Crenshaw's formula?
-double p_psDChebPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
-{
-    psVector *d;
-    psS32 n;
-    psS32 i;
-    double tmp;
-
-    n = myPoly->n;
-    d = psVectorAlloc(n, PS_TYPE_F64);
-    d->data.F64[n-1] = myPoly->coeff[n-1];
-    d->data.F64[n-2] = (2.0 * x * d->data.F64[n-1]) + myPoly->coeff[n-2];
-    for (i=n-3;i>=1;i--) {
-        d->data.F64[i] = (2.0 * x * d->data.F64[i+1]) -
-                         (d->data.F64[i+2]) +
-                         (myPoly->coeff[i]);
-    }
-
-    tmp = (x * d->data.F64[1]) -
-          (d->data.F64[2]) +
-          (0.5 * myPoly->coeff[0]);
-
-    psFree(d);
-    return(tmp);
-}
 
 double psDPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
@@ -1212,9 +1554,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psDOrdPolynomial1DEval(x, myPoly));
+        return(dOrdPolynomial1DEval(x, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psDChebPolynomial1DEval(x, myPoly));
+        return(dChebPolynomial1DEval(x, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -1244,61 +1588,4 @@
 
 
-
-double p_psDOrdPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    double polySum = 0.0;
-    double xSum = 1.0;
-    double ySum = 1.0;
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        ySum = xSum;
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            if (myPoly->mask[loop_x][loop_y] == 0) {
-                polySum += ySum * myPoly->coeff[loop_x][loop_y];
-                ySum *= y;
-            }
-        }
-        xSum *= x;
-    }
-
-    return(polySum);
-}
-
-double p_psDChebPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 i = 0;
-    double polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nX;
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            if (myPoly->mask[loop_x][loop_y] == 0) {
-                polySum += myPoly->coeff[loop_x][loop_y] *
-                           psPolynomial1DEval(x, chebPolys[loop_x]) *
-                           psPolynomial1DEval(y, chebPolys[loop_y]);
-            }
-        }
-    }
-
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
 double psDPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
 {
@@ -1306,9 +1593,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psDOrdPolynomial2DEval(x, y, myPoly));
+        return(dOrdPolynomial2DEval(x, y, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psDChebPolynomial2DEval(x, y, myPoly));
+        return(dChebPolynomial2DEval(x, y, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -1353,74 +1642,4 @@
 
 
-
-double p_psDOrdPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    double polySum = 0.0;
-    double xSum = 1.0;
-    double ySum = 1.0;
-    double zSum = 1.0;
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        ySum = xSum;
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            zSum = ySum;
-            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
-                    polySum += zSum * myPoly->coeff[loop_x][loop_y][loop_z];
-                    zSum *= z;
-                }
-            }
-            ySum *= y;
-        }
-        xSum *= x;
-    }
-
-    return(polySum);
-}
-
-double p_psDChebPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
-{
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    psS32 i = 0;
-    double polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nX;
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    if (myPoly->nZ > maxChebyPoly) {
-        maxChebyPoly = myPoly->nZ;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-        for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-            for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                if (myPoly->mask[loop_x][loop_y][loop_z] == 0) {
-                    polySum += myPoly->coeff[loop_x][loop_y][loop_z] *
-                               psPolynomial1DEval(x, chebPolys[loop_x]) *
-                               psPolynomial1DEval(y, chebPolys[loop_y]) *
-                               psPolynomial1DEval(z, chebPolys[loop_z]);
-                }
-            }
-        }
-    }
-
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
 double psDPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
 {
@@ -1428,9 +1647,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psDOrdPolynomial3DEval(x, y, z, myPoly));
+        return(dOrdPolynomial3DEval(x, y, z, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psDChebPolynomial3DEval(x, y, z, myPoly));
+        return(dChebPolynomial3DEval(x, y, z, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -1485,93 +1706,4 @@
 }
 
-
-
-
-
-
-
-
-double p_psDOrdPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
-{
-    psS32 loop_w = 0;
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    double polySum = 0.0;
-    double wSum = 1.0;
-    double xSum = 1.0;
-    double ySum = 1.0;
-    double zSum = 1.0;
-
-    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
-        xSum = wSum;
-        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-            ySum = xSum;
-            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-                zSum = ySum;
-                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
-                        polySum += zSum * myPoly->coeff[loop_w][loop_x][loop_y][loop_z];
-                        zSum *= z;
-                    }
-                }
-                ySum *= y;
-            }
-            xSum *= x;
-        }
-        wSum *= w;
-    }
-
-    return(polySum);
-}
-
-double p_psDChebPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
-{
-    psS32 loop_w = 0;
-    psS32 loop_x = 0;
-    psS32 loop_y = 0;
-    psS32 loop_z = 0;
-    psS32 i = 0;
-    double polySum = 0.0;
-    psPolynomial1D* *chebPolys = NULL;
-    psS32 maxChebyPoly = 0;
-
-    // Determine how many Chebyshev polynomials
-    // are needed, then create them.
-    maxChebyPoly = myPoly->nW;
-    if (myPoly->nX > maxChebyPoly) {
-        maxChebyPoly = myPoly->nX;
-    }
-    if (myPoly->nY > maxChebyPoly) {
-        maxChebyPoly = myPoly->nY;
-    }
-    if (myPoly->nZ > maxChebyPoly) {
-        maxChebyPoly = myPoly->nZ;
-    }
-    chebPolys = CreateChebyshevPolys(maxChebyPoly);
-
-    for (loop_w = 0; loop_w < myPoly->nW; loop_w++) {
-        for (loop_x = 0; loop_x < myPoly->nX; loop_x++) {
-            for (loop_y = 0; loop_y < myPoly->nY; loop_y++) {
-                for (loop_z = 0; loop_z < myPoly->nZ; loop_z++) {
-                    if (myPoly->mask[loop_w][loop_x][loop_y][loop_z] == 0) {
-                        polySum += myPoly->coeff[loop_w][loop_x][loop_y][loop_z] *
-                                   psPolynomial1DEval(w, chebPolys[loop_w]) *
-                                   psPolynomial1DEval(x, chebPolys[loop_x]) *
-                                   psPolynomial1DEval(y, chebPolys[loop_y]) *
-                                   psPolynomial1DEval(z, chebPolys[loop_z]);
-                    }
-                }
-            }
-        }
-    }
-
-    for (i=0;i<maxChebyPoly;i++) {
-        psFree(chebPolys[i]);
-    }
-    psFree(chebPolys);
-    return(polySum);
-}
-
 double psDPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
 {
@@ -1579,9 +1711,11 @@
 
     if (myPoly->type == PS_POLYNOMIAL_ORD) {
-        return(p_psDOrdPolynomial4DEval(w,x,y,z, myPoly));
+        return(dOrdPolynomial4DEval(w,x,y,z, myPoly));
     } else if (myPoly->type == PS_POLYNOMIAL_CHEB) {
-        return(p_psDChebPolynomial4DEval(w,x,y,z, myPoly));
+        return(dChebPolynomial4DEval(w,x,y,z, myPoly));
     } else {
-        psError(__func__, "Unknown polynomial type 0x%x\n", myPoly->type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psFunctions_INVALID_POLYNOMIAL_TYPE,
+                myPoly->type);
     }
     return(0.0);
@@ -1699,31 +1833,8 @@
     (tmp->domains)[numSplines] = max;
 
+    p_psMemSetDeallocator(tmp,(psFreeFcn)spline1DFree);
     return(tmp);
 }
 
-// XXX: Have Robert put the dealocator in the memory file.
-psS32 p_psSpline1DFree(psSpline1D *tmpSpline)
-{
-    psS32 i;
-
-    if (tmpSpline == NULL) {
-        return(0);
-    }
-
-    if (tmpSpline->spline != NULL) {
-        for (i=0;i<tmpSpline->n;i++) {
-            psFree((tmpSpline->spline)[i]);
-        }
-        psFree(tmpSpline->spline);
-    }
-
-    if (tmpSpline->p_psDeriv2 != NULL) {
-        psFree(tmpSpline->p_psDeriv2);
-    }
-    psFree(tmpSpline->domains);
-    psFree(tmpSpline);
-
-    return(0);
-}
 
 /*****************************************************************************
@@ -1765,5 +1876,5 @@
 
 /*****************************************************************************
-p_psVectorBinDisectF32(): This is a private function which takes as input a
+vectorBinDisectF32(): This is a private function which takes as input a
 vector of floating point data as well as a single floating point values.
 The input vector values are assumed to be non-decreasing (v[i-1] <= v[j] for
@@ -1776,7 +1887,7 @@
 XXX: name since we don't take psVectors as input.
  *****************************************************************************/
-psS32 p_psVectorBinDisectF32(float *bins,
-                             psS32 numBins,
-                             float x)
+static psS32 vectorBinDisectF32(float *bins,
+                                psS32 numBins,
+                                float x)
 {
     psS32 min;
@@ -1784,10 +1895,10 @@
     psS32 mid;
 
-    psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4,
-            "---- Calling p_psVectorBinDisectF32(%f)\n", x);
+    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
+            "---- Calling vectorBinDisectF32(%f)\n", x);
 
     if (x < bins[0]) {
         psLogMsg(__func__, PS_LOG_WARN,
-                 "p_psVectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",
+                 "vectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",
                  x, bins[0], bins[numBins-1]);
         return(-2);
@@ -1796,5 +1907,5 @@
     if (x > bins[numBins-1]) {
         psLogMsg(__func__, PS_LOG_WARN,
-                 "p_psVectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",
+                 "vectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",
                  x, bins[0], bins[numBins-1]);
         return(-1);
@@ -1806,11 +1917,11 @@
 
     while (min != max) {
-        psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4,
+        psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
                 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n",
                 min, mid, max, x, bins[mid]);
 
         if (x == bins[mid]) {
-            psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4,
-                    "---- Exiting p_psVectorBinDisectF32(): bin %d\n", mid);
+            psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
+                    "---- Exiting vectorBinDisectF32(): bin %d\n", mid);
             return(mid);
         } else if (x < bins[mid]) {
@@ -1822,15 +1933,15 @@
     }
 
-    psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4,
-            "---- Exiting p_psVectorBinDisectF32(): bin %d\n", min);
+    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
+            "---- Exiting vectorBinDisectF32(): bin %d\n", min);
     return(min);
 }
 
 /*****************************************************************************
-p_psVectorBinDisectS32(): integer version of above.
+vectorBinDisectS32(): integer version of above.
  *****************************************************************************/
-psS32 p_psVectorBinDisectS32(psS32 *bins,
-                             psS32 numBins,
-                             psS32 x)
+static psS32 vectorBinDisectS32(psS32 *bins,
+                                psS32 numBins,
+                                psS32 x)
 {
     psS32 min;
@@ -1838,11 +1949,11 @@
     psS32 mid;
 
-    psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4,
-            "---- Calling p_psVectorBinDisectS32(%f)\n", x);
+    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
+            "---- Calling vectorBinDisectS32(%f)\n", x);
 
     if ((x < bins[0]) ||
             (x > bins[numBins-1])) {
         psLogMsg(__func__, PS_LOG_WARN,
-                 "p_psVectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).",
+                 "vectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).",
                  x, bins[0], bins[numBins-1]);
         return(-1);
@@ -1854,11 +1965,11 @@
 
     while (min != max) {
-        psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4,
+        psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
                 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n",
                 min, mid, max, x, bins[mid]);
 
         if (x == bins[mid]) {
-            psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4,
-                    "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min);
+            psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
+                    "---- Exiting vectorBinDisectS32(): bin %d\n", min);
             return(min);
         } else if (x < bins[mid]) {
@@ -1870,6 +1981,6 @@
     }
 
-    psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4,
-            "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min);
+    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
+            "---- Exiting vectorBinDisectS32(): bin %d\n", min);
     return(min);
 }
@@ -1884,120 +1995,16 @@
 
     if (x->type.type == PS_TYPE_S32) {
-        return(p_psVectorBinDisectS32(bins->data.S32, bins->n, x->data.S32));
+        return(vectorBinDisectS32(bins->data.S32, bins->n, x->data.S32));
     } else if (x->type.type == PS_TYPE_F32) {
-        return(p_psVectorBinDisectF32(bins->data.F32, bins->n, x->data.F32));
+        return(vectorBinDisectF32(bins->data.F32, bins->n, x->data.F32));
     } else {
-        psError(__func__, "Unallowable data type.");
+        char* strType;
+        PS_TYPE_NAME(strType,x->type.type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE,
+                PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED,
+                strType);
         return(-2);
     }
     return(-1);
-}
-
-/*****************************************************************************
-p_psInterpolate1D(): This routine will take as input n-element floating
-point arrays domain and range, and the x value, assumed to lie with the
-domain vector.  It produces as output the (n-1)-order LaGrange interpolated
-value of x.
- 
-XXX: do we error check for non-distinct domain values?
- *****************************************************************************/
-float p_ps1DFullInterpolateF32(float *domain,
-                               float *range,
-                               psS32 n,
-                               float x)
-{
-    PS_INT_CHECK_NON_NEGATIVE(n, NAN);
-    PS_PTR_CHECK_NULL(domain, NAN);
-    PS_PTR_CHECK_NULL(range, NAN);
-
-    psS32 i;
-    psS32 m;
-    static psVector *p = NULL;
-    p = psVectorRecycle(p, n, PS_TYPE_F32);
-    p_psMemSetPersistent(p, true);
-    p_psMemSetPersistent(p->data.F32, true);
-    /*
-        psVector *p = psVectorAlloc(n, PS_TYPE_F32);
-        float tmp;
-    */
-
-    psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 4,
-            "---- p_ps1DFullInterpolateF32() begin (%d-order at x=%f) (%d data points)----\n", n-1, x, n);
-
-    for (i=0;i<n;i++) {
-        psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,
-                "domain/range is (%f %f)\n", domain[i], range[i]);
-    }
-
-    for (i=0;i<n;i++) {
-        p->data.F32[i] = range[i];
-        psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,
-                "p->data.F32[%d] is %f\n", i, p->data.F32[i]);
-
-    }
-
-    // From NR, during each iteration of the m loop, we are computing the
-    // p_{i ... i+m} terms.
-    for (m=1;m<n;m++) {
-        for (i=0;i<n-m;i++) {
-            // From NR: we are computing P_{i ... i+m}
-            p->data.F32[i] = (((x-domain[i+m]) * p->data.F32[i]) +
-                              ((domain[i]-x) * p->data.F32[i+1])) /
-                             (domain[i] - domain[i+m]);
-            //printf("((%f-%f * %f) + (%f-%f * %f)) / (%f - %f)\n", x, domain[i+m], p->data.F32[i], domain[i], x, p->data.F32[i+1], domain[i], domain[i+m]);
-            psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6,
-                    "p->data.F32[%d] is %f\n", i, p->data.F32[i]);
-        }
-    }
-    psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 4,
-            "---- p_ps1DFullInterpolateF32() end ----\n");
-
-    /*
-        tmp = p->data.F32[0];
-        psFree(p);
-        return(tmp);
-    */
-    return(p->data.F32[0]);
-}
-
-
-/*****************************************************************************
-p_ps1DInterpolateF32(): this is the base 1-D flat memory routine to perform
-LaGrange interpolation.
- *****************************************************************************/
-float p_ps1DInterpolateF32(float *domain,
-                           float *range,
-                           psS32 n,
-                           psS32 order,
-                           float x)
-{
-    psS32 binNum;
-    psS32 numIntPoints = order+1;
-    psS32 origin;
-
-    psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4,
-            "---- p_ps1DInterpolateF32() begin ----\n");
-
-    binNum = p_psVectorBinDisectF32(domain, n, x);
-
-    if (0 == numIntPoints%2) {
-        origin = binNum - ((numIntPoints/2) - 1);
-    } else {
-        origin = binNum - (numIntPoints/2);
-        if ((x-domain[binNum]) > (domain[binNum+1]-x)) {
-            // x is closer to binNum+1.
-            origin = 1 + (binNum - (numIntPoints/2));
-        }
-    }
-    if (origin < 0) {
-        origin = 0;
-    }
-    if ((origin + numIntPoints) > n) {
-        origin = n - numIntPoints;
-    }
-
-    psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4,
-            "---- p_ps1DInterpolateF32() end ----\n");
-    return(p_ps1DFullInterpolateF32(&domain[origin], &range[origin], order+1, x));
 }
 
@@ -2035,5 +2042,7 @@
 
     if (order > (domain->n - 1)) {
-        psError(__func__, "not enough data points for %d-order interpolation.\n", order);
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                PS_ERRORTEXT_psFunctions_NOT_ENOUGH_DATAPOINTS,
+                order);
         return(NULL);
     }
@@ -2042,9 +2051,9 @@
         psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4,
                 "---- p_psVectorInterpolate() end ----\n");
-        return(psScalarAlloc(p_ps1DInterpolateF32(domain->data.F32,
-                             range->data.F32,
-                             domain->n,
-                             order,
-                             x->data.F32), PS_TYPE_F32));
+        return(psScalarAlloc(interpolate1DF32(domain->data.F32,
+                                              range->data.F32,
+                                              domain->n,
+                                              order,
+                                              x->data.F32), PS_TYPE_F32));
     } else if (x->type.type == PS_TYPE_F64) {
         // XXX: use recycled vectors here.
@@ -2053,9 +2062,9 @@
 
         psScalar *tmpScalar = psScalarAlloc((double)
-                                            p_ps1DInterpolateF32(domain32->data.F32,
-                                                                 range32->data.F32,
-                                                                 domain32->n,
-                                                                 order,
-                                                                 (float) x->data.F64), PS_TYPE_F64);
+                                            interpolate1DF32(domain32->data.F32,
+                                                             range32->data.F32,
+                                                             domain32->n,
+                                                             order,
+                                                             (float) x->data.F64), PS_TYPE_F64);
         psFree(range32);
         psFree(domain32);
@@ -2067,6 +2076,9 @@
 
     } else {
-        // XXX psError: type not supported
-        psError(__func__, "type %d not supported\n", x->type.type);
+        char* strType;
+        PS_TYPE_NAME(strType,x->type.type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE,
+                PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED,
+                strType);
     }
 
@@ -2084,5 +2096,5 @@
 and an independent x value.  Each determines which spline that x corresponds
 to by doing a bracket disection on the domains of the spline data structure
-(p_psVectorBinDisectF32()).  Then it evaluates the spline at that x location
+(vectorBinDisectF32()).  Then it evaluates the spline at that x location
 by a call to the 1D polynomial functions.
  
@@ -2100,5 +2112,5 @@
 
     n = spline->n;
-    binNum = p_psVectorBinDisectF32(spline->domains, (spline->n)+1, x);
+    binNum = vectorBinDisectF32(spline->domains, (spline->n)+1, x);
     if (binNum < 0) {
         psLogMsg(__func__, PS_LOG_WARN,
@@ -2139,5 +2151,9 @@
         }
     } else {
-        psError(__func__, "Unknown data type.\n");
+        char* strType;
+        PS_TYPE_NAME(strType,x->type.type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE,
+                PS_ERRORTEXT_psFunctions_TYPE_NOT_SUPPORTED,
+                strType);
         return(NULL);
     }
Index: /trunk/psLib/src/math/psSpline.h
===================================================================
--- /trunk/psLib/src/math/psSpline.h	(revision 2272)
+++ /trunk/psLib/src/math/psSpline.h	(revision 2273)
@@ -12,6 +12,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-11-03 03:30:30 $
+*  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:04:59 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -398,6 +398,4 @@
                             float max);
 
-psS32 p_psSpline1DFree(psSpline1D *tmpSpline);
-
 psSpline1D *psSpline1DAllocGeneric(const psVector *bounds,
                                    psS32 order);
Index: /trunk/psLib/src/math/psStats.c
===================================================================
--- /trunk/psLib/src/math/psStats.c	(revision 2272)
+++ /trunk/psLib/src/math/psStats.c	(revision 2273)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-03 03:30:30 $
+ *  @version $Revision: 1.85 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:59 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -34,4 +34,6 @@
 #include "psFunctions.h"
 #include "psConstants.h"
+
+#include "psDataManipErrors.h"
 
 /*****************************************************************************/
@@ -735,13 +737,9 @@
 
     // Ensure that stats->clipIter is within the proper range.
-    if (!((PS_CLIPPED_NUM_ITER_LB <= stats->clipIter) && (stats->clipIter <= PS_CLIPPED_NUM_ITER_UB))) {
-        psError(__func__, "Unallowed value for clipIter (%d).\n", stats->clipIter);
-        return(-1);
-    }
+    PS_INT_CHECK_RANGE(stats->clipIter,PS_CLIPPED_NUM_ITER_LB,PS_CLIPPED_NUM_ITER_UB,-1);
+
     // Ensure that stats->clipSigma is within the proper range.
-    if (!((PS_CLIPPED_SIGMA_LB <= stats->clipSigma) && (stats->clipSigma <= PS_CLIPPED_SIGMA_UB))) {
-        psError(__func__, "Unallowed value for clipSigma (%f).\n", stats->clipSigma);
-        return(-1);
-    }
+    PS_INT_CHECK_RANGE(stats->clipSigma,PS_CLIPPED_SIGMA_LB,PS_CLIPPED_SIGMA_UB,-1);
+
     // We allocate a temporary mask vector since during the iterative
     // steps that follow, we will be masking off additional data points.
@@ -869,5 +867,9 @@
         p_psNormalizeVectorRangeF64(myData, low, high);
     } else {
-        psError(__func__, "Unalowable data type.\n");
+        char* strType;
+        PS_TYPE_NAME(strType,myData->type.type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psStats_NOT_F32_F64,
+                strType);
     }
 }
@@ -954,6 +956,7 @@
         // Ensure that yVal is within the range of the bins we are using.
         if (!((y->data.F64[0] <= yVal) && (yVal <= y->data.F64[2]))) {
-            printf("((%f), %f, %f)\n", yVal, y->data.F64[0], y->data.F64[2]);
-            psError(__func__, "yVal not within y-range\n");
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psStats_YVAL_OUT_OF_RANGE,
+                    (double)yVal,y->data.F64[2],y->data.F64[0]);
         }
         yErr->data.F64[0] = 1.0;
@@ -1113,9 +1116,11 @@
 
     if ((LQBinNum < 0) || (UQBinNum < 0)) {
-        psError(__func__, "Could not determine the robust lower/upper quartile bin numbers.");
+        psError(PS_ERR_UNKNOWN, true,
+                PS_ERRORTEXT_psStats_ROBUST_QUARTILE_BINS_FAILED);
         return(1);
     }
     if (medianBinNum < 0) {
-        psError(__func__, "Could not determine the robust lower/upper quartile bin numbers.");
+        psError(PS_ERR_UNKNOWN, true,
+                PS_ERRORTEXT_psStats_ROBUST_QUARTILE_BINS_FAILED);
         return(1);
     }
@@ -1174,5 +1179,5 @@
     psVector *y = psVectorAlloc(robustHistogramVector->n, PS_TYPE_F32);
 
-    p_psNormalizeVectorRange(robustHistogramVector, 0.0, 1.0);
+    psNormalizeVectorRange(robustHistogramVector, 0.0, 1.0);
     for (i=0;i<robustHistogramVector->n;i++) {
         myCoords->data[i] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32);
@@ -1536,5 +1541,9 @@
         // do nothing
     } else {
-        psError(__func__, "unsupported vector type 0x%x\n", in->type.type);
+        char* strType;
+        PS_TYPE_NAME(strType,in->type.type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psStats_VECTOR_TYPE_UNSUPPORTED,
+                strType);
     }
     return (tmp);
@@ -1603,5 +1612,6 @@
             (stats->options & PS_STAT_ROBUST_STDEV) || (stats->options & PS_STAT_ROBUST_QUARTILE)) {
         if (0 != p_psVectorRobustStats(inF32, mask, maskVal, stats)) {
-            psError(__func__, "p_psVectorRobustStats() failed.\n");
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psStats_STATS_FAILED);
         }
     }
@@ -1609,5 +1619,6 @@
     if ((stats->options & PS_STAT_CLIPPED_MEAN) || (stats->options & PS_STAT_CLIPPED_STDEV)) {
         if (0 != p_psVectorClippedStats(inF32, mask, maskVal, stats)) {
-            psError(__func__, "p_psVectorClippedStats() failed.\n");
+            psError(PS_ERR_UNKNOWN, false,
+                    "Failed to calculate statistics for input psVector.");
         }
     }
Index: /trunk/psLib/src/mathtypes/psImage.c
===================================================================
--- /trunk/psLib/src/mathtypes/psImage.c	(revision 2272)
+++ /trunk/psLib/src/mathtypes/psImage.c	(revision 2273)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -40,8 +40,7 @@
 
     if (area < 1) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageAlloc",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImage_AREA_NEGATIVE,
-                   numRows, numCols);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psImage_AREA_NEGATIVE,
+                numRows, numCols);
         return NULL;
     }
@@ -119,7 +118,6 @@
     if (old->type.dimen != PS_DIMEN_IMAGE) {
         psFree(old);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRecycle",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImage_NOT_AN_IMAGE);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImage_NOT_AN_IMAGE);
         return NULL;
     }
@@ -175,7 +173,6 @@
 
     if (input == NULL || input->data.V == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         psFree(output);
         return NULL;
@@ -183,7 +180,6 @@
 
     if (input == output) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psImage_INPLACE_NOTSUPPORTED);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psImage_INPLACE_NOTSUPPORTED);
         psFree(output);
         return NULL;
@@ -191,7 +187,6 @@
 
     if (input->type.dimen != PS_DIMEN_IMAGE) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImage_NOT_AN_IMAGE);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImage_NOT_AN_IMAGE);
         psFree(output);
         return NULL;
@@ -205,8 +200,7 @@
 
     if (inDatatype == PS_TYPE_PTR || type == PS_TYPE_PTR) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                   PS_TYPE_PTR_NAME);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                PS_TYPE_PTR_NAME);
         psFree(output);
         return NULL;
@@ -319,8 +313,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                       typeStr);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                    typeStr);
             psFree(output);
 
@@ -372,7 +365,6 @@
 
     if (input == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePixelInterpolate",
-                   PS_ERR_BAD_PARAMETER_NULL,true,
-                   PS_ERRORTEXT_psImage_IMAGE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL,true,
+                PS_ERRORTEXT_psImage_IMAGE_NULL);
         return unexposedValue;
     }
@@ -400,8 +392,7 @@
         break;                                                       \
     default:                                                         \
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePixelInterpolate",    \
-                   PS_ERR_BAD_PARAMETER_VALUE,true,                  \
-                   PS_ERRORTEXT_psImage_INTERPOLATE_METHOD_INVALID,  \
-                   mode);                                            \
+        psError(PS_ERR_BAD_PARAMETER_VALUE,true,                     \
+                PS_ERRORTEXT_psImage_INTERPOLATE_METHOD_INVALID,     \
+                mode);                                               \
     }                                                                \
     break
@@ -423,8 +414,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,input->type.type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePixelInterpolate",
-                       PS_ERR_BAD_PARAMETER_TYPE,true,
-                       PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
-                       typeStr);
+            psError(PS_ERR_BAD_PARAMETER_TYPE,true,
+                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
+                    typeStr);
         }
     }
Index: /trunk/psLib/src/mathtypes/psScalar.c
===================================================================
--- /trunk/psLib/src/mathtypes/psScalar.c	(revision 2272)
+++ /trunk/psLib/src/mathtypes/psScalar.c	(revision 2273)
@@ -8,6 +8,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-12 19:32:44 $
+ *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -70,8 +70,7 @@
         break;
     default:
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarAlloc",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE,
-                   dataType);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE,
+                dataType);
     }
 
@@ -85,7 +84,6 @@
 
     if (scalar == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarCopy",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psScalar_COPY_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psScalar_COPY_NULL);
         return NULL;
     }
@@ -130,8 +128,7 @@
         break;
     default:
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psScalarCopy",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE,
-                   dataType);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psScalar_UNSUPPORTED_TYPE,
+                dataType);
     }
 
Index: /trunk/psLib/src/mathtypes/psVector.c
===================================================================
--- /trunk/psLib/src/mathtypes/psVector.c	(revision 2272)
+++ /trunk/psLib/src/mathtypes/psVector.c	(revision 2273)
@@ -10,6 +10,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 00:57:31 $
+*  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:04:57 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -70,7 +70,6 @@
 
     if (in == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorRealloc",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psVector_REALLOC_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psVector_REALLOC_NULL);
         return NULL;
     } else if (in->nalloc != nalloc) {     // No need to realloc to same size
@@ -99,7 +98,6 @@
             in->type.dimen !=  PS_DIMEN_TRANSV) {
         psFree(in);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorRecycle",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVector_NOT_A_VECTOR);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVector_NOT_A_VECTOR);
         return NULL;
     }
@@ -122,7 +120,6 @@
 {
     if (in == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psVector_SORT_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psVector_SORT_NULL);
         psFree(out);
         return NULL;
@@ -183,8 +180,7 @@
                 char* typeStr; \
                 PS_TYPE_NAME(typeStr,type); \
-                psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", \
-                           PS_ERR_BAD_PARAMETER_TYPE, true, \
-                           PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, \
-                           typeStr); \
+                psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+                        PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, \
+                        typeStr); \
                 psFree(out); \
             } \
@@ -209,8 +205,7 @@
             char* typeStr;
             PS_TYPE_NAME(typeStr,type);
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy",
-                       PS_ERR_BAD_PARAMETER_TYPE, true,
-                       PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
-                       typeStr);
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                    PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
+                    typeStr);
             psFree(out);
 
@@ -232,7 +227,6 @@
 
     if (inVector == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psVector_SORT_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psVector_SORT_NULL);
         psFree(outVector);
         return NULL;
@@ -300,8 +294,7 @@
         break;
     default:
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
-                   inType);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
+                inType);
     }
 
@@ -317,7 +310,6 @@
 
     if (inVector == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSortIndex",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psVector_SORT_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psVector_SORT_NULL);
         psFree(outVector);
         return NULL;
@@ -400,8 +392,7 @@
         break;
     default:
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSortIndex",
-                   PS_ERR_BAD_PARAMETER_TYPE, true,
-                   PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
-                   inType);
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE,
+                inType);
     }
 
Index: /trunk/psLib/src/psErrorCodes.dat
===================================================================
--- /trunk/psLib/src/psErrorCodes.dat	(revision 2272)
+++ /trunk/psLib/src/psErrorCodes.dat	(revision 2273)
@@ -17,2 +17,3 @@
 BAD_PARAMETER_SIZE             size of parameter's data is outside of acceptable range.
 UNEXPECTED_NULL                unexpected NULL found
+OS_CALL_FAILED                 unexpected result from an OS standard library call.
Index: /trunk/psLib/src/sys/psError.c
===================================================================
--- /trunk/psLib/src/sys/psError.c	(revision 2272)
+++ /trunk/psLib/src/sys/psError.c	(revision 2273)
@@ -10,6 +10,6 @@
  *  @author Eric Van Alst, MHPCC
  *   
- *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -67,43 +67,17 @@
 }
 
-void psError(const char *name, const char *fmt, ...)
+psErrorCode p_psError(const char* file,
+                      int lineno,
+                      const char* func,
+                      psErrorCode code,
+                      psBool new,
+                      const char* fmt,
+                      ...)
 {
-    va_list argPtr;             // variable list arguement pointer
+    char errMsg[2048];
+    psErr* err;
+    char msgName[256];
 
-    // Get the variable list parameters to pass to logging function
-    va_start(argPtr, fmt);
-
-    // Call logging function with PS_LOG_ERROR level
-    psLogMsgV(name, PS_LOG_ERROR, fmt, argPtr);
-
-    // Clean up stack after variable argument has been used
-    va_end(argPtr);
-}
-
-void psErrorClear()
-{
-    pthread_mutex_lock(&lockErrorStack);
-    for (psS32 lcv=0;lcv<errorStackSize;lcv++) {
-        p_psMemSetPersistent(errorStack[lcv]->msg,false);
-        p_psMemSetPersistent(errorStack[lcv]->name,false);
-        p_psMemSetPersistent(errorStack[lcv],false);
-        psFree(errorStack[lcv]);
-    }
-    errorStackSize = 0;
-    pthread_mutex_unlock(&lockErrorStack);
-}
-
-psErrorCode psErrorMsg(const char *name, psErrorCode code, psBool new, const char* fmt, ...)
-{
-    char errMsg[1024];
-    psErr* err;
-    char* msgName;
-
-    // Check for null pointer and if found set to empty string;
-    if ( name == NULL ) {
-        msgName = "";
-    } else {
-        msgName = (char*)name;
-    }
+    snprintf(msgName,256,"%s (%s:%d)",func,file,lineno);
 
     va_list argPtr;             // variable list arguement pointer
@@ -116,5 +90,5 @@
     va_start(argPtr, fmt);
 
-    vsnprintf(errMsg,1024,fmt,argPtr);
+    vsnprintf(errMsg,2048,fmt,argPtr);
     err = psErrAlloc(msgName,code,errMsg);
     pushErrorStack(err);
@@ -160,4 +134,19 @@
 }
 
+void psErrorClear(void)
+{
+    pthread_mutex_lock(&lockErrorStack);
+
+    for (int lcv=0;lcv < errorStackSize; lcv++) {
+        p_psMemSetPersistent(errorStack[lcv],false);
+        p_psMemSetPersistent(errorStack[lcv]->msg,false);
+        p_psMemSetPersistent(errorStack[lcv]->name,false);
+        psFree(errorStack[lcv]);
+    }
+    errorStackSize = 0;
+
+    pthread_mutex_unlock(&lockErrorStack);
+
+}
 void psErrorStackPrint(FILE *fd, const char *fmt, ...)
 {
Index: /trunk/psLib/src/sys/psError.h
===================================================================
--- /trunk/psLib/src/sys/psError.h	(revision 2272)
+++ /trunk/psLib/src/sys/psError.h	(revision 2273)
@@ -12,6 +12,6 @@
  *  @author Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -104,25 +104,19 @@
  *  log message.
  *
+ *  This function modifies the error stack.
+ *
+ *  @return psErrorCode    the given error code
  */
-void psError(
-    const char *name,                  ///< Source of error such as file or function detected
-    const char *fmt,                   ///< A printf style formatting statement defining msg
+psErrorCode p_psError(
+    const char* file,
+    int lineno,
+    const char* func,
+    psErrorCode code,                  ///< Error class code
+    psBool new,                        ///< true if error originates at this location
+    const char* fmt,
     ...
 );
 
-/** Reports an error message to the logging facility
- *
- *  This function will invoke the psLogMsg function with a level of
- *  PS_LOG_ERROR and pass the parameters name and fmt to generate a proper
- *  log message.
- *
- */
-psErrorCode psErrorMsg(
-    const char *name,                  ///< Name of error in the form aaa.bbb.ccc
-    psErrorCode code,                  ///< Error class code
-    psBool new,                          ///< true if error originates at this location
-    const char* fmt,                   ///< printf style formatting statement defining error message
-    ...
-);
+#define psError(code,new,...) p_psError(__FILE__,__LINE__,__func__,code,new,__VA_ARGS__)
 
 /** Create a new psErr struct
Index: /trunk/psLib/src/sys/psErrorCodes.c
===================================================================
--- /trunk/psLib/src/sys/psErrorCodes.c	(revision 2272)
+++ /trunk/psLib/src/sys/psErrorCodes.c	(revision 2273)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -46,5 +46,6 @@
             {PS_ERR_BAD_PARAMETER_NULL,"parameter is null"},
             {PS_ERR_BAD_PARAMETER_SIZE,"size of parameter's data is outside of acceptable range."},
-            {PS_ERR_UNEXPECTED_NULL,"unexpected NULL foun"},
+            {PS_ERR_UNEXPECTED_NULL,"unexpected NULL found"},
+            {PS_ERR_OS_CALL_FAILED,"unexpected result from an OS standard library call"},
             //~End
             {PS_ERR_N_ERR_CLASSES,"error classes end marker"}
@@ -132,7 +133,6 @@
 
     if (errors == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psErrorCode_NULL_ERRORDESCRIPTION);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psErrorCode_NULL_ERRORDESCRIPTION);
         return;
     }
@@ -152,8 +152,7 @@
                         err) ) {
 
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister",
-                       PS_ERR_UNKNOWN, false,
-                       PS_ERRORTEXT_psErrorCode_ERRORCODE_REGISTER_FAILED,
-                       i);
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psErrorCode_ERRORCODE_REGISTER_FAILED,
+                    i);
         }
         p_psMemSetPersistent(dynamicErrorCodes->head,true);
Index: /trunk/psLib/src/sys/psErrorCodes.h
===================================================================
--- /trunk/psLib/src/sys/psErrorCodes.h	(revision 2272)
+++ /trunk/psLib/src/sys/psErrorCodes.h	(revision 2273)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -52,5 +52,6 @@
     PS_ERR_BAD_PARAMETER_NULL,   ///< parameter is null
     PS_ERR_BAD_PARAMETER_SIZE,   ///< size of parameter's data is outside of acceptable range.
-    PS_ERR_UNEXPECTED_NULL,   ///< unexpected NULL foun
+    PS_ERR_UNEXPECTED_NULL,   ///< unexpected NULL found
+    PS_ERR_OS_CALL_FAILED,   ///< unexpected result from an OS standard library call
     //~End
     PS_ERR_N_ERR_CLASSES               ///< end marker - should not be used as a true error
Index: /trunk/psLib/src/sys/psLogMsg.c
===================================================================
--- /trunk/psLib/src/sys/psLogMsg.c	(revision 2272)
+++ /trunk/psLib/src/sys/psLogMsg.c	(revision 2273)
@@ -11,6 +11,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -110,7 +110,7 @@
 
     if (sscanf(dest, "%4s:%256s", protocol, location) < 2) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,
-                   PS_ERRORTEXT_psLogMsg_DESTINATION_MALFORMED,
-                   dest);
+        psError(PS_ERR_LOCATION_INVALID, true,
+                PS_ERRORTEXT_psLogMsg_DESTINATION_MALFORMED,
+                dest);
         return false;
     }
@@ -131,7 +131,7 @@
             return true;
         }
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,
-                   PS_ERRORTEXT_psLogMsg_DEST_LOCATION_INVALID,
-                   location);
+        psError(PS_ERR_LOCATION_INVALID, true,
+                PS_ERRORTEXT_psLogMsg_DEST_LOCATION_INVALID,
+                location);
         return 1;
     } else if (strcmp(protocol, "file") == 0) {
@@ -139,7 +139,7 @@
 
         if (file == NULL) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_IO,
-                       PS_ERRORTEXT_psLogMsg_OPEN_FILE_FAILED,
-                       location);
+            psError(PS_ERR_IO, true,
+                    PS_ERRORTEXT_psLogMsg_OPEN_FILE_FAILED,
+                    location);
             return false;
         }
@@ -151,7 +151,7 @@
     }
 
-    psErrorMsg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,
-               PS_ERRORTEXT_psLogMsg_UNSUPPORTED_PROTOCOL,
-               protocol);
+    psError(PS_ERR_LOCATION_INVALID, true,
+            PS_ERRORTEXT_psLogMsg_UNSUPPORTED_PROTOCOL,
+            protocol);
     return false;
 }
@@ -215,6 +215,6 @@
             break;
         default:
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psLogSetFormat", true, PS_ERR_BAD_PARAMETER_VALUE,
-                       PS_ERRORTEXT_psLogMsg_UNKNOWN_KEY, *ptr);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psLogMsg_UNKNOWN_KEY, *ptr);
             break;
         }
Index: /trunk/psLib/src/sys/psMemory.c
===================================================================
--- /trunk/psLib/src/sys/psMemory.c	(revision 2272)
+++ /trunk/psLib/src/sys/psMemory.c	(revision 2273)
@@ -8,6 +8,6 @@
 *  @author Robert Lupton, Princeton University
 *
-*  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 19:35:59 $
+*  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:05:00 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -100,7 +100,7 @@
 {
     if (ptr->refCounter < 1) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "memProblemCallbackDefault", false, PS_ERR_MEMORY_CORRUPTION,
-                   PS_ERRORTEXT_psMemory_MULTIPLE_FREE,
-                   ptr->id, ptr->file, ptr->lineno, file, lineno);
+        psError(PS_ERR_MEMORY_CORRUPTION, false,
+                PS_ERRORTEXT_psMemory_MULTIPLE_FREE,
+                ptr->id, ptr->file, ptr->lineno, file, lineno);
     }
 
@@ -228,6 +228,6 @@
 
     if (m == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
-                   PS_ERRORTEXT_psMemory_NULL_BLOCK);
+        psError(PS_ERR_MEMORY_CORRUPTION, true,
+                PS_ERRORTEXT_psMemory_NULL_BLOCK);
         return 1;
     }
@@ -235,20 +235,20 @@
     if (m->refCounter == 0) {
         // using an unreferenced block of memory, are you?
-        psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
-                   PS_ERRORTEXT_psMemory_DEREF_BLOCK_USE,
-                   m->id);
+        psError(PS_ERR_MEMORY_CORRUPTION, true,
+                PS_ERRORTEXT_psMemory_DEREF_BLOCK_USE,
+                m->id);
         return 1;
     }
 
     if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
-                   PS_ERRORTEXT_psMemory_UNDERFLOW,
-                   m->id);
+        psError(PS_ERR_MEMORY_CORRUPTION, true,
+                PS_ERRORTEXT_psMemory_UNDERFLOW,
+                m->id);
         return 1;
     }
     if (*(psPtr *)((int8_t *) (m + 1) + m->userMemorySize) != P_PS_MEMMAGIC) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
-                   PS_ERRORTEXT_psMemory_OVERFLOW,
-                   m->id);
+        psError(PS_ERR_MEMORY_CORRUPTION, true,
+                PS_ERRORTEXT_psMemory_OVERFLOW,
+                m->id);
         return 1;
     }
@@ -431,7 +431,7 @@
         psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
 
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psFree",PS_ERR_MEMORY_DEREF_USAGE,true,
-                   PS_ERRORTEXT_psMemory_MULTIPLE_FREE,
-                   ptr->id, ptr->file, ptr->lineno, file, lineno);
+        psError(PS_ERR_MEMORY_DEREF_USAGE,true,
+                PS_ERRORTEXT_psMemory_MULTIPLE_FREE,
+                ptr->id, ptr->file, ptr->lineno, file, lineno);
 
         return;
Index: /trunk/psLib/src/sys/psString.c
===================================================================
--- /trunk/psLib/src/sys/psString.c	(revision 2272)
+++ /trunk/psLib/src/sys/psString.c	(revision 2273)
@@ -9,6 +9,6 @@
  *  @author Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -38,7 +38,7 @@
     if (nChar < 0) {
         // Log error message and return NULL
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psStringNCopy", PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psString_NCHAR_NEGATIVE,
-                   nChar);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psString_NCHAR_NEGATIVE,
+                nChar);
         return NULL;
     }
Index: /trunk/psLib/src/sys/psTrace.c
===================================================================
--- /trunk/psLib/src/sys/psTrace.c	(revision 2272)
+++ /trunk/psLib/src/sys/psTrace.c	(revision 2273)
@@ -9,6 +9,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 23:31:44 $
+ *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -161,6 +161,6 @@
     // XXX: Verify that this is the correct behavior.
     if (strcmp("", addNodeName) == 0) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "componentAdd",PS_ERR_BAD_PARAMETER_NULL,true,
-                   PS_ERRORTEXT_psTrace_ADD_NULL_COMPONENT);
+        psError(PS_ERR_BAD_PARAMETER_NULL,true,
+                PS_ERRORTEXT_psTrace_ADD_NULL_COMPONENT);
         return false;
     }
@@ -173,7 +173,7 @@
 
     if (addNodeName[0] != '.') {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "componentAdd",PS_ERR_BAD_PARAMETER_VALUE,true,
-                   PS_ERRORTEXT_psTrace_MALFORMED_COMPONENT_NAME,
-                   addNodeName);
+        psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                PS_ERRORTEXT_psTrace_MALFORMED_COMPONENT_NAME,
+                addNodeName);
         return false;
     }
@@ -262,10 +262,8 @@
     // Add the new component to the component tree.
     if ( !componentAdd(compName, level) ) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psTraceSetLevel",
-                   PS_ERR_UNKNOWN,
-                   false,
-                   PS_ERRORTEXT_psTrace_FAILED_TO_ADD_COMPONENT,
-                   level,
-                   compName);
+        psError(PS_ERR_UNKNOWN, false,
+                PS_ERRORTEXT_psTrace_FAILED_TO_ADD_COMPONENT,
+                level,
+                compName);
 
         if (comp[0] != '.') {
@@ -482,7 +480,7 @@
 
     if (NULL == comp) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psTrace", PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psTrace_NULL_TRACETREE,
-                   __func__);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psTrace_NULL_TRACETREE,
+                __func__);
         return;
     }
Index: /trunk/psLib/src/sysUtils/psError.c
===================================================================
--- /trunk/psLib/src/sysUtils/psError.c	(revision 2272)
+++ /trunk/psLib/src/sysUtils/psError.c	(revision 2273)
@@ -10,6 +10,6 @@
  *  @author Eric Van Alst, MHPCC
  *   
- *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -67,43 +67,17 @@
 }
 
-void psError(const char *name, const char *fmt, ...)
+psErrorCode p_psError(const char* file,
+                      int lineno,
+                      const char* func,
+                      psErrorCode code,
+                      psBool new,
+                      const char* fmt,
+                      ...)
 {
-    va_list argPtr;             // variable list arguement pointer
+    char errMsg[2048];
+    psErr* err;
+    char msgName[256];
 
-    // Get the variable list parameters to pass to logging function
-    va_start(argPtr, fmt);
-
-    // Call logging function with PS_LOG_ERROR level
-    psLogMsgV(name, PS_LOG_ERROR, fmt, argPtr);
-
-    // Clean up stack after variable argument has been used
-    va_end(argPtr);
-}
-
-void psErrorClear()
-{
-    pthread_mutex_lock(&lockErrorStack);
-    for (psS32 lcv=0;lcv<errorStackSize;lcv++) {
-        p_psMemSetPersistent(errorStack[lcv]->msg,false);
-        p_psMemSetPersistent(errorStack[lcv]->name,false);
-        p_psMemSetPersistent(errorStack[lcv],false);
-        psFree(errorStack[lcv]);
-    }
-    errorStackSize = 0;
-    pthread_mutex_unlock(&lockErrorStack);
-}
-
-psErrorCode psErrorMsg(const char *name, psErrorCode code, psBool new, const char* fmt, ...)
-{
-    char errMsg[1024];
-    psErr* err;
-    char* msgName;
-
-    // Check for null pointer and if found set to empty string;
-    if ( name == NULL ) {
-        msgName = "";
-    } else {
-        msgName = (char*)name;
-    }
+    snprintf(msgName,256,"%s (%s:%d)",func,file,lineno);
 
     va_list argPtr;             // variable list arguement pointer
@@ -116,5 +90,5 @@
     va_start(argPtr, fmt);
 
-    vsnprintf(errMsg,1024,fmt,argPtr);
+    vsnprintf(errMsg,2048,fmt,argPtr);
     err = psErrAlloc(msgName,code,errMsg);
     pushErrorStack(err);
@@ -160,4 +134,19 @@
 }
 
+void psErrorClear(void)
+{
+    pthread_mutex_lock(&lockErrorStack);
+
+    for (int lcv=0;lcv < errorStackSize; lcv++) {
+        p_psMemSetPersistent(errorStack[lcv],false);
+        p_psMemSetPersistent(errorStack[lcv]->msg,false);
+        p_psMemSetPersistent(errorStack[lcv]->name,false);
+        psFree(errorStack[lcv]);
+    }
+    errorStackSize = 0;
+
+    pthread_mutex_unlock(&lockErrorStack);
+
+}
 void psErrorStackPrint(FILE *fd, const char *fmt, ...)
 {
Index: /trunk/psLib/src/sysUtils/psError.h
===================================================================
--- /trunk/psLib/src/sysUtils/psError.h	(revision 2272)
+++ /trunk/psLib/src/sysUtils/psError.h	(revision 2273)
@@ -12,6 +12,6 @@
  *  @author Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -104,25 +104,19 @@
  *  log message.
  *
+ *  This function modifies the error stack.
+ *
+ *  @return psErrorCode    the given error code
  */
-void psError(
-    const char *name,                  ///< Source of error such as file or function detected
-    const char *fmt,                   ///< A printf style formatting statement defining msg
+psErrorCode p_psError(
+    const char* file,
+    int lineno,
+    const char* func,
+    psErrorCode code,                  ///< Error class code
+    psBool new,                        ///< true if error originates at this location
+    const char* fmt,
     ...
 );
 
-/** Reports an error message to the logging facility
- *
- *  This function will invoke the psLogMsg function with a level of
- *  PS_LOG_ERROR and pass the parameters name and fmt to generate a proper
- *  log message.
- *
- */
-psErrorCode psErrorMsg(
-    const char *name,                  ///< Name of error in the form aaa.bbb.ccc
-    psErrorCode code,                  ///< Error class code
-    psBool new,                          ///< true if error originates at this location
-    const char* fmt,                   ///< printf style formatting statement defining error message
-    ...
-);
+#define psError(code,new,...) p_psError(__FILE__,__LINE__,__func__,code,new,__VA_ARGS__)
 
 /** Create a new psErr struct
Index: /trunk/psLib/src/sysUtils/psErrorCodes.c
===================================================================
--- /trunk/psLib/src/sysUtils/psErrorCodes.c	(revision 2272)
+++ /trunk/psLib/src/sysUtils/psErrorCodes.c	(revision 2273)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -46,5 +46,6 @@
             {PS_ERR_BAD_PARAMETER_NULL,"parameter is null"},
             {PS_ERR_BAD_PARAMETER_SIZE,"size of parameter's data is outside of acceptable range."},
-            {PS_ERR_UNEXPECTED_NULL,"unexpected NULL foun"},
+            {PS_ERR_UNEXPECTED_NULL,"unexpected NULL found"},
+            {PS_ERR_OS_CALL_FAILED,"unexpected result from an OS standard library call"},
             //~End
             {PS_ERR_N_ERR_CLASSES,"error classes end marker"}
@@ -132,7 +133,6 @@
 
     if (errors == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psErrorCode_NULL_ERRORDESCRIPTION);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psErrorCode_NULL_ERRORDESCRIPTION);
         return;
     }
@@ -152,8 +152,7 @@
                         err) ) {
 
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister",
-                       PS_ERR_UNKNOWN, false,
-                       PS_ERRORTEXT_psErrorCode_ERRORCODE_REGISTER_FAILED,
-                       i);
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psErrorCode_ERRORCODE_REGISTER_FAILED,
+                    i);
         }
         p_psMemSetPersistent(dynamicErrorCodes->head,true);
Index: /trunk/psLib/src/sysUtils/psErrorCodes.h
===================================================================
--- /trunk/psLib/src/sysUtils/psErrorCodes.h	(revision 2272)
+++ /trunk/psLib/src/sysUtils/psErrorCodes.h	(revision 2273)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -52,5 +52,6 @@
     PS_ERR_BAD_PARAMETER_NULL,   ///< parameter is null
     PS_ERR_BAD_PARAMETER_SIZE,   ///< size of parameter's data is outside of acceptable range.
-    PS_ERR_UNEXPECTED_NULL,   ///< unexpected NULL foun
+    PS_ERR_UNEXPECTED_NULL,   ///< unexpected NULL found
+    PS_ERR_OS_CALL_FAILED,   ///< unexpected result from an OS standard library call
     //~End
     PS_ERR_N_ERR_CLASSES               ///< end marker - should not be used as a true error
Index: /trunk/psLib/src/sysUtils/psLogMsg.c
===================================================================
--- /trunk/psLib/src/sysUtils/psLogMsg.c	(revision 2272)
+++ /trunk/psLib/src/sysUtils/psLogMsg.c	(revision 2273)
@@ -11,6 +11,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -110,7 +110,7 @@
 
     if (sscanf(dest, "%4s:%256s", protocol, location) < 2) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,
-                   PS_ERRORTEXT_psLogMsg_DESTINATION_MALFORMED,
-                   dest);
+        psError(PS_ERR_LOCATION_INVALID, true,
+                PS_ERRORTEXT_psLogMsg_DESTINATION_MALFORMED,
+                dest);
         return false;
     }
@@ -131,7 +131,7 @@
             return true;
         }
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,
-                   PS_ERRORTEXT_psLogMsg_DEST_LOCATION_INVALID,
-                   location);
+        psError(PS_ERR_LOCATION_INVALID, true,
+                PS_ERRORTEXT_psLogMsg_DEST_LOCATION_INVALID,
+                location);
         return 1;
     } else if (strcmp(protocol, "file") == 0) {
@@ -139,7 +139,7 @@
 
         if (file == NULL) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_IO,
-                       PS_ERRORTEXT_psLogMsg_OPEN_FILE_FAILED,
-                       location);
+            psError(PS_ERR_IO, true,
+                    PS_ERRORTEXT_psLogMsg_OPEN_FILE_FAILED,
+                    location);
             return false;
         }
@@ -151,7 +151,7 @@
     }
 
-    psErrorMsg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,
-               PS_ERRORTEXT_psLogMsg_UNSUPPORTED_PROTOCOL,
-               protocol);
+    psError(PS_ERR_LOCATION_INVALID, true,
+            PS_ERRORTEXT_psLogMsg_UNSUPPORTED_PROTOCOL,
+            protocol);
     return false;
 }
@@ -215,6 +215,6 @@
             break;
         default:
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psLogSetFormat", true, PS_ERR_BAD_PARAMETER_VALUE,
-                       PS_ERRORTEXT_psLogMsg_UNKNOWN_KEY, *ptr);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psLogMsg_UNKNOWN_KEY, *ptr);
             break;
         }
Index: /trunk/psLib/src/sysUtils/psMemory.c
===================================================================
--- /trunk/psLib/src/sysUtils/psMemory.c	(revision 2272)
+++ /trunk/psLib/src/sysUtils/psMemory.c	(revision 2273)
@@ -8,6 +8,6 @@
 *  @author Robert Lupton, Princeton University
 *
-*  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 19:35:59 $
+*  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:05:00 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -100,7 +100,7 @@
 {
     if (ptr->refCounter < 1) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "memProblemCallbackDefault", false, PS_ERR_MEMORY_CORRUPTION,
-                   PS_ERRORTEXT_psMemory_MULTIPLE_FREE,
-                   ptr->id, ptr->file, ptr->lineno, file, lineno);
+        psError(PS_ERR_MEMORY_CORRUPTION, false,
+                PS_ERRORTEXT_psMemory_MULTIPLE_FREE,
+                ptr->id, ptr->file, ptr->lineno, file, lineno);
     }
 
@@ -228,6 +228,6 @@
 
     if (m == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
-                   PS_ERRORTEXT_psMemory_NULL_BLOCK);
+        psError(PS_ERR_MEMORY_CORRUPTION, true,
+                PS_ERRORTEXT_psMemory_NULL_BLOCK);
         return 1;
     }
@@ -235,20 +235,20 @@
     if (m->refCounter == 0) {
         // using an unreferenced block of memory, are you?
-        psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
-                   PS_ERRORTEXT_psMemory_DEREF_BLOCK_USE,
-                   m->id);
+        psError(PS_ERR_MEMORY_CORRUPTION, true,
+                PS_ERRORTEXT_psMemory_DEREF_BLOCK_USE,
+                m->id);
         return 1;
     }
 
     if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
-                   PS_ERRORTEXT_psMemory_UNDERFLOW,
-                   m->id);
+        psError(PS_ERR_MEMORY_CORRUPTION, true,
+                PS_ERRORTEXT_psMemory_UNDERFLOW,
+                m->id);
         return 1;
     }
     if (*(psPtr *)((int8_t *) (m + 1) + m->userMemorySize) != P_PS_MEMMAGIC) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
-                   PS_ERRORTEXT_psMemory_OVERFLOW,
-                   m->id);
+        psError(PS_ERR_MEMORY_CORRUPTION, true,
+                PS_ERRORTEXT_psMemory_OVERFLOW,
+                m->id);
         return 1;
     }
@@ -431,7 +431,7 @@
         psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
 
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psFree",PS_ERR_MEMORY_DEREF_USAGE,true,
-                   PS_ERRORTEXT_psMemory_MULTIPLE_FREE,
-                   ptr->id, ptr->file, ptr->lineno, file, lineno);
+        psError(PS_ERR_MEMORY_DEREF_USAGE,true,
+                PS_ERRORTEXT_psMemory_MULTIPLE_FREE,
+                ptr->id, ptr->file, ptr->lineno, file, lineno);
 
         return;
Index: /trunk/psLib/src/sysUtils/psString.c
===================================================================
--- /trunk/psLib/src/sysUtils/psString.c	(revision 2272)
+++ /trunk/psLib/src/sysUtils/psString.c	(revision 2273)
@@ -9,6 +9,6 @@
  *  @author Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -38,7 +38,7 @@
     if (nChar < 0) {
         // Log error message and return NULL
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psStringNCopy", PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psString_NCHAR_NEGATIVE,
-                   nChar);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psString_NCHAR_NEGATIVE,
+                nChar);
         return NULL;
     }
Index: /trunk/psLib/src/sysUtils/psTrace.c
===================================================================
--- /trunk/psLib/src/sysUtils/psTrace.c	(revision 2272)
+++ /trunk/psLib/src/sysUtils/psTrace.c	(revision 2273)
@@ -9,6 +9,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 23:31:44 $
+ *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -161,6 +161,6 @@
     // XXX: Verify that this is the correct behavior.
     if (strcmp("", addNodeName) == 0) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "componentAdd",PS_ERR_BAD_PARAMETER_NULL,true,
-                   PS_ERRORTEXT_psTrace_ADD_NULL_COMPONENT);
+        psError(PS_ERR_BAD_PARAMETER_NULL,true,
+                PS_ERRORTEXT_psTrace_ADD_NULL_COMPONENT);
         return false;
     }
@@ -173,7 +173,7 @@
 
     if (addNodeName[0] != '.') {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "componentAdd",PS_ERR_BAD_PARAMETER_VALUE,true,
-                   PS_ERRORTEXT_psTrace_MALFORMED_COMPONENT_NAME,
-                   addNodeName);
+        psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                PS_ERRORTEXT_psTrace_MALFORMED_COMPONENT_NAME,
+                addNodeName);
         return false;
     }
@@ -262,10 +262,8 @@
     // Add the new component to the component tree.
     if ( !componentAdd(compName, level) ) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psTraceSetLevel",
-                   PS_ERR_UNKNOWN,
-                   false,
-                   PS_ERRORTEXT_psTrace_FAILED_TO_ADD_COMPONENT,
-                   level,
-                   compName);
+        psError(PS_ERR_UNKNOWN, false,
+                PS_ERRORTEXT_psTrace_FAILED_TO_ADD_COMPONENT,
+                level,
+                compName);
 
         if (comp[0] != '.') {
@@ -482,7 +480,7 @@
 
     if (NULL == comp) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psTrace", PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psTrace_NULL_TRACETREE,
-                   __func__);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psTrace_NULL_TRACETREE,
+                __func__);
         return;
     }
Index: /trunk/psLib/src/types/psBitSet.c
===================================================================
--- /trunk/psLib/src/types/psBitSet.c	(revision 2272)
+++ /trunk/psLib/src/types/psBitSet.c	(revision 2273)
@@ -11,6 +11,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -72,8 +72,7 @@
 
     if (n < 0) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetAlloc",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psBitSet_ALLOC_NEG_SIZE,
-                   n);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psBitSet_ALLOC_NEG_SIZE,
+                n);
         return NULL;
     }
@@ -99,14 +98,12 @@
 
     if (inBitSet == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetSet",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psBitSet_SET_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psBitSet_SET_NULL);
         return inBitSet;
     } else if ( (bit < 0) ||
                 (bit > inBitSet->n * 8 - 1) ) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetSet",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
-                   bit,inBitSet->n * 8 - 1);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
+                bit,inBitSet->n * 8 - 1);
         return inBitSet;
     }
@@ -124,14 +121,12 @@
 
     if (inBitSet == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetClear",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psBitSet_SET_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psBitSet_SET_NULL);
         return inBitSet;
     } else if ( (bit < 0) ||
                 (bit > inBitSet->n * 8 - 1) ) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetClear",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
-                   bit,inBitSet->n * 8 - 1);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
+                bit,inBitSet->n * 8 - 1);
         return inBitSet;
     }
@@ -149,14 +144,12 @@
 
     if (inBitSet == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetTest",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psBitSet_SET_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psBitSet_SET_NULL);
         return false;
     } else if ( (bit < 0) ||
                 (bit > inBitSet->n * 8 - 1) ) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetTest",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
-                   bit,inBitSet->n * 8 - 1);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psBitSet_BIT_OUTOFRANGE,
+                bit,inBitSet->n * 8 - 1);
         return false;
     }
@@ -180,7 +173,6 @@
 
     if (inBitSet1 == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psBitSet_FIRST_OPERAND_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psBitSet_FIRST_OPERAND_NULL);
         psFree(outBitSet);
         return NULL;
@@ -189,7 +181,6 @@
 
     if (operator == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psBitSet_OPERATOR_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psBitSet_OPERATOR_NULL);
         psFree(outBitSet);
         return NULL;
@@ -217,8 +208,7 @@
         psFree(tempStr);
         psFree(outBitSet);
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psBitSet_OPERATOR_INVALID,
-                   operator);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psBitSet_OPERATOR_INVALID,
+                operator);
         return NULL;
     }
@@ -227,7 +217,6 @@
     if (op != NOT_OP) {
         if (inBitSet2 == NULL) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
-                       PS_ERR_BAD_PARAMETER_NULL, true,
-                       PS_ERRORTEXT_psBitSet_SECOND_OPERAND_NULL);
+            psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                    PS_ERRORTEXT_psBitSet_SECOND_OPERAND_NULL);
             psFree(outBitSet);
             return NULL;
@@ -235,7 +224,6 @@
 
         if (inBitSet1->n != inBitSet2->n) {
-            psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetOp",
-                       PS_ERR_BAD_PARAMETER_SIZE, true,
-                       PS_ERRORTEXT_psBitSet_OPERANDS_SIZE_DIFFER);
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    PS_ERRORTEXT_psBitSet_OPERANDS_SIZE_DIFFER);
             psFree(outBitSet);
             return NULL;
@@ -287,7 +275,6 @@
 {
     if (inBitSet == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetNot",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psBitSet_OPERAND_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psBitSet_OPERAND_NULL);
         psFree(outBitSet);
         return NULL;
@@ -297,7 +284,6 @@
 
     if (outBitSet == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psBitSetNot",
-                   PS_ERR_UNKNOWN, false,
-                   PS_ERRORTEXT_psBitSet_NOT_OP_FAILED);
+        psError(PS_ERR_UNKNOWN, false,
+                PS_ERRORTEXT_psBitSet_NOT_OP_FAILED);
     }
 
Index: /trunk/psLib/src/types/psHash.c
===================================================================
--- /trunk/psLib/src/types/psHash.c	(revision 2272)
+++ /trunk/psLib/src/types/psHash.c	(revision 2273)
@@ -11,6 +11,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 23:31:43 $
+*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:04:57 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -228,7 +228,6 @@
     // the way this procedure is called.
     if ((table == NULL) || (key == NULL)) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "doHashWork",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psHash_KEY_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psHash_KEY_NULL);
         return NULL;
     }
@@ -249,5 +248,6 @@
     // anyway.
     if ((hash < 0) || (hash >= table->nbucket)) {
-        psError(__func__, "Internal hash function out of range (%d)", hash);
+        psError(PS_ERR_UNKNOWN, true,
+                "Internal hash function out of range (%d)", hash);
     }
     // ptr will have the correct hash bucket.
@@ -347,19 +347,16 @@
 {
     if (table == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psHashAdd",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psHash_KEY_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psHash_KEY_NULL);
         return false;
     }
     if (key == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psHashAdd",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psHash_TABLE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psHash_TABLE_NULL);
         return false;
     }
     if (data == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psHashAdd",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psHash_DATA_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psHash_DATA_NULL);
     }
 
@@ -382,13 +379,11 @@
 {
     if (table == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psHashLookup",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psHash_KEY_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psHash_KEY_NULL);
         return NULL;
     }
     if (key == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psHashLookup",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psHash_TABLE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psHash_TABLE_NULL);
         return NULL;
     }
@@ -414,13 +409,11 @@
 
     if (table == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psHashRemove",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psHash_TABLE_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psHash_TABLE_NULL);
         return false;
     }
     if (key == NULL) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psHashRemove",
-                   PS_ERR_BAD_PARAMETER_NULL, true,
-                   PS_ERRORTEXT_psHash_KEY_NULL);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psHash_KEY_NULL);
         return false;
     }
Index: /trunk/psLib/src/types/psList.c
===================================================================
--- /trunk/psLib/src/types/psList.c	(revision 2272)
+++ /trunk/psLib/src/types/psList.c	(revision 2273)
@@ -6,6 +6,6 @@
  *  @author Robert Daniel DeSonia, MHPCC
  *
- *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:04:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -136,5 +136,6 @@
 
         if (position == NULL) {
-            psError(__func__, "%s failed to move cursor to specified location (%d)", __func__, location);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    "Failed to move cursor to specified location (%d)", location);
             position = list->head;         // since we no list->size != 0, this must be non-NULL
         }
@@ -173,5 +174,5 @@
 
     if (list == NULL) {
-        psError(__func__, "list parameter found to be NULL in %s", __func__);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true, "list parameter found to be NULL.");
         return false;
     }
@@ -194,5 +195,5 @@
 
         if (location == PS_LIST_UNKNOWN) {
-            psError(__func__, "Failed to find item in given psList.");
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Failed to find item in given psList.");
             pthread_mutex_unlock(&list->lock)
             ;
@@ -206,5 +207,6 @@
 
     if (elem == NULL) {
-        psError(__func__, "Couldn't position to given index (%d) to remove element from list.", location);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "Couldn't position to given index (%d) to remove element from list.", location);
         pthread_mutex_unlock(&list->lock)
         ;
@@ -257,5 +259,6 @@
 
     if (list == NULL) {
-        psError(__func__, "Unexpected null pointer for psList parameter (%s:%d).", __FILE__, __LINE__);
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                "Unexpected null pointer for psList parameter.");
         return;
     }
@@ -314,5 +317,6 @@
     default:
         if (where <= PS_LIST_HEAD) {   // bascially same as PS_LIST_UNKNOWN above
-            psError(__func__, "Can't move to an unknown position.  Not moving the iterator position.");
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    "Can't move to an unknown position.  Not moving the iterator position.");
         } else {
             cursor = listGetIterator(list);
Index: /trunk/psLib/src/types/psMetadata.c
===================================================================
--- /trunk/psLib/src/types/psMetadata.c	(revision 2272)
+++ /trunk/psLib/src/types/psMetadata.c	(revision 2273)
@@ -12,6 +12,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 00:57:30 $
+*  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:04:57 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -35,4 +35,6 @@
 #include "psMetadata.h"
 #include "psString.h"
+#include "psAstronomyErrors.h"
+#include "psConstants.h"
 
 /******************************************************************************/
@@ -123,8 +125,6 @@
 
 
-    if (name == NULL) {
-        psError(__func__, "Null value for name not allowed");
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(name,NULL);
+
     // Allocate metadata item
     metadataItem = (psMetadataItem* ) psAlloc(sizeof(psMetadataItem));
@@ -147,9 +147,16 @@
     // Set metadata item type
     metadataItem->type = type;
+    metadataItem->data.V = NULL;
+
+    // Allocate metadata items with same name.
+    metadataItem->items = psListAlloc(NULL);
+
+    // Allocate and set metadata item name
+    metadataItem->name = (char *)psAlloc(sizeof(char) * MAX_STRING_LENGTH);
+    vsprintf(metadataItem->name, name, argPtr);
 
     // Set metadata item value
     switch (type) {
     case PS_META_ITEM_SET:
-        metadataItem->data.V = NULL;
         break;
     case PS_META_BOOL:
@@ -180,13 +187,10 @@
     case PS_META_UNKNOWN:
     default:
-        psError(__func__, "Invalid psMetadataType: %d", type);
-    }
-
-    // Allocate and set metadata item name
-    metadataItem->name = (char *)psAlloc(sizeof(char) * MAX_STRING_LENGTH);
-    vsprintf(metadataItem->name, name, argPtr);
-
-    // Allocate metadata items with same name.
-    metadataItem->items = psListAlloc(NULL);
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psMetadata_METATYPE_INVALID,
+                type);
+        psFree(metadataItem);
+        metadataItem = NULL;
+    }
 
     return metadataItem;
@@ -224,33 +228,14 @@
     psMetadataType newType = PS_META_ITEM_SET;
 
-    if(md == NULL) {
-        psError( __func__, "Null metadata collection not allowed" );
-        return false;
-    }
-
-    if(metadataItem == NULL) {
-        psError( __func__, "Null metadata item not allowed" );
-        return false;
-    }
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->table,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
+    PS_PTR_CHECK_NULL(metadataItem,NULL);
+    PS_PTR_CHECK_NULL(metadataItem->name,NULL);
 
     newType = metadataItem->type;
-
     mdTable = md->table;
-    if(mdTable == NULL) {
-        psError( __func__, "Null metadata table not allowed" );
-        return false;
-    }
-
     mdList = md->list;
-    if(mdList == NULL) {
-        psError( __func__, "Null metadata list not allowed");
-        return false;
-    }
-
     key = metadataItem->name;
-    if(key == NULL) {
-        psError(__func__, "Null key item not allowed");
-        return false;
-    }
 
     // See if key is already in table
@@ -262,6 +247,7 @@
             // Add leaf node to existing folder node
             if(!psListAdd(existingEntry->items, PS_LIST_TAIL, metadataItem)) {
-                psError( __func__, "Couldn't add metadata item to items list. Name: %s",
-                         metadataItem->name );
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED,
+                        metadataItem->name );
                 return false;
             }
@@ -272,5 +258,7 @@
 
             if(!psListAdd(newFolderEntry->items, PS_LIST_TAIL, existingEntry)) {
-                psError( __func__, "Couldn't add metadata item to items list. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED,
+                        key);
                 psFree(newFolderEntry);
                 return false;
@@ -278,5 +266,7 @@
 
             if(!psListAdd(newFolderEntry->items, PS_LIST_TAIL, metadataItem)) {
-                psError( __func__, "Couldn't add metadata item to items list. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED,
+                        key);
                 psFree(newFolderEntry);
                 return false;
@@ -284,5 +274,7 @@
 
             if(!psHashRemove(mdTable, key)) {
-                psError( __func__, "Couldn't remove metadata item from metadata table. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED,
+                        key);
                 psFree(newFolderEntry);
                 return false;
@@ -290,5 +282,7 @@
 
             if(!psHashAdd(mdTable, key, newFolderEntry)) {
-                psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED,
+                        key);
                 psFree(newFolderEntry);
                 return false;
@@ -301,15 +295,21 @@
             // Folder node replaces leaf or folder node - Put old node into new folder and remove from table
             if(!psListAdd(metadataItem->items, PS_LIST_TAIL, existingEntry)) {
-                psError( __func__, "Couldn't add metadata item to items list. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_LIST_FAILED,
+                        key);
                 return false;
             }
 
             if(!psHashRemove(mdTable, key)) {
-                psError( __func__, "Couldn't remove metadata item from metadata table. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED,
+                        key);
                 return false;
             }
 
             if(!psHashAdd(mdTable, key, metadataItem)) {
-                psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED,
+                        key);
                 return false;
             }
@@ -319,5 +319,7 @@
         // Node doesn't exist - Add new metadata item to metadata collection's hash
         if(!psHashAdd(mdTable, key, metadataItem)) {
-            psError( __func__, "Couldn't add metadata item to metadata table. Name: %s", key);
+            psError(PS_ERR_UNKNOWN,false,
+                    PS_ERRORTEXT_psMetadata_ADD_TABLE_FAILED,
+                    key);
             return false;
         }
@@ -328,6 +330,7 @@
     if(metadataItem->type != PS_META_ITEM_SET) {
         if(!psListAdd(mdList, location, metadataItem)) {
-            psError( __func__, "Couldn't add metadata item to metadata collection list. Name: %s",
-                     metadataItem->name );
+            psError(PS_ERR_UNKNOWN,false,
+                    PS_ERRORTEXT_psMetadata_ADD_COLLECTION_FAILED,
+                    key);
             return false;
         }
@@ -348,6 +351,6 @@
 
     if (!psMetadataAddItem(md, metadataItem, where)) {
-        psError(__func__, "Couldn't add metadata item to metadata collection list. Name: %s",
-                metadataItem->name);
+        psError(PS_ERR_UNKNOWN,false,
+                PS_ERRORTEXT_psMetadata_ADD_FAILED);
         psFree(metadataItem);
         return false;
@@ -368,20 +371,11 @@
 
 
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return false;
-    }
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->table,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
 
     mdList = md->list;
-    if (mdList == NULL) {
-        psError(__func__, "Null metadata list not allowed");
-        return false;
-    }
-
     mdTable = md->table;
-    if (mdTable == NULL) {
-        psError(__func__, "Null metadata table not allowed");
-        return false;
-    }
+
     // Select removal by key or index
     if (key != NULL) {
@@ -390,5 +384,7 @@
         entry = (psMetadataItem* ) psHashLookup(mdTable, key);
         if (entry == NULL) {
-            psError(__func__, "Couldn't find metadata item. Name: %s", key);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psMetadata_FIND_FAILED,
+                    key);
             return false;
         }
@@ -402,5 +398,7 @@
             while (entryChild != NULL) {
                 if (!psListRemove(mdList, PS_LIST_UNKNOWN, entryChild)) {
-                    psError(__func__, "Couldn't remove metadata item from list. Name: %s", key);
+                    psError(PS_ERR_UNKNOWN,false,
+                            PS_ERRORTEXT_psMetadata_REMOVE_LIST_FAILED,
+                            key);
                     return false;
                 }
@@ -411,5 +409,7 @@
             // Table entry has no children. Remove entry from metadata collection's list
             if (!psListRemove(mdList, PS_LIST_UNKNOWN, entry)) {
-                psError(__func__, "Couldn't remove metadata item from list. Name: %s", key);
+                psError(PS_ERR_UNKNOWN,false,
+                        PS_ERRORTEXT_psMetadata_REMOVE_LIST_FAILED,
+                        key);
                 return false;
             }
@@ -417,5 +417,7 @@
         // Remove entry from metadata collection's table
         if (!psHashRemove(mdTable, key)) {
-            psError(__func__, "Couldn't remove metadata item from table. Name: %s", key);
+            psError(PS_ERR_UNKNOWN,false,
+                    PS_ERRORTEXT_psMetadata_REMOVE_TABLE_FAILED,
+                    key);
             return false;
         }
@@ -425,5 +427,7 @@
         entry = psListGet(mdList, where);
         if (entry == NULL) {
-            psError(__func__, "Couldn't find metadata item in list. Index: %d", where);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psMetadata_FIND_INDEX_FAILED,
+                    where);
             return false;
         }
@@ -431,5 +435,7 @@
         key = entry->name;
         if (key == NULL) {
-            psError(__func__, "Null key name not allowed. Index: %d", where);
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psMetadata_REMOVE_LIST_INDEX_FAILED,
+                    where);
             return false;
         }
@@ -447,19 +453,9 @@
 
 
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->table,NULL);
+    PS_PTR_CHECK_NULL(key,NULL);
 
     mdTable = md->table;
-    if (mdTable == NULL) {
-        psError(__func__, "Null metadata table not allowed");
-        return NULL;
-    }
-
-    if (key == NULL) {
-        psError(__func__, "Null key name not allowed");
-        return NULL;
-    }
 
     entry = (psMetadataItem* ) psHashLookup(mdTable, key);
@@ -473,64 +469,40 @@
 psMetadataItem* psMetadataGet(psMetadata* restrict md, psS32 where)
 {
+    psMetadataItem* entry = NULL;
+
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
+
+    entry = (psMetadataItem* ) psListGet(md->list, where);
+    if (entry == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psMetadata_FIND_INDEX_FAILED,
+                where);
+        return NULL;
+    }
+
+    return entry;
+}
+
+psBool psMetadataSetIterator(psMetadata* restrict md, psS32 where)
+{
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
+
+    psListSetIterator(md->list, where);
+
+    return true;
+}
+
+psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which)
+{
     psList* mdList = NULL;
     psMetadataItem* entry = NULL;
 
 
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
 
     mdList = md->list;
-    if (mdList == NULL) {
-        psError(__func__, "Null metadata list not allowed");
-        return NULL;
-    }
-
-    entry = (psMetadataItem* ) psListGet(mdList, where);
-    if (entry == NULL) {
-        psError(__func__, "Couldn't find metadata item with given index. Index: %d", where);
-        return NULL;
-    }
-
-    return entry;
-}
-
-psBool psMetadataSetIterator(psMetadata* restrict md, psS32 where)
-{
-    psList* mdList = NULL;
-
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return false;
-    }
-
-    mdList = md->list;
-    if (mdList == NULL) {
-        psError(__func__, "Null metadata list not allowed");
-        return false;
-    }
-
-    psListSetIterator(mdList, where);
-
-    return true;
-}
-
-psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which)
-{
-    psList* mdList = NULL;
-    psMetadataItem* entry = NULL;
-
-
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return NULL;
-    }
-
-    mdList = md->list;
-    if (mdList == NULL) {
-        psError(__func__, "Null metadata list not allowed");
-        return NULL;
-    }
 
     psListSetIterator(mdList, which);
@@ -559,14 +531,8 @@
 
 
-    if (md == NULL) {
-        psError(__func__, "Null metadata collection not allowed");
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(md,NULL);
+    PS_PTR_CHECK_NULL(md->list,NULL);
 
     mdList = md->list;
-    if (mdList == NULL) {
-        psError(__func__, "Null metadata list not allowed");
-        return NULL;
-    }
 
     psListSetIterator(mdList, which);
Index: /trunk/psLib/src/types/psMetadataConfig.c
===================================================================
--- /trunk/psLib/src/types/psMetadataConfig.c	(revision 2272)
+++ /trunk/psLib/src/types/psMetadataConfig.c	(revision 2273)
@@ -9,6 +9,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 00:57:30 $
+*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:04:57 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -29,4 +29,6 @@
 #include "psMetadata.h"
 #include "psMetadataIO.h"
+#include "psConstants.h"
+#include "psAstronomyErrors.h"
 
 
@@ -38,10 +40,10 @@
 #define FITS_ERROR(STRING,PS_ERROR) \
 fits_get_errstatus(status, fitsErr); \
-psError(__func__, STRING, PS_ERROR, fitsErr); \
+psError(PS_ERR_IO,true, STRING, PS_ERROR, fitsErr); \
 status = 0; \
 fits_close_file(fd, &status); \
 if(status){ \
     fits_get_errstatus(status, fitsErr); \
-    psError(__func__, "Couldn't close FITS file. FITS error: %s", fitsErr); \
+    psError(PS_ERR_IO,true, "Couldn't close FITS file. FITS error: %s", fitsErr); \
 } \
 status = 0; \
@@ -281,5 +283,7 @@
             default:
                 *status = 1;
-                psError(__func__, "Invalid type: %d", elemType);
+                psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                        PS_ERRORTEXT_psMetadataIO_TYPE_INVALID,
+                        elemType);
             }
 
@@ -302,18 +306,7 @@
     psMetadataType type;
 
-    if (fd == NULL) {
-        psError(__func__, "Null file descriptor not allowed");
-        return;
-    }
-
-    if (format == NULL) {
-        psError(__func__, "Null format not allowed");
-        return;
-    }
-
-    if (metadataItem == NULL) {
-        psError(__func__, "Null metadata not allowed");
-        return;
-    }
+    PS_PTR_CHECK_NULL(fd,);
+    PS_PTR_CHECK_NULL(format,);
+    PS_PTR_CHECK_NULL(metadataItem,);
 
     type = metadataItem->type;
@@ -336,5 +329,7 @@
         break;
     default:
-        psError(__func__, " Invalid psMetadataType to print: %d", type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE,true,
+                PS_ERRORTEXT_psMetadata_METATYPE_INVALID,
+                (int)type);
     }
 }
@@ -358,8 +353,5 @@
     fitsfile *fd = NULL;
 
-    if(fileName == NULL) {
-        psError(__func__, "Null fileName not allowed");
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(fileName,NULL);
 
     fits_open_file(&fd, fileName, READONLY, &status);
@@ -369,9 +361,8 @@
     }
 
-    if (extName == NULL && extNum == 0) {
-        psError(__func__, "Null extName and extNum = 0 not allowed");
-        return NULL;
-    } else if (extName && (extNum != -1) ) {
-        psError(__func__, "If extName specified, extNum arguments should be -1.");
+    if (extName == NULL && extNum < 1) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psMetadataIO_EXTNUM_NOTPOSITIVE,
+                extNum);
         return NULL;
     }
@@ -435,10 +426,14 @@
         case 'X':
         default:
-            psError(__func__, "Invalid psMetadataType: %c", keyType);
+            psError(PS_ERR_IO, true,
+                    PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID,
+                    keyType);
             return output;
         }
 
         if (!success) {
-            psError(__func__, "Failed to add metadata item. Name: %s", keyName);
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psMetadataIO_ADD_FAILED,
+                    keyName);
             return output;
         }
@@ -471,9 +466,9 @@
 
     // Check for nulls
-    if(fileName == NULL) {
-        psError(__func__, "Null fileName not allowed");
-        return -1;
-    } else if((fp=fopen(fileName, "r")) == NULL) {
-        psError(__func__, "Couldn't open file. Name: %s", fileName);
+    PS_PTR_CHECK_NULL(fileName,-1);
+    if((fp=fopen(fileName, "r")) == NULL) {
+        psError(PS_ERR_IO, true,
+                PS_ERRORTEXT_psMetadataIO_FILE_OPEN_FAILED,
+                fileName);
         return -1;
     }
@@ -486,7 +481,4 @@
     // Create reusable line for continuous read
     line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char));
-    if (line == NULL) {
-        psAbort(__func__, "Failed to allocate reusable line");
-    }
 
     // While loop to parse the file
@@ -504,13 +496,19 @@
             if(repeatedChars(linePtr, '@') > 1) {
                 failedLines++;
-                psError(__func__, "More than one @ charecter not allowed. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR,
+                        '@', lineCount, fileName);
                 continue;
             } else if(repeatedChars(linePtr, '*') > 1) {
                 failedLines++;
-                psError(__func__, "More than one * charecter not allowed. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR,
+                        '*', lineCount, fileName);
                 continue;
             } else if(repeatedChars(linePtr, '~') > 0) {
                 failedLines++;
-                psError(__func__, "Illegal character. Character:~ Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR,
+                        '~', lineCount, fileName);
                 continue;
             }
@@ -521,5 +519,7 @@
                 failedLines++;
                 status = 0;
-                psError(__func__, "Null name not allowed. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
+                        "name",lineCount, fileName);
                 continue;
             }
@@ -530,5 +530,7 @@
                 failedLines++;
                 status = 0;
-                psError(__func__, "Null type not allowed. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
+                        "type",lineCount, fileName);
                 continue;
             } else if(!strncmp(strType, "*", 1)) {
@@ -551,5 +553,7 @@
             } else {
                 failedLines++;
-                psError(__func__, "Invalid psMetadataType. Type: %s Line %d: %s", strType, lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID,
+                        strType, lineCount, fileName);
                 continue;
             }
@@ -565,5 +569,7 @@
                     failedLines++;
                     status = 0;
-                    psError(__func__, "Null value not allowed. Line %d: %s", lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
+                            "value",lineCount, fileName);
                     continue;
                 }
@@ -575,5 +581,7 @@
                 failedLines++;
                 status = 0;
-                psError(__func__, "Failed to parse comment. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
+                        "comment",lineCount, fileName);
                 continue;
             }
@@ -589,6 +597,7 @@
                     } else {
                         failedLines++;
-                        psError(__func__, "Overwrite for name not allowed. Name: %s. Line %d: %s", strName,
-                                lineCount, line);
+                        psError(PS_ERR_IO, true,
+                                PS_ERRORTEXT_psMetadataIO_OVERWRITE_ITEM,
+                                strName, lineCount, fileName);
                         continue;
                     }
@@ -608,5 +617,7 @@
                     status = 0;
                     failedLines++;
-                    psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
+                            strValue, strName, strType, lineCount, fileName);
                     continue;
                 }
@@ -619,5 +630,7 @@
                     status = 0;
                     failedLines++;
-                    psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
+                            strValue, strName, strType, lineCount, fileName);
                     continue;
                 }
@@ -631,5 +644,7 @@
                     status = 0;
                     failedLines++;
-                    psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
+                            strValue, strName, strType, lineCount, fileName);
                     continue;
                 }
@@ -645,5 +660,7 @@
                     status = 0;
                     failedLines++;
-                    psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
+                            strValue, strName, strType, lineCount, fileName);
                     continue;
                 }
@@ -651,5 +668,7 @@
             default:
                 failedLines++;
-                psError(__func__, "Invalid psMetadataType. Type: %d Line %d: %s", mdType, lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID,
+                        mdType, lineCount, fileName);
                 continue;
             } // switch
Index: /trunk/psLib/src/xml/psXML.c
===================================================================
--- /trunk/psLib/src/xml/psXML.c	(revision 2272)
+++ /trunk/psLib/src/xml/psXML.c	(revision 2273)
@@ -9,6 +9,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 00:57:30 $
+*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:04:57 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -29,4 +29,6 @@
 #include "psMetadata.h"
 #include "psMetadataIO.h"
+#include "psConstants.h"
+#include "psAstronomyErrors.h"
 
 
@@ -38,10 +40,10 @@
 #define FITS_ERROR(STRING,PS_ERROR) \
 fits_get_errstatus(status, fitsErr); \
-psError(__func__, STRING, PS_ERROR, fitsErr); \
+psError(PS_ERR_IO,true, STRING, PS_ERROR, fitsErr); \
 status = 0; \
 fits_close_file(fd, &status); \
 if(status){ \
     fits_get_errstatus(status, fitsErr); \
-    psError(__func__, "Couldn't close FITS file. FITS error: %s", fitsErr); \
+    psError(PS_ERR_IO,true, "Couldn't close FITS file. FITS error: %s", fitsErr); \
 } \
 status = 0; \
@@ -281,5 +283,7 @@
             default:
                 *status = 1;
-                psError(__func__, "Invalid type: %d", elemType);
+                psError(PS_ERR_BAD_PARAMETER_VALUE,true,
+                        PS_ERRORTEXT_psMetadataIO_TYPE_INVALID,
+                        elemType);
             }
 
@@ -302,18 +306,7 @@
     psMetadataType type;
 
-    if (fd == NULL) {
-        psError(__func__, "Null file descriptor not allowed");
-        return;
-    }
-
-    if (format == NULL) {
-        psError(__func__, "Null format not allowed");
-        return;
-    }
-
-    if (metadataItem == NULL) {
-        psError(__func__, "Null metadata not allowed");
-        return;
-    }
+    PS_PTR_CHECK_NULL(fd,);
+    PS_PTR_CHECK_NULL(format,);
+    PS_PTR_CHECK_NULL(metadataItem,);
 
     type = metadataItem->type;
@@ -336,5 +329,7 @@
         break;
     default:
-        psError(__func__, " Invalid psMetadataType to print: %d", type);
+        psError(PS_ERR_BAD_PARAMETER_TYPE,true,
+                PS_ERRORTEXT_psMetadata_METATYPE_INVALID,
+                (int)type);
     }
 }
@@ -358,8 +353,5 @@
     fitsfile *fd = NULL;
 
-    if(fileName == NULL) {
-        psError(__func__, "Null fileName not allowed");
-        return NULL;
-    }
+    PS_PTR_CHECK_NULL(fileName,NULL);
 
     fits_open_file(&fd, fileName, READONLY, &status);
@@ -369,9 +361,8 @@
     }
 
-    if (extName == NULL && extNum == 0) {
-        psError(__func__, "Null extName and extNum = 0 not allowed");
-        return NULL;
-    } else if (extName && (extNum != -1) ) {
-        psError(__func__, "If extName specified, extNum arguments should be -1.");
+    if (extName == NULL && extNum < 1) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psMetadataIO_EXTNUM_NOTPOSITIVE,
+                extNum);
         return NULL;
     }
@@ -435,10 +426,14 @@
         case 'X':
         default:
-            psError(__func__, "Invalid psMetadataType: %c", keyType);
+            psError(PS_ERR_IO, true,
+                    PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID,
+                    keyType);
             return output;
         }
 
         if (!success) {
-            psError(__func__, "Failed to add metadata item. Name: %s", keyName);
+            psError(PS_ERR_UNKNOWN, false,
+                    PS_ERRORTEXT_psMetadataIO_ADD_FAILED,
+                    keyName);
             return output;
         }
@@ -471,9 +466,9 @@
 
     // Check for nulls
-    if(fileName == NULL) {
-        psError(__func__, "Null fileName not allowed");
-        return -1;
-    } else if((fp=fopen(fileName, "r")) == NULL) {
-        psError(__func__, "Couldn't open file. Name: %s", fileName);
+    PS_PTR_CHECK_NULL(fileName,-1);
+    if((fp=fopen(fileName, "r")) == NULL) {
+        psError(PS_ERR_IO, true,
+                PS_ERRORTEXT_psMetadataIO_FILE_OPEN_FAILED,
+                fileName);
         return -1;
     }
@@ -486,7 +481,4 @@
     // Create reusable line for continuous read
     line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char));
-    if (line == NULL) {
-        psAbort(__func__, "Failed to allocate reusable line");
-    }
 
     // While loop to parse the file
@@ -504,13 +496,19 @@
             if(repeatedChars(linePtr, '@') > 1) {
                 failedLines++;
-                psError(__func__, "More than one @ charecter not allowed. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR,
+                        '@', lineCount, fileName);
                 continue;
             } else if(repeatedChars(linePtr, '*') > 1) {
                 failedLines++;
-                psError(__func__, "More than one * charecter not allowed. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR,
+                        '*', lineCount, fileName);
                 continue;
             } else if(repeatedChars(linePtr, '~') > 0) {
                 failedLines++;
-                psError(__func__, "Illegal character. Character:~ Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR,
+                        '~', lineCount, fileName);
                 continue;
             }
@@ -521,5 +519,7 @@
                 failedLines++;
                 status = 0;
-                psError(__func__, "Null name not allowed. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
+                        "name",lineCount, fileName);
                 continue;
             }
@@ -530,5 +530,7 @@
                 failedLines++;
                 status = 0;
-                psError(__func__, "Null type not allowed. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
+                        "type",lineCount, fileName);
                 continue;
             } else if(!strncmp(strType, "*", 1)) {
@@ -551,5 +553,7 @@
             } else {
                 failedLines++;
-                psError(__func__, "Invalid psMetadataType. Type: %s Line %d: %s", strType, lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID,
+                        strType, lineCount, fileName);
                 continue;
             }
@@ -565,5 +569,7 @@
                     failedLines++;
                     status = 0;
-                    psError(__func__, "Null value not allowed. Line %d: %s", lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
+                            "value",lineCount, fileName);
                     continue;
                 }
@@ -575,5 +581,7 @@
                 failedLines++;
                 status = 0;
-                psError(__func__, "Failed to parse comment. Line %d: %s", lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
+                        "comment",lineCount, fileName);
                 continue;
             }
@@ -589,6 +597,7 @@
                     } else {
                         failedLines++;
-                        psError(__func__, "Overwrite for name not allowed. Name: %s. Line %d: %s", strName,
-                                lineCount, line);
+                        psError(PS_ERR_IO, true,
+                                PS_ERRORTEXT_psMetadataIO_OVERWRITE_ITEM,
+                                strName, lineCount, fileName);
                         continue;
                     }
@@ -608,5 +617,7 @@
                     status = 0;
                     failedLines++;
-                    psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
+                            strValue, strName, strType, lineCount, fileName);
                     continue;
                 }
@@ -619,5 +630,7 @@
                     status = 0;
                     failedLines++;
-                    psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
+                            strValue, strName, strType, lineCount, fileName);
                     continue;
                 }
@@ -631,5 +644,7 @@
                     status = 0;
                     failedLines++;
-                    psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
+                            strValue, strName, strType, lineCount, fileName);
                     continue;
                 }
@@ -645,5 +660,7 @@
                     status = 0;
                     failedLines++;
-                    psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line);
+                    psError(PS_ERR_IO, true,
+                            PS_ERRORTEXT_psMetadataIO_PARSE_FAILED,
+                            strValue, strName, strType, lineCount, fileName);
                     continue;
                 }
@@ -651,5 +668,7 @@
             default:
                 failedLines++;
-                psError(__func__, "Invalid psMetadataType. Type: %d Line %d: %s", mdType, lineCount, line);
+                psError(PS_ERR_IO, true,
+                        PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID,
+                        mdType, lineCount, fileName);
                 continue;
             } // switch
Index: /trunk/psLib/test/astronomy/tst_psMetadata_01.c
===================================================================
--- /trunk/psLib/test/astronomy/tst_psMetadata_01.c	(revision 2272)
+++ /trunk/psLib/test/astronomy/tst_psMetadata_01.c	(revision 2273)
@@ -17,6 +17,6 @@
 *  @author  Ross Harman, MHPCC
 *
-*  @version $Revision: 1.13 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2004-10-27 00:57:33 $
+*  @version $Revision: 1.14 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2004-11-04 01:05:00 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -227,5 +227,5 @@
     metadata1 = psMetadataReadHeader(metadata1, NULL, 22, "header_2.fits");
     if (metadata1 != NULL ) {
-        psError(__func__,"psMetadataReadHeader did not return null when invalid ext given.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataReadHeader did not return null when invalid ext given.");
         return 10;
     }
@@ -238,5 +238,5 @@
     metadata1 = psMetadataReadHeader(NULL, "AARGH", -1, "header_2.fits");
     if (metadata1 != NULL ) {
-        psError(__func__,"psMetadataReadHeader did not return null invalid extname give.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataReadHeader did not return null invalid extname give.");
         return 11;
     }
@@ -249,5 +249,5 @@
     metadata1 = psMetadataReadHeader(NULL, "MY_DATA_2", 0, "header_2.fits");
     if (metadata1 != NULL ) {
-        psError(__func__,"psMetadataReadHeader did not return null w/ valid extname, invalid extnum");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataReadHeader did not return null w/ valid extname, invalid extnum");
         return 12;
     }
Index: /trunk/psLib/test/astronomy/tst_psMetadata_02.c
===================================================================
--- /trunk/psLib/test/astronomy/tst_psMetadata_02.c	(revision 2272)
+++ /trunk/psLib/test/astronomy/tst_psMetadata_02.c	(revision 2273)
@@ -14,6 +14,6 @@
 *  @author  Ross Harman, MHPCC
 *
-*  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2004-10-27 00:57:33 $
+*  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2004-11-04 01:05:00 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -92,5 +92,5 @@
     badItem = psMetadataItemAlloc(NULL, PS_META_STR, "I am a string", "HELLO WORLD");
     if (badItem != NULL) {
-        psError(__func__,"psMetadataItemAlloc did not return null with null name item.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataItemAlloc did not return null with null name item.");
         return 10;
     }
Index: /trunk/psLib/test/astronomy/tst_psMetadata_03.c
===================================================================
--- /trunk/psLib/test/astronomy/tst_psMetadata_03.c	(revision 2272)
+++ /trunk/psLib/test/astronomy/tst_psMetadata_03.c	(revision 2273)
@@ -14,6 +14,6 @@
 *  @author  Ross Harman, MHPCC
 *
-*  @version $Revision: 1.8 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2004-10-27 00:57:33 $
+*  @version $Revision: 1.9 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2004-11-04 01:05:00 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -91,17 +91,17 @@
     printPositiveTestHeader(stdout, "psMetadata", "Test B - Remove items from metadata by name");
     if( ! psMetadataAddItem(metadata, item1, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem did not return true when adding by name.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return true when adding by name.");
         return 10;
     }
     if( ! psMetadataAdd(metadata,PS_LIST_HEAD,"myItem2",PS_META_S32,"I am S32 integer",77) ) {
-        psError(__func__,"psMetadataAddItem did not return true when adding by name.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return true when adding by name.");
         return 11;
     }
     if ( ! psMetadataRemove(metadata, 0, "myItem1" ) ) {
-        psError(__func__,"psMetadataRemove did not return true when removing by name.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return true when removing by name.");
         return 12;
     }
     if ( ! psMetadataRemove(metadata, 0, "myItem2" ) ) {
-        psError(__func__,"psMetadataRemove did not return true when removing by name.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return true when removing by name.");
         return 13;
     }
@@ -112,17 +112,17 @@
     printPositiveTestHeader(stdout, "psMetadata", "Test C - Remove items from metadata by index");
     if ( ! psMetadataAddItem(metadata, item3, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem did not return true when adding by index.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return true when adding by index.");
         return 14;
     }
     if ( ! psMetadataAdd(metadata,PS_LIST_HEAD,"myItem4",PS_META_S32,"I am S32 integer",88) ) {
-        psError(__func__,"psMetadataAddItem did not return true when adding by index.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return true when adding by index.");
         return 15;
     }
     if( ! psMetadataRemove(metadata, 0, NULL) ) {
-        psError(__func__,"psMetadataRemove did not return true when removing by index.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return true when removing by index.");
         return 16;
     }
     if ( ! psMetadataRemove(metadata, 0, NULL ) ) {
-        psError(__func__,"psMetadataRemove did not return true when removing by index.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return true when removing by index.");
         return 17;
     }
@@ -134,5 +134,5 @@
                             "Null metadata collection not allowed", 0);
     if ( psMetadataRemove(NULL, 0, NULL) ) {
-        psError(__func__,"psMetadataRemove did not return false when removing from null metadata.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false when removing from null metadata.");
         return 18;
     }
@@ -144,5 +144,5 @@
                             "Couldn't find metadata item. Name: AARGH", 0);
     if( psMetadataRemove(metadata, 0, "AARGH") ) {
-        psError(__func__,"psMetadataRemove did not return false when removing non-existant item.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false when removing non-existant item.");
         return 19;
     }
@@ -154,5 +154,5 @@
                             "Couldn't find metadata item in list. Index: 22", 0);
     if( psMetadataRemove(metadata, 22, NULL) ) {
-        psError(__func__,"psMetadataRemove did not return false when removing non-existant item.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false when removing non-existant item.");
         return 20;
     }
@@ -167,9 +167,9 @@
     errMetadata->table = NULL;
     if ( psMetadataAddItem(errMetadata, item3, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem did not return false w/ invalid metadata struct w/o hash table.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return false w/ invalid metadata struct w/o hash table.");
         return 21;
     }
     if ( psMetadataRemove(errMetadata, PS_LIST_HEAD, "errItem") ) {
-        psError(__func__,"psMetadataRemove did not return false w/ invalid metadata struct w/o hash table.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false w/ invalid metadata struct w/o hash table.");
         return 31;
     }
@@ -183,9 +183,9 @@
     errMetadata->list = NULL;
     if ( psMetadataAddItem(errMetadata, item3, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem did not return false w/ invalid metadata struct w/o link list.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return false w/ invalid metadata struct w/o link list.");
         return 22;
     }
     if ( psMetadataRemove(errMetadata, PS_LIST_HEAD, "errItem") ) {
-        psError(__func__,"psMetadataRemove did not return false w/ invalid metadata struct w/o link list.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false w/ invalid metadata struct w/o link list.");
         return 32;
     }
@@ -199,5 +199,5 @@
     errItem->name = NULL;
     if ( psMetadataAddItem(errMetadata, errItem, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem did not return false with item with null name.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return false with item with null name.");
         return 23;
     }
@@ -211,5 +211,5 @@
     errMetadata->table = NULL;
     if ( psMetadataAdd(errMetadata, PS_LIST_HEAD, "errItem", PS_META_S32,"Integer",22) ) {
-        psError(__func__,"psMetadataAddItem did not return false w/ invalid metadata struct w/o hash table.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return false w/ invalid metadata struct w/o hash table.");
         return 24;
     }
@@ -227,5 +227,5 @@
     psFree(errMetadata);
     if( psMemCheckLeaks(0, NULL, stdout) != 0 ) {
-        psError(__func__,"Memory leaks detected.");
+        psError(PS_ERR_UNKNOWN, true,"Memory leaks detected.");
         return 25;
     }
Index: /trunk/psLib/test/astronomy/tst_psMetadata_04.c
===================================================================
--- /trunk/psLib/test/astronomy/tst_psMetadata_04.c	(revision 2272)
+++ /trunk/psLib/test/astronomy/tst_psMetadata_04.c	(revision 2273)
@@ -18,6 +18,6 @@
 *  @author  Ross Harman, MHPCC
 *
-*  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2004-10-27 00:57:33 $
+*  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2004-11-04 01:05:00 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -108,5 +108,5 @@
                             "Null metadata collection not allowed", 0);
     if ( psMetadataLookup(NULL, "myItem2") != NULL ) {
-        psError(__func__,"psMetadataLookup did not return NULL with null metadata.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataLookup did not return NULL with null metadata.");
         return 11;
     }
@@ -118,5 +118,5 @@
                             "Null key name not allowed", 0);
     if ( psMetadataLookup(metadata, NULL) != NULL ) {
-        psError(__func__,"psMetadata did not return NULL with null key.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadata did not return NULL with null key.");
         return 12;
     }
@@ -128,5 +128,5 @@
                             "Couldn't find metadata item. Name: AARGH", 0);
     if ( psMetadataLookup(metadata, "AARGH") != NULL ) {
-        psError(__func__,"psMetadata did not return NULL with a non-existant item.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadata did not return NULL with a non-existant item.");
         return 13;
     }
@@ -150,5 +150,5 @@
     item = psMetadataGet(NULL, 0);
     if ( item != NULL ) {
-        psError(__func__,"psMetadataGet did not return NULL with null metadata structure.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataGet did not return NULL with null metadata structure.");
         return 15;
     }
@@ -160,5 +160,5 @@
                             "Couldn't find metadata item with given index. Index: 22", 0);
     if ( psMetadataGet(metadata, 22) != NULL ) {
-        psError(__func__,"psMetadataGet did not return NULL with non-existant metadata item.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataGet did not return NULL with non-existant metadata item.");
         return 16;
     }
@@ -171,5 +171,5 @@
     metadata->table = NULL;
     if ( psMetadataLookup(metadata,"myItem2") != NULL ) {
-        psError(__func__,"psMetadataLookup did not return null for invalid metadata object.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataLookup did not return null for invalid metadata object.");
         return 20;
     }
@@ -183,5 +183,5 @@
     metadata->list = NULL;
     if ( psMetadataGet(metadata,0) != NULL ) {
-        psError(__func__,"psMetadataLookup did not return null for invalid metadata object.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataLookup did not return null for invalid metadata object.");
         return 20;
     }
@@ -197,5 +197,5 @@
     psFree(item4);
     if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) {
-        psError(__func__,"memory leaks detected.");
+        psError(PS_ERR_UNKNOWN, true,"memory leaks detected.");
         return 20;
     }
Index: /trunk/psLib/test/astronomy/tst_psMetadata_05.c
===================================================================
--- /trunk/psLib/test/astronomy/tst_psMetadata_05.c	(revision 2272)
+++ /trunk/psLib/test/astronomy/tst_psMetadata_05.c	(revision 2273)
@@ -22,6 +22,6 @@
 *  @author  Ross Harman, MHPCC
 *
-*  @version $Revision: 1.8 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2004-10-27 00:57:33 $
+*  @version $Revision: 1.9 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2004-11-04 01:05:00 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -145,5 +145,5 @@
     }
     if( psMetadataGetPrevious(metadata,"myItem3",1) == NULL) {
-        psError(__func__,"psMetadataGetPrevious did not return an item from metadata.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataGetPrevious did not return an item from metadata.");
         return 45;
     }
@@ -151,5 +151,5 @@
     metadata->list = NULL;
     if ( psMetadataGetPrevious(metadata,NULL,1) != NULL) {
-        psError(__func__,"psMetadataGetPrevious did not return null for invalid metadata.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataGetPrevious did not return null for invalid metadata.");
         return 50;
     }
@@ -213,5 +213,5 @@
                             "Null metadata collection not allowed", 0);
     if( psMetadataGetNext(NULL, "myItem2", 0) != NULL ) {
-        psError(__func__,"psMetadataGetNext did not return null for null metadata.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataGetNext did not return null for null metadata.");
         return 40;
     }
@@ -219,5 +219,5 @@
     metadata->list = NULL;
     if ( psMetadataGetNext(metadata, "myItem2", 0) != NULL ) {
-        psError(__func__,"psMetadataGetNext did not return null for invalid metadata.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataGetNext did not return null for invalid metadata.");
         return 41;
     }
@@ -267,5 +267,5 @@
     psFree(item8);
     if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) {
-        psError(__func__,"Memory leaks detected.");
+        psError(PS_ERR_UNKNOWN, true,"Memory leaks detected.");
         return 50;
     }
Index: /trunk/psLib/test/astronomy/tst_psMetadata_06.c
===================================================================
--- /trunk/psLib/test/astronomy/tst_psMetadata_06.c	(revision 2272)
+++ /trunk/psLib/test/astronomy/tst_psMetadata_06.c	(revision 2273)
@@ -13,6 +13,6 @@
 *  @author  Ross Harman, MHPCC
 *
-*  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2004-10-27 00:57:33 $
+*  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2004-11-04 01:05:00 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -88,9 +88,9 @@
     printPositiveTestHeader(stdout, "psMetadata", "Test B - Add leaf node on top of existing leaf node");
     if( ! psMetadataAddItem(metadata, item1a, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem returned false for adding a node top.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem returned false for adding a node top.");
         return 20;
     }
     if ( ! psMetadataAddItem(metadata, item1b, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem returned false for adding a node top.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem returned false for adding a node top.");
         return 21;
     }
@@ -102,5 +102,5 @@
     printPositiveTestHeader(stdout, "psMetadata", "Test C - Add leaf node to existing folder node");
     if ( ! psMetadataAddItem(metadata, item1c, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem return false for adding a not to existing node.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem return false for adding a not to existing node.");
         return 22;
     }
@@ -111,9 +111,9 @@
     printPositiveTestHeader(stdout, "psMetadata", "Test D - Add folder node on top of existing leaf node");
     if ( ! psMetadataAddItem(metadata, item2a, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem returned false for adding a node to existing leaf node.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem returned false for adding a node to existing leaf node.");
         return 23;
     }
     if ( ! psMetadataAddItem(metadata, item2b, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem returned false for adding a nod to existing leaf node.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem returned false for adding a nod to existing leaf node.");
         return 24;
     }
@@ -130,5 +130,5 @@
     psFree(metadata);
     if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) {
-        psError(__func__,"Memory leaks detected.");
+        psError(PS_ERR_UNKNOWN, true,"Memory leaks detected.");
         return 25;
     }
Index: /trunk/psLib/test/collections/tst_psArray.c
===================================================================
--- /trunk/psLib/test/collections/tst_psArray.c	(revision 2272)
+++ /trunk/psLib/test/collections/tst_psArray.c	(revision 2273)
@@ -12,6 +12,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2004-10-27 00:57:33 $
+ *  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -43,5 +43,5 @@
     psArray *psArr = psArrayAlloc(5);
     if (psArr->nalloc != 5) {
-        psError(__func__,"psArray didn't have proper number of elements.");
+        psError(PS_ERR_UNKNOWN, true,"psArray didn't have proper number of elements.");
         return 1;
     }
@@ -64,5 +64,5 @@
         printf("ts[%d].x = %d ts[%d].y = %.2f\n", i, ts->x, i, ts->y);
         if (fabsf(ts->x - 10*i) > 0.01f || fabsf(ts->y - 10.1*i) > 0.01f) {
-            psError(__func__,"Couldn't properly get elements from array.");
+            psError(PS_ERR_UNKNOWN, true,"Couldn't properly get elements from array.");
             return 2;
         }
@@ -70,10 +70,10 @@
     printf("array size = %d\n", psArr->nalloc);
     if (psArr->nalloc != 5) {
-        psError(__func__,"Array Size wrong");
+        psError(PS_ERR_UNKNOWN, true,"Array Size wrong");
         return 3;
     }
     printf("array population = %d\n", psArr->n);
     if (psArr->n != 5) {
-        psError(__func__,"Array population wrong");
+        psError(PS_ERR_UNKNOWN, true,"Array population wrong");
         return 4;
     }
@@ -98,5 +98,5 @@
         printf("ts[%d].x = %d ts[%d].y = %.2f\n", i, ts->x, i, ts->y);
         if (fabsf(ts->x - 10*i) > 0.01f || fabsf(ts->y - 10.1*i) > 0.01f) {
-            psError(__func__,"Couldn't properly get elements from array.");
+            psError(PS_ERR_UNKNOWN, true,"Couldn't properly get elements from array.");
             return 5;
         }
@@ -104,10 +104,10 @@
     printf("array size = %d\n", psArr->nalloc);
     if (psArr->nalloc != 10) {
-        psError(__func__,"Array Size wrong");
+        psError(PS_ERR_UNKNOWN, true,"Array Size wrong");
         return 6;
     }
     printf("array population = %d\n", psArr->n);
     if (psArr->n != 10) {
-        psError(__func__,"Array Population wrong");
+        psError(PS_ERR_UNKNOWN, true,"Array Population wrong");
         return 7;
     }
@@ -122,5 +122,5 @@
         printf("ts[%d].x = %d ts[%d].y = %.2f\n", i, ts->x, i, ts->y);
         if (fabsf(ts->x - 10*i) > 0.01f || fabsf(ts->y - 10.1*i) > 0.01f) {
-            psError(__func__,"Couldn't properly get elements from array.");
+            psError(PS_ERR_UNKNOWN, true,"Couldn't properly get elements from array.");
             return 8;
         }
@@ -128,10 +128,10 @@
     printf("array size = %d\n", psArr->nalloc);
     if (psArr->nalloc != 3) {
-        psError(__func__,"Array Size wrong");
+        psError(PS_ERR_UNKNOWN, true,"Array Size wrong");
         return 9;
     }
     printf("array population = %d\n", psArr->n);
     if (psArr->n != 3) {
-        psError(__func__,"Array Population wrong");
+        psError(PS_ERR_UNKNOWN, true,"Array Population wrong");
         return 10;
     }
Index: /trunk/psLib/test/collections/tst_psList.c
===================================================================
--- /trunk/psLib/test/collections/tst_psList.c	(revision 2272)
+++ /trunk/psLib/test/collections/tst_psList.c	(revision 2273)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:33 $
+ *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -44,5 +44,5 @@
 
     if (! runTestSuite(stderr,"psList",tests,argc,argv) ) {
-        psError(__FILE__,"One or more tests failed");
+        psError(PS_ERR_UNKNOWN,true,"One or more tests failed");
         return 1;
     }
@@ -66,15 +66,15 @@
     list = psListAlloc(NULL);
     if (list == NULL) {
-        psError(__func__,"psListAlloc failed to return a list.");
+        psError(PS_ERR_UNKNOWN, true,"psListAlloc failed to return a list.");
         return 1;
     }
 
     if (list->head != NULL || list->tail != NULL) {
-        psError(__func__,"head and/or tail was not NULL for empty list.");
+        psError(PS_ERR_UNKNOWN, true,"head and/or tail was not NULL for empty list.");
         return 2;
     }
 
     if (list->size != 0) {
-        psError(__func__,"size of list wasn't zero for empty list.");
+        psError(PS_ERR_UNKNOWN, true,"size of list wasn't zero for empty list.");
         return 3;
     }
@@ -84,20 +84,20 @@
     list = psListAlloc(data);
     if (list == NULL) {
-        psError(__func__,"psListAlloc failed to return a list.");
+        psError(PS_ERR_UNKNOWN, true,"psListAlloc failed to return a list.");
         return 4;
     }
 
     if (list->head == NULL || list->tail == NULL) {
-        psError(__func__,"head and/or tail was NULL for one-element new list.");
+        psError(PS_ERR_UNKNOWN, true,"head and/or tail was NULL for one-element new list.");
         return 5;
     }
 
     if (list->head->data != data || list->tail->data != data) {
-        psError(__func__,"head and/or tail didn't point to data's node for one-element new list.");
+        psError(PS_ERR_UNKNOWN, true,"head and/or tail didn't point to data's node for one-element new list.");
         return 6;
     }
 
     if (list->size != 1) {
-        psError(__func__,"size of list wasn't correctly set for new, one-element list.");
+        psError(PS_ERR_UNKNOWN, true,"size of list wasn't correctly set for new, one-element list.");
         return 7;
     }
@@ -105,5 +105,5 @@
     ref = psMemGetRefCounter(data);
     if (ref != 2) {
-        psError(__func__,"psList didn't increment reference count of data (%d.",ref);
+        psError(PS_ERR_UNKNOWN, true,"psList didn't increment reference count of data (%d.",ref);
         return 8;
     }
@@ -139,5 +139,5 @@
     //  1. list is NULL (error)
     if (psListAdd(NULL,PS_LIST_HEAD,data)) {
-        psError(__func__,"psListAdd was given a NULL list, but returned a true/success.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd was given a NULL list, but returned a true/success.");
         return 1;
     }
@@ -146,5 +146,5 @@
     psFree(data);
     if (list->size != 1) {
-        psError(__func__,"psListAlloc didn't create a list properly.");
+        psError(PS_ERR_UNKNOWN, true,"psListAlloc didn't create a list properly.");
         return 2;
     }
@@ -152,9 +152,9 @@
     //  2. data is NULL (error, list should not grow)
     if (psListAdd(list, PS_LIST_HEAD,NULL)) {
-        psError(__func__,"psListAdd successfully added a NULL data item?");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd successfully added a NULL data item?");
         return 40;
     }
     if ( list->size != 1) {
-        psError(__func__,"psListAdd with a NULL data element changed the list size or returned success.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd with a NULL data element changed the list size or returned success.");
         return 3;
     }
@@ -164,10 +164,10 @@
     *data = 2;
     if ( ! psListAdd(list,PS_LIST_HEAD,data) ) {
-        psError(__func__,"psListAdd failed to add a data item to head.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd failed to add a data item to head.");
         return 21;
     }
 
     if (psMemGetRefCounter(data) != 2) {
-        psError(__func__,"psListAdd didn't increment the data reference count.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd didn't increment the data reference count.");
         return 20;
     }
@@ -176,5 +176,5 @@
     // verify that the size incremented
     if (list->size != 2) {
-        psError(__func__,"psListAdd didn't increment the size by one");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd didn't increment the size by one");
         return 4;
     }
@@ -182,5 +182,5 @@
     // verify that the head is the inserted data item
     if (*(psS32*)list->head->data != 2) {
-        psError(__func__,"psListAdd with PS_LIST_HEAD didn't insert at the head.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd with PS_LIST_HEAD didn't insert at the head.");
         return 5;
     }
@@ -189,10 +189,10 @@
     *data = 3;
     if ( ! psListAdd(list,PS_LIST_TAIL,data) ) {
-        psError(__func__,"psListAdd failed to add a data item to tail.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd failed to add a data item to tail.");
         return 21;
     }
 
     if (psMemGetRefCounter(data) != 2) {
-        psError(__func__,"psListAdd didn't increment the data reference count.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd didn't increment the data reference count.");
         return 22;
     }
@@ -200,5 +200,5 @@
     // verify that the size incremented
     if (list->size != 3) {
-        psError(__func__,"psListAdd didn't increment the size by 1");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd didn't increment the size by 1");
         return 6;
     }
@@ -206,5 +206,5 @@
     // verify that the head is still the same
     if (*(psS32*)list->head->data != 2) {
-        psError(__func__,"psListAdd with PS_LIST_TAIL modified the head.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd with PS_LIST_TAIL modified the head.");
         return 7;
     }
@@ -212,5 +212,5 @@
     // verify that the tail is the data item inserted
     if (*(psS32*)list->tail->data != 3) {
-        psError(__func__,"psListAdd with PS_LIST_TAIL didn't insert at the tail.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd with PS_LIST_TAIL didn't insert at the tail.");
         return 8;
     }
@@ -223,9 +223,9 @@
 
     if ( psListAdd(list,-10,data) ) {
-        psError(__func__,"psListAdd successfully added data to a -10 position?");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd successfully added data to a -10 position?");
         return 30;
     }
     if (psMemGetRefCounter(data) != 1) {
-        psError(__func__,"psListAdd incremented the data reference count.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd incremented the data reference count.");
         return 24;
     }
@@ -234,5 +234,5 @@
     if (list->size != 3) {
         printListInt(list);
-        psError(__func__,"psListAdd didn't insert to head when where was invalid.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd didn't insert to head when where was invalid.");
         return 9;
     }
@@ -243,10 +243,10 @@
 
     if ( ! psListAdd(list,1,data) ) {
-        psError(__func__,"psListAdd failed to add data to 1 position.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd failed to add data to 1 position.");
         return 30;
     }
 
     if (psMemGetRefCounter(data) != 2) {
-        psError(__func__,"psListAdd didn't increment the data reference count.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd didn't increment the data reference count.");
         return 25;
     }
@@ -255,5 +255,5 @@
     if (list->size != 4 || *(psS32*)list->head->next->data != 5) {
         printListInt(list);
-        psError(__func__,"psListAdd didn't insert to position #1.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd didn't insert to position #1.");
         return 10;
     }
@@ -262,9 +262,9 @@
     *data = 6;
     if ( ! psListAdd(list,3,data) ) {
-        psError(__func__,"psListAdd failed to add data to 4 position.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd failed to add data to 4 position.");
         return 31;
     }
     if (psMemGetRefCounter(data) != 2) {
-        psError(__func__,"psListAdd didn't increment the data reference count.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd didn't increment the data reference count.");
         return 26;
     }
@@ -273,5 +273,5 @@
     if (list->size != 5  || *(psS32 *)list->head->next->next->next->data != 6) {
         printListInt(list);
-        psError(__func__,"psListAdd didn't insert to position #4.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd didn't insert to position #4.");
         return 50;
     }
@@ -280,9 +280,9 @@
     *data = 7;
     if ( ! psListAdd(list,2,data) ) {
-        psError(__func__,"psListAdd failed to add data to 2 position.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd failed to add data to 2 position.");
         return 32;
     }
     if (psMemGetRefCounter(data) != 2) {
-        psError(__func__,"psListAdd didn't increment the data reference count.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd didn't increment the data reference count.");
         return 28;
     }
@@ -291,5 +291,5 @@
     if (list->size != 6  || *(psS32 *)list->head->next->next->data != 7) {
         printListInt(list);
-        psError(__func__,"psListAdd didn't insert to position #2.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd didn't insert to position #2.");
         return 11;
     }
@@ -300,10 +300,10 @@
 
     if ( ! psListAdd(list,9,data) ) {
-        psError(__func__,"psListAdd failed to add data to a 9 position?");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd failed to add data to a 9 position?");
         return 30;
     }
 
     if (psMemGetRefCounter(data) != 2) {
-        psError(__func__,"psListAdd didn't increment the data reference count.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd didn't increment the data reference count.");
         return 29;
     }
@@ -314,5 +314,5 @@
     if (list->size != 7) {
         printListInt(list);
-        psError(__func__,"psListAdd didn't insert to position #9.");
+        psError(PS_ERR_UNKNOWN, true,"psListAdd didn't insert to position #9.");
         return 12;
     }
@@ -366,5 +366,5 @@
     psLogMsg(__func__,PS_LOG_INFO,"Following should be an error");
     if (psListGet(list,PS_LIST_HEAD) != NULL) {
-        psError(__func__,"psListGet didn't return NULL given a NULL list.");
+        psError(PS_ERR_UNKNOWN, true,"psListGet didn't return NULL given a NULL list.");
         return 1;
     };
@@ -394,10 +394,10 @@
     data = (psS32*)psListGet(list,3);
     if (data == NULL || *data != 3) {
-        psError(__func__,"psListGet failed with which=3");
+        psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=3");
         return 2;
     }
     data = (psS32*)psListGet(list,1);
     if (data == NULL || *data != 1) {
-        psError(__func__,"psListGet failed with which=1");
+        psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=1");
         return 3;
     }
@@ -406,10 +406,10 @@
     data = (psS32*)psListGet(list,5);
     if (data != NULL) {
-        psError(__func__,"psListGet failed with which=5");
+        psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=5");
         return 4;
     }
     data = (psS32*)psListGet(list,4);
     if (data != NULL) {
-        psError(__func__,"psListGet failed with which=4");
+        psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=4");
         return 5;
     }
@@ -418,5 +418,5 @@
     data = (psS32*)psListGet(list,PS_LIST_HEAD);
     if (data == NULL || *data != 0) {
-        psError(__func__,"psListGet failed with which=PS_LIST_HEAD");
+        psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=PS_LIST_HEAD");
         return 6;
     }
@@ -425,5 +425,5 @@
     data = (psS32*)psListGet(list,PS_LIST_NEXT);
     if (data == NULL || *data != 1) {
-        psError(__func__,"psListGet failed with which=PS_LIST_NEXT");
+        psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=PS_LIST_NEXT");
         return 7;
     }
@@ -432,5 +432,5 @@
     data = (psS32*)psListGet(list,PS_LIST_TAIL);
     if (data == NULL || *data != 3) {
-        psError(__func__,"psListGet failed with which=PS_LIST_TAIL");
+        psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=PS_LIST_TAIL");
         return 8;
     }
@@ -439,5 +439,5 @@
     data = (psS32*)psListGet(list,PS_LIST_PREVIOUS);
     if (data == NULL || *data != 2) {
-        psError(__func__,"psListGet failed with which=PS_LIST_PREV");
+        psError(PS_ERR_UNKNOWN, true,"psListGet failed with which=PS_LIST_PREV");
         return 9;
     }
@@ -473,5 +473,5 @@
     psLogMsg(__func__,PS_LOG_INFO,"Following should be an error");
     if (psListRemove(list,PS_LIST_HEAD,NULL)) {
-        psError(__func__,"psListRemove didn't return false given a NULL list.");
+        psError(PS_ERR_UNKNOWN, true,"psListRemove didn't return false given a NULL list.");
         return 1;
     };
@@ -493,5 +493,5 @@
             (psListGet(list,PS_LIST_HEAD) == data) ) {
         printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_HEAD");
+        psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_HEAD");
         return 1;
     }
@@ -499,5 +499,5 @@
     if (list->size != 14) {
         printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 14.");
+        psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 14.");
         return 1;
     }
@@ -508,5 +508,5 @@
             (psListGet(list,PS_LIST_TAIL) == data) ) {
         printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_TAIL");
+        psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_TAIL");
         return 1;
     }
@@ -514,5 +514,5 @@
     if (list->size != 13) {
         printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 13.");
+        psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 13.");
         return 1;
     }
@@ -522,5 +522,5 @@
     if (! psListRemove(list,PS_LIST_NEXT,NULL)) {
         printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_NEXT @ PS_LIST_HEAD");
+        psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_NEXT @ PS_LIST_HEAD");
         return 1;
     }
@@ -528,5 +528,5 @@
     if (list->size != 12) {
         printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 12.");
+        psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 12.");
         return 1;
     }
@@ -536,5 +536,5 @@
     if (psListRemove(list,PS_LIST_NEXT,NULL)) {
         printListInt(list);
-        psError(__func__,"Removed something with PS_LIST_NEXT @ PS_LIST_TAIL");
+        psError(PS_ERR_UNKNOWN, true,"Removed something with PS_LIST_NEXT @ PS_LIST_TAIL");
         return 1;
     }
@@ -545,5 +545,5 @@
             ( psListGet(list,3) == data) ) {
         printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_NEXT @ which=2");
+        psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_NEXT @ which=2");
         return 1;
     }
@@ -551,5 +551,5 @@
     if (list->size != 11) {
         printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 11.");
+        psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 11.");
         return 1;
     }
@@ -560,5 +560,5 @@
     if (psListRemove(list,PS_LIST_PREVIOUS,NULL)) {
         printListInt(list);
-        psError(__func__,"removed something for PS_LIST_PREVIOUS @ PS_LIST_HEAD");
+        psError(PS_ERR_UNKNOWN, true,"removed something for PS_LIST_PREVIOUS @ PS_LIST_HEAD");
         return 1;
     }
@@ -569,5 +569,5 @@
             (psListGet(list,9) == data) ) {
         printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_PREVIOUS @ PS_LIST_TAIL");
+        psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_PREVIOUS @ PS_LIST_TAIL");
         return 1;
     }
@@ -575,5 +575,5 @@
     if (list->size != 10) {
         printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 10.");
+        psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 10.");
         return 1;
     }
@@ -584,5 +584,5 @@
             ( psListGet(list,1) == data) ) {
         printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_PREVIOUS @ which=2");
+        psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_PREVIOUS @ which=2");
         return 1;
     }
@@ -590,5 +590,5 @@
     if (list->size != 9) {
         printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 9.");
+        psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 9.");
         return 1;
     }
@@ -598,5 +598,5 @@
     if (psListRemove(list,PS_LIST_UNKNOWN,NULL)) {
         printListInt(list);
-        psError(__func__,"removed something for PS_LIST_UNKNOWN with data=NULL");
+        psError(PS_ERR_UNKNOWN, true,"removed something for PS_LIST_UNKNOWN with data=NULL");
         return 1;
     }
@@ -607,5 +607,5 @@
             (psListGet(list,PS_LIST_HEAD) == data) ) {
         printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_UNKNOWN @ PS_LIST_HEAD");
+        psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_UNKNOWN @ PS_LIST_HEAD");
         return 1;
     }
@@ -613,5 +613,5 @@
     if (list->size != 8) {
         printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 8.");
+        psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 8.");
         return 1;
     }
@@ -621,5 +621,5 @@
             (psListGet(list,PS_LIST_TAIL) == data) ) {
         printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_UNKNOWN @ PS_LIST_TAIL");
+        psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_UNKNOWN @ PS_LIST_TAIL");
         return 1;
     }
@@ -627,5 +627,5 @@
     if (list->size != 7) {
         printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 7.");
+        psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 7.");
         return 1;
     }
@@ -637,5 +637,5 @@
             (psListGet(list,1) == data) ) {
         printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_UNKNOWN @ which=1");
+        psError(PS_ERR_UNKNOWN, true,"Failed to remove PS_LIST_UNKNOWN @ which=1");
         return 1;
     }
@@ -643,5 +643,5 @@
     if (list->size != 6) {
         printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 6.");
+        psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to 6.");
         return 1;
     }
@@ -651,5 +651,5 @@
     if ( psListRemove(list,PS_LIST_UNKNOWN,data) ) {
         printListInt(list);
-        psError(__func__,"removed something for PS_LIST_UNKNOWN with previously removed item");
+        psError(PS_ERR_UNKNOWN, true,"removed something for PS_LIST_UNKNOWN with previously removed item");
         return 1;
     }
@@ -666,5 +666,5 @@
             (psListGet(list,PS_LIST_HEAD) == data) ) {
         printListInt(list);
-        psError(__func__,"Failed to remove last element");
+        psError(PS_ERR_UNKNOWN, true,"Failed to remove last element");
         return 1;
     }
@@ -672,5 +672,5 @@
     if (list->size != 0) {
         printListInt(list);
-        psError(__func__,"Didn't remove all the elements.");
+        psError(PS_ERR_UNKNOWN, true,"Didn't remove all the elements.");
         return 1;
     }
@@ -709,20 +709,20 @@
 
     if (arr->n != 15 || list->size != 15) {
-        psError(__func__,"The created array didn't have the proper size");
+        psError(PS_ERR_UNKNOWN, true,"The created array didn't have the proper size");
         return 1;
     }
     for (psS32 i=0;i<arr->n;i++) {
         if (i != *(psS32*)arr->data[i]) {
-            psError(__func__,"Element %d of array is incorrect (%d).",
+            psError(PS_ERR_UNKNOWN, true,"Element %d of array is incorrect (%d).",
                     i,*(psS32*)arr->data[i]);
             return 1;
         }
         if (i != *(psS32*)psListGet(list,i)) {
-            psError(__func__,"Element %d of list is incorrect (%d).",
+            psError(PS_ERR_UNKNOWN, true,"Element %d of list is incorrect (%d).",
                     i,*(psS32*)arr->data[i]);
             return 1;
         }
         if (psMemGetRefCounter(arr->data[i]) != 2) {
-            psError(__func__,"Element %d had wrong reference count (%d).",
+            psError(PS_ERR_UNKNOWN, true,"Element %d had wrong reference count (%d).",
                     i,psMemGetRefCounter(arr->data[i]));
             return 1;
@@ -747,20 +747,20 @@
 
     if (arr->n != 15 || list->size != 15) {
-        psError(__func__,"The created array didn't have the proper size");
+        psError(PS_ERR_UNKNOWN, true,"The created array didn't have the proper size");
         return 1;
     }
     for (psS32 i=0;i<arr->n;i++) {
         if (i != *(psS32*)arr->data[i]) {
-            psError(__func__,"Element %d of array is incorrect (%d).",
+            psError(PS_ERR_UNKNOWN, true,"Element %d of array is incorrect (%d).",
                     i,*(psS32*)arr->data[i]);
             return 1;
         }
         if (i != *(psS32*)psListGet(list,i)) {
-            psError(__func__,"Element %d of list is incorrect (%d).",
+            psError(PS_ERR_UNKNOWN, true,"Element %d of list is incorrect (%d).",
                     i,*(psS32*)arr->data[i]);
             return 1;
         }
         if (psMemGetRefCounter(arr->data[i]) != 2) {
-            psError(__func__,"Element %d had wrong reference count (%d).",
+            psError(PS_ERR_UNKNOWN, true,"Element %d had wrong reference count (%d).",
                     i,psMemGetRefCounter(arr->data[i]));
             return 1;
@@ -775,5 +775,5 @@
     arr = psListToArray(NULL);
     if (arr != NULL) {
-        psError(__func__,"psListToArray didn't return NULL when given NULL");
+        psError(PS_ERR_UNKNOWN, true,"psListToArray didn't return NULL when given NULL");
         return 1;
     }
@@ -781,5 +781,5 @@
     list = psArrayToList(NULL);
     if (list != NULL) {
-        psError(__func__,"psArrayToList didn't return NULL when given NULL");
+        psError(PS_ERR_UNKNOWN, true,"psArrayToList didn't return NULL when given NULL");
         return 1;
     }
@@ -790,5 +790,5 @@
     list = psArrayToList(arr);
     if (list == NULL) {
-        psError(__func__,"psArrayToList didn't create an empty list from an "
+        psError(PS_ERR_UNKNOWN, true,"psArrayToList didn't create an empty list from an "
                 "empty array.");
         return 1;
@@ -800,5 +800,5 @@
     arr = psListToArray(list);
     if (arr == NULL) {
-        psError(__func__,"psArrayToList didn't create an empty array from an "
+        psError(PS_ERR_UNKNOWN, true,"psArrayToList didn't create an empty array from an "
                 "empty list.");
         return 1;
@@ -853,5 +853,5 @@
     psListSetIterator(list,PS_LIST_TAIL);
     if (*(psS32*)psListGetCurrent(list) != 14) {
-        psError(__func__,"Didn't successfully move cursor to tail.");
+        psError(PS_ERR_UNKNOWN, true,"Didn't successfully move cursor to tail.");
         return 1;
     }
@@ -860,5 +860,5 @@
     psListSetIterator(list,PS_LIST_HEAD);
     if (*(psS32*)psListGetCurrent(list) != 0) {
-        psError(__func__,"Didn't successfully move cursor to head.");
+        psError(PS_ERR_UNKNOWN, true,"Didn't successfully move cursor to head.");
         return 2;
     }
@@ -867,10 +867,10 @@
     psListSetIterator(list,PS_LIST_NEXT);
     if (*(psS32*)psListGetCurrent(list) != 1) {
-        psError(__func__,"Didn't successfully move cursor to next.");
+        psError(PS_ERR_UNKNOWN, true,"Didn't successfully move cursor to next.");
         return 3;
     }
     psListSetIterator(list,PS_LIST_NEXT);
     if (*(psS32*)psListGetCurrent(list) != 2) {
-        psError(__func__,"Didn't successfully move cursor to next twice.");
+        psError(PS_ERR_UNKNOWN, true,"Didn't successfully move cursor to next twice.");
         return 4;
     }
@@ -879,10 +879,10 @@
     psListSetIterator(list,PS_LIST_PREVIOUS);
     if (*(psS32*)psListGetCurrent(list) != 1) {
-        psError(__func__,"Didn't successfully move cursor to previous.");
+        psError(PS_ERR_UNKNOWN, true,"Didn't successfully move cursor to previous.");
         return 5;
     }
     psListSetIterator(list,PS_LIST_PREVIOUS);
     if (*(psS32*)psListGetCurrent(list) != 0) {
-        psError(__func__,"Didn't successfully move cursor to previous twice.");
+        psError(PS_ERR_UNKNOWN, true,"Didn't successfully move cursor to previous twice.");
         return 6;
     }
@@ -893,10 +893,10 @@
     psListSetIterator(list,PS_LIST_UNKNOWN);
     if (*(psS32*)psListGetCurrent(list) != 1) {
-        psError(__func__,"PS_LIST_UNKNOWN moved cursor.");
+        psError(PS_ERR_UNKNOWN, true,"PS_LIST_UNKNOWN moved cursor.");
         return 7;
     }
     psListSetIterator(list,PS_LIST_CURRENT);
     if (*(psS32*)psListGetCurrent(list) != 1) {
-        psError(__func__,"PS_LIST_CURRENT moved cursor.");
+        psError(PS_ERR_UNKNOWN, true,"PS_LIST_CURRENT moved cursor.");
         return 8;
     }
@@ -904,25 +904,25 @@
     // test psListGetPrevious/Next
     if (*(psS32*)psListGetNext(list) != 2) {
-        psError(__func__,"psListGetNext didn't move cursor to next.");
+        psError(PS_ERR_UNKNOWN, true,"psListGetNext didn't move cursor to next.");
         return 9;
     }
     if (*(psS32*)psListGetNext(list) != 3) {
-        psError(__func__,"psListGetNext didn't move cursor to next.");
+        psError(PS_ERR_UNKNOWN, true,"psListGetNext didn't move cursor to next.");
         return 10;
     }
     if (*(psS32*)psListGetPrevious(list) != 2) {
-        psError(__func__,"psListGetPrevious didn't move cursor to previous.");
+        psError(PS_ERR_UNKNOWN, true,"psListGetPrevious didn't move cursor to previous.");
         return 11;
     }
     if (*(psS32*)psListGetPrevious(list) != 1) {
-        psError(__func__,"psListGetPrevious didn't move cursor to previous.");
+        psError(PS_ERR_UNKNOWN, true,"psListGetPrevious didn't move cursor to previous.");
         return 12;
     }
     if (*(psS32*)psListGetPrevious(list) != 0) {
-        psError(__func__,"psListGetPrevious didn't move cursor to previous..");
+        psError(PS_ERR_UNKNOWN, true,"psListGetPrevious didn't move cursor to previous..");
         return 13;
     }
     if (psListGetPrevious(list) != NULL) {
-        psError(__func__,"psListGetPrevious moved cursor beyond head.");
+        psError(PS_ERR_UNKNOWN, true,"psListGetPrevious moved cursor beyond head.");
         return 14;
     }
@@ -930,5 +930,5 @@
     psListSetIterator(list,PS_LIST_TAIL); // works according to an above test
     if (psListGetNext(list) != NULL) {
-        psError(__func__,"psListGetNext moved cursor beyond tail.");
+        psError(PS_ERR_UNKNOWN, true,"psListGetNext moved cursor beyond tail.");
         return 15;
     }
@@ -959,5 +959,5 @@
         psListAdd(list,PS_LIST_TAIL,data[lcv]);
         if (psMemGetRefCounter(data[lcv]) != 2) {
-            psError(__func__,"Reference counter for data was not incremented");
+            psError(PS_ERR_UNKNOWN, true,"Reference counter for data was not incremented");
             return 1;
         }
@@ -969,5 +969,5 @@
     */
     if (list->size != 15) {
-        psError(__func__,"List wasn't populated as expected?");
+        psError(PS_ERR_UNKNOWN, true,"List wasn't populated as expected?");
         return 2;
     }
@@ -989,5 +989,5 @@
     for (psS32 i=0;i<15;i++) {
         if (psMemGetRefCounter(data[i]) != 1) {
-            psError(__func__,"pslistFree didn't decrement the data item's reference counter");
+            psError(PS_ERR_UNKNOWN, true,"pslistFree didn't decrement the data item's reference counter");
             return 3;
         }
@@ -1039,5 +1039,5 @@
             iter = psListGet(list,PS_LIST_NEXT)) {
         if (*prevValue > *iter) {
-            psError(__func__,"Hey, the list wasn't sorted!?");
+            psError(PS_ERR_UNKNOWN, true,"Hey, the list wasn't sorted!?");
             return 1;
         }
@@ -1059,5 +1059,5 @@
             iter = psListGet(list,PS_LIST_NEXT)) {
         if (*prevValue < *iter) {
-            psError(__func__,"Hey, the list wasn't sorted!?");
+            psError(PS_ERR_UNKNOWN, true,"Hey, the list wasn't sorted!?");
             return 1;
         }
@@ -1105,5 +1105,5 @@
             iter = psListGet(list,PS_LIST_NEXT)) {
         if (*prev > *iter) {
-            psError(__func__,"Hey, the list wasn't sorted!?");
+            psError(PS_ERR_UNKNOWN, true,"Hey, the list wasn't sorted!?");
             return 1;
         }
@@ -1125,5 +1125,5 @@
             iter = psListGet(list,PS_LIST_NEXT)) {
         if (*prev < *iter) {
-            psError(__func__,"Hey, the list wasn't sorted!?");
+            psError(PS_ERR_UNKNOWN, true,"Hey, the list wasn't sorted!?");
             return 1;
         }
Index: /trunk/psLib/test/collections/tst_psMetadata_01.c
===================================================================
--- /trunk/psLib/test/collections/tst_psMetadata_01.c	(revision 2272)
+++ /trunk/psLib/test/collections/tst_psMetadata_01.c	(revision 2273)
@@ -17,6 +17,6 @@
 *  @author  Ross Harman, MHPCC
 *
-*  @version $Revision: 1.13 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2004-10-27 00:57:33 $
+*  @version $Revision: 1.14 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2004-11-04 01:05:00 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -227,5 +227,5 @@
     metadata1 = psMetadataReadHeader(metadata1, NULL, 22, "header_2.fits");
     if (metadata1 != NULL ) {
-        psError(__func__,"psMetadataReadHeader did not return null when invalid ext given.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataReadHeader did not return null when invalid ext given.");
         return 10;
     }
@@ -238,5 +238,5 @@
     metadata1 = psMetadataReadHeader(NULL, "AARGH", -1, "header_2.fits");
     if (metadata1 != NULL ) {
-        psError(__func__,"psMetadataReadHeader did not return null invalid extname give.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataReadHeader did not return null invalid extname give.");
         return 11;
     }
@@ -249,5 +249,5 @@
     metadata1 = psMetadataReadHeader(NULL, "MY_DATA_2", 0, "header_2.fits");
     if (metadata1 != NULL ) {
-        psError(__func__,"psMetadataReadHeader did not return null w/ valid extname, invalid extnum");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataReadHeader did not return null w/ valid extname, invalid extnum");
         return 12;
     }
Index: /trunk/psLib/test/collections/tst_psMetadata_02.c
===================================================================
--- /trunk/psLib/test/collections/tst_psMetadata_02.c	(revision 2272)
+++ /trunk/psLib/test/collections/tst_psMetadata_02.c	(revision 2273)
@@ -14,6 +14,6 @@
 *  @author  Ross Harman, MHPCC
 *
-*  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2004-10-27 00:57:33 $
+*  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2004-11-04 01:05:00 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -92,5 +92,5 @@
     badItem = psMetadataItemAlloc(NULL, PS_META_STR, "I am a string", "HELLO WORLD");
     if (badItem != NULL) {
-        psError(__func__,"psMetadataItemAlloc did not return null with null name item.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataItemAlloc did not return null with null name item.");
         return 10;
     }
Index: /trunk/psLib/test/collections/tst_psMetadata_03.c
===================================================================
--- /trunk/psLib/test/collections/tst_psMetadata_03.c	(revision 2272)
+++ /trunk/psLib/test/collections/tst_psMetadata_03.c	(revision 2273)
@@ -14,6 +14,6 @@
 *  @author  Ross Harman, MHPCC
 *
-*  @version $Revision: 1.8 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2004-10-27 00:57:33 $
+*  @version $Revision: 1.9 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2004-11-04 01:05:00 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -91,17 +91,17 @@
     printPositiveTestHeader(stdout, "psMetadata", "Test B - Remove items from metadata by name");
     if( ! psMetadataAddItem(metadata, item1, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem did not return true when adding by name.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return true when adding by name.");
         return 10;
     }
     if( ! psMetadataAdd(metadata,PS_LIST_HEAD,"myItem2",PS_META_S32,"I am S32 integer",77) ) {
-        psError(__func__,"psMetadataAddItem did not return true when adding by name.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return true when adding by name.");
         return 11;
     }
     if ( ! psMetadataRemove(metadata, 0, "myItem1" ) ) {
-        psError(__func__,"psMetadataRemove did not return true when removing by name.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return true when removing by name.");
         return 12;
     }
     if ( ! psMetadataRemove(metadata, 0, "myItem2" ) ) {
-        psError(__func__,"psMetadataRemove did not return true when removing by name.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return true when removing by name.");
         return 13;
     }
@@ -112,17 +112,17 @@
     printPositiveTestHeader(stdout, "psMetadata", "Test C - Remove items from metadata by index");
     if ( ! psMetadataAddItem(metadata, item3, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem did not return true when adding by index.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return true when adding by index.");
         return 14;
     }
     if ( ! psMetadataAdd(metadata,PS_LIST_HEAD,"myItem4",PS_META_S32,"I am S32 integer",88) ) {
-        psError(__func__,"psMetadataAddItem did not return true when adding by index.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return true when adding by index.");
         return 15;
     }
     if( ! psMetadataRemove(metadata, 0, NULL) ) {
-        psError(__func__,"psMetadataRemove did not return true when removing by index.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return true when removing by index.");
         return 16;
     }
     if ( ! psMetadataRemove(metadata, 0, NULL ) ) {
-        psError(__func__,"psMetadataRemove did not return true when removing by index.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return true when removing by index.");
         return 17;
     }
@@ -134,5 +134,5 @@
                             "Null metadata collection not allowed", 0);
     if ( psMetadataRemove(NULL, 0, NULL) ) {
-        psError(__func__,"psMetadataRemove did not return false when removing from null metadata.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false when removing from null metadata.");
         return 18;
     }
@@ -144,5 +144,5 @@
                             "Couldn't find metadata item. Name: AARGH", 0);
     if( psMetadataRemove(metadata, 0, "AARGH") ) {
-        psError(__func__,"psMetadataRemove did not return false when removing non-existant item.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false when removing non-existant item.");
         return 19;
     }
@@ -154,5 +154,5 @@
                             "Couldn't find metadata item in list. Index: 22", 0);
     if( psMetadataRemove(metadata, 22, NULL) ) {
-        psError(__func__,"psMetadataRemove did not return false when removing non-existant item.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false when removing non-existant item.");
         return 20;
     }
@@ -167,9 +167,9 @@
     errMetadata->table = NULL;
     if ( psMetadataAddItem(errMetadata, item3, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem did not return false w/ invalid metadata struct w/o hash table.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return false w/ invalid metadata struct w/o hash table.");
         return 21;
     }
     if ( psMetadataRemove(errMetadata, PS_LIST_HEAD, "errItem") ) {
-        psError(__func__,"psMetadataRemove did not return false w/ invalid metadata struct w/o hash table.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false w/ invalid metadata struct w/o hash table.");
         return 31;
     }
@@ -183,9 +183,9 @@
     errMetadata->list = NULL;
     if ( psMetadataAddItem(errMetadata, item3, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem did not return false w/ invalid metadata struct w/o link list.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return false w/ invalid metadata struct w/o link list.");
         return 22;
     }
     if ( psMetadataRemove(errMetadata, PS_LIST_HEAD, "errItem") ) {
-        psError(__func__,"psMetadataRemove did not return false w/ invalid metadata struct w/o link list.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataRemove did not return false w/ invalid metadata struct w/o link list.");
         return 32;
     }
@@ -199,5 +199,5 @@
     errItem->name = NULL;
     if ( psMetadataAddItem(errMetadata, errItem, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem did not return false with item with null name.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return false with item with null name.");
         return 23;
     }
@@ -211,5 +211,5 @@
     errMetadata->table = NULL;
     if ( psMetadataAdd(errMetadata, PS_LIST_HEAD, "errItem", PS_META_S32,"Integer",22) ) {
-        psError(__func__,"psMetadataAddItem did not return false w/ invalid metadata struct w/o hash table.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem did not return false w/ invalid metadata struct w/o hash table.");
         return 24;
     }
@@ -227,5 +227,5 @@
     psFree(errMetadata);
     if( psMemCheckLeaks(0, NULL, stdout) != 0 ) {
-        psError(__func__,"Memory leaks detected.");
+        psError(PS_ERR_UNKNOWN, true,"Memory leaks detected.");
         return 25;
     }
Index: /trunk/psLib/test/collections/tst_psMetadata_04.c
===================================================================
--- /trunk/psLib/test/collections/tst_psMetadata_04.c	(revision 2272)
+++ /trunk/psLib/test/collections/tst_psMetadata_04.c	(revision 2273)
@@ -18,6 +18,6 @@
 *  @author  Ross Harman, MHPCC
 *
-*  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2004-10-27 00:57:33 $
+*  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2004-11-04 01:05:00 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -108,5 +108,5 @@
                             "Null metadata collection not allowed", 0);
     if ( psMetadataLookup(NULL, "myItem2") != NULL ) {
-        psError(__func__,"psMetadataLookup did not return NULL with null metadata.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataLookup did not return NULL with null metadata.");
         return 11;
     }
@@ -118,5 +118,5 @@
                             "Null key name not allowed", 0);
     if ( psMetadataLookup(metadata, NULL) != NULL ) {
-        psError(__func__,"psMetadata did not return NULL with null key.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadata did not return NULL with null key.");
         return 12;
     }
@@ -128,5 +128,5 @@
                             "Couldn't find metadata item. Name: AARGH", 0);
     if ( psMetadataLookup(metadata, "AARGH") != NULL ) {
-        psError(__func__,"psMetadata did not return NULL with a non-existant item.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadata did not return NULL with a non-existant item.");
         return 13;
     }
@@ -150,5 +150,5 @@
     item = psMetadataGet(NULL, 0);
     if ( item != NULL ) {
-        psError(__func__,"psMetadataGet did not return NULL with null metadata structure.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataGet did not return NULL with null metadata structure.");
         return 15;
     }
@@ -160,5 +160,5 @@
                             "Couldn't find metadata item with given index. Index: 22", 0);
     if ( psMetadataGet(metadata, 22) != NULL ) {
-        psError(__func__,"psMetadataGet did not return NULL with non-existant metadata item.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataGet did not return NULL with non-existant metadata item.");
         return 16;
     }
@@ -171,5 +171,5 @@
     metadata->table = NULL;
     if ( psMetadataLookup(metadata,"myItem2") != NULL ) {
-        psError(__func__,"psMetadataLookup did not return null for invalid metadata object.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataLookup did not return null for invalid metadata object.");
         return 20;
     }
@@ -183,5 +183,5 @@
     metadata->list = NULL;
     if ( psMetadataGet(metadata,0) != NULL ) {
-        psError(__func__,"psMetadataLookup did not return null for invalid metadata object.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataLookup did not return null for invalid metadata object.");
         return 20;
     }
@@ -197,5 +197,5 @@
     psFree(item4);
     if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) {
-        psError(__func__,"memory leaks detected.");
+        psError(PS_ERR_UNKNOWN, true,"memory leaks detected.");
         return 20;
     }
Index: /trunk/psLib/test/collections/tst_psMetadata_05.c
===================================================================
--- /trunk/psLib/test/collections/tst_psMetadata_05.c	(revision 2272)
+++ /trunk/psLib/test/collections/tst_psMetadata_05.c	(revision 2273)
@@ -22,6 +22,6 @@
 *  @author  Ross Harman, MHPCC
 *
-*  @version $Revision: 1.8 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2004-10-27 00:57:33 $
+*  @version $Revision: 1.9 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2004-11-04 01:05:00 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -145,5 +145,5 @@
     }
     if( psMetadataGetPrevious(metadata,"myItem3",1) == NULL) {
-        psError(__func__,"psMetadataGetPrevious did not return an item from metadata.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataGetPrevious did not return an item from metadata.");
         return 45;
     }
@@ -151,5 +151,5 @@
     metadata->list = NULL;
     if ( psMetadataGetPrevious(metadata,NULL,1) != NULL) {
-        psError(__func__,"psMetadataGetPrevious did not return null for invalid metadata.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataGetPrevious did not return null for invalid metadata.");
         return 50;
     }
@@ -213,5 +213,5 @@
                             "Null metadata collection not allowed", 0);
     if( psMetadataGetNext(NULL, "myItem2", 0) != NULL ) {
-        psError(__func__,"psMetadataGetNext did not return null for null metadata.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataGetNext did not return null for null metadata.");
         return 40;
     }
@@ -219,5 +219,5 @@
     metadata->list = NULL;
     if ( psMetadataGetNext(metadata, "myItem2", 0) != NULL ) {
-        psError(__func__,"psMetadataGetNext did not return null for invalid metadata.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataGetNext did not return null for invalid metadata.");
         return 41;
     }
@@ -267,5 +267,5 @@
     psFree(item8);
     if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) {
-        psError(__func__,"Memory leaks detected.");
+        psError(PS_ERR_UNKNOWN, true,"Memory leaks detected.");
         return 50;
     }
Index: /trunk/psLib/test/collections/tst_psMetadata_06.c
===================================================================
--- /trunk/psLib/test/collections/tst_psMetadata_06.c	(revision 2272)
+++ /trunk/psLib/test/collections/tst_psMetadata_06.c	(revision 2273)
@@ -13,6 +13,6 @@
 *  @author  Ross Harman, MHPCC
 *
-*  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2004-10-27 00:57:33 $
+*  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2004-11-04 01:05:00 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -88,9 +88,9 @@
     printPositiveTestHeader(stdout, "psMetadata", "Test B - Add leaf node on top of existing leaf node");
     if( ! psMetadataAddItem(metadata, item1a, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem returned false for adding a node top.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem returned false for adding a node top.");
         return 20;
     }
     if ( ! psMetadataAddItem(metadata, item1b, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem returned false for adding a node top.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem returned false for adding a node top.");
         return 21;
     }
@@ -102,5 +102,5 @@
     printPositiveTestHeader(stdout, "psMetadata", "Test C - Add leaf node to existing folder node");
     if ( ! psMetadataAddItem(metadata, item1c, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem return false for adding a not to existing node.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem return false for adding a not to existing node.");
         return 22;
     }
@@ -111,9 +111,9 @@
     printPositiveTestHeader(stdout, "psMetadata", "Test D - Add folder node on top of existing leaf node");
     if ( ! psMetadataAddItem(metadata, item2a, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem returned false for adding a node to existing leaf node.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem returned false for adding a node to existing leaf node.");
         return 23;
     }
     if ( ! psMetadataAddItem(metadata, item2b, PS_LIST_HEAD) ) {
-        psError(__func__,"psMetadataAddItem returned false for adding a nod to existing leaf node.");
+        psError(PS_ERR_UNKNOWN, true,"psMetadataAddItem returned false for adding a nod to existing leaf node.");
         return 24;
     }
@@ -130,5 +130,5 @@
     psFree(metadata);
     if ( psMemCheckLeaks(0, NULL, stdout) != 0 ) {
-        psError(__func__,"Memory leaks detected.");
+        psError(PS_ERR_UNKNOWN, true,"Memory leaks detected.");
         return 25;
     }
Index: /trunk/psLib/test/dataManip/tst_psFunc02.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psFunc02.c	(revision 2272)
+++ /trunk/psLib/test/dataManip/tst_psFunc02.c	(revision 2273)
@@ -64,5 +64,5 @@
     }
 
-    p_psSpline1DFree(tmpSpline);
+    psFree(tmpSpline);
     psMemCheckCorruption(1);
     memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
@@ -90,5 +90,5 @@
     }
 
-    p_psSpline1DFree(tmpSpline);
+    psFree(tmpSpline);
     psMemCheckCorruption(1);
     memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
@@ -144,5 +144,5 @@
     }
 
-    p_psSpline1DFree(tmpSpline);
+    psFree(tmpSpline);
     psMemCheckCorruption(1);
     memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
@@ -198,5 +198,5 @@
     }
 
-    p_psSpline1DFree(tmpSpline);
+    psFree(tmpSpline);
     psMemCheckCorruption(1);
     memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
@@ -224,5 +224,5 @@
     }
 
-    p_psSpline1DFree(tmpSpline);
+    psFree(tmpSpline);
     psMemCheckCorruption(1);
     memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
@@ -278,5 +278,5 @@
     }
 
-    p_psSpline1DFree(tmpSpline);
+    psFree(tmpSpline);
     psMemCheckCorruption(1);
     memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
Index: /trunk/psLib/test/dataManip/tst_psFunc03.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psFunc03.c	(revision 2272)
+++ /trunk/psLib/test/dataManip/tst_psFunc03.c	(revision 2273)
@@ -72,5 +72,5 @@
     }
 
-    p_psSpline1DFree(tmpSpline);
+    psFree(tmpSpline);
     psFree(bounds);
     psMemCheckCorruption(1);
@@ -132,5 +132,5 @@
     }
 
-    p_psSpline1DFree(tmpSpline);
+    psFree(tmpSpline);
     psFree(bounds);
     psMemCheckCorruption(1);
Index: /trunk/psLib/test/dataManip/tst_psFunc04.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psFunc04.c	(revision 2272)
+++ /trunk/psLib/test/dataManip/tst_psFunc04.c	(revision 2273)
@@ -53,5 +53,5 @@
     }
 
-    p_psSpline1DFree(tmpSpline);
+    psFree(tmpSpline);
     psMemCheckCorruption(1);
     psFree(data);
@@ -105,5 +105,5 @@
     }
 
-    p_psSpline1DFree(tmpSpline);
+    psFree(tmpSpline);
     psMemCheckCorruption(1);
     psFree(data);
Index: /trunk/psLib/test/dataManip/tst_psFunc05.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psFunc05.c	(revision 2272)
+++ /trunk/psLib/test/dataManip/tst_psFunc05.c	(revision 2273)
@@ -59,5 +59,5 @@
     }
 
-    p_psSpline1DFree(tmpSpline);
+    psFree(tmpSpline);
 
     psFree(x);
Index: /trunk/psLib/test/dataManip/tst_psFunc07.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psFunc07.c	(revision 2272)
+++ /trunk/psLib/test/dataManip/tst_psFunc07.c	(revision 2273)
@@ -83,5 +83,5 @@
     psFree(newX);
     psFree(y);
-    p_psSpline1DFree(tmpSpline);
+    psFree(tmpSpline);
     psFree(newY);
 
@@ -152,5 +152,5 @@
     psFree(newX);
     psFree(y);
-    p_psSpline1DFree(tmpSpline);
+    psFree(tmpSpline);
     psFree(newY);
 
Index: /trunk/psLib/test/dataManip/tst_psMatrixVectorArithmetic02.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psMatrixVectorArithmetic02.c	(revision 2272)
+++ /trunk/psLib/test/dataManip/tst_psMatrixVectorArithmetic02.c	(revision 2273)
@@ -10,6 +10,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2004-10-27 00:57:33 $
+ *  @version $Revision: 1.8 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -83,10 +83,10 @@
 #define CHECK_MEMORY \
 if( psMemCheckLeaks(0, NULL, stdout) != 0 ) {  \
-    psError(__func__,"Memory leaks detected."); \
+    psError(PS_ERR_UNKNOWN, true,"Memory leaks detected."); \
     return 50; \
 } \
 psS32 nBad = psMemCheckCorruption(0); \
 if(nBad) { \
-    psError(__func__,"ERROR: Found %d bad memory blocks\n", nBad); \
+    psError(PS_ERR_UNKNOWN, true,"ERROR: Found %d bad memory blocks\n", nBad); \
     return 51; \
 }
Index: /trunk/psLib/test/dataManip/tst_psMatrixVectorArithmetic03.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psMatrixVectorArithmetic03.c	(revision 2272)
+++ /trunk/psLib/test/dataManip/tst_psMatrixVectorArithmetic03.c	(revision 2273)
@@ -15,6 +15,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2004-10-27 00:57:33 $
+ *  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -221,5 +221,5 @@
     CREATE_AND_SET_VECTOR(vector6,F64,0,3);
     if ( psBinaryOp(vector6,vector4,"+",NULL) != NULL ) {
-        psError(__func__,"psBinaryOp should return null when out and in1 valid but in2 null.");
+        psError(PS_ERR_UNKNOWN, true,"psBinaryOp should return null when out and in1 valid but in2 null.");
         return 10;
     }
@@ -228,5 +228,5 @@
     vector4->type.dimen = PS_DIMEN_OTHER;
     if ( psBinaryOp(NULL,vector4,"+",vector5) != NULL) {
-        psError(__func__,"psBinaryOp should return null when input dimen PS_DIMEN_OTHER.");
+        psError(PS_ERR_UNKNOWN, true,"psBinaryOp should return null when input dimen PS_DIMEN_OTHER.");
         return 11;
     }
@@ -236,5 +236,5 @@
     CREATE_AND_SET_IMAGE(image10,F64,0,3,3);
     if ( psBinaryOp(image10,inScalar,"+",vector4) == NULL ) {
-        psError(__func__,"psBinaryOp should not return null when input/out dimension don't match.");
+        psError(PS_ERR_UNKNOWN, true,"psBinaryOp should not return null when input/out dimension don't match.");
         return 12;
     }
Index: /trunk/psLib/test/dataManip/tst_psMinimize04.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psMinimize04.c	(revision 2272)
+++ /trunk/psLib/test/dataManip/tst_psMinimize04.c	(revision 2273)
@@ -237,5 +237,5 @@
     myPoly = psVectorFitPolynomial1D(NULL, NULL, NULL, NULL);
     if ( myPoly != NULL ) {
-        psError(__func__,"A null polynomial should have returned a null pointer.");
+        psError(PS_ERR_UNKNOWN, true,"A null polynomial should have returned a null pointer.");
         testStatus = false;
     }
Index: /trunk/psLib/test/dataManip/tst_psMinimize04b.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psMinimize04b.c	(revision 2272)
+++ /trunk/psLib/test/dataManip/tst_psMinimize04b.c	(revision 2273)
@@ -47,5 +47,5 @@
         yErr->data.F64[i] = 1.0;
     }
-    p_psNormalizeVectorF64(x);
+    psNormalizeVectorRange(x,0.0,1.0);
 
     printPositiveTestHeader(stdout,
@@ -113,5 +113,5 @@
         y->data.F64[i] = setData(x->data.F64[i]);
     }
-    p_psNormalizeVectorF64(x);
+    psNormalizeVectorRange(x,0.0,1.0);
 
     printPositiveTestHeader(stdout,
@@ -173,5 +173,5 @@
         y->data.F64[i] = setData(x->data.F64[i]);
     }
-    p_psNormalizeVectorF64(x);
+    psNormalizeVectorRange(x,0.0,1.0);
 
     printPositiveTestHeader(stdout,
Index: /trunk/psLib/test/dataManip/tst_psMinimize04b_F32.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psMinimize04b_F32.c	(revision 2272)
+++ /trunk/psLib/test/dataManip/tst_psMinimize04b_F32.c	(revision 2273)
@@ -47,5 +47,5 @@
         yErr->data.F32[i] = 1.0;
     }
-    p_psNormalizeVector(x);
+    psNormalizeVectorRange(x,0.0f,1.0f);
 
     printPositiveTestHeader(stdout,
@@ -113,5 +113,5 @@
         y->data.F32[i] = setData(x->data.F32[i]);
     }
-    p_psNormalizeVector(x);
+    psNormalizeVectorRange(x,0.0f,1.0f);
 
     printPositiveTestHeader(stdout,
@@ -173,5 +173,5 @@
         y->data.F32[i] = setData(x->data.F32[i]);
     }
-    p_psNormalizeVector(x);
+    psNormalizeVectorRange(x,0.0,1.0);
 
     printPositiveTestHeader(stdout,
Index: /trunk/psLib/test/dataManip/tst_psMinimize06.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psMinimize06.c	(revision 2272)
+++ /trunk/psLib/test/dataManip/tst_psMinimize06.c	(revision 2273)
@@ -35,5 +35,5 @@
     if (myDeriv == NULL) {
         myDeriv = psImageAlloc(myParams->n, myCoords->n, PS_TYPE_F32);
-        psError(__func__, "myDeriv is NULL.\n");
+        psError(PS_ERR_UNKNOWN, true, "myDeriv is NULL.\n");
     }
 
Index: /trunk/psLib/test/dataManip/tst_psVectorFFT.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psVectorFFT.c	(revision 2272)
+++ /trunk/psLib/test/dataManip/tst_psVectorFFT.c	(revision 2273)
@@ -6,6 +6,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 00:57:33 $
+*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:05:00 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -85,5 +85,5 @@
     vec2 = psVectorFFT( NULL, vec, PS_FFT_FORWARD );
     if ( vec2->type.type != PS_TYPE_C32 ) {
-        psError( __func__, "FFT didn't produce complex values?" );
+        psError(PS_ERR_UNKNOWN,true, "FFT didn't produce complex values?" );
         return 1;
     }
@@ -94,10 +94,10 @@
         if ( n == 1 || n == 99 ) {
             if ( fabsf( cabsf( vec2->data.C32[ n ] ) - 50.0f ) > 0.1f ) {
-                psError( __func__, "FFT didn't work for vector (n=%d)", n );
+                psError(PS_ERR_UNKNOWN,true, "FFT didn't work for vector (n=%d)", n );
                 return 2;
             }
         } else {
             if ( fabsf( cabsf( vec2->data.C32[ n ] ) ) > 0.1f ) {
-                psError( __func__, "FFT didn't work for vector (n=%d)", n );
+                psError(PS_ERR_UNKNOWN,true, "FFT didn't work for vector (n=%d)", n );
                 return 3;
             }
@@ -108,5 +108,5 @@
     vec3 = psVectorFFT( NULL, vec2, PS_FFT_REVERSE );
     if ( vec3->type.type != PS_TYPE_C32 ) {
-        psError( __func__, "FFT didn't produce complex values?" );
+        psError(PS_ERR_UNKNOWN,true, "FFT didn't produce complex values?" );
         return 4;
     }
@@ -115,6 +115,6 @@
         psF32 vecVal = crealf( vec3->data.C32[ n ] ) / 100;
         if ( fabsf( vecVal - val ) > 0.1f ) {
-            psError( __func__, "Reverse FFT didn't give me the original vector back (n=%d) (%.2f vs %.2f)",
-                     n, vecVal, val );
+            psError(PS_ERR_UNKNOWN,true, "Reverse FFT didn't give me the original vector back (n=%d) (%.2f vs %.2f)",
+                    n, vecVal, val );
             return 5;
         }
@@ -150,10 +150,10 @@
     vec2 = psVectorReal( vec2, vec );
     if ( vec2 == NULL ) {
-        psError( __func__, "psVectorReal returned a NULL?" );
+        psError(PS_ERR_UNKNOWN,true, "psVectorReal returned a NULL?" );
         return 1;
     }
     if ( vec2->type.type != PS_TYPE_F32 ) {
-        psError( __func__, "psVectorReal returned a wrong type (%d)?",
-                 vec2->type.type );
+        psError(PS_ERR_UNKNOWN,true, "psVectorReal returned a wrong type (%d)?",
+                vec2->type.type );
         return 2;
     }
@@ -161,10 +161,10 @@
     vec3 = psVectorImaginary( vec3, vec );
     if ( vec3 == NULL ) {
-        psError( __func__, "psVectorImaginary returned a NULL?" );
+        psError(PS_ERR_UNKNOWN,true, "psVectorImaginary returned a NULL?" );
         return 3;
     }
     if ( vec3->type.type != PS_TYPE_F32 ) {
-        psError( __func__, "psVectorImaginary returned a wrong type (%d)?",
-                 vec3->type.type );
+        psError(PS_ERR_UNKNOWN,true, "psVectorImaginary returned a wrong type (%d)?",
+                vec3->type.type );
         return 4;
     }
@@ -175,11 +175,11 @@
         psF32 i = ( n * 2 );
         if ( fabsf( vec2->data.F32[ n ] - r ) > FLT_EPSILON ) {
-            psError( __func__, "psVectorReal didn't return the real portion at n=%d",
-                     n );
+            psError(PS_ERR_UNKNOWN,true, "psVectorReal didn't return the real portion at n=%d",
+                    n );
             return 5;
         }
         if ( fabsf( vec3->data.F32[ n ] - i ) > FLT_EPSILON ) {
-            psError( __func__, "psVectorImaginary didn't return the real portion at n=%d",
-                     n );
+            psError(PS_ERR_UNKNOWN,true, "psVectorImaginary didn't return the real portion at n=%d",
+                    n );
             return 6;
         }
@@ -230,6 +230,6 @@
     // 3. verify that the result is a psC32
     if ( vec3->type.type != PS_TYPE_C32 ) {
-        psError( __func__, "Vector Type from psVectorComplex is not complex? (%d)",
-                 vec3->type.type );
+        psError(PS_ERR_UNKNOWN,true, "Vector Type from psVectorComplex is not complex? (%d)",
+                vec3->type.type );
         return 1;
     }
@@ -240,6 +240,6 @@
         if ( fabsf( crealf( vec3->data.C32[ n ] ) - n ) > FLT_EPSILON ||
                 fabsf( cimagf( vec3->data.C32[ n ] ) - ( n * 2 ) ) > FLT_EPSILON ) {
-            psError( __func__, "psVectorComplex result is invalid (n=%d, %.2f+%.2fi)",
-                     n, crealf( vec3->data.C32[ n ] ), cimagf( vec3->data.C32[ n ] ) );
+            psError(PS_ERR_UNKNOWN,true, "psVectorComplex result is invalid (n=%d, %.2f+%.2fi)",
+                    n, crealf( vec3->data.C32[ n ] ), cimagf( vec3->data.C32[ n ] ) );
             return 2;
         };
@@ -251,9 +251,9 @@
 
     // 7. call psVectorComplex
-    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error (type mismatch)." );
+    psLogMsg(__func__, PS_LOG_INFO, "Following should be an error (type mismatch)." );
     vec3 = psVectorComplex( vec3, vec, vec2 );
     // 8. verify that an appropriate error occurred. (this partially has to be done via inspection)
     if ( vec3 != NULL ) {
-        psError( __func__, "psVectorComplex returned a vector though input types mismatched." );
+        psError(PS_ERR_UNKNOWN,true, "psVectorComplex returned a vector though input types mismatched." );
         return 3;
     }
@@ -267,5 +267,5 @@
     // 11. verify thet an appropriate error occurred. (actually, it isn't an error...)
     if ( vec3->n != 100 ) {
-        psError( __func__, "psVectorComplex returned a larger vector than the input supported (%d).", vec3->n );
+        psError(PS_ERR_UNKNOWN,true, "psVectorComplex returned a larger vector than the input supported (%d).", vec3->n );
         return 4;
     }
@@ -302,5 +302,5 @@
     // 3. verify result is psC32
     if ( vec2->type.type != PS_TYPE_C32 ) {
-        psError( __func__, "the psVectorConjugate didn't return a C32 vector" );
+        psError(PS_ERR_UNKNOWN,true, "the psVectorConjugate didn't return a C32 vector" );
         return 1;
     }
@@ -310,6 +310,6 @@
         if ( fabsf( crealf( vec->data.C32[ n ] ) - crealf( vec2->data.C32[ n ] ) ) > FLT_EPSILON ||
                 fabsf( cimagf( vec->data.C32[ n ] ) + cimagf( vec2->data.C32[ n ] ) ) > FLT_EPSILON ) {
-            psError( __func__, "psVectorComplex result is invalid (n=%d, %.2f+%.2fi)",
-                     n, crealf( vec2->data.C32[ n ] ), cimagf( vec2->data.C32[ n ] ) );
+            psError(PS_ERR_UNKNOWN,true, "psVectorComplex result is invalid (n=%d, %.2f+%.2fi)",
+                    n, crealf( vec2->data.C32[ n ] ), cimagf( vec2->data.C32[ n ] ) );
             return 2;
         };
@@ -347,5 +347,5 @@
     // 3. verify result is psF32
     if ( vec2->type.type != PS_TYPE_F32 ) {
-        psError( __func__, "the type was not PS_TYPE_F32." );
+        psError(PS_ERR_UNKNOWN,true, "the type was not PS_TYPE_F32." );
         return 1;
     }
@@ -360,6 +360,6 @@
     val = cabsf( vec->data.C32[ 0 ] ) * cabsf( vec->data.C32[ 0 ] ) / 100 / 100;
     if ( fabsf( vec2->data.F32[ 0 ] - val ) > FLT_EPSILON ) {
-        psError( __func__, "psVectorPowerSpectrum result is invalid (n=0, %.2f %.2f)",
-                 vec2->data.F32[ 0 ], val );
+        psError(PS_ERR_UNKNOWN,true, "psVectorPowerSpectrum result is invalid (n=0, %.2f %.2f)",
+                vec2->data.F32[ 0 ], val );
         return 2;
     };
@@ -370,6 +370,6 @@
 
         if ( fabsf( val - vec2->data.F32[ n ] ) > FLT_EPSILON ) {
-            psError( __func__, "psVectorPowerSpectrum result is invalid (n=%d, %.2f %.2f)",
-                     n, vec2->data.F32[ n ], val );
+            psError(PS_ERR_UNKNOWN,true, "psVectorPowerSpectrum result is invalid (n=%d, %.2f %.2f)",
+                    n, vec2->data.F32[ n ], val );
             return 2;
         };
@@ -378,6 +378,6 @@
     val = cabsf( vec->data.C32[ 50 ] ) * cabsf( vec->data.C32[ 50 ] ) / 100 / 100;
     if ( fabsf( vec2->data.F32[ 50 ] - val ) > FLT_EPSILON ) {
-        psError( __func__, "psVectorPowerSpectrum result is invalid (n=50, %.2f %.2f)",
-                 vec2->data.F32[ 0 ], val );
+        psError(PS_ERR_UNKNOWN,true, "psVectorPowerSpectrum result is invalid (n=50, %.2f %.2f)",
+                vec2->data.F32[ 0 ], val );
         return 2;
     };
Index: /trunk/psLib/test/image/tst_psImage.c
===================================================================
--- /trunk/psLib/test/image/tst_psImage.c	(revision 2272)
+++ /trunk/psLib/test/image/tst_psImage.c	(revision 2273)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:33 $
+ *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -71,5 +71,5 @@
                     continue;
                 }
-                psError(__func__,"psImageAlloc returned NULL for type %x, size %dx%d.",
+                psError(PS_ERR_UNKNOWN, true,"psImageAlloc returned NULL for type %x, size %dx%d.",
                         type[t], numCols[i], numRows[i]);
                 psFree(image);
@@ -78,5 +78,5 @@
 
             if (image->type.dimen != PS_DIMEN_IMAGE || image->type.type != type[t]) {
-                psError(__func__,"psImageAlloc allocated wrong dimen/type (%d/%d), should be "
+                psError(PS_ERR_UNKNOWN, true,"psImageAlloc allocated wrong dimen/type (%d/%d), should be "
                         "PS_IMAGE_DIMEN/%d", image->type.dimen, image->type.type, type[t]);
                 psFree(image);
@@ -85,5 +85,5 @@
 
             if (image->numCols != numCols[i] || image->numRows != numRows[i]) {
-                psError(__func__,"psImageAlloc allocated wrong size %dx%d, should be %dx%d (type = %d)",
+                psError(PS_ERR_UNKNOWN, true,"psImageAlloc allocated wrong size %dx%d, should be %dx%d (type = %d)",
                         image->numCols, image->numRows, numCols[i], numRows[i],type[t]);
                 psFree(image);
@@ -92,5 +92,5 @@
 
             if (image->col0 != 0 || image->row0 != 0) {
-                psError(__func__,"psImageAlloc returned row0/col0 of %d/%d.  Should be 0/0.",
+                psError(PS_ERR_UNKNOWN, true,"psImageAlloc returned row0/col0 of %d/%d.  Should be 0/0.",
                         image->row0, image->row0);
                 psFree(image);
@@ -99,5 +99,5 @@
 
             if (image->parent != NULL) {
-                psError(__func__,"psImageAlloc returned non-NULL parent");
+                psError(PS_ERR_UNKNOWN, true,"psImageAlloc returned non-NULL parent");
                 psFree(image);
                 return 5;
@@ -105,5 +105,5 @@
 
             if (image->children != NULL) {
-                psError(__func__,"psImageAlloc returned non-NULL children array");
+                psError(PS_ERR_UNKNOWN, true,"psImageAlloc returned non-NULL children array");
                 psFree(image);
                 return 7;
@@ -123,5 +123,5 @@
                         for (psS32 c=0;c<cols;c++) {
                             if (image->data.U16[r][c] != 2*c+r) {
-                                psError(__func__,"Could not set all pixels in uint16 image at (%d,%d)",c,r);
+                                psError(PS_ERR_UNKNOWN, true,"Could not set all pixels in uint16 image at (%d,%d)",c,r);
                                 psFree(image);
                                 return 8;
@@ -143,5 +143,5 @@
                         for (psS32 c=0;c<cols;c++) {
                             if (fabsf(image->data.F32[r][c] - (2.0f*c+r)) > FLT_EPSILON) {
-                                psError(__func__,"Could not set all pixels in float image at (%d,%d)",c,r);
+                                psError(PS_ERR_UNKNOWN, true,"Could not set all pixels in float image at (%d,%d)",c,r);
                                 psFree(image);
                                 return 8;
@@ -163,5 +163,5 @@
                         for (psS32 c=0;c<cols;c++) {
                             if (fabs(image->data.F64[r][c] - (2.0f*c+r)) > DBL_EPSILON) {
-                                psError(__func__,"Could not set all pixels in double image at (%d,%d)",c,r);
+                                psError(PS_ERR_UNKNOWN, true,"Could not set all pixels in double image at (%d,%d)",c,r);
                                 psFree(image);
                                 return 8;
@@ -184,5 +184,5 @@
                             if (fabsf(crealf(image->data.C32[r][c]) - r) > FLT_EPSILON ||
                                     fabsf(cimagf(image->data.C32[r][c]) - c) > FLT_EPSILON ) {
-                                psError(__func__,"Could not set all pixels in complex image at (%d,%d)",c,r);
+                                psError(PS_ERR_UNKNOWN, true,"Could not set all pixels in complex image at (%d,%d)",c,r);
                                 psFree(image);
                                 return 8;
@@ -205,5 +205,5 @@
                         for (psS32 c=0;c<cols;c++) {
                             if (image->data.PTR[r][c] != temp) {
-                                psError(__func__, "Could not set pixel in pointer image at (%d,%d): %x %x",
+                                psError(PS_ERR_UNKNOWN, true, "Could not set pixel in pointer image at (%d,%d): %x %x",
                                         c,r,image->data.PTR[r][c],temp);
                                 psFree(image);
@@ -229,5 +229,5 @@
                         for (psS32 c=0;c<cols;c++) {
                             if (image->data.U8[r][c] != (uint8_t)(r + c)) {
-                                psError(__func__,"Could not set all pixels in image (type=%d) at (%d,%d)",
+                                psError(PS_ERR_UNKNOWN, true,"Could not set all pixels in image (type=%d) at (%d,%d)",
                                         type[t],c,r);
                                 psFree(image);
@@ -281,5 +281,5 @@
     // Verify the returned psImage structure pointer is equal to the input parameter output.
     if (img2 != img3) {
-        psError(__func__,"the image given for recycled wasn't");
+        psError(PS_ERR_UNKNOWN, true,"the image given for recycled wasn't");
         return 1;
     }
@@ -289,9 +289,9 @@
     img4 = psImageCopy(NULL,img,PS_TYPE_F32);
     if (img4 == NULL) {
-        psError(__func__,"output image doesn't exist");
+        psError(PS_ERR_UNKNOWN, true,"output image doesn't exist");
         return 4;
     }
     if (img4->type.type != img->type.type) {
-        psError(__func__,"output image is not the same type as input image");
+        psError(PS_ERR_UNKNOWN, true,"output image is not the same type as input image");
         return 4;
     }
@@ -301,5 +301,5 @@
         for (unsigned col=0;col<c;col++) {
             if( imgInRow[col] != imgOutRow[col] ) {
-                psError(__func__,"Input image not equal to output image at %d,%d!",
+                psError(PS_ERR_UNKNOWN, true,"Input image not equal to output image at %d,%d!",
                         col, row);
                 return 4;
@@ -321,5 +321,5 @@
     img2 = psImageCopy(img2,img,PS_TYPE_##OUT); \
     if (img2 == NULL) { \
-        psError(__func__,"psImageCopy failed to copy U8."); \
+        psError(PS_ERR_UNKNOWN, true,"psImageCopy failed to copy U8."); \
         return 2; \
     } \
@@ -329,10 +329,10 @@
         for (psU32 col=0;col<c;col++) { \
             if (abs(imgRow[col] - (ps##IN)(row+col)) > 0.5) { \
-                psError(__func__,"Input image was changed at %d,%d!", \
+                psError(PS_ERR_UNKNOWN, true,"Input image was changed at %d,%d!", \
                         col,row); \
                 return 2; \
             } \
             if (abs(img2Row[col] - (ps##OUT)(imgRow[col])) > 0.5) { \
-                psError(__func__,"returned psImage values after copy don't match at %d,%d " \
+                psError(PS_ERR_UNKNOWN, true,"returned psImage values after copy don't match at %d,%d " \
                         "(%d vs %d)",\
                         col,row,img2Row[col], (ps##OUT)(imgRow[col])); \
@@ -382,5 +382,5 @@
     img3 = psImageCopy(NULL,NULL,PS_TYPE_F32);
     if (img3 != NULL) {
-        psError(__func__,"psImageCopy didn't return NULL when input image was NULL.");
+        psError(PS_ERR_UNKNOWN, true,"psImageCopy didn't return NULL when input image was NULL.");
         return 3;
     }
Index: /trunk/psLib/test/image/tst_psImageConvolve.c
===================================================================
--- /trunk/psLib/test/image/tst_psImageConvolve.c	(revision 2272)
+++ /trunk/psLib/test/image/tst_psImageConvolve.c	(revision 2273)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:33 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -52,5 +52,5 @@
 
         if (k == NULL) {
-            psError(__func__,"psKernelAlloc returned NULL for [%d:%d,%d:%d].",
+            psError(PS_ERR_UNKNOWN, true,"psKernelAlloc returned NULL for [%d:%d,%d:%d].",
                     xMin[i], xMax[i], yMin[i], yMax[i]);
             return i*10+1;
@@ -59,5 +59,5 @@
         if (k->xMin != xMin[i] || k->xMax != xMax[i] ||
                 k->yMin != yMin[i] || k->yMax != yMax[i]) {
-            psError(__func__,"Min/max members, [%d:%d,%d:%d], of psKernel wrong. Should be [%d:%d,%d:%d].",
+            psError(PS_ERR_UNKNOWN, true,"Min/max members, [%d:%d,%d:%d], of psKernel wrong. Should be [%d:%d,%d:%d].",
                     k->xMin,k->xMax, k->yMin, k->yMax,
                     xMin[i], xMax[i], yMin[i], yMax[i]);
@@ -67,5 +67,5 @@
         if (k->image->numCols != xMax[i]-xMin[i]+1 ||
                 k->image->numRows != yMax[i]-yMin[i]+1) {
-            psError(__func__,"Size of the kernel image is wrong (%dx%d vs %dx%d).",
+            psError(PS_ERR_UNKNOWN, true,"Size of the kernel image is wrong (%dx%d vs %dx%d).",
                     xMax[i]-xMin[i]+1, yMax[i]-yMin[i]+1,
                     k->image->numCols, k->image->numRows);
@@ -75,5 +75,5 @@
         for (psS32 j=yMin[i]; j<yMax[i]; j++) {
             if (k->kernel[j]+xMin[i] != k->image->data.PS_TYPE_KERNEL_DATA[j-yMin[i]]) {
-                psError(__func__,"The kernel pointer was set wrong for row %d.",
+                psError(PS_ERR_UNKNOWN, true,"The kernel pointer was set wrong for row %d.",
                         j);
                 return i*10+4;
@@ -87,10 +87,10 @@
     k = psKernelAlloc(5, -5, -2, 2);
     if (k == NULL) {
-        psError(__func__,"psKernelAlloc returned NULL for xMin > xMax.");
+        psError(PS_ERR_UNKNOWN, true,"psKernelAlloc returned NULL for xMin > xMax.");
         return i*10+5;
     }
 
     if (k->xMin != -5 || k->xMax != 5) {
-        psError(__func__,"psKernelAlloc didn't swap xMin & xMax.");
+        psError(PS_ERR_UNKNOWN, true,"psKernelAlloc didn't swap xMin & xMax.");
         return i*10+6;
     }
@@ -101,10 +101,10 @@
     k = psKernelAlloc(-2, 2, 5, -5);
     if (k == NULL) {
-        psError(__func__,"psKernelAlloc returned NULL for yMin > yMax.");
+        psError(PS_ERR_UNKNOWN, true,"psKernelAlloc returned NULL for yMin > yMax.");
         return i*10+7;
     }
 
     if (k->yMin != -5 || k->yMax != 5) {
-        psError(__func__,"psKernelAlloc didn't swap yMin & yMax.");
+        psError(PS_ERR_UNKNOWN, true,"psKernelAlloc didn't swap yMin & yMax.");
         return i*10+8;
     }
@@ -136,5 +136,5 @@
 
     if (result == NULL) {
-        psError(__func__,"psKernelGenerate returned NULL.");
+        psError(PS_ERR_UNKNOWN, true,"psKernelGenerate returned NULL.");
         return 1;
     }
@@ -142,5 +142,5 @@
     if (result->xMin != -1 || result->xMax != 1 ||
             result->yMin != -2 || result->yMax != 2) {
-        psError(__func__,"psKernelGenerate result had a range of [%d:%d,%d:%d].  Suppose to be [0:1,1:2].",
+        psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result had a range of [%d:%d,%d:%d].  Suppose to be [0:1,1:2].",
                 result->xMin, result->xMax, result->yMin, result->yMax);
         return 2;
@@ -154,5 +154,5 @@
     }
     if (fabsf(1.0 - sum) > FLT_EPSILON) {
-        psError(__func__,"psKernelGenerate result is not normalized (sum=%g).",
+        psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result is not normalized (sum=%g).",
                 sum);
 
@@ -166,5 +166,5 @@
             fabsf(result->kernel[-1][ 0] - 2.0/10.0) > FLT_EPSILON ||
             fabsf(result->kernel[-2][-1] - 0.0/10.0) > FLT_EPSILON) {
-        psError(__func__,"psKernelGenerate result values, %g,%g;%g,%g, are wrong. Suppose to be 2,6;1,0.",
+        psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result values, %g,%g;%g,%g, are wrong. Suppose to be 2,6;1,0.",
                 result->kernel[-1][0], result->kernel[1][1],
                 result->kernel[2][0], result->kernel[-2][-1]);
@@ -191,5 +191,5 @@
 
     if (result == NULL) {
-        psError(__func__,"psKernelGenerate returned NULL.");
+        psError(PS_ERR_UNKNOWN, true,"psKernelGenerate returned NULL.");
         return 5;
     }
@@ -197,5 +197,5 @@
     if (result->xMin != 0 || result->xMax != 1 ||
             result->yMin != 0 || result->yMax != 3) {
-        psError(__func__,"psKernelGenerate result had a range of [%d:%d,%d:%d].  Suppose to be [0:1,1:2].",
+        psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result had a range of [%d:%d,%d:%d].  Suppose to be [0:1,1:2].",
                 result->xMin, result->xMax, result->yMin, result->yMax);
         return 6;
@@ -209,5 +209,5 @@
     }
     if (fabsf(1.0 - sum) > FLT_EPSILON) {
-        psError(__func__,"psKernelGenerate result is not normalized (sum=%g).",
+        psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result is not normalized (sum=%g).",
                 sum);
 
@@ -220,5 +220,5 @@
             fabsf(result->kernel[3][1] - 8.0/21.0) > FLT_EPSILON ||
             fabsf(result->kernel[2][1] - 10.0/21.0) > FLT_EPSILON) {
-        psError(__func__,"psKernelGenerate result values, %g,%g;%g,%g, are wrong. Suppose to be 2,6;1,0.",
+        psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result values, %g,%g;%g,%g, are wrong. Suppose to be 2,6;1,0.",
                 result->kernel[1][0], result->kernel[1][1],
                 result->kernel[2][0], result->kernel[2][1]);
@@ -246,5 +246,5 @@
     result = psKernelGenerate(tVec, xVec, yVec, false);
     if (result == NULL) {
-        psError(__func__,"psKernelGenerate returned NULL.");
+        psError(PS_ERR_UNKNOWN, true,"psKernelGenerate returned NULL.");
         return 9;
     }
@@ -254,5 +254,5 @@
             fabsf(result->kernel[ 1][ 1] - 6.0/8.0) > FLT_EPSILON ||
             fabsf(result->kernel[ 0][ 0] - 1.0/8.0) > FLT_EPSILON) {
-        psError(__func__,"psKernelGenerate result values wrong for truncated time vector.");
+        psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result values wrong for truncated time vector.");
 
         return 10;
@@ -264,5 +264,5 @@
     result = psKernelGenerate(NULL, xVec, yVec, true);
     if (result != NULL) {
-        psError(__func__,"psKernelGenerate returned a kernel with no time vector.");
+        psError(PS_ERR_UNKNOWN, true,"psKernelGenerate returned a kernel with no time vector.");
         return 11;
     }
@@ -271,5 +271,5 @@
     result = psKernelGenerate(tVec, NULL, yVec, true);
     if (result != NULL) {
-        psError(__func__,"psKernelGenerate returned a kernel with no x vector.");
+        psError(PS_ERR_UNKNOWN, true,"psKernelGenerate returned a kernel with no x vector.");
         return 11;
     }
@@ -278,5 +278,5 @@
     result = psKernelGenerate(tVec, xVec, NULL, true);
     if (result != NULL) {
-        psError(__func__,"psKernelGenerate returned a kernel with no y vector.");
+        psError(PS_ERR_UNKNOWN, true,"psKernelGenerate returned a kernel with no y vector.");
         return 11;
     }
@@ -336,10 +336,10 @@
  
     if (out == NULL) {
-        psError(__func__, "psImageConvolve returned a NULL for direct gaussian case.");
+        psError(PS_ERR_UNKNOWN, true, "psImageConvolve returned a NULL for direct gaussian case.");
         return 1;
     }
  
     if (out->numCols != c || out->numRows != r) {
-        psError(__func__, "psImageConvolve result image is %dx%d, but expected %dx%d.",
+        psError(PS_ERR_UNKNOWN, true, "psImageConvolve result image is %dx%d, but expected %dx%d.",
                 out->numCols, out->numRows,
                 c,r);
@@ -350,5 +350,5 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,out->type.type);
-        psError(__func__, "psImageConvolve result image is of type %s, not psF32.",
+        psError(PS_ERR_UNKNOWN, true, "psImageConvolve result image is of type %s, not psF32.",
                 typeStr);
         return 3;
@@ -359,5 +359,5 @@
         for (psS32 j=-1;j<1;j++) {
             if (fabsf(out->data.F32[r/2+i][c/2+j] - g->kernel[i][j]) > 0.0001) {
-                psError(__func__,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
+                psError(PS_ERR_UNKNOWN, true,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
                         c/2+j,r/2+i,
                         out->data.F32[r/2+i][c/2+j], g->kernel[i][j]);
@@ -365,5 +365,5 @@
             }
             if (i >= 0 && j >= 0 && fabsf(out->data.F32[i][j] - g->kernel[i][j]) > 0.0001) {
-                psError(__func__,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
+                psError(PS_ERR_UNKNOWN, true,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
                         j,i,
                         out->data.F32[i][j], g->kernel[i][j]);
@@ -371,5 +371,5 @@
             }
             if (i <= 0 && fabsf(out->data.F32[r-1+i][c/2+j] - g->kernel[i][j]) > 0.0001) {
-                psError(__func__,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
+                psError(PS_ERR_UNKNOWN, true,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
                         c/2+j,r-1+i,
                         out->data.F32[r-1+i][c/2+j], g->kernel[i][j]);
@@ -397,15 +397,15 @@
  
     if (out == NULL) {
-        psError(__func__, "psImageConvolve returned a NULL for gaussian case.");
+        psError(PS_ERR_UNKNOWN, true, "psImageConvolve returned a NULL for gaussian case.");
         return 10;
     }
  
     if (out != out2) {
-        psError(__func__, "psImageConvolve didn't recycle the supplied out image struct.");
+        psError(PS_ERR_UNKNOWN, true, "psImageConvolve didn't recycle the supplied out image struct.");
         return 11;
     }
  
     if (out->numCols != c || out->numRows != r) {
-        psError(__func__, "psImageConvolve result image is %dx%d, but expected %dx%d.",
+        psError(PS_ERR_UNKNOWN, true, "psImageConvolve result image is %dx%d, but expected %dx%d.",
                 out->numCols, out->numRows,
                 c,r);
@@ -416,5 +416,5 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,out->type.type);
-        psError(__func__, "psImageConvolve result image is of type %s, not psF32.",
+        psError(PS_ERR_UNKNOWN, true, "psImageConvolve result image is of type %s, not psF32.",
                 typeStr);
         return 13;
@@ -426,5 +426,5 @@
         for (psS32 j=-1;j<1;j++) {
             if (fabsf(out->data.F32[r/2+i][c/2+j] - g->kernel[i][j]) > 0.0001) {
-                psError(__func__,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
+                psError(PS_ERR_UNKNOWN, true,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
                         c/2+j,r/2+i,
                         out->data.F32[r/2+i][c/2+j], g->kernel[i][j]);
@@ -433,5 +433,5 @@
             }
             if (i >= 0 && j >= 0 && fabsf(out->data.F32[i][j] - g->kernel[i][j]) > 0.0001) {
-                psError(__func__,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
+                psError(PS_ERR_UNKNOWN, true,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
                         j,i,
                         out->data.F32[i][j], g->kernel[i][j]);
@@ -439,5 +439,5 @@
             }
             if (i <= 0 && fabsf(out->data.F32[r-1+i][c/2+j] - g->kernel[i][j]) > 0.0001) {
-                psError(__func__,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
+                psError(PS_ERR_UNKNOWN, true,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
                         c/2+j,r-1+i,
                         out->data.F32[r-1+i][c/2+j], g->kernel[i][j]);
Index: /trunk/psLib/test/image/tst_psImageExtraction.c
===================================================================
--- /trunk/psLib/test/image/tst_psImageExtraction.c	(revision 2272)
+++ /trunk/psLib/test/image/tst_psImageExtraction.c	(revision 2273)
@@ -6,6 +6,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 00:57:33 $
+*  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:05:00 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -87,5 +87,5 @@
     \
     if (out->n != TRUTH_SIZE) { \
-        psError(__func__,"Number of results is wrong (%d, not %d)", \
+        psError(PS_ERR_UNKNOWN,true,"Number of results is wrong (%d, not %d)", \
                 out->n,n); \
         return TESTNUM*4+1; \
@@ -93,5 +93,5 @@
     \
     if (positions->n != TRUTH_SIZE) { \
-        psError(__func__,"Number of results for positions vector is wrong (%d, not %d)", \
+        psError(PS_ERR_UNKNOWN,true,"Number of results for positions vector is wrong (%d, not %d)", \
                 out->n,n); \
         return TESTNUM*4+2; \
@@ -100,5 +100,5 @@
     for (psS32 i=0;i<out->n;i++) { \
         if (fabs(out->data.F64[i]-image->data.TYPE[r/10+TRUTHPIX_Y][c/10+TRUTHPIX_X]) > 1.0/(psF64)r) { \
-            psError(__func__,"Improper result at position %d.  Got %g, expected %g",i, \
+            psError(PS_ERR_UNKNOWN,true,"Improper result at position %d.  Got %g, expected %g",i, \
                     out->data.F64[i],image->data.TYPE[r/10+TRUTHPIX_Y][c/10+TRUTHPIX_X]); \
             return TESTNUM*4+3; \
@@ -106,5 +106,5 @@
         if (DIRECTION == PS_CUT_X_POS || DIRECTION == PS_CUT_X_NEG) { \
             if (positions->data.U32[i] != c/10+TRUTHPIX_X) { \
-                psError(__func__,"Improper positions (%d vs %d) result @ %d.", \
+                psError(PS_ERR_UNKNOWN,true,"Improper positions (%d vs %d) result @ %d.", \
                         positions->data.U32[i],c/10+TRUTHPIX_X,i); \
                 return TESTNUM*4+4; \
@@ -112,5 +112,5 @@
         } else { \
             if (positions->data.U32[i] != r/10+TRUTHPIX_Y) { \
-                psError(__func__,"Improper positions (%d vs %d) result @ %d.", \
+                psError(PS_ERR_UNKNOWN,true,"Improper positions (%d vs %d) result @ %d.", \
                         positions->data.U32[i],r/10+TRUTHPIX_Y,i); \
                 return TESTNUM*4+4; \
@@ -165,5 +165,5 @@
                         stat );
     if ( out != NULL ) {
-        psError( __func__, "Giving a NULL image, psImageSlice didn't return NULL as expected" );
+        psError( PS_ERR_UNKNOWN,true, "Giving a NULL image, psImageSlice didn't return NULL as expected" );
         return 101;
     }
@@ -184,5 +184,5 @@
                         NULL );
     if ( out != NULL ) {
-        psError( __func__, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected" );
+        psError( PS_ERR_UNKNOWN,true, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected" );
         return 102;
     }
@@ -202,5 +202,5 @@
                         stat);
     if ( out != NULL ) {
-        psError( __func__, "Giving a bogus direction flag, psImageSlice didn't return NULL as expected" );
+        psError( PS_ERR_UNKNOWN,true, "Giving a bogus direction flag, psImageSlice didn't return NULL as expected" );
         return 103;
     }
@@ -220,5 +220,5 @@
                         stat );
     if ( out != NULL ) {
-        psError( __func__, "Giving a 0x0 region, psImageSlice didn't return NULL as expected" );
+        psError( PS_ERR_UNKNOWN,true, "Giving a 0x0 region, psImageSlice didn't return NULL as expected" );
         return 104;
     }
@@ -238,5 +238,5 @@
                         stat );
     if ( out != NULL ) {
-        psError( __func__, "Giving an invalid x position, psImageSlice didn't return NULL as expected" );
+        psError( PS_ERR_UNKNOWN,true, "Giving an invalid x position, psImageSlice didn't return NULL as expected" );
         return 105;
     }
@@ -251,5 +251,5 @@
                         stat );
     if ( out != NULL ) {
-        psError( __func__, "Giving an invalid y position, psImageSlice didn't return NULL as expected" );
+        psError( PS_ERR_UNKNOWN,true, "Giving an invalid y position, psImageSlice didn't return NULL as expected" );
         return 106;
     }
@@ -264,5 +264,5 @@
                         stat);
     if ( out != NULL ) {
-        psError( __func__, "Giving an invalid numCols, psImageSlice didn't return NULL as expected" );
+        psError( PS_ERR_UNKNOWN,true, "Giving an invalid numCols, psImageSlice didn't return NULL as expected" );
         return 107;
     }
@@ -277,5 +277,5 @@
                         stat);
     if ( out != NULL ) {
-        psError( __func__, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" );
+        psError( PS_ERR_UNKNOWN,true, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" );
         return 108;
     }
@@ -296,5 +296,5 @@
                         stat);
     if ( out != NULL ) {
-        psError( __func__, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" );
+        psError( PS_ERR_UNKNOWN,true, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" );
         return 109;
     }
@@ -314,5 +314,5 @@
                         stat);
     if ( out != NULL ) {
-        psError( __func__, "Mask size different than image size didn't return NULL as expected" );
+        psError( PS_ERR_UNKNOWN,true, "Mask size different than image size didn't return NULL as expected" );
         return 110;
     }
@@ -330,5 +330,5 @@
                          stat);
     if ( out != NULL ) {
-        psError( __func__, "Mask invalid type didn't return NULL as expected.");
+        psError( PS_ERR_UNKNOWN,true, "Mask invalid type didn't return NULL as expected.");
         return 111;
     }
@@ -345,5 +345,5 @@
                         stat);
     if ( out != NULL ) {
-        psError( __func__, "Input image with invalid type didn't return NULL as expected.");
+        psError( PS_ERR_UNKNOWN,true, "Input image with invalid type didn't return NULL as expected.");
         return 112;
     }
@@ -390,5 +390,5 @@
 
     if (subset2->numCols != c/2 || subset2->numRows != r/2) {
-        psError(__func__,"psImageSubset output size was not proper(%dx%d, should be %dx%d).",
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset output size was not proper(%dx%d, should be %dx%d).",
                 subset2->numCols, subset2->numRows, c/2,r/2);
         return 1;
@@ -396,5 +396,5 @@
 
     if (subset3->numCols != c/2 || subset3->numRows != r/2) {
-        psError(__func__,"psImageSubset output size was not proper(%dx%d, should be %dx%d).",
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset output size was not proper(%dx%d, should be %dx%d).",
                 subset3->numCols, subset3->numRows, c/2,r/2);
         return 2;
@@ -407,10 +407,10 @@
         for (psS32 col=0;col<c/2;col++) {
             if (subset2->data.U32[row][col] != original->data.U32[row+r/4][col+c/4]) {
-                psError(__func__,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).",
+                psError(PS_ERR_UNKNOWN,true,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).",
                         row,col,subset2->data.U32[row][col], original->data.U32[row+r/4][col+c/4]);
                 return 3;
             }
             if (subset3->data.U32[row][col] != original->data.U32[row][col]) {
-                psError(__func__,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).",
+                psError(PS_ERR_UNKNOWN,true,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).",
                         row,col,subset2->data.U32[row][col], original->data.U32[row][col]);
                 return 4;
@@ -423,10 +423,10 @@
 
     if (subset2->type.type != PS_TYPE_U32) {
-        psError(__func__,"psImageSubset output type was not proper(%d, should be %d).",
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset output type was not proper(%d, should be %d).",
                 subset2->type.type, PS_TYPE_U32);
         return 6;
     }
     if (subset3->type.type != PS_TYPE_U32) {
-        psError(__func__,"psImageSubset output type was not proper(%d, should be %d).",
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset output type was not proper(%d, should be %d).",
                 subset3->type.type, PS_TYPE_U32);
         return 7;
@@ -437,10 +437,10 @@
 
     if (subset2->col0 != c/4 || subset2->row0 != r/4) {
-        psError(__func__,"psImageSubset didn't set col0/row0 for subset2 (%d/%d, should be %d/%d).",
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't set col0/row0 for subset2 (%d/%d, should be %d/%d).",
                 subset2->col0,subset2->row0,c/4,r/4);
         return 8;
     }
     if (subset3->col0 != 0 || subset3->row0 != 0) {
-        psError(__func__,"psImageSubset didn't set col0/row0 for subset3 (%d/%d, should be %d/%d).",
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't set col0/row0 for subset3 (%d/%d, should be %d/%d).",
                 subset3->col0,subset3->row0,0,0);
         return 9;
@@ -451,5 +451,5 @@
 
     if (subset2->parent != original || subset3->parent != original) {
-        psError(__func__,"psImageSubset didn't set parent.");
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't set parent.");
         return 10;
     }
@@ -458,5 +458,5 @@
 
     if (subset2->children != NULL || subset3->children != NULL) {
-        psError(__func__,"psImageSubset didn't set children to NULL.");
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't set children to NULL.");
         return 11;
     }
@@ -467,9 +467,9 @@
 
     if (original->children == NULL || original->children->n != 2) {
-        psError(__func__,"psImageSubset didn't increment number of children by one per subset.");
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't increment number of children by one per subset.");
         return 12;
     }
     if (original->children->data[0] != subset2 || original->children->data[1] != subset3) {
-        psError(__func__,"psImageSubset didn't properly store the children pointers.");
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't properly store the children pointers.");
         return 13;
     }
@@ -482,5 +482,5 @@
     subset1 = psImageSubset(NULL,0,0,c/2,r/2);
     if (subset1 != NULL) {
-        psError(__func__,"psImageSubset didn't return NULL when input image was NULL.");
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when input image was NULL.");
         return 14;
     }
@@ -494,5 +494,5 @@
     subset1 = psImageSubset(original,0,r/2,c/2,r/2);
     if (subset1 != NULL) {
-        psError(__func__,"psImageSubset didn't return NULL when numRows=0.");
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when numRows=0.");
         return 15;
     }
@@ -500,9 +500,9 @@
     subset1 = psImageSubset(original,c/2,0,c/2,r/2);
     if (subset1 != NULL) {
-        psError(__func__,"psImageSubset didn't return NULL when numCols=0.");
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when numCols=0.");
         return 16;
     }
     if (memcmp(original,&preSubsetStruct,sizeof(psImage)) != 0) {
-        psError(__func__,"psImageSubset changed the original struct though it failed to subset.");
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset changed the original struct though it failed to subset.");
         return 17;
     }
@@ -516,5 +516,5 @@
     subset1 = psImageSubset(original,0,0,c/2,r*2);
     if (subset1 != NULL) {
-        psError(__func__,"psImageSubset didn't return NULL when subset origin was outside of "
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset origin was outside of "
                 "image (via cols).");
         return 18;
@@ -523,5 +523,5 @@
     subset1 = psImageSubset(original,0,0,c*2,r/2);
     if (subset1 != NULL) {
-        psError(__func__,"psImageSubset didn't return NULL when subset origin was outside of "
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset origin was outside of "
                 "image (via rows).");
         return 19;
@@ -530,5 +530,5 @@
     subset1 = psImageSubset(original,-1,0,c/2,r/2);
     if (subset1 != NULL) {
-        psError(__func__,"psImageSubset didn't return NULL when subset origin was outside of "
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset origin was outside of "
                 "image (col0=-1).");
         return 20;
@@ -537,5 +537,5 @@
     subset1 = psImageSubset(original,0,-1,c/2,r/2);
     if (subset1 != NULL) {
-        psError(__func__,"psImageSubset didn't return NULL when subset origin was outside of "
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset origin was outside of "
                 "image (row0=-1).");
         return 21;
@@ -550,5 +550,5 @@
     subset1 = psImageSubset(original,0,0,c/2,r+1);
     if (subset1 != NULL) {
-        psError(__func__,"psImageSubset didn't return NULL when subset was outside of image (via rows).");
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset was outside of image (via rows).");
         return 22;
     }
@@ -556,5 +556,5 @@
     subset1 = psImageSubset(original,0,0,c+1,r/2);
     if (subset1 != NULL) {
-        psError(__func__,"psImageSubset didn't return NULL when subset was outside of image (via cols).");
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset was outside of image (via cols).");
         return 23;
     }
@@ -562,5 +562,5 @@
     subset1 = psImageSubset(original,0,0,c+1,r+1);
     if (subset1 != NULL) {
-        psError(__func__,"psImageSubset didn't return NULL when subset was outside of image (via row+cols).");
+        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset was outside of image (via row+cols).");
         return 24;
     }
@@ -575,5 +575,5 @@
     // Verify the returned psImage structure member Nchildren is set to zero.
     if (original->children != NULL && original->children->n > 0) {
-        psError(__func__,"psImageFreeChildren didn't set number of children to zero.");
+        psError(PS_ERR_UNKNOWN,true,"psImageFreeChildren didn't set number of children to zero.");
         return 25;
     }
@@ -586,5 +586,5 @@
             preSubsetStruct.col0 != original->col0) {
 
-        psError(__func__,"psImageFreeChildren modified parent's non-children elements.");
+        psError(PS_ERR_UNKNOWN,true,"psImageFreeChildren modified parent's non-children elements.");
         return 27;
     }
@@ -626,5 +626,5 @@
 
         if (subset == NULL) {
-            psError(__func__,"psImageSubsection returned a NULL with a subset of %s.",
+            psError(PS_ERR_UNKNOWN,true,"psImageSubsection returned a NULL with a subset of %s.",
                     sectionStr);
             return 10*i+1;
@@ -632,5 +632,5 @@
 
         if (subset->type.type != PS_TYPE_U32) {
-            psError(__func__,"psImageSubsection output type was not proper(%d, should be %d).",
+            psError(PS_ERR_UNKNOWN,true,"psImageSubsection output type was not proper(%d, should be %d).",
                     subset->type.type, PS_TYPE_U32);
             return 10*i+2;
@@ -638,5 +638,5 @@
 
         if (subset->col0 != x1[i] || subset->row0 != y1[i]) {
-            psError(__func__,"psImageSubsection didn't set properly col0/row0 (%d/%d, should be %d/%d).",
+            psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't set properly col0/row0 (%d/%d, should be %d/%d).",
                     subset->col0,subset->row0,x1[i],y1[i]);
             return 10*i+3;
@@ -644,15 +644,15 @@
 
         if (subset->parent != original) {
-            psError(__func__,"psImageSubsection didn't set parent.");
+            psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't set parent.");
             return 10*i+4;
         }
 
         if (subset->children != NULL) {
-            psError(__func__,"psImageSubsection didn't set children to NULL.");
+            psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't set children to NULL.");
             return 10*i+5;
         }
 
         if (original->children == NULL || original->children->n != i+1) {
-            psError(__func__,"psImageSubsection didn't increment number of children by one per subset.");
+            psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't increment number of children by one per subset.");
             return 10*i+6;
         }
@@ -660,5 +660,5 @@
 
         if (original->children->data[i] != subset) {
-            psError(__func__,"psImageSubsection didn't properly store the children pointer.");
+            psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't properly store the children pointer.");
             return 10*i+7;
         }
@@ -667,5 +667,5 @@
         psS32 numRows = y2[i]-y1[i]+1;
         if (subset->numCols != numCols || subset->numRows != numRows) {
-            psError(__func__,"psImageSubsection output size was not proper(%dx%d, should be %dx%d).",
+            psError(PS_ERR_UNKNOWN,true,"psImageSubsection output size was not proper(%dx%d, should be %dx%d).",
                     subset->numCols, subset->numRows, numCols, numRows);
             return 10*i+8;
@@ -675,5 +675,5 @@
             for (psS32 col=0;col<numCols;col++) {
                 if (subset->data.U32[row][col] != original->data.U32[row+y1[i]][col+x1[i]]) {
-                    psError(__func__,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).",
+                    psError(PS_ERR_UNKNOWN,true,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).",
                             row,col,subset->data.U32[row][col], original->data.U32[row+y1[i]][col+x1[i]]);
                     return 10*i+9;
@@ -686,5 +686,5 @@
     subset = psImageSubsection(original,"[64:32,32:64]");
     if (subset != NULL) {
-        psError(__func__,"psImageSubsection didn't return NULL when x1 > x2.");
+        psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't return NULL when x1 > x2.");
         return 10*i+10;
     }
@@ -693,5 +693,5 @@
     subset = psImageSubsection(original,"[32:64,64:32]");
     if (subset != NULL) {
-        psError(__func__,"psImageSubsection didn't return NULL when y1 > y2.");
+        psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't return NULL when y1 > y2.");
         return 10*i+11;
     }
@@ -700,5 +700,5 @@
     subset = psImageSubsection(original,"[64:256,32:64]"); // assumes c<256
     if (subset != NULL) {
-        psError(__func__,"psImageSubsection didn't return NULL when x2 > c.");
+        psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when x2 > c.");
         return 10*i+12;
     }
@@ -707,5 +707,5 @@
     subset = psImageSubsection(original,"[32:64,64:256]"); // assumes r==256
     if (subset != NULL) {
-        psError(__func__,"psImageSubsection didn't return NULL when y2 > r.");
+        psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when y2 > r.");
         return 10*i+13;
     }
@@ -714,5 +714,5 @@
     subset = psImageSubsection(original,"32:64,32:64");
     if (subset != NULL) {
-        psError(__func__,"psImageSubsection didn't return NULL when subsection was '32:64,32:64'.");
+        psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when subsection was '32:64,32:64'.");
         return 10*i+14;
     }
@@ -721,5 +721,5 @@
     subset = psImageSubsection(original,"[32-64,32-64]");
     if (subset != NULL) {
-        psError(__func__,"psImageSubsection didn't return NULL when subsection was '[32-64,32-64]'.");
+        psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when subsection was '[32-64,32-64]'.");
         return 10*i+15;
     }
@@ -728,5 +728,5 @@
     subset = psImageSubsection(original,"[32:64,32]");
     if (subset != NULL) {
-        psError(__func__,"psImageSubsection didn't return NULL when subsection was '[32:64,32]'.");
+        psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when subsection was '[32:64,32]'.");
         return 10*i+16;
     }
@@ -735,5 +735,5 @@
     subset = psImageSubsection(NULL,"[32:64,32:64]");
     if (subset != NULL) {
-        psError(__func__,"psImageSubsection didn't return NULL when image was NULL.");
+        psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when image was NULL.");
         return 10*i+17;
     }
@@ -742,5 +742,5 @@
     subset = psImageSubsection(original,NULL);
     if (subset != NULL) {
-        psError(__func__,"psImageSubsection didn't return NULL when subsection was NULL.");
+        psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when subsection was NULL.");
         return 10*i+18;
     }
Index: /trunk/psLib/test/image/tst_psImageFFT.c
===================================================================
--- /trunk/psLib/test/image/tst_psImageFFT.c	(revision 2272)
+++ /trunk/psLib/test/image/tst_psImageFFT.c	(revision 2273)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:33 $
+ *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -85,9 +85,9 @@
     img2 = psImageFFT(img2,img,PS_FFT_FORWARD);
     if (img2->type.type != PS_TYPE_C32) {
-        psError(__func__,"FFT didn't produce complex values?");
+        psError(PS_ERR_UNKNOWN, true,"FFT didn't produce complex values?");
         return 1;
     }
     if (img2->numCols != m || img2->numRows != n) {
-        psError(__func__,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).",
+        psError(PS_ERR_UNKNOWN, true,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).",
                 img2->numCols,img2->numRows,m,n);
         return 2;
@@ -103,5 +103,5 @@
                 if (! (col == 0 && (row == 1 || row == n-1))
                         && ! (row == 0 && (col==1 || col == n-1)) ) {
-                    psError(__func__,"Result invalid at %d,%d (%.2f)",col,row,mag);
+                    psError(PS_ERR_UNKNOWN, true,"Result invalid at %d,%d (%.2f)",col,row,mag);
                     return 3;
                 }
@@ -109,5 +109,5 @@
                 if ( (col == 0 && (row == 1 || row == n-1))
                         || (row == 0 && (col==1 || col == n-1)) ) {
-                    psError(__func__,"Result invalid at %d,%d (%.2f)",col,row,mag);
+                    psError(PS_ERR_UNKNOWN, true,"Result invalid at %d,%d (%.2f)",col,row,mag);
                     return 4;
                 }
@@ -120,10 +120,10 @@
 
     if (img3->type.type != PS_TYPE_C32) {
-        psError(__func__,"FFT didn't produce complex values?");
+        psError(PS_ERR_UNKNOWN, true,"FFT didn't produce complex values?");
         return 5;
     }
 
     if (img3->numCols != m || img3->numRows != n) {
-        psError(__func__,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).",
+        psError(PS_ERR_UNKNOWN, true,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).",
                 img3->numCols,img3->numRows,m,n);
         return 6;
@@ -136,5 +136,5 @@
             psF32 pixel = creal(img3Row[col])/m/n;
             if (fabsf(pixel-imgRow[col]) > 0.1) {
-                psError(__func__,"Reverse FFT didn't give original image back (%d,%d %.2f vs %.2f)",
+                psError(PS_ERR_UNKNOWN, true,"Reverse FFT didn't give original image back (%d,%d %.2f vs %.2f)",
                         col,row,pixel,imgRow[col]);
                 return 7;
@@ -149,10 +149,10 @@
         char* typeStr;
         PS_TYPE_NAME(typeStr,img3->type.type)
-        psError(__func__,"FFT asked to make real result, but I got a %s type image?",typeStr);
+        psError(PS_ERR_UNKNOWN, true,"FFT asked to make real result, but I got a %s type image?",typeStr);
         return 8;
     }
 
     if (img3->numCols != m || img3->numRows != n) {
-        psError(__func__,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).",
+        psError(PS_ERR_UNKNOWN, true,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).",
                 img3->numCols,img3->numRows,m,n);
         return 9;
@@ -165,5 +165,5 @@
             psF32 pixel = img3Row[col]/m/n;
             if (fabsf(pixel-imgRow[col]) > 0.1) {
-                psError(__func__,"Reverse FFT didn't give original image back (%d,%d %.2f vs %.2f)",
+                psError(PS_ERR_UNKNOWN, true,"Reverse FFT didn't give original image back (%d,%d %.2f vs %.2f)",
                         col,row,pixel,imgRow[col]);
                 return 10;
@@ -175,5 +175,5 @@
     psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
     if (psImageFFT(NULL,img2,PS_FFT_REVERSE|PS_FFT_FORWARD) != NULL) {
-        psError(__func__,"PS_FFT_REVERSE|PS_FFT_FORWARD option produced something?");
+        psError(PS_ERR_UNKNOWN, true,"PS_FFT_REVERSE|PS_FFT_FORWARD option produced something?");
         return 11;
     }
@@ -181,5 +181,5 @@
     psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
     if (psImageFFT(NULL,img2,PS_FFT_FORWARD|PS_FFT_REAL_RESULT) != NULL) {
-        psError(__func__,"PS_FFT_FORWARD|PS_FFT_REAL_RESULT option produced something?");
+        psError(PS_ERR_UNKNOWN, true,"PS_FFT_FORWARD|PS_FFT_REAL_RESULT option produced something?");
         return 12;
     }
@@ -188,5 +188,5 @@
     img4 = psImageFFT(NULL,NULL,PS_FFT_FORWARD);
     if (img4 != NULL ) {
-        psError(__func__,"psImageFFT should return null for a null input image.");
+        psError(PS_ERR_UNKNOWN, true,"psImageFFT should return null for a null input image.");
         return 10;
     }
@@ -197,5 +197,5 @@
     img5 = psImageFFT(NULL,img4,PS_FFT_REAL_RESULT);
     if (img5 != NULL) {
-        psError(__func__,"psImageFFT should return null for an invalid FFT direction.");
+        psError(PS_ERR_UNKNOWN, true,"psImageFFT should return null for an invalid FFT direction.");
         return 11;
     }
@@ -229,9 +229,9 @@
     img2 = psImageReal(img2,img);
     if (img2 == NULL) {
-        psError(__func__,"psImageReal returned a NULL?");
+        psError(PS_ERR_UNKNOWN, true,"psImageReal returned a NULL?");
         return 1;
     }
     if (img2->type.type != PS_TYPE_F32) {
-        psError(__func__,"psImageReal returned a wrong type (%d)?",
+        psError(PS_ERR_UNKNOWN, true,"psImageReal returned a wrong type (%d)?",
                 img2->type.type);
         return 2;
@@ -240,9 +240,9 @@
     img3 = psImageImaginary(img3,img);
     if (img3 == NULL) {
-        psError(__func__,"psImageImaginary returned a NULL?");
+        psError(PS_ERR_UNKNOWN, true,"psImageImaginary returned a NULL?");
         return 3;
     }
     if (img3->type.type != PS_TYPE_F32) {
-        psError(__func__,"psImageImaginary returned a wrong type (%d)?",
+        psError(PS_ERR_UNKNOWN, true,"psImageImaginary returned a wrong type (%d)?",
                 img3->type.type);
         return 4;
@@ -255,10 +255,10 @@
         for (psU32 col=0;col<m;col++) {
             if (fabsf(img2Row[col] - row) > FLT_EPSILON) {
-                psError(__func__,"psImageReal didn't return the real portion at n=%d",
+                psError(PS_ERR_UNKNOWN, true,"psImageReal didn't return the real portion at n=%d",
                         n);
                 return 5;
             }
             if (fabsf(img3Row[col] - col) > FLT_EPSILON) {
-                psError(__func__,"psImageImaginary didn't return the imag portion at n=%d",
+                psError(PS_ERR_UNKNOWN, true,"psImageImaginary didn't return the imag portion at n=%d",
                         n);
                 return 6;
@@ -307,5 +307,5 @@
     // 3. verify that the result is a psC32
     if (img3->type.type != PS_TYPE_C32) {
-        psError(__func__,"Image Type from psImageComplex is not complex? (%d)",
+        psError(PS_ERR_UNKNOWN, true,"Image Type from psImageComplex is not complex? (%d)",
                 img3->type.type);
         return 1;
@@ -319,5 +319,5 @@
             if (fabsf(crealf(img3Row[col]) - row) > FLT_EPSILON ||
                     fabsf(cimagf(img3Row[col]) - col) > FLT_EPSILON) {
-                psError(__func__,"psImageComplex result is invalid (%d,%d, %.2f+%.2fi)",
+                psError(PS_ERR_UNKNOWN, true,"psImageComplex result is invalid (%d,%d, %.2f+%.2fi)",
                         col,row,crealf(img3Row[col]),cimagf(img3Row[col]));
                 return 2;
@@ -334,5 +334,5 @@
     // 8. verify that an appropriate error occurred. (this partially has to be done via inspection)
     if (img3 != NULL) {
-        psError(__func__,"psImageComplex returned a image though input types mismatched.");
+        psError(PS_ERR_UNKNOWN, true,"psImageComplex returned a image though input types mismatched.");
         return 3;
     }
@@ -347,5 +347,5 @@
     // 11. verify thet an appropriate error occurred.
     if (img3 != NULL) {
-        psError(__func__,"psImageComplex returned a image though input sizes mismatched.");
+        psError(PS_ERR_UNKNOWN, true,"psImageComplex returned a image though input sizes mismatched.");
         return 4;
     }
@@ -380,5 +380,5 @@
     // 3. verify result is psC32
     if (img2->type.type != PS_TYPE_C32) {
-        psError(__func__,"the psImageConjugate didn't return a C32 image.");
+        psError(PS_ERR_UNKNOWN, true,"the psImageConjugate didn't return a C32 image.");
         return 1;
     }
@@ -390,5 +390,5 @@
             if (fabsf(crealf(img2Row[col]) - row) > FLT_EPSILON ||
                     fabsf(cimagf(img2Row[col]) + col) > FLT_EPSILON) {
-                psError(__func__,"psImageComplex result is invalid (%d,%d, %.2f+%.2fi)",
+                psError(PS_ERR_UNKNOWN, true,"psImageComplex result is invalid (%d,%d, %.2f+%.2fi)",
                         col,row,crealf(img2Row[col]),cimagf(img2Row[col]));
                 return 2;
@@ -425,5 +425,5 @@
     // 3. verify result is psF32
     if (img2->type.type != PS_TYPE_F32) {
-        psError(__func__,"the type was not PS_TYPE_F32.");
+        psError(PS_ERR_UNKNOWN, true,"the type was not PS_TYPE_F32.");
         return 1;
     }
@@ -438,5 +438,5 @@
 
             if (fabsf(img2Row[col] - power) > 2.0f*FLT_EPSILON) {
-                psError(__func__,"psImagePowerSpectrum result is invalid (%d,%d, %.2f vs %.2f)",
+                psError(PS_ERR_UNKNOWN, true,"psImagePowerSpectrum result is invalid (%d,%d, %.2f vs %.2f)",
                         col,row,img2Row[col],power);
                 return 2;
Index: /trunk/psLib/test/image/tst_psImageIO.c
===================================================================
--- /trunk/psLib/test/image/tst_psImageIO.c	(revision 2272)
+++ /trunk/psLib/test/image/tst_psImageIO.c	(revision 2273)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:33 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -97,17 +97,17 @@
         remove(filename); \
         if (! psImageWriteSection(img3,0,0,1,NULL,0,filename)) { \
-            psError(__func__,"Failed to write test image %s",filename); \
+            psError(PS_ERR_UNKNOWN, true,"Failed to write test image %s",filename); \
             return 1; \
         } \
         if (! psImageWriteSection(img,0,0,0,NULL,0,filename)) { \
-            psError(__func__,"Failed to write test image %s",filename); \
+            psError(PS_ERR_UNKNOWN, true,"Failed to write test image %s",filename); \
             return 2; \
         } \
         if (! psImageWriteSection(img,0,0,1,NULL,1,filename)) { \
-            psError(__func__,"Failed to write test image %s",filename); \
+            psError(PS_ERR_UNKNOWN, true,"Failed to write test image %s",filename); \
             return 3; \
         } \
         if (! psImageWriteSection(img3,0,0,0,NULL,1,filename)) { \
-            psError(__func__,"Failed to write test image %s",filename); \
+            psError(PS_ERR_UNKNOWN, true,"Failed to write test image %s",filename); \
             return 4; \
         } \
@@ -119,10 +119,10 @@
         img = psImageReadSection(img,readM0,readN0,readM,readN,0,NULL,0,filename); \
         /*        if (img_ref != img) { */ \
-        /*            psError(__func__,"psImageReadSection didn't recycle the psImage?"); */ \
+        /*            psError(PS_ERR_UNKNOWN, true,"psImageReadSection didn't recycle the psImage?"); */ \
         /*            return 5; */ \
         /*        } */ \
         img3 = psImageReadSection(img3,readM0,readN0,readM,readN,1,NULL,0,filename); \
         if (img3 == NULL) { \
-            psError(__func__,"Failed to read test image %s",filename); \
+            psError(PS_ERR_UNKNOWN, true,"Failed to read test image %s",filename); \
             return 6; \
         } \
@@ -134,10 +134,10 @@
             for (psU32 col = readM0; col < readM; col++) { \
                 if (fabsf(imgRow[col-readM0]-img2Row[col]) > FLT_EPSILON) { \
-                    psError(__func__,"Image changed in I/O operation at %d,%d,0 (%.2f vs %.2f) for %s", \
+                    psError(PS_ERR_UNKNOWN, true,"Image changed in I/O operation at %d,%d,0 (%.2f vs %.2f) for %s", \
                             col,row,(psF32)imgRow[col-readM0],(psF32)img2Row[col],filename); \
                     return 7; \
                 } \
                 if (fabsf(img3Row[col-readM0]-img4Row[col]) > FLT_EPSILON) { \
-                    psError(__func__,"Image changed in I/O operation at %d,%d,1 (%.2f vs %.2f) for %s", \
+                    psError(PS_ERR_UNKNOWN, true,"Image changed in I/O operation at %d,%d,1 (%.2f vs %.2f) for %s", \
                             col,row,(psF32)img3Row[col-readM0],(psF32)img4Row[col],filename); \
                     return 8; \
@@ -152,5 +152,5 @@
         img = psImageReadSection(img,readM0,readN0,readM,readN,1,NULL,1,filename); \
         if (img == NULL) { \
-            psError(__func__,"Failed to read test image %s",filename); \
+            psError(PS_ERR_UNKNOWN, true,"Failed to read test image %s",filename); \
             return 9; \
         } \
@@ -162,10 +162,10 @@
             for (psU32 col = readM0; col < readM; col++) { \
                 if (fabsf(imgRow[col-readM0]-img2Row[col]) > FLT_EPSILON) { \
-                    psError(__func__,"Image changed in I/O operation at %d,%d,0 (%.2f vs %.2f) for %s", \
+                    psError(PS_ERR_UNKNOWN, true,"Image changed in I/O operation at %d,%d,0 (%.2f vs %.2f) for %s", \
                             col,row,(psF32)imgRow[col-readM0],(psF32)img2Row[col],filename); \
                     return 10; \
                 } \
                 if (fabsf(img3Row[col-readM0]-img4Row[col]) > FLT_EPSILON) { \
-                    psError(__func__,"Image changed in I/O operation at %d,%d,1 (%.2f vs %.2f) for %s", \
+                    psError(PS_ERR_UNKNOWN, true,"Image changed in I/O operation at %d,%d,1 (%.2f vs %.2f) for %s", \
                             col,row,(psF32)img3Row[col-readM0],(psF32)img4Row[col],filename); \
                     return 11; \
@@ -204,5 +204,5 @@
     image = psImageReadSection(image,0,0,M,N,0,NULL,0,"foobar.fits");
     if (image != NULL) {
-        psError(__func__,"Image returned though filename did not exist.");
+        psError(PS_ERR_UNKNOWN, true,"Image returned though filename did not exist.");
         return 12;
     }
@@ -220,5 +220,5 @@
     image = psImageReadSection(image,0,0,M,N,0,NULL,0,NULL);
     if (image != NULL) {
-        psError(__func__,"Image returned though filename was NULL.");
+        psError(PS_ERR_UNKNOWN, true,"Image returned though filename was NULL.");
         return 13;
     }
@@ -233,5 +233,5 @@
     image = psImageReadSection(image,0,0,M,N,0,NULL,4,"tmpImages/MxN_F32.fits");
     if (image != NULL) {
-        psError(__func__,"Image returned though extnum was invalid.");
+        psError(PS_ERR_UNKNOWN, true,"Image returned though extnum was invalid.");
         return 14;
     }
@@ -239,5 +239,5 @@
     image = psImageReadSection(image,0,0,M,N,0,"bogus",0,"tmpImages/MxN_F32.fits");
     if (image != NULL) {
-        psError(__func__,"Image returned though extnum was invalid.");
+        psError(PS_ERR_UNKNOWN, true,"Image returned though extnum was invalid.");
         return 15;
     }
@@ -302,9 +302,9 @@
         ;
     if (! psImageWriteSection(img,0,0,0,NULL,0,"tmpImages/writeTest.fits")) {
-        psError(__func__,"Couldn't write writeTest.fits.");
+        psError(PS_ERR_UNKNOWN, true,"Couldn't write writeTest.fits.");
         return 14;
     }
     if (! psImageWriteSection(img2,0,0,0,NULL,0,"tmpImages/writeTest.fits")) {
-        psError(__func__,"Couldn't overwrite writeTest.fits.");
+        psError(PS_ERR_UNKNOWN, true,"Couldn't overwrite writeTest.fits.");
         return 15;
     }
@@ -315,5 +315,5 @@
     img = psImageReadSection(NULL,0,0,m,n,0,NULL,0,"tmpImages/writeTest.fits");
     if (img == NULL) {
-        psError(__func__,"Could not read in writeTest.fits.");
+        psError(PS_ERR_UNKNOWN, true,"Could not read in writeTest.fits.");
         return 16;
     }
@@ -322,5 +322,5 @@
         for (psU32 col=0;col<m;col++) {
             if (fabsf(imgRow[col] - (row+2*col)) > FLT_EPSILON) {
-                psError(__func__,"The image values were not overwritten at %d,%d (%.2f vs %.2f)",
+                psError(PS_ERR_UNKNOWN, true,"The image values were not overwritten at %d,%d (%.2f vs %.2f)",
                         col,row,imgRow[col],(row+2*col));
                 return 17;
@@ -337,5 +337,5 @@
     psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message because input image is null.");
     if ( psImageWriteSection(NULL,0,0,0,NULL,0,"tmpImages/writeTest.fits")) {
-        psError(__func__,"psImageWriteSection did not return false when input image is NULL.");
+        psError(PS_ERR_UNKNOWN, true,"psImageWriteSection did not return false when input image is NULL.");
         return 20;
     }
@@ -347,5 +347,5 @@
     GENIMAGE(img,32,32,S8,row+2*col);
     if ( psImageWriteSection(img,0,0,0,NULL,0,"tmpImages/writeTest.fits")) {
-        psError(__func__,"psImageWriteSection did not return false when input image type invalid.");
+        psError(PS_ERR_UNKNOWN, true,"psImageWriteSection did not return false when input image type invalid.");
         return 21;
     }
@@ -358,5 +358,5 @@
     GENIMAGE(img,32,32,U8,row+2*col);
     if ( psImageWriteSection(img,0,0,0,NULL,0,"panstarrs/writeFits.fits")) {
-        psError(__func__,"psImageWriteSection did not return false for invalid path name.");
+        psError(PS_ERR_UNKNOWN, true,"psImageWriteSection did not return false for invalid path name.");
         return 22;
     }
@@ -370,5 +370,5 @@
     psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for passing invalid FITS file.");
     if ( psImageWriteSection(img,0,0,0,NULL,0,"tmpImages/writeInvalidFile.fits")) {
-        psError(__func__,"psImageWriteSection did not return false for invalid FITS file.");
+        psError(PS_ERR_UNKNOWN, true,"psImageWriteSection did not return false for invalid FITS file.");
         return 22;
     }
@@ -381,5 +381,5 @@
     psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for invalid extension name.");
     if ( psImageWriteSection(img,0,0,0,"ext2",0,"tmpImages/writeTest.fits")) {
-        psError(__func__,"psImageWriteSection did not return false for invalid extension name.");
+        psError(PS_ERR_UNKNOWN, true,"psImageWriteSection did not return false for invalid extension name.");
         return 23;
     }
@@ -390,5 +390,5 @@
     psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for invalid extension number.");
     if ( psImageWriteSection(img,0,0,0,NULL,99,"tmpImages/writeTest.fits")) {
-        psError(__func__,"psImageWriteSection did not return false for invalid extension number.");
+        psError(PS_ERR_UNKNOWN, true,"psImageWriteSection did not return false for invalid extension number.");
         return 24;
     }
Index: /trunk/psLib/test/image/tst_psImageManip.c
===================================================================
--- /trunk/psLib/test/image/tst_psImageManip.c	(revision 2272)
+++ /trunk/psLib/test/image/tst_psImageManip.c	(revision 2273)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:33 $
+ *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -119,5 +119,5 @@
             } \
             if (fabsf(imgRow[col]-value) > FLT_EPSILON) { \
-                psError(__func__,"Pixel value is not as expected (%g vs %g) at %u,%u", \
+                psError(PS_ERR_UNKNOWN, true,"Pixel value is not as expected (%g vs %g) at %u,%u", \
                         (psF64)imgRow[col],(psF64)value,col,row); \
                 return 1; \
@@ -126,5 +126,5 @@
     } \
     if (retVal != numClipped) { \
-        psError(__func__,"Expected %d clips, but got %d", \
+        psError(PS_ERR_UNKNOWN, true,"Expected %d clips, but got %d", \
                 numClipped,retVal); \
         return 2; \
@@ -159,5 +159,5 @@
             if (fabsf(creal(imgRow[col])-creal(value)) > FLT_EPSILON || \
                     fabsf(cimag(imgRow[col])-cimag(value)) > FLT_EPSILON) { \
-                psError(__func__,"Pixel value is not as expected (%.2f+%.2fi vs %.2f+%.2fi) at %u,%u", \
+                psError(PS_ERR_UNKNOWN, true,"Pixel value is not as expected (%.2f+%.2fi vs %.2f+%.2fi) at %u,%u", \
                         creal(imgRow[col]),cimag(imgRow[col]),creal(value),cimag(value),col,row); \
                 return 1; \
@@ -166,5 +166,5 @@
     } \
     if (retVal != numClipped) { \
-        psError(__func__,"Expected %d clips, but got %d", \
+        psError(PS_ERR_UNKNOWN, true,"Expected %d clips, but got %d", \
                 numClipped,retVal); \
         return 2; \
@@ -198,5 +198,5 @@
     retVal = psImageClip(NULL,min,-1.0f,max,-2.0f);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for clips of a NULL image.");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for clips of a NULL image.");
         return 3;
     }
@@ -207,5 +207,5 @@
     retVal = psImageClip(img,max,-1.0f,min,-2.0f);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for clips when max < min.");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for clips when max < min.");
         return 4;
     }
@@ -217,5 +217,5 @@
     retVal = psImageClip(img,min,-1.0f,max,-2.0f);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for clip of invalid image type.");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for clip of invalid image type.");
         return 5;
     }
@@ -276,5 +276,5 @@
             } \
             if (fabsf(imgRow[col]-value) > FLT_EPSILON) { \
-                psError(__func__,"Pixel value is not as expected (%f vs %f) at %d,%d", \
+                psError(PS_ERR_UNKNOWN, true,"Pixel value is not as expected (%f vs %f) at %d,%d", \
                         imgRow[col],value,col,row); \
                 return 1; \
@@ -283,5 +283,5 @@
     } \
     if (retVal != numClipped) { \
-        psError(__func__,"Expected %d clips, but got %d", \
+        psError(PS_ERR_UNKNOWN, true,"Expected %d clips, but got %d", \
                 numClipped,retVal); \
         return 2; \
@@ -299,5 +299,5 @@
     retVal = psImageClipNaN(NULL,-1.0f);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for clips of a NULL image.");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for clips of a NULL image.");
         return 3;
     }
@@ -309,5 +309,5 @@
     retVal = psImageClipNaN(img,2.0f);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for clip of invalid image type.");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for clip of invalid image type.");
         return 4;
     }
@@ -377,5 +377,5 @@
             } \
             if (cabs(imgRow[col]-value) > FLT_EPSILON) { \
-                psError(__func__,"Pixel value is not as expected (%g%+gi vs %g%+gi) at %d,%d", \
+                psError(PS_ERR_UNKNOWN, true,"Pixel value is not as expected (%g%+gi vs %g%+gi) at %d,%d", \
                         creal(imgRow[col]),cimag(imgRow[col]),creal(value),cimag(value),col,row); \
                 return 1; \
@@ -384,5 +384,5 @@
     } \
     if (retVal != numClipped) { \
-        psError(__func__,"Expected %d clips, but got %d", \
+        psError(PS_ERR_UNKNOWN, true,"Expected %d clips, but got %d", \
                 numClipped,retVal); \
         return 2; \
@@ -408,5 +408,5 @@
     retVal = psImageClipComplexRegion(NULL,0,0,0,0);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for clips of a NULL image.");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for clips of a NULL image.");
         return 3;
     }
@@ -427,5 +427,5 @@
     retVal = psImageClipComplexRegion(img,10.0+I*1.0,-1.0,5.0+5.0*I,-2.0);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for creal(min)>creal(max).");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for creal(min)>creal(max).");
         return 3;
     }
@@ -433,5 +433,5 @@
     retVal = psImageClipComplexRegion(img,1.0+I*10.0,-1.0,5.0+5.0*I,-2.0);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for cimag(min)>cimag(max).");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for cimag(min)>cimag(max).");
         return 3;
     }
@@ -439,5 +439,5 @@
     retVal = psImageClipComplexRegion(img,10.0+I*10.0,-1.0,5.0+5.0*I,-2.0);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for min>max.");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for min>max.");
         return 3;
     }
@@ -457,5 +457,5 @@
                                       0.0);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for vmin not in datatype range.");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for vmin not in datatype range.");
         return 80;
     }
@@ -468,5 +468,5 @@
                                       0.0);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for vmin not in datatype range.");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for vmin not in datatype range.");
         return 81;
     }
@@ -479,5 +479,5 @@
                                       0.0);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for vmin not in datatype range.");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for vmin not in datatype range.");
         return 82;
     }
@@ -490,5 +490,5 @@
                                       0.0);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for vmin not in datatype range.");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for vmin not in datatype range.");
         return 83;
     }
@@ -501,5 +501,5 @@
                                       -2.0*(double)FLT_MAX);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for vmax not in datatype range.");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for vmax not in datatype range.");
         return 84;
     }
@@ -512,5 +512,5 @@
                                       2.0*(double)FLT_MAX);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for vmax not in datatype range.");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for vmax not in datatype range.");
         return 85;
     }
@@ -523,5 +523,5 @@
                                       -2.0*(double)FLT_MAX*I);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for vmax not in datatype range.");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for vmax not in datatype range.");
         return 87;
     }
@@ -534,5 +534,5 @@
                                       2.0*(double)FLT_MAX*I);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for vmax not in datatype range.");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for vmax not in datatype range.");
         return 88;
     }
@@ -552,5 +552,5 @@
                                       0.0);
     if (retVal == 0) {
-        psError(__func__,"Didn't expect zero return for vmin > vmax.");
+        psError(PS_ERR_UNKNOWN, true,"Didn't expect zero return for vmin > vmax.");
         return 83;
     }
@@ -573,5 +573,5 @@
     retVal = psImageClipComplexRegion(img,2.0,10.0,5.0,0.0);
     if (retVal != 0) {
-        psError(__func__,"Expected zero return for clip of invalid image type.");
+        psError(PS_ERR_UNKNOWN, true,"Expected zero return for clip of invalid image type.");
         return 84;
     }
@@ -625,5 +625,5 @@
     retVal = psImageOverlaySection(img,img2,c/4,r/4,OPSTRING); \
     if (retVal != 0) { \
-        psError(__func__,"psImageOverlaySection returned non-zero %s op",OPSTRING); \
+        psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned non-zero %s op",OPSTRING); \
         return 1; \
     } \
@@ -637,10 +637,10 @@
             } \
             if (fabsf(imgRow[col] - val) > FLT_EPSILON) { \
-                psError(__func__,"Value incorrect at %d,%d (%.2f vs %.2f for %s)", \
+                psError(PS_ERR_UNKNOWN, true,"Value incorrect at %d,%d (%.2f vs %.2f for %s)", \
                         col,row,imgRow[col],val,OPSTRING); \
                 return 2; \
             } \
             if (row < r/2 && col < c/2 && fabsf(img2Row[col] - 2.0) > FLT_EPSILON) { \
-                psError(__func__,"Overlay modified at %d,%d (%.2f for %s)", \
+                psError(PS_ERR_UNKNOWN, true,"Overlay modified at %d,%d (%.2f for %s)", \
                         col,row,img2Row[col],OPSTRING); \
                 return 2; \
@@ -706,5 +706,5 @@
     retVal = psImageOverlaySection(img,img2,c/4,r/4,"+");
     if (retVal == 0) {
-        psError(__func__,"psImageOverlaySection returned zero even though "
+        psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though "
                 "overlay too big");
         return 3;
@@ -714,5 +714,5 @@
         for (unsigned col=0;col<c;col++) {
             if (imgRow[col] != 6.0f) {
-                psError(__func__,"Input image modified when overlay size too big");
+                psError(PS_ERR_UNKNOWN, true,"Input image modified when overlay size too big");
                 return 4;
             }
@@ -729,5 +729,5 @@
     retVal = psImageOverlaySection(img,NULL,c/4,r/4,"+");
     if (retVal == 0) {
-        psError(__func__,"psImageOverlaySection returned zero even though "
+        psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though "
                 "overlay too big");
         return 5;
@@ -737,5 +737,5 @@
         for (unsigned col=0;col<c;col++) {
             if (imgRow[col] != 6.0f) {
-                psError(__func__,"Input image modified when overlay NULL");
+                psError(PS_ERR_UNKNOWN, true,"Input image modified when overlay NULL");
                 return 6;
             }
@@ -751,5 +751,5 @@
     retVal = psImageOverlaySection(NULL,img2,c/4,r/4,"+");
     if (retVal == 0) {
-        psError(__func__,"psImageOverlaySection returned zero even though "
+        psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though "
                 "overlay too big");
         return 7;
@@ -764,5 +764,5 @@
     retVal = psImageOverlaySection(img,img2,0,0,"$");
     if (retVal == 0) {
-        psError(__func__,"psImageOverlaySection returned zero even though "
+        psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though "
                 "overlay operator is invalid");
         return 8;
@@ -777,5 +777,5 @@
     retVal = psImageOverlaySection(img,img2,0,0,NULL);
     if(retVal == 0) {
-        psError(__func__,"psImageOverlaySection returned zero even though "
+        psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though "
                 "overlay operator is NULL");
         return 9;
@@ -790,5 +790,5 @@
     retVal = psImageOverlaySection(img,img3,0,0,"+");
     if(retVal == 0) {
-        psError(__func__,"psImageOverlaySection returned zero eventhough "
+        psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero eventhough "
                 " overlay image type is different than input image.");
         return 10;
@@ -803,5 +803,5 @@
     retVal = psImageOverlaySection(img3,img4,0,0,"+");
     if(retVal == 0) {
-        psError(__func__,"psImageOverlaySection returned zero eventhough "
+        psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero eventhough "
                 "overlay and image type are invalid type.");
         return 11;
@@ -820,5 +820,5 @@
     retVal = psImageOverlaySection(img,img2,0,0,"/");
     if (retVal != 0) {
-        psError(__func__,"psImageOverlaySection returned non-zero when "
+        psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned non-zero when "
                 "checking divide-by-zero.");
         return 12;
@@ -906,9 +906,9 @@
     out = psImageRebin(NULL,in,NULL,0,4,&stats); \
     if (out == NULL) { \
-        psError(__func__,"psImageRebin returned a NULL pointer!?"); \
+        psError(PS_ERR_UNKNOWN, true,"psImageRebin returned a NULL pointer!?"); \
         return 1; \
     } \
     if (out->numRows != 4 || out->numCols != 4) { \
-        psError(__func__,"psImageRebin didn't produce the proper size image " \
+        psError(PS_ERR_UNKNOWN, true,"psImageRebin didn't produce the proper size image " \
                 "(%d x %d).", \
                 out->numCols, out->numRows); \
@@ -920,5 +920,5 @@
         for (psS32 col = 0; col<4; col++) { \
             if (fabsf((float)outRow[col]-(float)truthRow[col]) > FLT_EPSILON) { \
-                psError(__func__,"psImageRebin didn't produce the proper mean " \
+                psError(PS_ERR_UNKNOWN, true,"psImageRebin didn't produce the proper mean " \
                         "result at (%d,%d) [%f vs %f].", \
                         col,row,outRow[col],truthRow[col]); \
@@ -934,5 +934,5 @@
         for ( psS32 col = 0; col<4; col++) { \
             if(abs((psS32)outRow[col]-(psS32)truthRow[col]) > FLT_EPSILON) { \
-                psError(__func__,"psImageRebin with mask didn't produce the proper mean " \
+                psError(PS_ERR_UNKNOWN, true,"psImageRebin with mask didn't produce the proper mean " \
                         "result at (%d,%d) [%f vs %f].", \
                         col,row,outRow[col],truthRow[col]); \
@@ -944,13 +944,13 @@
     out2 = psImageRebin(out,in,NULL,0,3,&stats); \
     if (out != out2) { \
-        psError(__func__,"psImageRebin didn't recycle a psImage properly!?"); \
+        psError(PS_ERR_UNKNOWN, true,"psImageRebin didn't recycle a psImage properly!?"); \
         return 7; \
     } \
     if (out == NULL) { \
-        psError(__func__,"psImageRebin returned a NULL pointer!?"); \
+        psError(PS_ERR_UNKNOWN, true,"psImageRebin returned a NULL pointer!?"); \
         return 4; \
     } \
     if (out->numRows != 6 || out->numCols != 6) { \
-        psError(__func__,"psImageRebin didn't produce the proper size image " \
+        psError(PS_ERR_UNKNOWN, true,"psImageRebin didn't produce the proper size image " \
                 "(%d x %d).", \
                 out->numCols, out->numRows); \
@@ -962,5 +962,5 @@
         for (psS32 col = 0; col<6; col++) { \
             if (fabsf((float)outRow[col]-(float)truthRow[col]) > FLT_EPSILON) { \
-                psError(__func__,"psImageRebin didn't produce the proper " \
+                psError(PS_ERR_UNKNOWN, true,"psImageRebin didn't produce the proper " \
                         "max result at (%d,%d) [%f vs %f].", \
                         col,row,outRow[col],truthRow[col]); \
@@ -990,5 +990,5 @@
     out = psImageRebin(NULL,in,NULL,0,4,&stats);
     if(out != NULL) {
-        psError(__func__,"psImageRebin return an image eventhough the "
+        psError(PS_ERR_UNKNOWN, true,"psImageRebin return an image eventhough the "
                 "type is not handled.");
         return 14;
@@ -999,5 +999,5 @@
     out = psImageRebin(NULL,in,mask,1,4,&stats);
     if(out != NULL) {
-        psError(__func__,"psImageRebin return an image eventhough the "
+        psError(PS_ERR_UNKNOWN, true,"psImageRebin return an image eventhough the "
                 "mask is not the correct type.");
         return 17;
@@ -1012,5 +1012,5 @@
 
     if (out2 != NULL) {
-        psError(__func__,"psImageRebin returned an image though the input was "
+        psError(PS_ERR_UNKNOWN, true,"psImageRebin returned an image though the input was "
                 "NULL!?");
         return 8;
@@ -1024,5 +1024,5 @@
 
     if (out2 != NULL) {
-        psError(__func__,"psImageRebin returned an image though the scale was "
+        psError(PS_ERR_UNKNOWN, true,"psImageRebin returned an image though the scale was "
                 "zero!?");
         return 9;
@@ -1035,5 +1035,5 @@
 
     if (out2 != NULL) {
-        psError(__func__,"psImageRebin returned an image though the stats was "
+        psError(PS_ERR_UNKNOWN, true,"psImageRebin returned an image though the stats was "
                 "NULL!?");
         return 10;
@@ -1049,5 +1049,5 @@
 
     if (out2 != NULL) {
-        psError(__func__,"psImageRebin returned an image though the stats "
+        psError(PS_ERR_UNKNOWN, true,"psImageRebin returned an image though the stats "
                 "options was zero!?");
         return 11;
@@ -1059,5 +1059,5 @@
 
     if (out2 != NULL) {
-        psError(__func__,"psImageRebin returned an image though the stats "
+        psError(PS_ERR_UNKNOWN, true,"psImageRebin returned an image though the stats "
                 "options was PS_STAT_USE_RANGE!?");
         return 12;
@@ -1072,5 +1072,5 @@
 
     if (out2 != NULL) {
-        psError(__func__,"psImageRebin returned an image though the stats "
+        psError(PS_ERR_UNKNOWN, true,"psImageRebin returned an image though the stats "
                 "options was PS_STAT_SAMPLE_MEAN+PS_STAT_MAX!?");
         return 13;
@@ -1121,5 +1121,5 @@
         for (psS32 col=0;col<cols;col++) {
             if (inRow[col] != outRow[col]) {
-                psError(__func__,"psImageRoll didn't produce expected result "
+                psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't produce expected result "
                         "at %d,%d (%f vs %f) for dx=0, dy=0.",
                         col,row,inRow[col],outRow[col]);
@@ -1135,5 +1135,5 @@
         for (psS32 col=0;col<cols;col++) {
             if (inRow[(col+cols/4) % cols] != outRow[col]) {
-                psError(__func__,"psImageRoll didn't produce expected result "
+                psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't produce expected result "
                         "at %d,%d (%f vs %f) for dx=cols/4, dy=0.",
                         col,row,inRow[(col+cols/4) % cols],outRow[col]);
@@ -1146,5 +1146,5 @@
     // parameter out if provided.
     if (out2 != out) {
-        psError(__func__,"psImageRoll didn't recycle my out psImage!?");
+        psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't recycle my out psImage!?");
         return 1;
     }
@@ -1156,5 +1156,5 @@
         for (psS32 col=0;col<cols;col++) {
             if (inRow[col] != outRow[col]) {
-                psError(__func__,"psImageRoll didn't produce expected result "
+                psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't produce expected result "
                         "at %d,%d (%f vs %f) for dx=0, dy=rows/4.",
                         col,row,inRow[col],outRow[col]);
@@ -1170,5 +1170,5 @@
         for (psS32 col=0;col<cols;col++) {
             if (inRow[(col+cols/4) % cols] != outRow[col]) {
-                psError(__func__,"psImageRoll didn't produce expected result "
+                psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't produce expected result "
                         "at %d,%d (%f vs %f) for dx=cols/4, dy=rows/4.",
                         col,row,inRow[(col+cols/4) % cols],outRow[col]);
@@ -1184,5 +1184,5 @@
         for (psS32 col=0;col<cols;col++) {
             if (inRow[(col+(cols-cols/4)) % cols] != outRow[col]) {
-                psError(__func__,"psImageRoll didn't produce expected result "
+                psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't produce expected result "
                         "at %d,%d (%f vs %f) for dx=-cols/4, dy=0.",
                         col,row,inRow[(col+(cols-cols/4)) % cols],outRow[col]);
@@ -1198,5 +1198,5 @@
         for (psS32 col=0;col<cols;col++) {
             if (inRow[col] != outRow[col]) {
-                psError(__func__,"psImageRoll didn't produce expected result "
+                psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't produce expected result "
                         "at %d,%d (%f vs %f) for dx=0, dy=-rows/4.",
                         col,row,inRow[col],outRow[col]);
@@ -1212,5 +1212,5 @@
         for (psS32 col=0;col<cols;col++) {
             if (inRow[(col+cols-cols/4) % cols] != outRow[col]) {
-                psError(__func__,"psImageRoll didn't produce expected result "
+                psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't produce expected result "
                         "at %d,%d (%f vs %f) for dx=cols/4, dy=rows/4.",
                         col,row,inRow[(col+cols-cols/4) % cols],outRow[col]);
@@ -1226,5 +1226,5 @@
     out2 = psImageRoll(NULL,NULL,0,0);
     if (out2 != NULL) {
-        psError(__func__,"psImageRoll did not return NULL though input image was NULL!?");
+        psError(PS_ERR_UNKNOWN, true,"psImageRoll did not return NULL though input image was NULL!?");
         return 2;
     }
@@ -1249,5 +1249,5 @@
         for (psS32 col=0;col<cols1;col++) { \
             if (inRow[(col+cols1/4)%cols1] != outRow[col]) { \
-                psError(__func__,"psImageRoll didn't produce expected result " \
+                psError(PS_ERR_UNKNOWN, true,"psImageRoll didn't produce expected result " \
                         "at %d,%d (%f vs %f) for dx=0, dy=0.", \
                         col,row,(float)inRow[col],(float)outRow[col]); \
@@ -1346,9 +1346,9 @@
         // parameter out if provided.
         if (oldOut != NULL && oldOut != fOut) {
-            psError(__func__,"the output recycle functionality failed");
+            psError(PS_ERR_UNKNOWN, true,"the output recycle functionality failed");
             return 2;
         }
         if (oldBiOut != NULL && oldBiOut != fBiOut) {
-            psError(__func__,"the output recycle functionality failed");
+            psError(PS_ERR_UNKNOWN, true,"the output recycle functionality failed");
             return 4;
         }
@@ -1356,17 +1356,17 @@
         sBiOut = psImageRotate(sBiOut,sImg,rot,-1.0,PS_INTERPOLATE_BILINEAR);
         if (! psImageWriteSection(fOut,0,0,0,NULL,index,"temp/fOut.fits") ) {
-            psError(__func__,"Can not write to temp/fOut.fits, so why continue!?");
+            psError(PS_ERR_UNKNOWN, true,"Can not write to temp/fOut.fits, so why continue!?");
             return 20;
         }
         if (! psImageWriteSection(sOut,0,0,0,NULL,index,"temp/sOut.fits") ) {
-            psError(__func__,"Can not write to temp/sOut.fits, so why continue!?");
+            psError(PS_ERR_UNKNOWN, true,"Can not write to temp/sOut.fits, so why continue!?");
             return 21;
         }
         if (! psImageWriteSection(fBiOut,0,0,0,NULL,index,"temp/fBiOut.fits") ) {
-            psError(__func__,"Can not write to temp/fBiOut.fits, so why continue!?");
+            psError(PS_ERR_UNKNOWN, true,"Can not write to temp/fBiOut.fits, so why continue!?");
             return 40;
         }
         if (! psImageWriteSection(sBiOut,0,0,0,NULL,index,"temp/sBiOut.fits") ) {
-            psError(__func__,"Can not write to temp/sBiOut.fits, so why continue!?");
+            psError(PS_ERR_UNKNOWN, true,"Can not write to temp/sBiOut.fits, so why continue!?");
             return 41;
         }
@@ -1378,10 +1378,10 @@
         sBiTruth = psImageReadSection(sBiTruth,0,0,0,0,0,NULL,index,"verified/sBiOut.fits");
         if (fTruth == NULL) {
-            psError(__func__,"verified psF32 image failed to be read (%d deg. rotation)",
+            psError(PS_ERR_UNKNOWN, true,"verified psF32 image failed to be read (%d deg. rotation)",
                     rot);
             fail = true;
         } else {
             if (fTruth->numRows != fOut->numRows || fTruth->numCols != fOut->numCols) {
-                psError(__func__,"Rotated float image size did not match truth "
+                psError(PS_ERR_UNKNOWN, true,"Rotated float image size did not match truth "
                         "image for %d deg rotation (%dx%d vs %dx%d).",
                         rot,fOut->numCols,fOut->numRows,fTruth->numCols,fTruth->numRows);
@@ -1393,5 +1393,5 @@
                     for (psS32 col=0;col<fTruth->numCols;col++) {
                         if (fabsf(truthRow[col]-outRow[col]) > 1) {
-                            psError(__func__,"Float Image mismatch (%f vs %f) at %d,%d.",
+                            psError(PS_ERR_UNKNOWN, true,"Float Image mismatch (%f vs %f) at %d,%d.",
                                     outRow[col], truthRow[col],col,row);
                             fail = true;
@@ -1403,5 +1403,5 @@
 
         if (sTruth == NULL) {
-            psError(__func__,"verified psS16 image failed to be read "
+            psError(PS_ERR_UNKNOWN, true,"verified psS16 image failed to be read "
                     "(%d deg. rotation)",rot);
             fail = true;
@@ -1409,5 +1409,5 @@
             if (sTruth->numRows != sOut->numRows ||
                     sTruth->numCols != sOut->numCols) {
-                psError(__func__,"Rotated psS16 image size did not match truth "
+                psError(PS_ERR_UNKNOWN, true,"Rotated psS16 image size did not match truth "
                         "image for %d deg rotation.",rot);
                 fail = true;
@@ -1418,5 +1418,5 @@
                     for (psS32 col=0;col<sTruth->numCols;col++) {
                         if (fabsf(truthRow[col]-outRow[col]) > 1) {
-                            psError(__func__,"Short Image mismatch (%d vs %d) "
+                            psError(PS_ERR_UNKNOWN, true,"Short Image mismatch (%d vs %d) "
                                     "at %d,%d.",
                                     outRow[col], truthRow[col],col,row);
@@ -1430,10 +1430,10 @@
 
         if (fBiTruth == NULL) {
-            psError(__func__,"verified psF32 Bi image failed to be read (%d deg. rotation)",
+            psError(PS_ERR_UNKNOWN, true,"verified psF32 Bi image failed to be read (%d deg. rotation)",
                     rot);
             fail = true;
         } else {
             if (fBiTruth->numRows != fBiOut->numRows || fBiTruth->numCols != fBiOut->numCols) {
-                psError(__func__,"Rotated float image size did not match truth "
+                psError(PS_ERR_UNKNOWN, true,"Rotated float image size did not match truth "
                         "image for %d deg rotation (%dx%d vs %dx%d). BILINEAR",
                         rot,fBiOut->numCols,fBiOut->numRows,fBiTruth->numCols,fBiTruth->numRows);
@@ -1445,5 +1445,5 @@
                     for (psS32 col=0;col<fBiTruth->numCols;col++) {
                         if (fabsf(truthRow[col]-outRow[col]) > 1) {
-                            psError(__func__,"Float Image mismatch (%f vs %f) at %d,%d. BILINEAR",
+                            psError(PS_ERR_UNKNOWN, true,"Float Image mismatch (%f vs %f) at %d,%d. BILINEAR",
                                     outRow[col], truthRow[col],col,row);
                             fail = true;
@@ -1455,5 +1455,5 @@
 
         if (sBiTruth == NULL) {
-            psError(__func__,"verified psS16 image failed to be read "
+            psError(PS_ERR_UNKNOWN, true,"verified psS16 image failed to be read "
                     "(%d deg. rotation) BILINEAR",rot);
             fail = true;
@@ -1461,5 +1461,5 @@
             if (sBiTruth->numRows != sBiOut->numRows ||
                     sBiTruth->numCols != sBiOut->numCols) {
-                psError(__func__,"Rotated psS16 image size did not match truth "
+                psError(PS_ERR_UNKNOWN, true,"Rotated psS16 image size did not match truth "
                         "image for %d deg rotation. BILINEAR",rot);
                 fail = true;
@@ -1470,5 +1470,5 @@
                     for (psS32 col=0;col<sBiTruth->numCols;col++) {
                         if (fabsf(truthRow[col]-outRow[col]) > 1) {
-                            psError(__func__,"Short Image mismatch (%d vs %d) "
+                            psError(PS_ERR_UNKNOWN, true,"Short Image mismatch (%d vs %d) "
                                     "at %d,%d. BILINEAR",
                                     outRow[col], truthRow[col],col,row);
@@ -1487,5 +1487,5 @@
             s32Out = psImageRotate(s32Out,s32Img,rot,-1.0,PS_INTERPOLATE_FLAT);
             if( s32Out != NULL ) {
-                psError(__func__,"psImage returned is not NULL for invalid image type.");
+                psError(PS_ERR_UNKNOWN, true,"psImage returned is not NULL for invalid image type.");
                 return 5;
             }
@@ -1496,5 +1496,5 @@
 
     if (fail) {
-        psError(__func__,"One or more images didn't match truth or truth did "
+        psError(PS_ERR_UNKNOWN, true,"One or more images didn't match truth or truth did "
                 "not exist.");
         return 10;
@@ -1507,5 +1507,5 @@
     fOut = psImageRotate(fOut,NULL,0,0,PS_INTERPOLATE_FLAT);
     if (fOut != NULL) {
-        psError(__func__,"NULL wasn't returned though the input image was NULL.");
+        psError(PS_ERR_UNKNOWN, true,"NULL wasn't returned though the input image was NULL.");
         return 3;
     }
@@ -1517,5 +1517,5 @@
     fOut = psImageRotate(fOut, fImg, 33, 0, -1);
     if (fOut != NULL) {
-        psError(__func__,"NULL wasn't returned though the interpolation mode "
+        psError(PS_ERR_UNKNOWN, true,"NULL wasn't returned though the interpolation mode "
                 "is invalid.");
         return 4;
@@ -1598,5 +1598,5 @@
 
     if (fRecycle != fOut) {
-        psError(__func__,"psImageShift didn't recycle my image?");
+        psError(PS_ERR_UNKNOWN, true,"psImageShift didn't recycle my image?");
         return 10;
     }
@@ -1609,5 +1609,5 @@
     fOut = psImageShift(fOut,NULL,8,8,NAN,PS_INTERPOLATE_FLAT);
     if (fOut != NULL) {
-        psError(__func__,"psImageShift didn't return NULL given a NULL input image.");
+        psError(PS_ERR_UNKNOWN, true,"psImageShift didn't return NULL given a NULL input image.");
         return 11;
     }
@@ -1618,5 +1618,5 @@
     fOut = psImageShift(fOut,fImg,8,8,NAN,-1);
     if (fOut != NULL ) {
-        psError(__func__,"psImageShift didn't return NULL given an invalid interpolation mode.");
+        psError(PS_ERR_UNKNOWN, true,"psImageShift didn't return NULL given an invalid interpolation mode.");
         return 12;
     }
@@ -1675,20 +1675,20 @@
 
             if (fabsf(fRow[col] - fValue) > FLT_EPSILON) {
-                psError(__func__,"Float image not shifted correctly at %d,%d (%g vs %g)",
+                psError(PS_ERR_UNKNOWN, true,"Float image not shifted correctly at %d,%d (%g vs %g)",
                         col,row,fRow[col],fValue);
                 return 1;
             }
             if (sRow[col] != sValue) {
-                psError(__func__,"Short image not shifted correctly at %d,%d (%d vs %d)",
+                psError(PS_ERR_UNKNOWN, true,"Short image not shifted correctly at %d,%d (%d vs %d)",
                         col,row,sRow[col],sValue);
                 return 2;
             }
             if (fabsf(fBiRow[col] - fBiValue) > FLT_EPSILON) {
-                psError(__func__,"Float image not shifted correctly at %d,%d (%g vs %g)",
+                psError(PS_ERR_UNKNOWN, true,"Float image not shifted correctly at %d,%d (%g vs %g)",
                         col,row,fBiRow[col],fBiValue);
                 return 1;
             }
             if (sBiRow[col] != sBiValue) {
-                psError(__func__,"Short image not shifted correctly at %d,%d (%d vs %d)",
+                psError(PS_ERR_UNKNOWN, true,"Short image not shifted correctly at %d,%d (%d vs %d)",
                         col,row,sBiRow[col],sBiValue);
                 return 2;
Index: /trunk/psLib/test/psTest.c
===================================================================
--- /trunk/psLib/test/psTest.c	(revision 2272)
+++ /trunk/psLib/test/psTest.c	(revision 2273)
@@ -85,6 +85,6 @@
                 runAll = false;
                 if ( sscanf( optarg, "%i", &n ) != 1 ) {
-                    psError( __func__, "Failed to parse the testpoint number (%s).",
-                             optarg );
+                    psError(PS_ERR_UNKNOWN, true, "Failed to parse the testpoint number (%s).",
+                            optarg );
                     break;
                 }
@@ -103,11 +103,11 @@
                 }
                 if ( ! found ) {
-                    psError( __func__, "The specified testpoint number (%d) doesn't exist in this test driver.",
-                             n );
+                    psError(PS_ERR_UNKNOWN, true, "The specified testpoint number (%d) doesn't exist in this test driver.",
+                            n );
                     break;
                 }
                 break;
             case '?':
-                psError( __func__, "Option %s is not recognized and is ignored.", optarg );
+                psError(PS_ERR_UNKNOWN, true, "Option %s is not recognized and is ignored.", optarg );
                 break;
             }
@@ -130,5 +130,6 @@
 
     if ( ! success ) {
-        psError( testPointFile, "One or more tests failed" );
+        psError( PS_ERR_UNKNOWN, true,
+                 "One or more tests failed" );
     }
 
@@ -151,5 +152,5 @@
             if ( retVal == 0 ) { // only bother checking memory if test executed to end.
                 if ( psMemCheckLeaks( currentId, NULL, stderr ) != 0 ) {
-                    psError( __func__, "Memory Leaks Detected" );
+                    psError(PS_ERR_UNKNOWN, true, "Memory Leaks Detected" );
                     retVal = 64;
                 }
@@ -175,5 +176,5 @@
         if ( childReturn == 0 ) { // only bother checking memory if test executed to end.
             if ( psMemCheckLeaks( currentId, NULL, stderr ) != 0 ) {
-                psError( __func__, "Memory Leaks Detected" );
+                psError(PS_ERR_UNKNOWN, true, "Memory Leaks Detected" );
                 childReturn = 64;
             }
Index: /trunk/psLib/test/sysUtils/tst_psError.c
===================================================================
--- /trunk/psLib/test/sysUtils/tst_psError.c	(revision 2272)
+++ /trunk/psLib/test/sysUtils/tst_psError.c	(revision 2273)
@@ -13,6 +13,6 @@
  *  @author  Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.14 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2004-10-27 00:57:33 $
+ *  @version $Revision: 1.15 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2004-11-04 01:05:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -99,13 +99,13 @@
 
     // Generate three error messages to have messages on error stack
-    if (psErrorMsg("test4A", code, true, "Error code = %d", code) !=  code) {
+    if (psError(code, true, "Error code = %d", code) !=  code) {
         psLogMsg("tst_psError04", PS_LOG_ERROR, "Failed return value verify.");
         return 31;
     }
-    if (psErrorMsg("test4A", (code+1), false, "Error code = %d", (code+1)) != (code+1)) {
+    if (psError((code+1), false, "Error code = %d", (code+1)) != (code+1)) {
         psLogMsg("tst_psError04", PS_LOG_ERROR, "Failed return value verify.");
         return 32;
     }
-    if (psErrorMsg("test4A", (code+2), false, "Error code = %d", (code+2)) != (code+2)) {
+    if (psError((code+2), false, "Error code = %d", (code+2)) != (code+2)) {
         psLogMsg("tst_psError04", PS_LOG_ERROR, "Failed return value verify.");
         return 33;
@@ -165,13 +165,13 @@
 
     // Generate three error messages
-    if (psErrorMsg("test3A", code, true, "Error code = %d", code) !=  code) {
+    if (psError(code, true, "Error code = %d", code) !=  code) {
         psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify.");
         return 23;
     }
-    if (psErrorMsg("test3A", (code+1), false, "Error code = %d", (code+1)) != (code+1)) {
+    if (psError((code+1), false, "Error code = %d", (code+1)) != (code+1)) {
         psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify.");
         return 24;
     }
-    if (psErrorMsg("test3A", (code+2), false, "Error code = %d", (code+2)) != (code+2)) {
+    if (psError((code+2), false, "Error code = %d", (code+2)) != (code+2)) {
         psLogMsg("tst_psError03", PS_LOG_ERROR, "Failed return value verify.");
         return 25;
@@ -219,5 +219,5 @@
 
     // Generate error message and verify return value
-    if (psErrorMsg("test2A", code, true, "Error code = %d", code) != code ) {
+    if (psError(code, true, "Error code = %d", code) != code ) {
         psLogMsg("tst_psError02", PS_LOG_ERROR, "Failed return value verify.");
         return 10;
@@ -233,5 +233,5 @@
 
     // Verify the return value of psErrorMsg is the psErrorCode passed
-    if ( psErrorMsg("test1A", code, true, "Error code = %d", code) != code) {
+    if ( psError(code, true, "Error code = %d", code) != code) {
         psLogMsg("tst_psError01", PS_LOG_ERROR, "Failed return value verify.");
         return 1;
@@ -240,5 +240,5 @@
 
     // test1B empty string in for name argument
-    if ( psErrorMsg("", code+1, true, "Error code = %d", code+1) != code+1) {
+    if ( psError(code+1, true, "Error code = %d", code+1) != code+1) {
         psLogMsg("tst_psError01", PS_LOG_ERROR, "Failed return with empty string.");
         return 2;
@@ -246,13 +246,6 @@
     psErrorStackPrint(stderr,"ERROR STACK PRINT Test1B");
 
-    // test1C null pointer in  for name argument
-    if ( psErrorMsg(NULL, code+2, true, "Error code = %d", code+2) != code+2) {
-        psLogMsg("tst_psError01", PS_LOG_ERROR, "Failed return with null name arg.");
-        return 3;
-    }
-    psErrorStackPrint(stderr,"ERROR STACK PRINT Test1C");
-
     // test1D undefined code
-    if ( psErrorMsg("test1D", -1, true, "Error code = %d", -1) != -1) {
+    if ( psError(-1, true, "Error code = %d", -1) != -1) {
         psLogMsg("test_psError01", PS_LOG_ERROR, "Failed return with undefined code.");
         return 4;
@@ -261,5 +254,5 @@
 
     // test1E set psErrorMsg argument to false
-    if( psErrorMsg("test1E", code, false, "Error code = %d", code) != code) {
+    if( psError(code, false, "Error code = %d", code) != code) {
         psLogMsg("test_psError01", PS_LOG_ERROR, "Failed return with false new arg.");
         return 5;
@@ -268,5 +261,5 @@
 
     // test1F psErrorMsg with a error code less then PS_ERR_BASE(256)
-    if( psErrorMsg("test1F", 9, true, "Errno code = %d", 9) != 9) {
+    if( psError(9, true, "Errno code = %d", 9) != 9) {
         psLogMsg("test_psError01", PS_LOG_ERROR, "Failed return with errno code.");
         return 6;
@@ -287,13 +280,13 @@
 
     // Test point #1 Multiple type values placed in the error string
-    psError(__func__,
+    psError(PS_ERR_UNKNOWN, true,
             "ALL TYPES intval = %d longval = %ld floatval = %f charval = %c strval = %s",
             intval,longval,floatval,charval,stringval);
 
     // Test point #2 String values in error message
-    psError(PS_STRING(__LINE__),"NO VALUES");
+    psError(PS_ERR_UNKNOWN, true, "NO VALUES");
 
     // Test point #3 Empty strings in error message
-    psError("","");
+    psError(PS_ERR_UNKNOWN, true, "");
 
     return 0;
Index: /trunk/psLib/test/sysUtils/tst_psMemory.c
===================================================================
--- /trunk/psLib/test/sysUtils/tst_psMemory.c	(revision 2272)
+++ /trunk/psLib/test/sysUtils/tst_psMemory.c	(revision 2273)
@@ -6,6 +6,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-27 00:57:33 $
+*  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-11-04 01:05:00 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -99,5 +99,5 @@
     mem = ( psS32* ) psAlloc( size * sizeof( psS32 ) );
     if ( mem == NULL ) {
-        psError( __FILE__, "psAlloc returned a NULL value in %s!", __func__ );
+        psError(PS_ERR_UNKNOWN, true, "psAlloc returned a NULL value in %s!", __func__ );
         return 1;
     }
@@ -130,5 +130,5 @@
     ref = psMemGetRefCounter( mem );
     if ( ref != 1 ) {
-        psError( __func__, "Expected to buffer reference count to be initially 1, but it was %d.", ref );
+        psError(PS_ERR_UNKNOWN, true, "Expected to buffer reference count to be initially 1, but it was %d.", ref );
         return 1;
     }
@@ -140,5 +140,5 @@
     ref = psMemGetRefCounter( mem );
     if ( ref != 4 ) {
-        psError( __func__, "Expected to find buffer reference count to be 4, but it was %d.", ref );
+        psError(PS_ERR_UNKNOWN, true, "Expected to find buffer reference count to be 4, but it was %d.", ref );
         return 1;
     }
@@ -149,5 +149,5 @@
     ref = psMemGetRefCounter( mem );
     if ( ref != 2 ) {
-        psError( __func__, "Expected to find buffer reference count to be 2, but it was %d.", ref );
+        psError(PS_ERR_UNKNOWN, true, "Expected to find buffer reference count to be 2, but it was %d.", ref );
         return 1;
     }
@@ -159,5 +159,5 @@
     ref = psMemGetRefCounter( mem );
     if ( ref != 1 ) {
-        psError( __func__, "Expected to find buffer reference count to be 1, but it was %d.", ref );
+        psError(PS_ERR_UNKNOWN, true, "Expected to find buffer reference count to be 1, but it was %d.", ref );
         return 1;
     }
@@ -197,5 +197,5 @@
 
     if ( exhaustedCallbackCalled == 0 ) {
-        psError( __FILE__, "Called psRealloc with HUGE memory requirement and survived in %s!", __func__ );
+        psError(PS_ERR_UNKNOWN,true, "Called psRealloc with HUGE memory requirement and survived in %s!", __func__ );
         return 1;
     }
@@ -232,5 +232,5 @@
 
     if ( exhaustedCallbackCalled == 0 ) {
-        psError( __FILE__, "Called psAlloc with HUGE memory requirement and survived in %s!", __func__ );
+        psError(PS_ERR_UNKNOWN,true, "Called psAlloc with HUGE memory requirement and survived in %s!", __func__ );
         return 1;
     }
@@ -273,6 +273,6 @@
     for ( psS32 i = 0;i < initialSize;i++ ) {
         if ( mem1[ i ] != i || mem2[ i ] != i || mem3[ i ] != i ) {
-            psError( __FILE__, "Realloc didn't preserve the contents with expanding buffer in %s.",
-                     __func__ );
+            psError(PS_ERR_UNKNOWN,true, "Realloc didn't preserve the contents with expanding buffer in %s.",
+                    __func__ );
             break;
         }
@@ -290,6 +290,6 @@
     for ( psS32 i = 0;i < initialSize / 2;i++ ) {
         if ( mem1[ i ] != i || mem2[ i ] != i || mem3[ i ] != i ) {
-            psError( __FILE__, "Realloc didn't preserve the contents with shrinking buffer in %s.",
-                     __func__ );
+            psError(PS_ERR_UNKNOWN,true, "Realloc didn't preserve the contents with shrinking buffer in %s.",
+                    __func__ );
             break;
         }
@@ -333,6 +333,6 @@
 
     if ( allocCallbackCalled != 2 || freeCallbackCalled != 2 ) {
-        psError( __FILE__, "alloc/free callbacks were not called the proper number of times in %s",
-                 __func__ );
+        psError(PS_ERR_UNKNOWN,true, "alloc/free callbacks were not called the proper number of times in %s",
+                __func__ );
         return 1;
     }
@@ -352,6 +352,6 @@
 
     if ( allocCallbackCalled != 2 ) {
-        psError( __FILE__, "realloc callbacks were not called the proper number of times in %s",
-                 __func__ );
+        psError(PS_ERR_UNKNOWN,true, "realloc callbacks were not called the proper number of times in %s",
+                __func__ );
         return 1;
     }
@@ -388,11 +388,11 @@
 
     if ( nLeaks != 1 ) {
-        psError( __FILE__, "psMemCheckLeaks should have found 1 leak, but found %d in %s.", nLeaks, __func__ );
+        psError(PS_ERR_UNKNOWN,true, "psMemCheckLeaks should have found 1 leak, but found %d in %s.", nLeaks, __func__ );
         return 1;
     }
 
     if ( blks[ 0 ] ->lineno != lineMark ) {
-        psError( __FILE__, "psMemCheckLeaks found a leak other than the expected one (line %d vs %d) in %s.",
-                 lineMark, blks[ 0 ] ->lineno, __func__ );
+        psError(PS_ERR_UNKNOWN,true, "psMemCheckLeaks found a leak other than the expected one (line %d vs %d) in %s.",
+                lineMark, blks[ 0 ] ->lineno, __func__ );
         return 1;
     }
@@ -418,10 +418,10 @@
 
     if ( nLeaks != 1 ) {
-        psError( __FILE__, "psMemCheckLeaks should have found 1 leak, but found %d in %s.", nLeaks, __func__ );
+        psError(PS_ERR_UNKNOWN,true, "psMemCheckLeaks should have found 1 leak, but found %d in %s.", nLeaks, __func__ );
         return 1;
     }
 
     if ( blks[ 0 ] ->lineno != lineMark ) {
-        psError( __FILE__, "psMemCheckLeaks found a leak other than the expected one in %s.", __func__ );
+        psError(PS_ERR_UNKNOWN,true, "psMemCheckLeaks found a leak other than the expected one in %s.", __func__ );
         return 1;
     }
@@ -448,10 +448,10 @@
 
     if ( nLeaks != 2 ) {
-        psError( __FILE__, "psMemCheckLeaks should have found 1 leak, but found %d in %s.", nLeaks, __func__ );
+        psError(PS_ERR_UNKNOWN,true, "psMemCheckLeaks should have found 1 leak, but found %d in %s.", nLeaks, __func__ );
         return 1;
     }
 
     if ( blks[ 0 ] ->lineno != lineMark ) {
-        psError( __FILE__, "psMemCheckLeaks found a leak other than the expected one in %s.", __func__ );
+        psError(PS_ERR_UNKNOWN,true, "psMemCheckLeaks found a leak other than the expected one in %s.", __func__ );
         return 1;
     }
@@ -499,12 +499,12 @@
 
     if ( corruptions != 1 ) {
-        psError( __FILE__, "Expected one memory corruption but found %d in %s.",
-                 corruptions, __func__ );
+        psError(PS_ERR_UNKNOWN,true, "Expected one memory corruption but found %d in %s.",
+                corruptions, __func__ );
         return 1;
     }
 
     if ( problemCallbackCalled != 1 ) {
-        psError( __FILE__, "The memProblemCallback was not invoked but should have been in %s",
-                 __func__ );
+        psError(PS_ERR_UNKNOWN,true, "The memProblemCallback was not invoked but should have been in %s",
+                __func__ );
         return 1;
     }
@@ -556,7 +556,7 @@
 
     if (err->code != PS_ERR_MEMORY_DEREF_USAGE) {
-        psErrorMsg("psLibTest.sysUtils.tst_psMemory",PS_ERR_UNKNOWN,true,
-                   "Multiple psFree calls generated wrong error code (%d)",
-                   err->code);
+        psError(PS_ERR_UNKNOWN,true,
+                "Multiple psFree calls generated wrong error code (%d)",
+                err->code);
         psFree(err);
         return 1;
