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); \
 }
