Index: /trunk/ppConfigDump/.cvsignore
===================================================================
--- /trunk/ppConfigDump/.cvsignore	(revision 12809)
+++ /trunk/ppConfigDump/.cvsignore	(revision 12809)
@@ -0,0 +1,15 @@
+aclocal.m4
+autom4te.cache
+compile
+config.guess
+config.log
+config.status
+config.sub
+configure
+depcomp
+install-sh
+ltmain.sh
+Makefile
+Makefile.in
+missing
+libtool
Index: /trunk/ppConfigDump/Makefile.am
===================================================================
--- /trunk/ppConfigDump/Makefile.am	(revision 12809)
+++ /trunk/ppConfigDump/Makefile.am	(revision 12809)
@@ -0,0 +1,3 @@
+SUBDIRS = src
+
+CLEANFILES = *~ core core.*
Index: /trunk/ppConfigDump/autogen.sh
===================================================================
--- /trunk/ppConfigDump/autogen.sh	(revision 12809)
+++ /trunk/ppConfigDump/autogen.sh	(revision 12809)
@@ -0,0 +1,103 @@
+#!/bin/sh
+# Run this to generate all the initial makefiles, etc.
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+cd $srcdir
+
+PROJECT=ppConfigDump
+TEST_TYPE=-f
+# change this to be a unique filename in the top level dir
+FILE=autogen.sh
+
+DIE=0
+
+LIBTOOLIZE=libtoolize
+ACLOCAL="aclocal $ACLOCAL_FLAGS"
+AUTOHEADER=autoheader
+AUTOMAKE=automake
+AUTOCONF=autoconf
+
+($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || {
+        echo
+        echo "You must have $LIBTOOlIZE installed to compile $PROJECT."
+        echo "Download the appropriate package for your distribution,"
+        echo "or get the source tarball at http://ftp.gnu.org/gnu/libtool/"
+        DIE=1
+}
+
+($ACLOCAL --version) < /dev/null > /dev/null 2>&1 || {
+        echo
+        echo "You must have $ACLOCAL installed to compile $PROJECT."
+        echo "Download the appropriate package for your distribution,"
+        echo "or get the source tarball at http://ftp.gnu.org/gnu/automake/"
+        DIE=1
+}
+
+($AUTOHEADER --version) < /dev/null > /dev/null 2>&1 || {
+        echo
+        echo "You must have $AUTOHEADER installed to compile $PROJECT."
+        echo "Download the appropriate package for your distribution,"
+        echo "or get the source tarball at http://ftp.gnu.org/gnu/autoconf/"
+        DIE=1
+}
+
+($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || {
+        echo
+        echo "You must have $AUTOMAKE installed to compile $PROJECT."
+        echo "Download the appropriate package for your distribution,"
+        echo "or get the source tarball at http://ftp.gnu.org/gnu/automake/"
+        DIE=1
+}
+
+($AUTOCONF --version) < /dev/null > /dev/null 2>&1 || {
+        echo
+        echo "You must have $AUTOCONF installed to compile $PROJECT."
+        echo "Download the appropriate package for your distribution,"
+        echo "or get the source tarball at http://ftp.gnu.org/gnu/autoconf/"
+        DIE=1
+}
+
+if test "$DIE" -eq 1; then
+        exit 1
+fi
+
+test $TEST_TYPE $FILE || {
+        echo "You must run this script in the top-level $PROJECT directory"
+        exit 1
+}
+
+if test -z "$*"; then
+        echo "I am going to run ./configure with no arguments - if you wish "
+        echo "to pass any to it, please specify them on the $0 command line."
+fi
+
+$LIBTOOLIZE --copy --force || echo "$LIBTOOlIZE failed"
+$ACLOCAL || echo "$ACLOCAL failed"
+$AUTOHEADER || echo "$AUTOHEADER failed"
+$AUTOMAKE --add-missing --force-missing --copy || echo "$AUTOMAKE failed"
+$AUTOCONF || echo "$AUTOCONF failed"
+
+cd $ORIGDIR
+
+run_configure=true
+for arg in $*; do
+    case $arg in
+        --no-configure)
+            run_configure=false
+            ;;
+        *)
+            ;;
+    esac
+done
+
+if $run_configure; then
+    $srcdir/configure --enable-maintainer-mode "$@"
+    echo
+    echo "Now type 'make' to compile $PROJECT."
+else
+    echo
+    echo "Now run 'configure' and 'make' to compile $PROJECT."
+fi
Index: /trunk/ppConfigDump/configure.ac
===================================================================
--- /trunk/ppConfigDump/configure.ac	(revision 12809)
+++ /trunk/ppConfigDump/configure.ac	(revision 12809)
@@ -0,0 +1,29 @@
+AC_PREREQ(2.59)
+
+AC_INIT([ppConfigDump], [1.1.0], [ipp-support@ifa.hawaii.edu])
+AC_CONFIG_SRCDIR([src])
+
+AM_INIT_AUTOMAKE([1.6 foreign dist-bzip2])
+AM_CONFIG_HEADER([src/config.h])
+AM_MAINTAINER_MODE
+
+IPP_STDCFLAGS
+
+AC_LANG(C)
+AC_GNU_SOURCE
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_LIBTOOL
+AC_SYS_LARGEFILE
+
+PKG_CHECK_MODULES([PSLIB], [pslib >= 1.0.0])
+PKG_CHECK_MODULES([PSMODULE], [psmodules >= 1.0.0])
+
+IPP_STDOPTS
+CFLAGS="${CFLAGS=} -Wall -Werror -std=c99"
+
+AC_CONFIG_FILES([
+  Makefile
+  src/Makefile
+])
+AC_OUTPUT
Index: /trunk/ppConfigDump/src/.cvsignore
===================================================================
--- /trunk/ppConfigDump/src/.cvsignore	(revision 12809)
+++ /trunk/ppConfigDump/src/.cvsignore	(revision 12809)
@@ -0,0 +1,8 @@
+.libs
+config.h
+config.h.in
+Makefile
+Makefile.in
+ppConfigDump
+stamp-h1
+.deps
Index: /trunk/ppConfigDump/src/Makefile.am
===================================================================
--- /trunk/ppConfigDump/src/Makefile.am	(revision 12809)
+++ /trunk/ppConfigDump/src/Makefile.am	(revision 12809)
@@ -0,0 +1,13 @@
+bin_PROGRAMS = ppConfigDump
+
+ppConfigDump_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(ppConfigDump_CFLAGS)
+ppConfigDump_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS)
+ppConfigDump_SOURCES = ppConfigDump.c
+
+CLEANFILES = *~
+
+clean-local:
+	-rm -f TAGS
+# Tags for emacs
+tags:
+	etags `find . -name \*.[ch] -print`
Index: /trunk/ppConfigDump/src/ppConfigDump.c
===================================================================
--- /trunk/ppConfigDump/src/ppConfigDump.c	(revision 12809)
+++ /trunk/ppConfigDump/src/ppConfigDump.c	(revision 12809)
@@ -0,0 +1,112 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <pslib.h>
+#include <psmodules.h>
+
+pmConfig *config = NULL;                // Configuration; declared globally for convenience
+psMetadata *arguments = NULL;           // Command-line arguments; declared globally for convenience
+
+// Clean up and die
+void die(int code                       // Exit code
+         )
+{
+    psFree(arguments);
+    psFree(config);
+    pmConceptsDone();
+    pmConfigDone();
+    psLibFinalize();
+
+    exit(code);
+}
+
+
+int main(int argc, char *argv[])
+{
+    psLibInit(NULL);
+    psTraceSetLevel("err", 10);
+
+    // load the site-wide configuration information
+    config = pmConfigRead(&argc, argv, NULL);
+    if (!config) {
+        psErrorStackPrint(stderr, "Can't find site configuration!\n");
+        die(PS_EXIT_CONFIG_ERROR);
+    }
+
+    //    psMetadata *options = pmConfigRecipeOptions(config, RECIPE_NAME);
+
+    arguments = psMetadataAlloc();
+    psMetadataAddStr(arguments, PS_LIST_TAIL, "-file", 0,
+                     "FITS file to use for camera determination", NULL);
+    psMetadataAddStr(arguments, PS_LIST_TAIL, "-dump-site", 0,
+                     "Filename to dump site configuration", NULL);
+    psMetadataAddStr(arguments, PS_LIST_TAIL, "-dump-camera", 0,
+                     "Filename to dump camera configuration", NULL);
+    psMetadataAddStr(arguments, PS_LIST_TAIL, "-dump-format", 0,
+                     "Filename to dump camera format", NULL);
+    psMetadataAddStr(arguments, PS_LIST_TAIL, "-dump-recipes", 0,
+                     "Filename to dump recipes", NULL);
+
+    if (argc == 1 || !psArgumentParse(arguments, &argc, argv)) {
+        fprintf(stderr, "\nPan-STARRS IPP configuration dumper\n\n");
+        fprintf(stderr, "Usage: %s [-file INPUT.fits] [-dump-site FILE.mdc]\n", argv[0]);
+        fprintf(stderr, "       [-dump-camera FILE.mdc] [-dump-format FILE.mdc] [-dump-recipe FILE.mdc]\n");
+        fprintf(stderr, "\n");
+        psArgumentHelp(arguments);
+        die(PS_EXIT_CONFIG_ERROR);
+    }
+
+    const char *inName = psMetadataLookupStr(NULL, arguments, "-file"); // Name of input FITS file
+    if (inName) {
+        psFits *inFile = psFitsOpen(inName, "r"); // File handle for FITS file
+        if (!inFile) {
+            psErrorStackPrint(stderr, "Can't open input image: %s\n", inName);
+            die(PS_EXIT_DATA_ERROR);
+        }
+
+        psMetadata *phu = psFitsReadHeader(NULL, inFile); // FITS primary header
+        psFitsClose(inFile);
+        if (!phu) {
+            psErrorStackPrint(stderr, "Can't read PHU of input image: %s\n", inName);
+            die(PS_EXIT_DATA_ERROR);
+        }
+
+        psMetadata *format = pmConfigCameraFormatFromHeader(config, phu, true); // Camera format
+        if (!format || !config->camera) {
+            psErrorStackPrint(stderr, "Can't find suitable camera configuration!\n");
+            psFree(format);
+            psFree(phu);
+            die(PS_EXIT_SYS_ERROR);
+        }
+        psFree(format);
+        psFree(phu);
+    }
+
+    const char *siteName = psMetadataLookupStr(NULL, arguments, "-dump-site"); // Site filename
+    if (siteName && !psMetadataConfigWrite(config->site, siteName)) {
+        psErrorStackPrint(stderr, "Can't write site configuration to %s\n", siteName);
+        die(PS_EXIT_SYS_ERROR);
+    }
+
+    const char *camName = psMetadataLookupStr(NULL, arguments, "-dump-camera"); // Camera filename
+    if (camName && !psMetadataConfigWrite(config->camera, camName)) {
+        psErrorStackPrint(stderr, "Can't write camera configuration to %s\n", camName);
+        die(PS_EXIT_SYS_ERROR);
+    }
+
+    const char *formatName = psMetadataLookupStr(NULL, arguments, "-dump-format"); // Format filename
+    if (formatName && !psMetadataConfigWrite(config->format, formatName)) {
+        psErrorStackPrint(stderr, "Can't write camera format to %s\n", formatName);
+        die(PS_EXIT_SYS_ERROR);
+    }
+
+    const char *recipeName = psMetadataLookupStr(NULL, arguments, "-dump-recipes"); // Recipe filename
+    if (recipeName && !psMetadataConfigWrite(config->recipes, recipeName)) {
+        psErrorStackPrint(stderr, "Can't write recipes to %s\n", recipeName);
+        die(PS_EXIT_SYS_ERROR);
+    }
+
+    die(PS_EXIT_SUCCESS);
+}
