Index: /trunk/psLib/psLib.kdevses
===================================================================
--- /trunk/psLib/psLib.kdevses	(revision 2128)
+++ /trunk/psLib/psLib.kdevses	(revision 2129)
@@ -2,40 +2,10 @@
 <!DOCTYPE KDevPrjSession>
 <KDevPrjSession>
- <DocsAndViews NumberOfDocuments="7" >
-  <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/test/astronomy/tst_psAstrometry01.c" >
-   <View0 line="462" Type="???" >
-    <AdditionalSettings Top="2" Width="1181" Attach="1" Height="732" Left="2" MinMaxMode="0" />
+ <DocsAndViews NumberOfDocuments="1" >
+  <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/src/dataManip/psConstants.h" >
+   <View0 line="109" Type="???" >
+    <AdditionalSettings Top="2" Width="878" Attach="1" Height="750" Left="2" MinMaxMode="0" />
    </View0>
   </Doc0>
-  <Doc1 context="" NumberOfViews="1" URL="man:/printf" >
-   <View0 Type="???" >
-    <AdditionalSettings Top="2" Width="1181" Attach="1" Height="732" Left="2" MinMaxMode="0" />
-   </View0>
-  </Doc1>
-  <Doc2 context="" NumberOfViews="1" URL="man:/usr/share/man/man3/printf.3.gz" >
-   <View0 Type="???" >
-    <AdditionalSettings Top="2" Width="1181" Attach="1" Height="732" Left="2" MinMaxMode="0" />
-   </View0>
-  </Doc2>
-  <Doc3 NumberOfViews="1" URL="file:/home/desonia/psLib/test/astronomy/Makefile" >
-   <View0 line="31" Type="???" >
-    <AdditionalSettings Top="2" Width="1181" Attach="1" Height="732" Left="2" MinMaxMode="0" />
-   </View0>
-  </Doc3>
-  <Doc4 NumberOfViews="1" URL="file:/home/desonia/psLib/src/sysUtils/psTrace.c" >
-   <View0 line="201" Type="???" >
-    <AdditionalSettings Top="2" Width="1181" Attach="1" Height="508" Left="2" MinMaxMode="0" />
-   </View0>
-  </Doc4>
-  <Doc5 NumberOfViews="1" URL="file:/home/desonia/psLib/src/sysUtils/psTrace.h" >
-   <View0 line="19" Type="???" >
-    <AdditionalSettings Top="2" Width="1181" Attach="1" Height="732" Left="2" MinMaxMode="0" />
-   </View0>
-  </Doc5>
-  <Doc6 NumberOfViews="1" URL="file:/home/desonia/psLib/test/astronomy/tst_psTime_01.c" >
-   <View0 line="0" Type="???" >
-    <AdditionalSettings Top="2" Width="1181" Attach="1" Height="508" Left="2" MinMaxMode="0" />
-   </View0>
-  </Doc6>
  </DocsAndViews>
  <pluginList>
Index: /trunk/psLib/src/pslib.h
===================================================================
--- /trunk/psLib/src/pslib.h	(revision 2128)
+++ /trunk/psLib/src/pslib.h	(revision 2129)
@@ -9,6 +9,6 @@
 *  @author Eric Van Alst, MHPCC
 *
-*  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-06 01:21:34 $
+*  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-10-14 21:14:57 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -161,4 +161,5 @@
 #include "psAstrometry.h"
 
+#include "psConstants.h"
 /// @}
 
Index: /trunk/psLib/src/sys/psErrorCodes.c
===================================================================
--- /trunk/psLib/src/sys/psErrorCodes.c	(revision 2128)
+++ /trunk/psLib/src/sys/psErrorCodes.c	(revision 2129)
@@ -7,9 +7,11 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-27 20:38:02 $
+ *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-14 21:14:58 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
+
+#include <string.h>
 
 #include "psError.h"
@@ -75,12 +77,34 @@
         desc = (psErrorDescription*)psListGet(dynamicErrorCodes,PS_LIST_HEAD);
         while (desc != NULL) {
-            desc = (psErrorDescription*)psListGetNext(dynamicErrorCodes);
-            if (desc != NULL && desc->code == code) {
+            if (desc->code == code) {
                 return desc;
             }
+            desc = (psErrorDescription*)psListGetNext(dynamicErrorCodes);
         }
     }
     return NULL;
 }
+
+static void freeErrorDescription(psErrorDescription* err)
+{
+    psFree((void*)err->description);
+}
+
+psErrorDescription* psErrorDescriptionAlloc(psErrorCode code,
+        const char *description)
+{
+    psErrorDescription* err = psAlloc(sizeof(psErrorDescription));
+    err->code = code;
+    if (description == NULL) {
+        err->description = NULL;
+    } else {
+        err->description = psAlloc(sizeof(char)*strlen(description)+1);
+        strcpy((char*)err->description,description);
+    }
+
+    p_psMemSetDeallocator(err,(psFreeFcn)freeErrorDescription);
+    return err;
+}
+
 
 const char *psErrorCodeString(psErrorCode code)
@@ -114,8 +138,17 @@
     }
 
+    if (dynamicErrorCodes == NULL) {
+        dynamicErrorCodes = psListAlloc(NULL);
+        p_psMemSetPersistent(dynamicErrorCodes,true);
+    }
+
     for (int i=0;i<nerror;i++) {
+        psErrorDescription* err = psErrorDescriptionAlloc(
+                                      errors[i].code, errors[i].description);
+        p_psMemSetPersistent(err,true);
+        p_psMemSetPersistent((void*)err->description,true);
         if (! psListAdd(dynamicErrorCodes,
                         PS_LIST_HEAD,
-                        (void*)&errors[i]) ) {
+                        err) ) {
 
             psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister",
@@ -124,5 +157,26 @@
                        i);
         }
+        p_psMemSetPersistent(dynamicErrorCodes->head,true);
+        psFree(err);
     }
 }
 
+bool p_psErrorUnregister(psErrorCode code)
+{
+    // Check input argument is non-negative
+    if ( code < 0 ) {
+        return false;
+    }
+
+    const psErrorDescription* desc = getErrorDescription(code);
+
+    if (desc == NULL) {
+        return false;
+    }
+
+    if (dynamicErrorCodes == NULL) {
+        return false;
+    }
+
+    return psListRemove(dynamicErrorCodes,PS_LIST_UNKNOWN,(void*)desc);
+}
Index: /trunk/psLib/src/sys/psErrorCodes.h
===================================================================
--- /trunk/psLib/src/sys/psErrorCodes.h	(revision 2128)
+++ /trunk/psLib/src/sys/psErrorCodes.h	(revision 2129)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-27 20:38:02 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-14 21:14:58 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -64,4 +64,13 @@
 psErrorDescription;
 
+/** Allocates a new psErrorDescription
+ *
+ *  @return psErrorDescription*        new psErrorDescription struct.
+ */
+psErrorDescription* psErrorDescriptionAlloc(
+    psErrorCode code,                  ///< An error code
+    const char *description            ///< the associated description
+);
+
 /** Retrieves the description of an error code.
  *
@@ -87,4 +96,12 @@
 );
 
+/** Clears error codes registered via psErrorRegister.
+ *
+ *  @return bool    TRUE if given errorcode was removed, otherwise FALSE.
+ */
+bool p_psErrorUnregister(
+    psErrorCode code                   ///< the error code to find and remove
+);
+
 /// @}
 
Index: /trunk/psLib/src/sysUtils/psErrorCodes.c
===================================================================
--- /trunk/psLib/src/sysUtils/psErrorCodes.c	(revision 2128)
+++ /trunk/psLib/src/sysUtils/psErrorCodes.c	(revision 2129)
@@ -7,9 +7,11 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-27 20:38:02 $
+ *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-14 21:14:58 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
+
+#include <string.h>
 
 #include "psError.h"
@@ -75,12 +77,34 @@
         desc = (psErrorDescription*)psListGet(dynamicErrorCodes,PS_LIST_HEAD);
         while (desc != NULL) {
-            desc = (psErrorDescription*)psListGetNext(dynamicErrorCodes);
-            if (desc != NULL && desc->code == code) {
+            if (desc->code == code) {
                 return desc;
             }
+            desc = (psErrorDescription*)psListGetNext(dynamicErrorCodes);
         }
     }
     return NULL;
 }
+
+static void freeErrorDescription(psErrorDescription* err)
+{
+    psFree((void*)err->description);
+}
+
+psErrorDescription* psErrorDescriptionAlloc(psErrorCode code,
+        const char *description)
+{
+    psErrorDescription* err = psAlloc(sizeof(psErrorDescription));
+    err->code = code;
+    if (description == NULL) {
+        err->description = NULL;
+    } else {
+        err->description = psAlloc(sizeof(char)*strlen(description)+1);
+        strcpy((char*)err->description,description);
+    }
+
+    p_psMemSetDeallocator(err,(psFreeFcn)freeErrorDescription);
+    return err;
+}
+
 
 const char *psErrorCodeString(psErrorCode code)
@@ -114,8 +138,17 @@
     }
 
+    if (dynamicErrorCodes == NULL) {
+        dynamicErrorCodes = psListAlloc(NULL);
+        p_psMemSetPersistent(dynamicErrorCodes,true);
+    }
+
     for (int i=0;i<nerror;i++) {
+        psErrorDescription* err = psErrorDescriptionAlloc(
+                                      errors[i].code, errors[i].description);
+        p_psMemSetPersistent(err,true);
+        p_psMemSetPersistent((void*)err->description,true);
         if (! psListAdd(dynamicErrorCodes,
                         PS_LIST_HEAD,
-                        (void*)&errors[i]) ) {
+                        err) ) {
 
             psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister",
@@ -124,5 +157,26 @@
                        i);
         }
+        p_psMemSetPersistent(dynamicErrorCodes->head,true);
+        psFree(err);
     }
 }
 
+bool p_psErrorUnregister(psErrorCode code)
+{
+    // Check input argument is non-negative
+    if ( code < 0 ) {
+        return false;
+    }
+
+    const psErrorDescription* desc = getErrorDescription(code);
+
+    if (desc == NULL) {
+        return false;
+    }
+
+    if (dynamicErrorCodes == NULL) {
+        return false;
+    }
+
+    return psListRemove(dynamicErrorCodes,PS_LIST_UNKNOWN,(void*)desc);
+}
Index: /trunk/psLib/src/sysUtils/psErrorCodes.h
===================================================================
--- /trunk/psLib/src/sysUtils/psErrorCodes.h	(revision 2128)
+++ /trunk/psLib/src/sysUtils/psErrorCodes.h	(revision 2129)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-27 20:38:02 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-14 21:14:58 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -64,4 +64,13 @@
 psErrorDescription;
 
+/** Allocates a new psErrorDescription
+ *
+ *  @return psErrorDescription*        new psErrorDescription struct.
+ */
+psErrorDescription* psErrorDescriptionAlloc(
+    psErrorCode code,                  ///< An error code
+    const char *description            ///< the associated description
+);
+
 /** Retrieves the description of an error code.
  *
@@ -87,4 +96,12 @@
 );
 
+/** Clears error codes registered via psErrorRegister.
+ *
+ *  @return bool    TRUE if given errorcode was removed, otherwise FALSE.
+ */
+bool p_psErrorUnregister(
+    psErrorCode code                   ///< the error code to find and remove
+);
+
 /// @}
 
Index: /trunk/psLib/test/sysUtils/tst_psError.c
===================================================================
--- /trunk/psLib/test/sysUtils/tst_psError.c	(revision 2128)
+++ /trunk/psLib/test/sysUtils/tst_psError.c	(revision 2129)
@@ -13,6 +13,6 @@
  *  @author  Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.12 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2004-09-24 22:48:59 $
+ *  @version $Revision: 1.13 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2004-10-14 21:14:58 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -32,4 +32,5 @@
 static int testError04(void);
 static int testError05(void);
+static int testErrorRegister(void);
 
 // Function used in testError02 to verify the psErrorStackPrintV function
@@ -53,4 +54,5 @@
                               {testError04, 728, "psErrorClear()", 0, false},
                               {testError05, 729, "psErrorCodeString()", 0, false},
+                              {testErrorRegister, 751, "psErrorRegister()", 0, false},
                               {NULL}
                           };
@@ -298,2 +300,101 @@
 }
 
+static int testErrorRegister(void)
+{
+
+    int numErr = 4;
+    psErrorDescription errDesc[] = { {PS_ERR_N_ERR_CLASSES+1,"first"},
+                                     {PS_ERR_N_ERR_CLASSES+2,"second"},
+                                     {PS_ERR_N_ERR_CLASSES+3,"third"},
+                                     {PS_ERR_N_ERR_CLASSES+4,"fourth"} };
+    /*
+        1. invoke psErrorRegister with a n>1 array of psErrorDescriptions. Verify that:
+            a. Each error description given is retrievable with psErrorCodeString.
+    */
+    psErrorRegister(errDesc,numErr);
+
+    for (int i = 0; i < numErr; i++) {
+        const char* desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES+1+i);
+        if (desc == NULL) {
+            psLogMsg(__func__,PS_LOG_ERROR,
+                     "psErrorCode didn't find registered error code.");
+            return 1+i*10;
+        }
+        if (strcmp(desc,errDesc[i].description) != 0) {
+            psLogMsg(__func__,PS_LOG_ERROR,
+                     "psErrorCode didn't return the proper description.  Got '%s', expected '%s'.",
+                     desc,errDesc[i].description);
+            return 2+i*10;
+        }
+    }
+
+    /*
+        2. invoke psErrorCodeString with a static/builtin psLib error code. Verify:
+            a. the result is correct.
+    */
+    const char* desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES);
+    if (desc == NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psErrorCode didn't find static error code.");
+        return 40;
+    }
+    if (strcmp(desc,"error classes end marker") != 0) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psErrorCode didn't return the proper description.  Got '%s', expected '%s'.",
+                 desc,"error classes end marker");
+        return 41;
+    }
+
+    desc = psErrorCodeString(PS_ERR_NONE);
+    if (desc == NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psErrorCode didn't find static error code.");
+        return 42;
+    }
+    if (strcmp(desc,"not an error") != 0) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psErrorCode didn't return the proper description.  Got '%s', expected '%s'.",
+                 desc,"not an error");
+        return 43;
+    }
+
+    /*
+        3. invoke psErrorCodeString with an invalid code. Verify a NULL is returned.
+    */
+    desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES+numErr+1);
+    if (desc != NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psErrorCode didn't return a NULL with a bogus input code.");
+        return 44;
+    }
+
+    /*
+        4. invoke psErrorRegister with a NULL psErrorDescription. Verify that:
+            a. the execution does not cease.
+            b. an appropriate error is generated.
+    */
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
+    psErrorClear();
+    psErrorRegister(NULL,1);
+    psErr* err = psErrorLast();
+    if (err->code != PS_ERR_BAD_PARAMETER_NULL) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psErrorCode didn't generate proper error code for NULL input.");
+        return 45;
+    }
+    psFree(err);
+
+    /*
+        5. invoke psErrorRegister with nerror=0. Verify that no error occurs.
+    */
+    psErrorClear();
+    psErrorRegister(errDesc,0);
+    err = psErrorLast();
+    if (err->code != PS_ERR_NONE) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psErrorCode generated an error for nErrors = 0.");
+        return 46;
+    }
+    psFree(err);
+    return 0;
+}
Index: /trunk/psLib/test/sysUtils/verified/tst_psError.stderr
===================================================================
--- /trunk/psLib/test/sysUtils/verified/tst_psError.stderr	(revision 2128)
+++ /trunk/psLib/test/sysUtils/verified/tst_psError.stderr	(revision 2129)
@@ -102,2 +102,15 @@
 ---> TESTPOINT PASSED (psError{psErrorCodeString()} | tst_psError.c)
 
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psError.c                                              *
+*            TestPoint: psError{psErrorRegister()}                                 *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|I|testErrorRegister
+    Following should be an error.
+<DATE><TIME>|<HOST>|E|psLib.sysUtils.psErrorRegister
+    Specified psErrorDescription pointer can not be NULL.
+
+---> TESTPOINT PASSED (psError{psErrorRegister()} | tst_psError.c)
+
