Index: trunk/psLib/src/sysUtils/.cvsignore
===================================================================
--- trunk/psLib/src/sysUtils/.cvsignore	(revision 1641)
+++ trunk/psLib/src/sysUtils/.cvsignore	(revision 1683)
@@ -1,1 +1,2 @@
 *.i
+psErrorCodes.h
Index: trunk/psLib/src/sysUtils/Makefile
===================================================================
--- trunk/psLib/src/sysUtils/Makefile	(revision 1641)
+++ trunk/psLib/src/sysUtils/Makefile	(revision 1683)
@@ -3,6 +3,6 @@
 ##  Makefile:   sysUtils
 ##
-##  $Revision: 1.18 $  $Name: not supported by cvs2svn $
-##  $Date: 2004-08-09 20:28:54 $
+##  $Revision: 1.19 $  $Name: not supported by cvs2svn $
+##  $Date: 2004-09-02 22:23:20 $
 ##
 ##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -35,5 +35,6 @@
            psLogMsg.o    \
            psAbort.o     \
-           psString.o    
+           psString.o    \
+           psErrorCodes.o 
 
 OBJS = $(addprefix makedir/,$(SRC_OBJS))
@@ -42,4 +43,10 @@
 
 all: $(TARGET_STATIC)
+
+psErrorCodes.h: psErrorCodes.dat
+	perl parseErrorCodes.pl --data=$? $@
+
+psErrorCodes.c: psErrorCodes.dat
+	perl parseErrorCodes.pl --data=$? $@
 
 # Rule to make static library
Index: trunk/psLib/src/sysUtils/parseErrorCodes.pl
===================================================================
--- trunk/psLib/src/sysUtils/parseErrorCodes.pl	(revision 1683)
+++ trunk/psLib/src/sysUtils/parseErrorCodes.pl	(revision 1683)
@@ -0,0 +1,95 @@
+#!/usr/bin/perl
+
+# Provides functions for handling long command line options
+use Getopt::Long;
+
+my @ErrorCodes        = ();
+my @ErrorDescriptions = ();
+
+my $data = "psErrorCodes.dat";
+
+# Assign variables based on the presence of command line options to the script
+GetOptions(
+    "data=s"  => \$data,
+    "verbose" => \$verbose,
+    "help"    => \$help
+);
+
+if ($help) {
+    print "Usage: parseErrorCodes ", "[--data=$data] ", "[--help] ",
+      "[--verbose] filename [filename ...]\n\n";
+    exit(0);
+}
+
+print "Using data file '$data'\n" if $verbose;
+unless ( open( DATAFILE, "<", $data ) ) {
+    die "Can not open data file $data.";
+}
+
+print "Datafile:\n" if $verbose;
+while (<DATAFILE>) {
+    chop;
+    if (/^\s*\#/) {
+        print "C $_\n" if $verbose;
+    }
+    else {
+        /^\s*(\w+)\s+(\w.*)/;
+        my $ErrorCode        = $1;
+        my $ErrorDescription = $2;
+        print "  $ErrorCode: '$ErrorDescription'\n" if $verbose;
+        push( @ErrorCodes,        $ErrorCode );
+        push( @ErrorDescriptions, $ErrorDescription );
+
+    }
+}
+close(DATAFILE);
+
+my $found = $#ErrorCodes + 1;
+print "\nFound $found error codes.\n" if $verbose;
+
+foreach (@ARGV) {
+    my $filename = $_;
+    my @result   = ();
+
+    die "Failed to open input file"
+      if !open( INFILE, "<", $filename );
+
+    print "\nOutput File:\n" if $verbose;
+    while (<INFILE>) {
+        chop;
+        push( @result, $_ );
+        if (/^\s*\/\/~Start(.*)$/) {
+            $line = $1;
+            for ( $n = 0 ; $n < $found ; $n++ ) {
+                $_ = $line;
+                s/\$ErrorCode/$ErrorCodes[$n]/g;
+                s/\$ErrorDescription/$ErrorDescriptions[$n]/g;
+                s/\$ErrorNumber/$n/g;
+                push( @result, $_ );
+                print "$_\n" if $verbose;
+            }
+
+            $break = 0;
+            while ( ( $break == 0 ) && ( $_ = <INFILE> ) ) {
+                if (/^\s*\/\/~End/) {
+                    $break = 1;
+                }
+            }
+            chop;
+            push( @result, $_ );
+        }
+    }
+
+    close(INFILE);
+
+    die "Failed to overwrite input file"
+      if !open( OUTFILE, ">", $filename );
+
+    foreach (@result) {
+        print OUTFILE "$_\n";
+        print "$_\n" if $verbose;
+    }
+
+    close(OUTFILE);
+
+}
Index: trunk/psLib/src/sysUtils/psError.h
===================================================================
--- trunk/psLib/src/sysUtils/psError.h	(revision 1641)
+++ trunk/psLib/src/sysUtils/psError.h	(revision 1683)
@@ -1,3 +1,2 @@
-
 /** @file  psError.h
  *
@@ -13,6 +12,6 @@
  *  @author Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-10 01:55:34 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-02 22:23:20 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -22,7 +21,26 @@
 #define PS_ERROR_H
 
+#include<stdio.h>
+
+#include "psErrorCodes.h"
+
 /** @addtogroup ErrorHandling
  *  @{
  */
+
+typedef struct
+{
+    char *name;                        ///< category of code that caused the error
+    psErrorCode code;                  ///< class of error
+    char *msg;                         ///< the message associated with the error
+}
+psErr;
+
+const psErr *psErrorGet(int which);
+const psErr *psErrorLast(void);
+void psErrorClear(void);
+
+void psErrorStackPrint(FILE *fd, const char *fmt, ...);
+void psErrorStackPrintV(FILE *fd, const char *fmt, va_list va);
 
 /** Reports an error message to the logging facility
Index: trunk/psLib/src/sysUtils/psErrorCodes.c
===================================================================
--- trunk/psLib/src/sysUtils/psErrorCodes.c	(revision 1683)
+++ trunk/psLib/src/sysUtils/psErrorCodes.c	(revision 1683)
@@ -0,0 +1,87 @@
+/** @file  psErrorCodes.c
+ *
+ *  @brief Contains the error codes for the error classes
+ *
+ *  @ingroup ErrorHandling
+ *
+ *  @author Robert DeSonia, MHPCC
+ *
+ *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-02 22:23:20 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
+
+#include "psErrorCodes.h"
+#include "psList.h"
+#include "psMemory.h"
+
+/* N.B., lines between '//~Start' and '//~End' are automatic generated from
+ * the template following the '//~Start'.  The template is used to generate
+ * the other lines by, for each error class in psErrorCodes.dat, the following
+ * substitutions are made:
+ *     $ErrorCode        The error code name (first word in the psErrorCodes.dat lines)
+ *     $ErrorDescription The error description (rest of the line in psErrorCodes.dat)
+ *     $ErrorNumber      The order of the source line in psErrorCodes.dat (comments excluded)
+ * 
+ * DO NOT EDIT THE LINES BETWEEN //~Start and //~End!  ANY CHANGES WILL BE OVERWRITTEN.
+ */
+
+static psErrorDescription errorDescriptions[] = {
+            {PS_ERR_NONE,"not an error"},
+            {PS_ERR_BASE,"base error"},
+            //~Start    {PS_ERR_$ErrorCode,"$ErrorDescription"},
+            {PS_ERR_UNKNOWN,"unknown error"},
+            {PS_ERR_IO,"I/O error"},
+            {PS_ERR_MEMORY_CORRUPTION,"memory corruption detected"},
+            //~End
+            {PS_ERR_N_ERR_CLASSES,"error classes end marker"}
+        };
+
+static psList* errorCodes = NULL;
+static psErrorDescription* getErrorDescription(psErrorCode code);
+
+
+static 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) {
+        n++;
+    }
+
+    if (errorDescriptions[n].code == code) {
+        return &errorDescriptions[n];
+    } else {
+        psErrorDescription* desc;
+        // make sure there is a list to search
+        if (errorCodes == 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);
+        }
+    }
+    return NULL;
+}
+
+const char *psErrorCodeString(psErrorCode code)
+{
+    psErrorDescription* desc = getErrorDescription(code);
+
+    if (desc == NULL) {
+        return NULL;
+    }
+
+    return desc->description;
+}
+
Index: trunk/psLib/src/sysUtils/psErrorCodes.dat
===================================================================
--- trunk/psLib/src/sysUtils/psErrorCodes.dat	(revision 1683)
+++ trunk/psLib/src/sysUtils/psErrorCodes.dat	(revision 1683)
@@ -0,0 +1,6 @@
+#
+#  This file is used to generate psErrorCode.h content
+#
+UNKNOWN                unknown error
+IO                     I/O error
+MEMORY_CORRUPTION      memory corruption detected
Index: trunk/psLib/src/sysUtils/psErrorCodes.h
===================================================================
--- trunk/psLib/src/sysUtils/psErrorCodes.h	(revision 1683)
+++ trunk/psLib/src/sysUtils/psErrorCodes.h	(revision 1683)
@@ -0,0 +1,72 @@
+/** @file  psErrorCodes.h
+ *
+ *  @brief Contains the error codes for the error classes
+ *
+ *  @ingroup ErrorHandling
+ *
+ *  @author Robert DeSonia, MHPCC
+ *
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-02 22:23:20 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
+
+#ifndef PS_ERROR_CODES_H
+#define PS_ERROR_CODES_H
+
+/* N.B., lines between '//~Start' and '//~End' are automatic generated from
+ * the template following the '//~Start'.  The template is used to generate
+ * the other lines by, for each error class in psErrorCodes.dat, the following
+ * substitutions are made:
+ *     $ErrorCode        The error code name (first word in the psErrorCodes.dat lines)
+ *     $ErrorDescription The error description (rest of the line in psErrorCodes.dat)
+ *     $ErrorNumber      The order of the source line in psErrorCodes.dat (comments excluded)
+ * 
+ * DO NOT EDIT THE LINES BETWEEN //~Start and //~End!  ANY CHANGES WILL BE OVERWRITTEN.
+ */
+
+/** @addtogroup ErrorHandling
+ *  @{
+ */
+
+/** enumeration of the static error code classes
+ */
+typedef enum {
+    PS_ERR_NONE = 0,                   ///< not an error
+    PS_ERR_BASE = 256,
+    /**< base error.  Any psErrorCode less than this should be taken to be
+     *   valid values of errno
+     */
+
+    //~Start     PS_ERR_$ErrorCode, ///< $ErrorDescription
+    PS_ERR_UNKNOWN, ///< unknown error
+    PS_ERR_IO, ///< I/O error
+    PS_ERR_MEMORY_CORRUPTION, ///< memory corruption detected
+    //~End
+    PS_ERR_N_ERR_CLASSES               ///< end marker - should not be used as a true error
+} psErrorCode;
+
+/** An error code with description
+ */
+typedef struct
+{
+    psErrorCode code;                  ///< An error code
+    const char *description;           ///< the associated description
+}
+psErrorDescription;
+
+/** Retrieves the description of an error code.
+ *
+ *  The routine psErrorCodeString returns the string associated with an error 
+ *  code.
+ *
+ *  @return const char*     the description associated with the given code.
+ */
+const char *psErrorCodeString(
+    psErrorCode code                   ///< the associated error code
+);
+
+/// @}
+
+#endif
