Index: /trunk/psLib/src/fits/psFits.c
===================================================================
--- /trunk/psLib/src/fits/psFits.c	(revision 5056)
+++ /trunk/psLib/src/fits/psFits.c	(revision 5057)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-08-30 01:14:13 $
+ *  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-15 21:22:21 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -186,5 +186,5 @@
     int status = 0;
 
-    fits_get_hdrspace(fits->p_fd, &keysexist, &morekeys, &status);
+    fits_get_hdrspace(fits->fd, &keysexist, &morekeys, &status);
 
     // if no keys exist and not primary HDU, this really is an empty HDU
@@ -202,5 +202,5 @@
 
     if (fits != NULL) {
-        (void)fits_close_file(fits->p_fd, &status);
+        (void)fits_close_file(fits->fd, &status);
         psFree(fits->filename);
     }
@@ -247,5 +247,5 @@
     psFits* fits = psAlloc(sizeof(psFits));
     fits->filename = psAlloc(strlen(name)+1);
-    fits->p_fd = fptr;
+    fits->fd = fptr;
     strcpy((char*)fits->filename,name);
     psMemSetDeallocator(fits,(psFreeFunc)fitsFree);
@@ -279,5 +279,5 @@
 
 
-    if (fits_movnam_hdu(fits->p_fd, ANY_HDU, (char*)extname, 0, &status) != 0) {
+    if (fits_movnam_hdu(fits->fd, ANY_HDU, (char*)extname, 0, &status) != 0) {
         char fitsErr[MAX_STRING_LENGTH];
         fits_get_errstatus(status, fitsErr);
@@ -305,5 +305,5 @@
 
     if (relative) {
-        fits_movrel_hdu(fits->p_fd, extnum, &hdutype, &status);
+        fits_movrel_hdu(fits->fd, extnum, &hdutype, &status);
         if (status != 0) {
             char fitsErr[MAX_STRING_LENGTH];
@@ -315,5 +315,5 @@
         }
     } else {
-        fits_movabs_hdu(fits->p_fd, extnum+1, &hdutype, &status);
+        fits_movabs_hdu(fits->fd, extnum+1, &hdutype, &status);
         if (status != 0) {
             char fitsErr[MAX_STRING_LENGTH];
@@ -340,5 +340,5 @@
 
 
-    return fits_get_hdu_num(fits->p_fd,&hdunum) - 1;
+    return fits_get_hdu_num(fits->fd,&hdunum) - 1;
 }
 
@@ -354,7 +354,7 @@
     char name[MAX_STRING_LENGTH];
 
-    if (fits_read_key_str(fits->p_fd, "EXTNAME", name, NULL, &status) != 0) {
+    if (fits_read_key_str(fits->fd, "EXTNAME", name, NULL, &status) != 0) {
         status = 0;
-        if (fits_read_key_str(fits->p_fd, "HDUNAME", name, NULL, &status) != 0) {
+        if (fits_read_key_str(fits->fd, "HDUNAME", name, NULL, &status) != 0) {
             int num = psFitsGetExtNum(fits);
             snprintf(name, MAX_STRING_LENGTH, "EXT-%3d",num);
@@ -380,5 +380,5 @@
     int status = 0;
 
-    if (fits_update_key_str(fits->p_fd, "EXTNAME", (char*)name, NULL, &status) != 0) {
+    if (fits_update_key_str(fits->fd, "EXTNAME", (char*)name, NULL, &status) != 0) {
         char fitsErr[MAX_STRING_LENGTH];
         (void)fits_get_errstatus(status, fitsErr);
@@ -403,5 +403,5 @@
     int status = 0;
 
-    if (fits_get_num_hdus(fits->p_fd, &num, &status) != 0) {
+    if (fits_get_num_hdus(fits->fd, &num, &status) != 0) {
         char fitsErr[MAX_STRING_LENGTH];
         fits_get_errstatus(status, fitsErr);
@@ -426,5 +426,5 @@
     int hdutype = PS_FITS_TYPE_NONE;
 
-    if (fits_get_hdu_type(fits->p_fd, &hdutype, &status) != 0) {
+    if (fits_get_hdu_type(fits->fd, &hdutype, &status) != 0) {
         char fitsErr[MAX_STRING_LENGTH];
         fits_get_errstatus(status, fitsErr);
@@ -466,5 +466,5 @@
     int keyNum = 0;
     int status = 0;
-    fits_get_hdrpos(fits->p_fd, &numKeys, &keyNum, &status);
+    fits_get_hdrpos(fits->fd, &numKeys, &keyNum, &status);
 
     // Get each key name. Keywords start at one.
@@ -478,5 +478,5 @@
     for (int i = 1; i <= numKeys; i++) {
 
-        fits_read_keyn(fits->p_fd, i, keyName, keyValue, keyComment, &status);
+        fits_read_keyn(fits->fd, i, keyName, keyValue, keyComment, &status);
 
         stdKey = false;
@@ -657,5 +657,5 @@
     // check to see if we even are positioned on an image HDU
     int hdutype;
-    if ( fits_get_hdu_type(fits->p_fd,&hdutype, &status) != 0) {
+    if ( fits_get_hdu_type(fits->fd,&hdutype, &status) != 0) {
         char fitsErr[MAX_STRING_LENGTH];
         (void)fits_get_errstatus(status, fitsErr);
@@ -672,5 +672,5 @@
 
     /* Get the data type 'bitPix' from the FITS image */
-    if (fits_get_img_equivtype(fits->p_fd, &bitPix, &status) != 0) {
+    if (fits_get_img_equivtype(fits->fd, &bitPix, &status) != 0) {
         fits_get_errstatus(status, fitsErr);
         psError(PS_ERR_IO, true,
@@ -682,5 +682,5 @@
 
     /* Get the dimensions 'nAxis' from the FITS image */
-    if (fits_get_img_dim(fits->p_fd, &nAxis, &status) != 0) {
+    if (fits_get_img_dim(fits->fd, &nAxis, &status) != 0) {
         (void)fits_get_errstatus(status, fitsErr);
         psError(PS_ERR_IO, true,
@@ -701,5 +701,5 @@
 
     /* Get the Image size from the FITS file */
-    if (fits_get_img_size(fits->p_fd, nAxis, nAxes, &status) != 0) {
+    if (fits_get_img_size(fits->fd, nAxis, nAxes, &status) != 0) {
         (void)fits_get_errstatus(status, fitsErr);
         psError(PS_ERR_IO, true,
@@ -787,5 +787,5 @@
 
     // n.b., this assumes contiguous image buffer
-    if (fits_read_subset(fits->p_fd, fitsDatatype, firstPixel, lastPixel, increment,
+    if (fits_read_subset(fits->fd, fitsDatatype, firstPixel, lastPixel, increment,
                          NULL, output->data.V[0], &anynull, &status) != 0) {
         psFree(output);
@@ -842,10 +842,10 @@
     }
 
-    fits_create_img(fits->p_fd, bitPix, naxis, naxes, &status);
+    fits_create_img(fits->fd, bitPix, naxis, naxes, &status);
 
     if (bZero != 0) {        // set the bscale/bzero
-        fits_write_key_dbl(fits->p_fd, "BZERO", bZero, 12, "Pixel Value Offset", &status);
-        fits_write_key_dbl(fits->p_fd, "BSCALE", 1.0, 12, "Pixel Value Scale", &status);
-        fits_set_bscale(fits->p_fd, 1.0, bZero, &status);
+        fits_write_key_dbl(fits->fd, "BZERO", bZero, 12, "Pixel Value Offset", &status);
+        fits_write_key_dbl(fits->fd, "BSCALE", 1.0, 12, "Pixel Value Scale", &status);
+        fits_set_bscale(fits->fd, 1.0, bZero, &status);
     }
 
@@ -856,5 +856,5 @@
 
     if (input->parent == NULL) { // if no parent, assume that the image data is contiguous
-        fits_write_img(fits->p_fd,
+        fits_write_img(fits->fd,
                        dataType,              // datatype
                        1,                     // writing to the first z-plane
@@ -865,5 +865,5 @@
         int firstPixel = 1;
         for (int row = 0; row < numRows; row++) {
-            fits_write_img(fits->p_fd,
+            fits_write_img(fits->fd,
                            dataType,          // datatype
                            firstPixel,
@@ -909,5 +909,5 @@
     // check to see if we are positioned on an image HDU
     int hdutype;
-    if ( fits_get_hdu_type(fits->p_fd,&hdutype, &status) != 0) {
+    if ( fits_get_hdu_type(fits->fd,&hdutype, &status) != 0) {
         char fitsErr[MAX_STRING_LENGTH];
         (void)fits_get_errstatus(status, fitsErr);
@@ -939,5 +939,5 @@
     long nAxes[3];
     nAxes[2] = 1;
-    fits_get_img_param(fits->p_fd, 3, &fileBitpix, &naxis, nAxes, &status);
+    fits_get_img_param(fits->fd, 3, &fileBitpix, &naxis, nAxes, &status);
 
     //check to see if the HDU has the same datatype
@@ -1012,5 +1012,5 @@
     }
 
-    fits_write_subset(fits->p_fd, dataType, firstPixel, lastPixel, subset->data.V[0], &status);
+    fits_write_subset(fits->fd, dataType, firstPixel, lastPixel, subset->data.V[0], &status);
 
     if ( status != 0) {
@@ -1052,5 +1052,5 @@
         case PS_META_BOOL: {
                 int value = item->data.B;
-                fits_update_key(fits->p_fd,
+                fits_update_key(fits->fd,
                                 TLOGICAL,
                                 item->name,
@@ -1061,5 +1061,5 @@
             }
         case PS_META_S32:
-            fits_update_key(fits->p_fd,
+            fits_update_key(fits->fd,
                             TINT,
                             item->name,
@@ -1069,5 +1069,5 @@
             break;
         case PS_META_F32:
-            fits_update_key(fits->p_fd,
+            fits_update_key(fits->fd,
                             TFLOAT,
                             item->name,
@@ -1077,5 +1077,5 @@
             break;
         case PS_META_F64:
-            fits_update_key(fits->p_fd,
+            fits_update_key(fits->fd,
                             TDOUBLE,
                             item->name,
@@ -1085,5 +1085,5 @@
             break;
         case PS_META_STR:
-            fits_update_key(fits->p_fd,
+            fits_update_key(fits->fd,
                             TSTRING,
                             item->name,
@@ -1124,5 +1124,5 @@
     // check to see if we even are positioned on a table HDU
     int hdutype;
-    fits_get_hdu_type(fits->p_fd,&hdutype, &status);
+    fits_get_hdu_type(fits->fd,&hdutype, &status);
     if ( status != 0) {
         char fitsErr[MAX_STRING_LENGTH];
@@ -1140,6 +1140,6 @@
 
     // get the size of the FITS table
-    fits_get_num_rows(fits->p_fd, &numRows, &status);
-    fits_get_num_cols(fits->p_fd, &numCols, &status);
+    fits_get_num_rows(fits->fd, &numRows, &status);
+    fits_get_num_cols(fits->fd, &numCols, &status);
     if ( status != 0) {
         char fitsErr[MAX_STRING_LENGTH];
@@ -1169,12 +1169,12 @@
         // get the column name
         if (hdutype == BINARY_TBL) {
-            fits_get_bcolparms(fits->p_fd, col, name,
+            fits_get_bcolparms(fits->fd, col, name,
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL, &status);
         } else {
-            fits_get_acolparms(fits->p_fd, col, name,
+            fits_get_acolparms(fits->fd, col, name,
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL, &status);
         }
         // get the column type
-        fits_get_coltype(fits->p_fd, col, &typecode, &repeat, &width, &status);
+        fits_get_coltype(fits->fd, col, &typecode, &repeat, &width, &status);
 
         if (status == 0) {
@@ -1184,5 +1184,5 @@
                 NATIVETYPE value = 0; \
                 int anynul = 0; \
-                fits_read_col(fits->p_fd, FITSTYPE, col,row+1, \
+                fits_read_col(fits->fd, FITSTYPE, col,row+1, \
                               1, 1, NULL, &value, &anynul, &status); \
                 psTrace(".psFits.psFitsReadTableRow",5,"Column #%i, '%s', is type %i, repeat %i, Value = %g\n", \
@@ -1205,5 +1205,5 @@
                     char* value = psAlloc(repeat+1);
                     int anynul = 0;
-                    fits_read_col(fits->p_fd, TSTRING, col,row+1,
+                    fits_read_col(fits->fd, TSTRING, col,row+1,
                                   1, 1, NULL, &value, &anynul, &status);
                     psTrace(".psFits.psFitsReadTableRow",5,"Column #%i, '%s', is type %i, repeat %i, value = %s\n",
@@ -1253,5 +1253,5 @@
     // check to see if we even are positioned on a table HDU
     int hdutype;
-    if ( fits_get_hdu_type(fits->p_fd,&hdutype, &status) != 0) {
+    if ( fits_get_hdu_type(fits->fd,&hdutype, &status) != 0) {
         char fitsErr[MAX_STRING_LENGTH];
         (void)fits_get_errstatus(status, fitsErr);
@@ -1268,5 +1268,5 @@
 
     // find the column by name
-    if ( fits_get_colnum(fits->p_fd, CASESEN, (char*)colname, &colnum, &status) != 0) {
+    if ( fits_get_colnum(fits->fd, CASESEN, (char*)colname, &colnum, &status) != 0) {
         char fitsErr[MAX_STRING_LENGTH];
         (void)fits_get_errstatus(status, fitsErr);
@@ -1279,9 +1279,9 @@
     // get the number of rows
     long numRows = 0;
-    fits_get_num_rows(fits->p_fd, &numRows, &status);
+    fits_get_num_rows(fits->fd, &numRows, &status);
 
     // get the column length.
     int width;
-    if ( fits_get_col_display_width(fits->p_fd, colnum, &width, &status) != 0) {
+    if ( fits_get_col_display_width(fits->fd, colnum, &width, &status) != 0) {
         char fitsErr[MAX_STRING_LENGTH];
         (void)fits_get_errstatus(status, fitsErr);
@@ -1299,5 +1299,5 @@
     result->n = numRows;
 
-    fits_read_col_str(fits->p_fd,
+    fits_read_col_str(fits->fd,
                       colnum,
                       1, // firstrow
@@ -1335,5 +1335,5 @@
     // check to see if we even are positioned on a table HDU
     int hdutype;
-    if ( fits_get_hdu_type(fits->p_fd,&hdutype, &status) != 0) {
+    if ( fits_get_hdu_type(fits->fd,&hdutype, &status) != 0) {
         char fitsErr[MAX_STRING_LENGTH];
         (void)fits_get_errstatus(status, fitsErr);
@@ -1350,5 +1350,5 @@
 
     // find the column by name
-    if ( fits_get_colnum(fits->p_fd, CASESEN, (char*)colname, &colnum, &status) != 0) {
+    if ( fits_get_colnum(fits->fd, CASESEN, (char*)colname, &colnum, &status) != 0) {
         char fitsErr[MAX_STRING_LENGTH];
         (void)fits_get_errstatus(status, fitsErr);
@@ -1361,5 +1361,5 @@
     // get the number of rows
     long numRows = 0;
-    fits_get_num_rows(fits->p_fd,
+    fits_get_num_rows(fits->fd,
                       &numRows,
                       &status);
@@ -1369,5 +1369,5 @@
     long repeat;
     long width;
-    if ( fits_get_eqcoltype(fits->p_fd, colnum, &typecode, &repeat, &width, &status) != 0) {
+    if ( fits_get_eqcoltype(fits->fd, colnum, &typecode, &repeat, &width, &status) != 0) {
         char fitsErr[MAX_STRING_LENGTH];
         (void)fits_get_errstatus(status, fitsErr);
@@ -1380,5 +1380,5 @@
     psVector* result = psVectorAlloc(numRows, convertFitsToPsType(typecode));
 
-    fits_read_col(fits->p_fd,
+    fits_read_col(fits->fd,
                   typecode,
                   colnum,
@@ -1416,5 +1416,5 @@
     // check to see if we even are positioned on a table HDU
     int hdutype;
-    if ( fits_get_hdu_type(fits->p_fd,&hdutype, &status) != 0) {
+    if ( fits_get_hdu_type(fits->fd,&hdutype, &status) != 0) {
         char fitsErr[MAX_STRING_LENGTH];
         (void)fits_get_errstatus(status, fitsErr);
@@ -1432,5 +1432,5 @@
     // get the size of the FITS table
     long numRows = 0;
-    fits_get_num_rows(fits->p_fd, &numRows, &status);
+    fits_get_num_rows(fits->fd, &numRows, &status);
     if ( status != 0) {
         char fitsErr[MAX_STRING_LENGTH];
@@ -1535,5 +1535,5 @@
     }
 
-    fits_create_tbl(fits->p_fd,
+    fits_create_tbl(fits->fd,
                     BINARY_TBL,
                     table->n, // number of rows in table
@@ -1562,5 +1562,5 @@
                                          item->name);
                 }
-                fits_write_col_int(fits->p_fd,
+                fits_write_col_int(fits->fd,
                                    n+1, // column number
                                    1, // firstrow
@@ -1577,5 +1577,5 @@
                                          item->name);
                 }
-                fits_write_col_flt(fits->p_fd,
+                fits_write_col_flt(fits->fd,
                                    n+1, // column number
                                    1, // firstrow
@@ -1592,5 +1592,5 @@
                                          item->name);
                 }
-                fits_write_col_dbl(fits->p_fd,
+                fits_write_col_dbl(fits->fd,
                                    n+1, // column number
                                    1, // firstrow
@@ -1607,5 +1607,5 @@
                                         item->name);
                 }
-                fits_write_col_log(fits->p_fd,
+                fits_write_col_log(fits->fd,
                                    n+1, // column number
                                    1, // firstrow
@@ -1625,5 +1625,5 @@
                 col->data[row] = item->data.V;
             }
-            fits_write_col_str(fits->p_fd,
+            fits_write_col_str(fits->fd,
                                n, // column number
                                1, // firstrow
@@ -1661,5 +1661,5 @@
     // check to see if we even are positioned on a table HDU
     int hdutype;
-    if ( fits_get_hdu_type(fits->p_fd,&hdutype, &status) != 0) {
+    if ( fits_get_hdu_type(fits->fd,&hdutype, &status) != 0) {
         char fitsErr[MAX_STRING_LENGTH];
         (void)fits_get_errstatus(status, fitsErr);
@@ -1684,10 +1684,10 @@
             int colnum = 0;
 
-            if ( fits_get_colnum(fits->p_fd, CASESEN, item->name, &colnum, &status) == 0) {
+            if ( fits_get_colnum(fits->fd, CASESEN, item->name, &colnum, &status) == 0) {
                 // cooresponding column found in table
                 int dataType = 0;
                 convertPsTypeToFits(item->type, NULL, NULL, &dataType);
 
-                if (fits_write_col(fits->p_fd, dataType, colnum, row+1, 1, 1, &item->data,&status) != 0) {
+                if (fits_write_col(fits->fd, dataType, colnum, row+1, 1, 1, &item->data,&status) != 0) {
                     char fitsErr[MAX_STRING_LENGTH];
                     (void)fits_get_errstatus(status, fitsErr);
Index: /trunk/psLib/src/fits/psFits.h
===================================================================
--- /trunk/psLib/src/fits/psFits.h	(revision 5056)
+++ /trunk/psLib/src/fits/psFits.h	(revision 5057)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-08-30 01:14:13 $
+ *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-15 21:22:21 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -48,6 +48,7 @@
 typedef struct
 {
-    fitsfile* p_fd;                    ///< the CFITSIO fits files handle.
+    fitsfile* fd;                      ///< the CFITSIO fits files handle.
     const char* filename;              ///< the filename of the fits file
+    bool writable;                     ///< Is the file writable?
 }
 psFits;
Index: /trunk/psLib/src/imageops/psImageConvolve.c
===================================================================
--- /trunk/psLib/src/imageops/psImageConvolve.c	(revision 5056)
+++ /trunk/psLib/src/imageops/psImageConvolve.c	(revision 5057)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-08-31 02:07:11 $
+ *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-15 21:22:22 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -64,5 +64,5 @@
     result->yMax = yMax;
     result->image = psImageAlloc(numCols,numRows,PS_TYPE_KERNEL);
-    memset(result->image->rawDataBuffer,0,numCols*numRows*PSELEMTYPE_SIZEOF(PS_TYPE_KERNEL));
+    memset((result->image->p_rawDataBuffer),0,numCols*numRows*PSELEMTYPE_SIZEOF(PS_TYPE_KERNEL));
     result->p_kernelRows = psAlloc(sizeof(float*)*numRows);
 
Index: /trunk/psLib/src/imageops/psImageStructManip.c
===================================================================
--- /trunk/psLib/src/imageops/psImageStructManip.c	(revision 5056)
+++ /trunk/psLib/src/imageops/psImageStructManip.c	(revision 5057)
@@ -8,6 +8,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-07-12 19:33:49 $
+ *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-15 21:22:22 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -91,5 +91,5 @@
 
     // increment the raw data buffer before freeing anything in the 'out'
-    psPtr rawData = psMemIncrRefCounter(image->rawDataBuffer);
+    psPtr rawData = psMemIncrRefCounter(image->p_rawDataBuffer);
 
     if (out != NULL) {
@@ -100,5 +100,5 @@
         }
 
-        psFree(out->rawDataBuffer); // free the previous data reference
+        psFree(out->p_rawDataBuffer); // free the previous data reference
     } else {
         out = psAlloc(sizeof(psImage));
@@ -116,5 +116,5 @@
     out->parent = image;
     out->children = NULL;
-    out->rawDataBuffer = rawData;
+    out->p_rawDataBuffer = rawData;
 
     // set the new psImage's deallocator to the same as the input image
@@ -357,5 +357,5 @@
     psU32 rowSize = elementSize*numCols;
     psU32 colOffset = elementSize * col0;
-    psU8* imageData = image->rawDataBuffer;
+    psU8* imageData = image->p_rawDataBuffer;
     for (psS32 row = row0; row < row1; row++) {
         memmove(imageData,image->data.U8[row] + colOffset,rowSize);
@@ -368,7 +368,7 @@
     // XXX: should I really resize the buffers?
     image->data.V = psRealloc(image->data.V,sizeof(psPtr)*numRows);
-    image->rawDataBuffer = psRealloc(image->rawDataBuffer,rowSize*numRows);
-
-    image->data.V[0] = image->rawDataBuffer;
+    image->p_rawDataBuffer = psRealloc(image->p_rawDataBuffer,rowSize*numRows);
+
+    image->data.V[0] = image->p_rawDataBuffer;
     for (psS32 r = 1; r < numRows; r++) {
         image->data.U8[r] = image->data.U8[r-1] + rowSize;
Index: /trunk/psLib/src/mathtypes/psImage.c
===================================================================
--- /trunk/psLib/src/mathtypes/psImage.c	(revision 5056)
+++ /trunk/psLib/src/mathtypes/psImage.c	(revision 5057)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.81 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-09 02:02:54 $
+ *  @version $Revision: 1.82 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-15 21:22:22 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -44,5 +44,5 @@
     psImageFreeChildren(image);
 
-    psFree(image->rawDataBuffer);
+    psFree(image->p_rawDataBuffer);
     psFree(image->data.V);
 }
@@ -71,8 +71,8 @@
     image->data.V = psAlloc(sizeof(psPtr ) * numRows);
 
-    image->rawDataBuffer = psAlloc(area * elementSize);
+    image->p_rawDataBuffer = psAlloc(area * elementSize);
 
     // set the row pointers.
-    image->data.V[0] = image->rawDataBuffer;
+    image->data.V[0] = image->p_rawDataBuffer;
     for (psS32 i = 1; i < numRows; i++) {
         image->data.V[i] = (psPtr )((int8_t *) image->data.V[i - 1] + rowSize);
@@ -293,10 +293,10 @@
     }
     // Resize the image buffer
-    old->rawDataBuffer = psRealloc(old->data.V[0],
-                                   numCols * numRows * elementSize);
+    old->p_rawDataBuffer = psRealloc(old->data.V[0],
+                                     numCols * numRows * elementSize);
     old->data.V = (psPtr *)psRealloc(old->data.V, numRows * sizeof(psPtr ));
 
     // recreate the row pointers
-    old->data.V[0] = old->rawDataBuffer;
+    old->data.V[0] = old->p_rawDataBuffer;
     for (psS32 i = 1; i < numRows; i++) {
         old->data.V[i] = (psPtr )((int8_t *) old->data.V[i - 1] + rowSize);
Index: /trunk/psLib/src/mathtypes/psImage.h
===================================================================
--- /trunk/psLib/src/mathtypes/psImage.h	(revision 5056)
+++ /trunk/psLib/src/mathtypes/psImage.h	(revision 5057)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.67 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-10 00:16:58 $
+ *  @version $Revision: 1.68 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-15 21:22:22 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -59,23 +59,21 @@
 
     union {
+        psS8**  S8;                    ///< Signed 8-bit integer data.
+        psS16** S16;                   ///< Signed 16-bit integer data.
+        psS32** S32;                   ///< Signed 32-bit integer data.
+        psS64** S64;                   ///< Signed 64-bit integer data.
         psU8**  U8;                    ///< Unsigned 8-bit integer data.
         psU16** U16;                   ///< Unsigned 16-bit integer data.
         psU32** U32;                   ///< Unsigned 32-bit integer data.
         psU64** U64;                   ///< Unsigned 64-bit integer data.
-        psS8**  S8;                    ///< Signed 8-bit integer data.
-        psS16** S16;                   ///< Signed 16-bit integer data.
-        psS32** S32;                   ///< Signed 32-bit integer data.
-        psS64** S64;                   ///< Signed 64-bit integer data.
         psF32** F32;                   ///< Single-precision float data.
         psF64** F64;                   ///< Double-precision float data.
         psC32** C32;                   ///< Single-precision complex data.
         psC64** C64;                   ///< Double-precision complex data.
-        //        psPtr** PTR;                   ///< Void pointers.
         psPtr*  V;                     ///< Pointer to data.
     } data;                            ///< Union for data types.
     const struct psImage* parent;      ///< Parent, if a subimage.
+    psPtr p_rawDataBuffer;             ///< Raw data buffer for Allocating/Freeing Images; private
     psArray* children;                 ///< Children of this region.
-
-    psPtr rawDataBuffer;               ///< Raw data buffer for Allocating/Freeing Images
     void *lock;                        ///< Optional lock for thread safety
 }
Index: /trunk/psLib/src/mathtypes/psScalar.h
===================================================================
--- /trunk/psLib/src/mathtypes/psScalar.h	(revision 5056)
+++ /trunk/psLib/src/mathtypes/psScalar.h	(revision 5057)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-08-31 22:00:10 $
+ *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-15 21:22:22 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -35,12 +35,12 @@
 
     union {
+        psS8 S8;                ///< Signed 8-bit integer data.
+        psS16 S16;              ///< Signed 16-bit integer data.
+        psS32 S32;              ///< Signed 32-bit integer data.
+        psS64 S64;              ///< Signed 64-bit integer data.
         psU8 U8;                ///< Unsigned 8-bit integer data.
         psU16 U16;              ///< Unsigned 16-bit integer data.
         psU32 U32;              ///< Unsigned 32-bit integer data.
         psU64 U64;              ///< Unsigned 64-bit integer data.
-        psS8 S8;                ///< Signed 8-bit integer data.
-        psS16 S16;              ///< Signed 16-bit integer data.
-        psS32 S32;              ///< Signed 32-bit integer data.
-        psS64 S64;              ///< Signed 64-bit integer data.
         psF32 F32;              ///< Single-precision float data.
         psF64 F64;              ///< Double-precision float data.
Index: /trunk/psLib/src/mathtypes/psVector.h
===================================================================
--- /trunk/psLib/src/mathtypes/psVector.h	(revision 5056)
+++ /trunk/psLib/src/mathtypes/psVector.h	(revision 5057)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-02 21:32:06 $
+ *  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-15 21:22:22 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -38,12 +38,12 @@
     const long nalloc;                 ///< Total number of elements available.
     union {
+        psS8* S8;                      ///< Signed 8-bit integer data.
+        psS16* S16;                    ///< Signed 16-bit integer data.
+        psS32* S32;                    ///< Signed 32-bit integer data.
+        psS64* S64;                    ///< Signed 64-bit integer data.
         psU8* U8;                      ///< Unsigned 8-bit integer data.
         psU16* U16;                    ///< Unsigned 16-bit integer data.
         psU32* U32;                    ///< Unsigned 32-bit integer data.
         psU64* U64;                    ///< Unsigned 64-bit integer data.
-        psS8* S8;                      ///< Signed 8-bit integer data.
-        psS16* S16;                    ///< Signed 16-bit integer data.
-        psS32* S32;                    ///< Signed 32-bit integer data.
-        psS64* S64;                    ///< Signed 64-bit integer data.
         psF32* F32;                    ///< Single-precision float data.
         psF64* F64;                    ///< Double-precision float data.
Index: /trunk/psLib/src/sys/psLogMsg.h
===================================================================
--- /trunk/psLib/src/sys/psLogMsg.h	(revision 5056)
+++ /trunk/psLib/src/sys/psLogMsg.h	(revision 5057)
@@ -11,6 +11,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-09 01:11:22 $
+ *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-15 21:22:22 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -107,7 +107,7 @@
 ///< Destinations for log messages
 enum {
-    PS_LOG_NONE,                       ///< turn off logging
-    PS_LOG_TO_STDERR,                  ///< log to system's stderr
-    PS_LOG_TO_STDOUT                   ///< log to system's stdout
+    PS_LOG_TO_NONE = 0,                ///< turn off logging
+    PS_LOG_TO_STDERR = 1,              ///< log to system's stderr
+    PS_LOG_TO_STDOUT = 2               ///< log to system's stdout
 };
 
Index: /trunk/psLib/src/sys/psTrace.h
===================================================================
--- /trunk/psLib/src/sys/psTrace.h	(revision 5056)
+++ /trunk/psLib/src/sys/psTrace.h	(revision 5057)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-13 00:54:15 $
+ *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-15 21:22:22 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -25,4 +25,10 @@
  *  \{
  */
+
+enum {
+    PS_TRACE_TO_NONE = 0,             ///< turn off all traces
+    PS_TRACE_TO_STDOUT = 1,           ///< trace to system's stdout
+    PS_TRACE_TO_STDERR = 2,           ///< trace to system's stderr
+};
 
 /** Functions **************************************************************/
@@ -137,5 +143,5 @@
  *  @return FILE*:      File Destination
  */
-int psTraceGetDestination(void);
+int psTraceGetDestination();
 
 /* \} */// End of SystemGroup Functions
Index: /trunk/psLib/src/sys/psType.h
===================================================================
--- /trunk/psLib/src/sys/psType.h	(revision 5056)
+++ /trunk/psLib/src/sys/psType.h	(revision 5057)
@@ -10,6 +10,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-08-31 02:07:11 $
+*  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-09-15 21:22:22 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -105,6 +105,6 @@
     PS_DATA_ARRAY,                     ///< psArray
     PS_DATA_BITSET,                    ///< psBitSet
-    PS_DATA_CELL,                      ///< psCell
-    PS_DATA_CHIP,                      ///< psChip
+    //    PS_DATA_CELL,                      ///< psCell
+    //    PS_DATA_CHIP,                      ///< psChip
     PS_DATA_CUBE,                      ///< psCube
     PS_DATA_FITS,                      ///< psFits
@@ -127,6 +127,6 @@
     PS_DATA_POLYNOMIAL4D,              ///< psPolynomial4D
     PS_DATA_PROJECTION,                ///< psProjection
-    PS_DATA_READOUT,                   ///< psReadout
-    PS_DATA_REGION,                    ///< psRegion
+    //    PS_DATA_READOUT,                   ///< psReadout
+    //    PS_DATA_REGION,                    ///< psRegion
     PS_DATA_SCALAR,                    ///< psScalar
     PS_DATA_SPHERE,                    ///< psSphere
Index: /trunk/psLib/src/types/psBitSet.h
===================================================================
--- /trunk/psLib/src/types/psBitSet.h	(revision 5056)
+++ /trunk/psLib/src/types/psBitSet.h	(revision 5057)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-08-30 01:14:13 $
+ *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-15 21:22:22 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -58,5 +58,4 @@
 ;
 
-
 /** Allocate a psBitSet.
  *
@@ -92,5 +91,4 @@
  */
 psBitSet* psBitSetClear(
-    /* @returned@ */
     psBitSet* bitSet,                  ///< Pointer to psBitSet to be cleared.
     long bit                           ///< Bit to be cleared.
@@ -120,5 +118,4 @@
  */
 psBitSet* psBitSetOp(
-    /* @returned@ */
     psBitSet* outBitSet,                 ///< Resulting psBitSet from binary operation
     const psBitSet* inBitSet1,           ///< First psBitSet on which to operate
Index: /trunk/psLib/src/types/psMetadata.c
===================================================================
--- /trunk/psLib/src/types/psMetadata.c	(revision 5056)
+++ /trunk/psLib/src/types/psMetadata.c	(revision 5057)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.82 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-12 21:36:54 $
+ *  @version $Revision: 1.83 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-15 21:22:22 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -39,4 +39,5 @@
 #include "psConstants.h"
 #include "psLogMsg.h"
+#include "psTrace.h"
 
 /******************************************************************************/
@@ -811,7 +812,7 @@
 
 
-char *psMetadataLookupString(bool *status,
-                             const psMetadata *md,
-                             const char *key)
+char *psMetadataLookupStr(bool *status,
+                          const psMetadata *md,
+                          const char *key)
 {
     psMetadataItem *item = psMetadataLookup((psMetadata*)md, key); // The metadata with instruments
@@ -893,2 +894,377 @@
 
 
+// Set verbosity level
+int psArgumentVerbosity(int *argc, char **argv)
+{
+    int logLevel = 2;   // Default log level
+    int argnum = 0;   // Argument number
+
+    // set in order, so that -vvv overrides -vv overrides -v
+    if ( (argnum = psArgumentGet(*argc, argv, "-v")) ) {
+        psArgumentRemove(argnum, argc, argv);
+        logLevel = 3;
+    }
+    if ( (argnum = psArgumentGet(*argc, argv, "-vv")) ) {
+        psArgumentRemove(argnum, argc, argv);
+        logLevel = 4;
+    }
+    if ( (argnum = psArgumentGet(*argc, argv, "-vvv")) ) {
+        psArgumentRemove(argnum, argc, argv);
+        logLevel = 5;
+    }
+    psLogSetLevel (logLevel);  // XXX: This function should return an error if the log level is invalid
+
+    if ( (argnum = psArgumentGet(*argc, argv, "-logfmt")) ) {
+        if (*argc < argnum + 2) {
+            psError(PS_ERR_IO, true, "-logfmt switch specified without a format.");
+        } else {
+            psArgumentRemove(argnum, argc, argv);
+            psLogSetFormat(argv[argnum]); // XXX EAM : this function should return an error if the log format is invalid
+            psArgumentRemove(argnum, argc, argv);
+        }
+    }
+
+    // Now the trace stuff
+    // argument format is: -trace (facil) (level)
+    while ( (argnum = psArgumentGet(*argc, argv, "-trace")) ) {
+        if ( (*argc < argnum + 3) ) {
+            psError(PS_ERR_IO, true, "-trace switch specified without facility and level.");
+        }
+        psArgumentRemove(argnum, argc, argv);
+        psTraceSetLevel(argv[argnum], atoi(argv[argnum+1])); // XXX: This function should return an error if the trace level is invalid
+        psArgumentRemove(argnum, argc, argv);
+        psArgumentRemove(argnum, argc, argv);
+    }
+    if ((argnum = psArgumentGet(*argc, argv, "-trace-levels"))) {
+        psTracePrintLevels();
+        exit(2);
+    }
+
+    return logLevel;
+}
+
+// Find the location of the specified argument
+int psArgumentGet(int argc, char **argv, const char *arg)
+{
+    for (int i = 1; i < argc; i++) {
+        if (!strcmp(argv[i], arg))
+            return i;
+    }
+
+    return 0;
+}
+
+// Remove the specified argument (by location)
+bool psArgumentRemove(int argnum, int *argc, char **argv)
+{
+    if (argnum > 0) {
+        (*argc)--;
+        for (int i = argnum; i < *argc; i++) {
+            argv[i] = argv[i+1];
+        }
+    } else {
+        return false;
+    }
+
+    return true;
+}
+
+
+static psMetadataItem *argumentRead(psMetadataItem *item, // Item to read into
+                                    int argnum, // Argument number
+                                    int *argc, // Number of arguments in total
+                                    char **argv) // The arguments
+
+{
+    psMetadataItem *newItem = NULL;
+    switch(item->type)
+    {
+        // Only doing a representative set of types
+    case PS_META_S32:
+        newItem = psMetadataItemAlloc(item->name, item->type, item->comment, atoi(argv[argnum]));
+        psArgumentRemove(argnum, argc, argv);
+        break;
+    case PS_META_F32:
+        newItem = psMetadataItemAlloc(item->name, item->type, item->comment, atof(argv[argnum]));
+        psArgumentRemove(argnum, argc, argv);
+        break;
+    case PS_META_BOOL:
+        // Turn option on; no optional argument to remove
+        newItem = psMetadataItemAlloc(item->name, item->type, item->comment, true);
+        break;
+        // XXX: Include the other numerical types
+    case PS_META_STR: {
+            //psString string = psStringCopy(argv[argnum]); // Get the argument into PS memory management
+            //psFree(string);
+            newItem = psMetadataItemAlloc(item->name, item->type, item->comment, argv[argnum]);
+            psArgumentRemove(argnum, argc, argv);
+        }
+        break;
+    default:
+        psError(PS_ERR_IO, true, "Argument type (%x) is not supported --- argument %s ignored\n",
+                item->type, item->name);
+        psFree(newItem);
+        return NULL;
+    }
+
+    return newItem;
+}
+
+
+// XXX: There is a memory leak in the MULTI section.  I think it might have something to do with reference
+// counting between lists and MD, in the second section of the code (copy newArgs into arguments), but I'm not
+// entirely sure.
+bool psArgumentParse(psMetadata *arguments,
+                     int *argc,
+                     char **argv)
+{
+    // We need to do a bit of mucking around in order to preserve the arguments metadata until the last
+    // minute --- if there is a bad argument, we need to return the old "arguments", since they contain
+    // the default values, which we probably want to output in a "help" message (we don't want to print
+    // the changed values and have the user think that they are default values).
+
+    psMetadata *newArgs = psMetadataAlloc(); // Place to read arguments into
+    psList *changed = psListAlloc(NULL);// List of keys that have changed
+
+    for (int i = 1; i < *argc; i++) {
+        psTrace(__func__, 7, "Looking at %s\n", argv[i]);
+        psMetadataItem *argItem = psMetadataLookup(arguments, argv[i]);
+        if (argItem) {
+            psArgumentRemove(i, argc, argv); // Remove the switch
+            if (argItem->type != PS_META_MULTI) {
+                if (argItem->type != PS_META_BOOL && *argc < i + 1) {
+                    psError(PS_ERR_IO, true, "Required argument for %s is missing.\n", argItem->name);
+                    // XXX: Cleanup before returning
+                    psFree(newArgs);
+                    return false;
+                }
+                psMetadataItem *newItem = argumentRead(argItem, i, argc, argv);
+                psMetadataAddItem(newArgs, newItem, PS_LIST_TAIL, PS_META_REPLACE);
+                psFree(newItem);
+            } else {
+                // Go through the MULTI
+                psList *multi = argItem->data.V; // The list of MULTI psMetadataItems
+                if (*argc < i + multi->n) {
+                    psError(PS_ERR_IO, true, "Not enough arguments for %s.\n", argItem->name);
+                    // Remove the arguments --- they will be ignored
+                    for (int j = i; j < *argc; j++) {
+                        psArgumentRemove(i, argc, argv);
+                    }
+                    // XXX: Cleanup before returning
+                    psFree(newArgs);
+                    return false;
+                }
+
+                // Remove any prior existence in the newArgs --- this is important because we specify
+                // adding the new items as DUPLICATE_OK, so if some idiot specifies it twice, we'd end
+                // up with two copies of everything.
+                psMetadataItem *checkItem = psMetadataLookup(newArgs, argItem->name);
+                if (checkItem) {
+                    (void)psMetadataRemove(newArgs, 0, argItem->name);
+                    (void)psListRemoveData(changed, argItem->name);
+                }
+
+                psListIterator *multiIter = psListIteratorAlloc(multi, PS_LIST_HEAD, true);
+                psMetadataItem *nextItem = NULL; // Item from list
+                while ( (nextItem = psListGetAndIncrement(multiIter)) ) {
+                    psMetadataItem *newItem = argumentRead(nextItem, i, argc, argv);
+                    psMetadataAddItem(newArgs, newItem, PS_LIST_TAIL, PS_META_DUPLICATE_OK);
+                    //psFree(newItem);
+                }
+                psFree(multiIter);
+            }
+
+            // Some book-keeping
+            //     psString name = psStringCopy(argItem->name);
+            psListAdd(changed, PS_LIST_TAIL, argItem->name);
+            i--;
+
+        } else if ( (strncmp(argv[i], "-", 1) == 0 ) || (strncmp(argv[i], "+", 1) == 0) ) {
+            // Someone's specified a bad option
+            psError(PS_ERR_IO, true, "Unknown option: %s\n", argv[i]);
+            psFree(newArgs);
+            return false;
+        }
+    }
+
+    // All the arguments are good, so now we can copy the newArgs over
+    psListIterator *changedIter = psListIteratorAlloc(changed, PS_LIST_HEAD, false); // Iterator
+    psString name = NULL;  // Item from iteration
+    while ( (name = psListGetAndIncrement(changedIter)) ) {
+        printf("Updating %s\n", name);
+        psMetadataItem *oldItem = psMetadataLookup(arguments, name);
+        psMetadataItem *newItem = psMetadataLookup(newArgs, name);
+        if ( (oldItem->type != newItem->type) ) {
+            psAbort(__func__, "Shouldn't reach here!\n");
+        }
+        switch (oldItem->type) {
+            // Only doing a representative set of types
+        case PS_META_S32:
+            oldItem->data.S32 = newItem->data.S32;
+            break;
+        case PS_META_F32:
+            oldItem->data.F32 = newItem->data.F32;
+            break;
+        case PS_META_BOOL:
+            oldItem->data.B = newItem->data.B;
+            break;
+            // XXX: Include the other numerical types
+        case PS_META_STR:
+            psFree(oldItem->data.V);
+            oldItem->data.V = psMemIncrRefCounter(newItem->data.V);
+            break;
+        case PS_META_MULTI: {
+                psList *newMulti = psMemIncrRefCounter(newItem->data.V); // The new list of MULTI
+                psList *oldMulti = oldItem->data.V; // The old list of MULTI
+                psListIterator *newMultiIter = psListIteratorAlloc(newMulti, PS_LIST_HEAD, false);
+                psListIterator *oldMultiIter = psListIteratorAlloc(oldMulti, PS_LIST_HEAD, true);
+                psMetadataItem *newMultiItem = NULL; // Item from iterator
+                while ( (newMultiItem = psListGetAndIncrement(newMultiIter)) ) {
+                    psMetadataItem *oldMultiItem = psListGetAndIncrement(oldMultiIter);
+                    if (!oldMultiItem) {
+                        psAbort(__func__,
+                                "Something went very wrong here!  The lists SHOULD be of the same length!\n");
+                    }
+                    switch (oldMultiItem->type) {
+                        // Only doing a representative set of types
+                    case PS_META_S32:
+                        oldItem->data.S32 = newItem->data.S32;
+                        break;
+                    case PS_META_F32:
+                        oldItem->data.F32 = newItem->data.F32;
+                        break;
+                        // XXX: Include the other numerical types
+                    case PS_META_STR:
+                        psFree(oldItem->data.V);
+                        oldItem->data.V = psMemIncrRefCounter(newItem->data.V);
+                        break;
+                    default:
+                        psAbort(__func__, "Should never ever get here, ever.\n");
+                    }
+                    psFree(oldMultiItem);
+                    psFree(newMultiItem);
+                }
+                psFree(newMultiIter);
+                psFree(oldMultiIter);
+            }
+            break;
+        default:
+            psAbort(__func__, "Should never ever ever get here.\n");
+        }
+    }
+    psFree(changedIter);
+    psFree(changed);
+
+    // Now, blow away the newArgs and we're done.
+    psFree(newArgs);
+    return true;
+}
+
+
+static int argLength(psMetadataItem *arg)
+{
+    switch (arg->type) {
+        // Only doing a representative set of types
+    case PS_META_S32:
+        return arg->data.S32 >= 0 ? (int)log10f((float)arg->data.S32) + 1 :
+               (int)log10f(-(float)arg->data.S32) + 2;
+        // XXX: Other numerical types
+    case PS_META_F32:
+        return arg->data.F32 >= 0 ? 12 : 13; // -d.dddddde?dd
+    case PS_META_F64:
+        return arg->data.F64 >= 0 ? 12 : 13; // -d.dddddde?dd
+    case PS_META_BOOL:
+        return arg->data.B ? 4 : 5;
+    case PS_META_STR:
+        return strlen(arg->data.V);
+    default:
+        psAbort(__func__, "Argument type (%x) is not supported.\n", arg->type);
+    }
+
+    return 0;
+}
+
+#define NUM_SPACES 4   // Number of spaces between
+
+void psArgumentHelp(psMetadata *arguments)
+{
+    printf("Optional arguments, with default values:\n");
+    psMetadataIterator *argIter = psMetadataIteratorAlloc(arguments, PS_LIST_HEAD, NULL);
+    psMetadataItem *argItem = NULL; // Item from iterator
+    int maxName = 4;   // Maximum length of a name
+    int maxValue = 4;   // Maximum length of a value
+
+    // First pass to get the sizes
+    while ( (argItem = psMetadataGetAndIncrement(argIter)) ) {
+        if (strlen(argItem->name) > maxName) {
+            maxName = strlen(argItem->name);
+        }
+        int valLength = argLength(argItem);
+        if (valLength > maxValue) {
+            maxValue = valLength;
+        }
+    }
+
+    // Second pass to print
+    psMetadataIteratorSet(argIter, PS_LIST_HEAD);
+    psString lastName = NULL;  // Last name we printed
+    while ( (argItem = psMetadataGetAndIncrement(argIter)) ) {
+        // Initial indent
+        for (int i = 0; i < NUM_SPACES; i++) {
+            printf(" ");
+        }
+
+        // Print the name if required
+        int position = 0; // Number of spaces in
+        if (! lastName || strcmp(lastName, argItem->name) != 0) {
+            // A new name
+            printf("%s", argItem->name);
+            position += strlen(argItem->name);
+            lastName = argItem->name;
+        }
+        for (int i = position; i < maxName + NUM_SPACES; i++) {
+            printf(" ");
+        }
+
+        // Print the value
+        printf("(");
+        switch (argItem->type) {
+            // Only doing a representative set of types
+        case PS_META_S32:
+            printf("%d", argItem->data.S32);
+            break;
+            // XXX: Other numerical types
+        case PS_META_F32:
+            printf("%.6e", argItem->data.F32);
+            break;
+        case PS_META_F64:
+            printf("%.6e", argItem->data.F64);
+            break;
+        case PS_META_BOOL:
+            if (argItem->data.B) {
+                printf("TRUE");
+            } else {
+                printf("FALSE");
+            }
+            break;
+        case PS_META_STR:
+            printf("%s", (char*)(argItem->data.V));
+            break;
+        default:
+            psAbort(__func__, "Argument type (%x) is not supported.\n", argItem->type);
+        }
+        printf(")");
+        for (int i = argLength(argItem); i < maxValue + NUM_SPACES; i++) {
+            printf(" ");
+        }
+
+        // Print the comment
+        if (argItem->comment) {
+            printf("%s", argItem->comment);
+        }
+        printf("\n");
+    }
+
+    psFree(argIter);
+}
+
Index: /trunk/psLib/src/types/psMetadata.h
===================================================================
--- /trunk/psLib/src/types/psMetadata.h	(revision 5056)
+++ /trunk/psLib/src/types/psMetadata.h	(revision 5057)
@@ -11,6 +11,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.63 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-09-12 23:27:48 $
+*  @version $Revision: 1.64 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-09-15 21:22:22 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -122,5 +122,10 @@
     union {
         psBool B;                      ///< boolean data
+        psS8 S8;                       ///< Signed 8-bit integer data.
+        psS16 S16;                     ///< Signed 16-bit integer data.
         psS32 S32;                     ///< Signed 32-bit integer data.
+        psU8 U8;                       ///< Unsigned 8-bit integer data.
+        psU16 U16;                     ///< Unsigned 16-bit integer data.
+        psU32 U32;                     ///< Unsigned 32-bit integer data.
         psF32 F32;                     ///< Single-precision float data.
         psF64 F64;                     ///< Double-precision float data.
@@ -686,5 +691,5 @@
  *  @return char*:           Value of metadata item.
  */
-char *psMetadataLookupString(
+char *psMetadataLookupStr(
     bool *status,                      ///< Status of lookup.
     const psMetadata *md,              ///< Metadata collection to lookup metadata item.
@@ -698,4 +703,57 @@
 );
 
+/** Implements the various verbosity controls.
+ *
+ *  Arguments shall be removed from the argument list as they are processed.
+ *
+ *  @return int:        The resultant logging level.
+ */
+int psArgumentVerbosity(
+    int *argc,                         ///< number or arguments
+    char **argv                        ///< the argument list
+);
+
+/** Checks for an argument and returns its index position if found.
+ *
+ *  @return int:        The index of the element in the argument list, otherwise 0.
+ */
+int psArgumentGet(
+    int argc,                          ///< number or arguments
+    char **argv,                       ///< the argument list
+    const char *arg                    ///< the specified argument to match
+);
+
+/** Removes from the argument list the argument whose index is argnum.
+ *
+ *  The number of entries in the argument list shall be decremented.
+ *
+ *  @return bool:       True if the argnum is in the argument list, otherwise false.
+ */
+bool psArgumentRemove(
+    int argnum,                        ///< the argument to remove
+    int *argc,                         ///< number or arguments
+    char **argv                        ///< the argument list
+);
+
+/** Parses the command line arguments into a metadata container of arguments.
+ *
+ *  The input arguments shall contain the list of possible arguments as the keywords providing
+ *  the default values.  As matching arguments are found on the command line, the values shall be
+ *  read into the arguments metadata, with the appropriate type.  The arguments and their values
+ *  shall be removed from the list of command line arguments as they are processed.
+ *
+ *  @return bool:       False if any argument was encountered that is not present in arguments.
+ */
+bool psArgumentParse(
+    psMetadata *arguments,             ///< metadata container for arguments
+    int *argc,                         ///< number or arguments
+    char **argv                        ///< the argument list
+);
+
+/** Prints to stdout a guide to the command-line arguments.      */
+void psArgumentHelp(
+    psMetadata *arguments              ///< metadata container for arguments
+);
+
 /// @}
 
Index: /trunk/psLib/src/types/psMetadataConfig.c
===================================================================
--- /trunk/psLib/src/types/psMetadataConfig.c	(revision 5056)
+++ /trunk/psLib/src/types/psMetadataConfig.c	(revision 5057)
@@ -10,6 +10,6 @@
 *  @author Eric Van Alst, MHPCC
 *
-*  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-09-13 01:04:39 $
+*  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-09-15 21:22:22 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -1242,9 +1242,9 @@
     while ( (item = psMetadataGetAndIncrement(iter)) ) {
         type = item->type;
-        if ( type == 65537)
+        if ( type == PS_META_STR)
             type = PS_DATA_STRING;
-        if ( type == 65538)
+        if ( type == PS_META_VEC)
             type = PS_DATA_VECTOR;
-        if ( type == 65551)
+        if ( type == PS_META_TIME)
             type = PS_DATA_TIME;
         if ( item->type == PS_META_META)
Index: /trunk/psLib/src/xml/psXML.c
===================================================================
--- /trunk/psLib/src/xml/psXML.c	(revision 5056)
+++ /trunk/psLib/src/xml/psXML.c	(revision 5057)
@@ -10,6 +10,6 @@
 *  @author David Robbins, MHPCC
 *
-*  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-09-12 23:27:48 $
+*  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-09-15 21:22:22 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -68,11 +68,9 @@
     while ( item != NULL ) {
         type = item->type;
-        if ( type == 65537)
+        if ( type == PS_META_STR)
             type = PS_DATA_STRING;
-        if ( type == 65538)
+        if ( type == PS_META_VEC)
             type = PS_DATA_VECTOR;
-        //        if ( type == 65547)
-        //            type = PS_DATA_METADATA;
-        if ( type == 65551)
+        if ( type == PS_META_TIME)
             type = PS_DATA_TIME;
         switch (type) {
Index: /trunk/psLib/test/imageops/tst_psImageGeomManip.c
===================================================================
--- /trunk/psLib/test/imageops/tst_psImageGeomManip.c	(revision 5056)
+++ /trunk/psLib/test/imageops/tst_psImageGeomManip.c	(revision 5057)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-07-15 02:40:20 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-15 21:22:22 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -1055,5 +1055,5 @@
     psErrorClear();
     psImage* invImage = psImageAlloc(cols,rows,PS_TYPE_BOOL);
-    memset(invImage->rawDataBuffer,0,cols*rows*PSELEMTYPE_SIZEOF(PS_TYPE_BOOL)); // make sure the image is of all NULLs
+    memset(invImage->p_rawDataBuffer,0,cols*rows*PSELEMTYPE_SIZEOF(PS_TYPE_BOOL)); // make sure the image is of all NULLs
     result = psImageResample(result,invImage,2,PS_INTERPOLATE_FLAT);
     if (result != NULL) {
Index: /trunk/psLib/test/types/tst_psMetadata_04.c
===================================================================
--- /trunk/psLib/test/types/tst_psMetadata_04.c	(revision 5056)
+++ /trunk/psLib/test/types/tst_psMetadata_04.c	(revision 5057)
@@ -25,6 +25,6 @@
 *  @author  Ross Harman, MHPCC
 *
-*  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2005-08-27 01:33:41 $
+*  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2005-09-15 21:22:22 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -224,5 +224,5 @@
     printPositiveTestHeader(stdout, "psMetadata", "Test K - Lookup metadata item and return psString value");
     char *newSTR;
-    newSTR = psMetadataLookupString(&status, metadata, "myItem8");
+    newSTR = psMetadataLookupStr(&status, metadata, "myItem8");
     if( strncmp(newSTR, string, 50) ) {
         printf("ERROR: Bad string value \n");
