Index: /trunk/pstamp/src/Makefile.am
===================================================================
--- /trunk/pstamp/src/Makefile.am	(revision 16897)
+++ /trunk/pstamp/src/Makefile.am	(revision 16898)
@@ -1,3 +1,3 @@
-bin_PROGRAMS = ppstamp pstamprequest pstampparse pstampfinish
+bin_PROGRAMS = ppstamp pstamprequest pstampparse pstampfinish pstampdump
 
 noinst_HEADERS = \
@@ -9,4 +9,5 @@
 pstampparse_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS)
 pstampfinish_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(IPPDB_CFLAGS)
+pstampdump_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS)
 
 # $(PSASTRO_CFLAGS) $(PPSTATS_CFLAGS) $(ppstamp_CFLAGS)
@@ -16,4 +17,5 @@
 pstampparse_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) 
 pstampfinish_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(IPPDB_LIBS)
+pstampdump_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS)
 
 ppstamp_SOURCES = \
@@ -41,4 +43,7 @@
 	pstampfinish.c
 
+pstampdump_SOURCES = \
+        pstampdump.c
+
 
 clean-local:
Index: /trunk/pstamp/src/pstampdump.c
===================================================================
--- /trunk/pstamp/src/pstampdump.c	(revision 16898)
+++ /trunk/pstamp/src/pstampdump.c	(revision 16898)
@@ -0,0 +1,50 @@
+// pstampdump  - read a fits table describing a postage stamp request or response file and
+//               print the contents to stdout
+//
+//              Actually should work for any kind of fits table, but I'm not sure what will
+//              happen for binary data.
+
+#include <pslib.h>
+#include <psmodules.h>
+#include <string.h>
+
+static psArray *readRequestTable(psString fileName)
+{
+    psFits *fitsFile = psFitsOpen(fileName, "r");
+    if (fitsFile == NULL) {
+        psError(PS_ERR_IO, false, "failed to open %s for output", fileName);
+        return NULL;
+    }
+
+    psArray *array = psFitsReadTable(fitsFile);
+
+    psFitsClose(fitsFile);
+
+    if (array == NULL) {
+        psError(PS_ERR_IO, false, "psFitsReadTable failed for %s", fileName);
+        return NULL;
+    } 
+
+    return array;
+}
+
+int main(int argc, char *argv[])
+{
+    if (argc != 2) {
+        fprintf(stderr, "usage: %s filename\n", argv[0]);
+        return 1;
+    }
+
+    psString fileName = argv[1];
+
+    psArray *array = readRequestTable(fileName);
+    if (array == NULL) {
+        return 1;
+    }
+
+    for (int i=0; i<psArrayLength(array); i++) {
+        psMetadataPrint(stderr, array->data[i], 0);
+    }
+
+    return 0;
+}
Index: /trunk/pstamp/src/pstamprequest.c
===================================================================
--- /trunk/pstamp/src/pstamprequest.c	(revision 16897)
+++ /trunk/pstamp/src/pstamprequest.c	(revision 16898)
@@ -4,119 +4,8 @@
 #include "pstampROI.h"
 
-// pstamprequest  - create a fits table for a request to the postage stamp server
-
-
-/*******
-
-Description of program arguments
-
-
-Request Style
--------------
-One of the following is required to select the target image files
-
-    -byid raw  exp_id class_id
-    -byid chip exp_id chip_id
-    -byid warp warp_id
-    -byid diff diff_id
-    -byid stack stack_id
-
-
-    -byexp  raw | chip | warp | diff | stack     exp_name 
-
-for raw and chip level the chip name must be specified as well (see -chip)
-
-
-    -bycoord
-
-For this style the center of the ROI must be specified in sky coordinates.
-
-
-
-
-ROI
----
-One of the following is required to specify the center of the region of interest.
-(Note these are the same as the arguments ppstamp uses to specify the ROI).
-
-
-    -skycenter ra dec  
-
-ra and dec are in sexagesimal notation or in decimal degrees
-
-    -pixcenter x y
-
--chip name may be required depending on the file class of the target
-(ppstamp determines this)
-
-
-One of the following is required to define the size of the ROI
-
-    -pixrange width height
-
-width and height are in pixels
-
-    -arcrange dRA dDEC
-
-dRA and dDEC in seconds of arc
-
-
-Miscellaneous Arguments
------------------------
-
-    -project "project name"
-
-    -chip "chip name"
-(required for -byid or -byexp when target file type is at chip level or below and the center
-is specified in pixels)
-
-
-    -after date_time
-    -before date_time
-May be used to narrow down the request for -bycoord queries
-
-
-
-*************************************************************************************************
-Table Columns
-
-Name        Type    Values                                  Required                    Notes
--------------------------------------------------------------------------------------------------
-VERSION     String  N.N                                     all                         file format version
-PROJECT     String  any                                     all
-REQ_TYPE    String  byid | byexp | bycoord                  all
-IMG_TYPE    String  raw | chip | warp | diff | stack        byid and byexp
-ID          String  any                                     byid
-CLASS_ID    String  any                                     byid raw byexp raw
-EXPOSURE    String  any                                     byexp
-FILTER      String  any                                     only used when bycoord 
-
-RA          String  sexigesimal or decimal deg              null if pixcenter
-DEC         String  segigesimal or decimal deg              null of pixcenter
-CENTER_X    S32     any                                     null if not pixcenter
-CENTER_Y    S32     any                                     null if not pixcenter
-D_RA        F32     > 0                                     0 if pixrange
-D_DEC       F32     > 0                                     0 if pixrange
-WIDTH       U32     > 0                                     0 if not pixrange
-HEIGHT      U32     > 0                                     0 if not pixrange
-
-IMG_VERSION String
-
-The following need some more thought. Perhaps I need TIME_LIMIT  with values like "latest", "after", "before"
-AFTER       String  YYYYMMDD-HH:MM:SS                       only used when bycoord      UTC 
-BEFORE      String  YYYYMMDD-HH:MM:SS                       only used when bycoord      UTC
-OPTIONS     String  -latest
-
-This may be useful for debugging at least.
-FLAGS       String  -ls                                                                 Don't make stamps
-                                                                                        generate list of
-                                                                                        matching images
-
-*/
+// pstamprequest  - create a fits table containing a postage stamp server request
+
 
 typedef struct {
-#ifdef USE_DBNAME_FOR_PROJECT
-    pmConfig    *config;
-#endif
     psMetadata  *md;
     psString    fileName;
@@ -220,4 +109,6 @@
     bool        gotCenter = false;
     bool        gotRange = false;
+    bool        needROI = true;
+    bool        makeStamps = true;
 
     options->md = md;
@@ -225,20 +116,12 @@
     psMetadataAdd (md, PS_LIST_TAIL, "VERSION", PS_DATA_STRING, "", STAMP_REQUEST_VERSION);
 
-#ifdef USE_DBNAME_FOR_PROJECT
-    options->config = pmConfigRead(&argc, argv, NULL);
-    if (!options->config) {
-        psError(PS_ERR_UNKNOWN, false, "cannot find site file");
-        psFree(options->md);
-        psFree(options);
-        return NULL;
-    }
-
-    bool        status = false;
-    psString project = psMetadataLookupStr(&status, options->config->site, "DBNAME");
-    if (!project) {
-        fprintf(stderr, "DBNAME not specified\n");
-    }
-    psMetadataAdd(md, PS_LIST_TAIL, "PROJECT", PS_DATA_STRING, "", project);
-#else
+    if ((argnum = psArgumentGet(argc, argv, "-list"))) {
+        psMetadataAdd (md, PS_LIST_TAIL, "CMD_MODE", PS_DATA_STRING, "", "LIST_URI");
+        psArgumentRemove(argnum, &argc, argv);
+        // we don't need coordinates if we're listing unless mode is -bycoord. May be set true below.
+        needROI = false;    
+        makeStamps = false;
+    }
+
     // get project from command line
     if ((argnum = psArgumentGet(argc, argv, "-project"))) {
@@ -254,5 +137,4 @@
         usage();
     }
-#endif
 
     // get user tag (base name for the postage stamp files
@@ -265,5 +147,5 @@
         psMetadataAdd(md, PS_LIST_TAIL, "USER_TAG", PS_DATA_STRING, "", argv[argnum]);
         psArgumentRemove(argnum, &argc, argv);
-    } else {
+    } else if (makeStamps) {
         psError(PS_ERR_BAD_PARAMETER_NULL, true, "no user_tag specified");
         usage();
@@ -276,4 +158,5 @@
         psArgumentRemove(argnum, &argc, argv);
         needCoord = true;
+        needROI = true;
         // TODO: we need an IMG_TYPE too...
     }
@@ -306,35 +189,32 @@
     }
 
-    // find roi re-using ppstamp's ROI argument parsing code which value checking
-    // we just pass the strings along as provided by the user
-
     pstampROI roiParam;
 
+    // try and parse the ROI even if we don't "need it" to absorb arguments if they were provided
     if (!pstampGetROI(&roiParam, &argc, argv, &gotCenter, &gotRange)) {
-        usage();
-    }
-
-    if (roiParam.celestialCenter) {
-        psMetadataAdd (options->md, PS_LIST_TAIL, "RA", PS_DATA_STRING, "", roiParam.center[0]);
-        psMetadataAdd (options->md, PS_LIST_TAIL, "DEC", PS_DATA_STRING, "", roiParam.center[1]);
-    } else {
-        if (needCoord) {
-            fprintf(stderr, "need to specify ROI in sky coordinates\n");
+        if (needROI) {
             usage();
         }
-        psMetadataAdd (options->md, PS_LIST_TAIL, "CENTER_X", PS_DATA_STRING, "", roiParam.center[0]);
-        psMetadataAdd (options->md, PS_LIST_TAIL, "CENTER_Y", PS_DATA_STRING, "", roiParam.center[1]);
-    }
-    if (roiParam.celestialRange) {
-        psMetadataAdd (options->md, PS_LIST_TAIL, "D_RA", PS_DATA_STRING, "",  roiParam.range[0]);
-        psMetadataAdd (options->md, PS_LIST_TAIL, "D_DEC", PS_DATA_STRING, "", roiParam.range[1]);
-    } else {
-        psMetadataAdd (options->md, PS_LIST_TAIL, "WIDTH", PS_DATA_STRING, "",  roiParam.range[0]);
-        psMetadataAdd (options->md, PS_LIST_TAIL, "HEIGHT", PS_DATA_STRING, "", roiParam.range[1]);
-    }
-
-    if ((argnum = psArgumentGet(argc, argv, "-list"))) {
-        psMetadataAdd (options->md, PS_LIST_TAIL, "CMD_MODE", PS_DATA_STRING, "", "LIST_URI");
-        psArgumentRemove(argnum, &argc, argv);
+    }
+
+    if (needROI) {
+        if (roiParam.celestialCenter) {
+            psMetadataAdd (md, PS_LIST_TAIL, "RA", PS_DATA_STRING, "", roiParam.center[0]);
+            psMetadataAdd (md, PS_LIST_TAIL, "DEC", PS_DATA_STRING, "", roiParam.center[1]);
+        } else {
+            if (needCoord) {
+                fprintf(stderr, "need to specify ROI in sky coordinates\n");
+                usage();
+            }
+            psMetadataAdd (md, PS_LIST_TAIL, "CENTER_X", PS_DATA_STRING, "", roiParam.center[0]);
+            psMetadataAdd (md, PS_LIST_TAIL, "CENTER_Y", PS_DATA_STRING, "", roiParam.center[1]);
+        }
+        if (roiParam.celestialRange) {
+            psMetadataAdd (md, PS_LIST_TAIL, "D_RA", PS_DATA_STRING, "",  roiParam.range[0]);
+            psMetadataAdd (md, PS_LIST_TAIL, "D_DEC", PS_DATA_STRING, "", roiParam.range[1]);
+        } else {
+            psMetadataAdd (md, PS_LIST_TAIL, "WIDTH", PS_DATA_STRING, "",  roiParam.range[0]);
+            psMetadataAdd (md, PS_LIST_TAIL, "HEIGHT", PS_DATA_STRING, "", roiParam.range[1]);
+        }
     }
 
