Index: trunk/psLib/src/types/psMetadataConfig.c
===================================================================
--- trunk/psLib/src/types/psMetadataConfig.c	(revision 29933)
+++ trunk/psLib/src/types/psMetadataConfig.c	(revision 29934)
@@ -1630,36 +1630,66 @@
 }
 
-
-bool psMetadataConfigWrite(psMetadata *md,
-                           const char *filename)
-{
-    PS_ASSERT_METADATA_NON_NULL(md, NULL);
-    PS_ASSERT_STRING_NON_EMPTY(filename, NULL);
-    FILE *file;
-    if ( !(file = fopen(filename, "w")) ) {
-        psError(PS_ERR_IO, true,
-                "Failed to open specified file, %s\n", filename);
-        return false;
-    }
-    psString fileString = NULL;
-    fileString = psMetadataConfigFormat(md);
-    if (fileString == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, false,
-                "psMetadataConfigFormat returned NULL.\n");
-        return false;
-    }
-    if (fprintf(file, "%s", fileString) != strlen(fileString)) {
-        psError(PS_ERR_IO, true, "Failed to write contents of configuration file %s", filename);
-        psFree(fileString);
-        fclose(file);
-        return false;
+bool psMetadataConfigWrite(psMetadata *md, const char *filename, const char *compress)
+{
+  PS_ASSERT_METADATA_NON_NULL(md, NULL);
+  PS_ASSERT_STRING_NON_EMPTY(filename, NULL);
+
+  psString fileString = NULL;
+  fileString = psMetadataConfigFormat(md);
+  if (fileString == NULL) {
+    psError(PS_ERR_BAD_PARAMETER_NULL, false, "psMetadataConfigFormat returned NULL.\n");
+    return false;
+  }
+
+  if (compress) {
+    if (strlen(compress) > 2) {
+      psError(PS_ERR_BAD_PARAMETER_VALUE, true, "invalid compression options %s", compress);
+      psFree(fileString);
+      return false;
+    }
+    char modeString[4];
+    snprintf (modeString, 4, "w%s", compress);
+
+    gzFile file = gzopen(filename, modeString);
+    if (file == Z_NULL) {
+      psError(PS_ERR_IO, true, "Failed to open specified file, %s\n", filename);
+      psFree(fileString);
+      return false;
+    }
+
+    int nbytes = gzwrite (file, fileString, strlen(fileString));
+    if (nbytes != strlen(fileString)) {
+      psError(PS_ERR_IO, true, "Failed to write contents of configuration file %s", filename);
+      psFree(fileString);
+      gzclose(file);
+      return false;
+    }
+    psFree(fileString);
+    if (gzclose(file) != Z_OK) {
+      psError(PS_ERR_IO, true, "Failed to close file, %s\n", filename);
+      return false;
+    }
+  } else {
+    FILE *file = fopen(filename, "w");
+    if (file == NULL) {
+      psError(PS_ERR_IO, true, "Failed to open specified file, %s\n", filename);
+      psFree(fileString);
+      return false;
+    }
+
+    int nbytes = fwrite(fileString, 1, strlen(fileString), file);
+    if (nbytes != strlen(fileString)) {
+      psError(PS_ERR_IO, true, "Failed to write contents of configuration file %s", filename);
+      psFree(fileString);
+      fclose(file);
+      return false;
     }
     psFree(fileString);
     if (fclose(file) == EOF) {
-        psError(PS_ERR_IO, true,
-                "Failed to close file, %s\n", filename);
-        return false;
-    }
-    return true;
+      psError(PS_ERR_IO, true, "Failed to close file, %s\n", filename);
+      return false;
+    }
+  }
+  return true;
 }
 
Index: trunk/psLib/src/types/psMetadataConfig.h
===================================================================
--- trunk/psLib/src/types/psMetadataConfig.h	(revision 29933)
+++ trunk/psLib/src/types/psMetadataConfig.h	(revision 29934)
@@ -33,4 +33,5 @@
  *  a string, the formatting command must also be for a string. If the
  *  metadata type is any other data type, printing is not allowed.
+ *  Currently, this function does not compress the output file
  *
  * @return psMetadataItem* :    Pointer metadata item.
@@ -85,9 +86,11 @@
 bool psMetadataConfigWrite(
     psMetadata *md,                    ///< The metadata to convert
-    const char *filename               ///< Name of file to write
+    const char *filename,	       ///< Name of file to write
+    const char *compress	       ///< Output compression options 
 );
 
 /** Converts a psMetadata structure (including any nested psMetadata) into a
  *  configuration file formatted string that is written a file stream.
+ *  Currently, this function does not compress the output file
  *
  *  @return bool:       True if successful, otherwise false.
