Index: trunk/psLib/src/sys/psErrorCodes.c
===================================================================
--- trunk/psLib/src/sys/psErrorCodes.c	(revision 1873)
+++ trunk/psLib/src/sys/psErrorCodes.c	(revision 1905)
@@ -7,13 +7,16 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-24 01:09:18 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-27 20:38:02 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
 
+#include "psError.h"
 #include "psErrorCodes.h"
 #include "psList.h"
 #include "psMemory.h"
+
+#include "psSysUtilsErrors.h"
 
 /* N.B., lines between '//~Start' and '//~End' are automatic generated from
@@ -28,5 +31,5 @@
  */
 
-static psErrorDescription errorDescriptions[] = {
+static psErrorDescription staticErrorCodes[] = {
             {PS_ERR_NONE,"not an error"},
             {PS_ERR_BASE,"base error"},
@@ -46,35 +49,34 @@
         };
 
-static psList* errorCodes = NULL;
-static psErrorDescription* getErrorDescription(psErrorCode code);
+static psList* dynamicErrorCodes = NULL;
+static const psErrorDescription* getErrorDescription(psErrorCode code);
 
 
-static psErrorDescription* getErrorDescription(psErrorCode code)
+static const psErrorDescription* getErrorDescription(psErrorCode code)
 {
     // first, search the static error codes
 
     int n = 0;
-    while(errorDescriptions[n].code != PS_ERR_N_ERR_CLASSES &&
-            errorDescriptions[n].code != code) {
+    while(staticErrorCodes[n].code != PS_ERR_N_ERR_CLASSES &&
+            staticErrorCodes[n].code != code) {
         n++;
     }
 
-    if (errorDescriptions[n].code == code) {
-        return &errorDescriptions[n];
+    if (staticErrorCodes[n].code == code) {
+        return &staticErrorCodes[n];
     } else {
         psErrorDescription* desc;
         // make sure there is a list to search
-        if (errorCodes == NULL) {
+        if (dynamicErrorCodes == NULL) {
             return NULL;
         }
 
         // search dynamic list of error descriptions before giving up.
-        desc = (psErrorDescription*)psListGet(errorCodes,PS_LIST_HEAD);
-        while (desc != NULL && desc->code != code) {
-            desc = (psErrorDescription*)psListGetNext(errorCodes);
-        }
-
-        if (desc != NULL && desc->code == code) {
-            return psMemIncrRefCounter(desc);
+        desc = (psErrorDescription*)psListGet(dynamicErrorCodes,PS_LIST_HEAD);
+        while (desc != NULL) {
+            desc = (psErrorDescription*)psListGetNext(dynamicErrorCodes);
+            if (desc != NULL && desc->code == code) {
+                return desc;
+            }
         }
     }
@@ -89,5 +91,5 @@
     }
 
-    psErrorDescription* desc = getErrorDescription(code);
+    const psErrorDescription* desc = getErrorDescription(code);
 
     if (desc == NULL) {
@@ -98,2 +100,29 @@
 }
 
+void psErrorRegister(const psErrorDescription* errors,
+                     int nerror)
+{
+    if (nerror < 1) {
+        return;
+    }
+
+    if (errors == NULL) {
+        psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister",
+                   PS_ERR_BAD_PARAMETER_NULL, true,
+                   PS_ERRORTEXT_psErrorCode_NULL_ERRORDESCRIPTION);
+        return;
+    }
+
+    for (int i=0;i<nerror;i++) {
+        if (! psListAdd(dynamicErrorCodes,
+                        PS_LIST_HEAD,
+                        (void*)&errors[i]) ) {
+
+            psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister",
+                       PS_ERR_UNKNOWN, false,
+                       PS_ERRORTEXT_psErrorCode_ERRORCODE_REGISTER_FAILED,
+                       i);
+        }
+    }
+}
+
