Index: trunk/psLib/src/sys/psSlurp.c
===================================================================
--- trunk/psLib/src/sys/psSlurp.c	(revision 12072)
+++ trunk/psLib/src/sys/psSlurp.c	(revision 29933)
@@ -27,5 +27,22 @@
 #include "psMemory.h"
 
-#define SLURP_SIZE 4096
+# define SLURP_SIZE 4096
+
+# if (PS_SLURP_GZIP) 
+
+psString psSlurpFD(int fd) {
+
+ gzFile file = gzdopen (fd, "r");
+ if (file == Z_NULL) {
+     psError(PS_ERR_IO, true, "Failed to open file\n");
+     return NULL;
+ }
+ 
+ psString str = psSlurpGZIP(file);
+
+ return str;
+}
+
+# else
 
 psString psSlurpFD(int fd)
@@ -38,5 +55,5 @@
         // increase the allocated string size
         size += SLURP_SIZE;
-        str = psRealloc(str, size);
+        str = psStringRealloc(str, size);
 
         // read a block from the stream
@@ -59,5 +76,38 @@
     return str;
 }
+# endif
 
+# if (PS_SLURP_GZIP)
+psString psSlurpGZIP(gzFile fd)
+{
+    psString str = NULL;                // String to which to write
+    size_t size  = 1;                   // bytes allocated -  make sure there is room for '\0'
+    size_t used = 0;                    // bytes actually used
+    ssize_t bytes;                      // Number of bytes read
+    do {
+        // increase the allocated string size
+        size += SLURP_SIZE;
+        str = psStringRealloc(str, size);
+
+        // read a block from the stream
+        bytes = gzread(fd, str + used, SLURP_SIZE);
+        if (bytes < 0) {
+            // it's an error
+            psError(PS_ERR_IO, true, "slurp failed on read");
+            psFree(str);
+            return NULL;
+        }
+
+        // Increase the size of the known string
+        used += bytes;
+
+    } while (bytes != 0);
+
+    // append '\0' to the end of the string
+    str[used] = '\0';
+
+    return str;
+}
+# endif
 
 psString psSlurpFile(FILE *stream)
@@ -70,4 +120,20 @@
 {
     PS_ASSERT_PTR_NON_NULL(filename, NULL);
+    
+# if (PS_SLURP_GZIP)
+    gzFile fd = gzopen(filename, "r");
+    if (fd == Z_NULL) {
+        psError(PS_ERR_IO, true, "Failed to open specified file, %s\n", filename);
+        return NULL;
+    }
+    psString text = psSlurpGZIP(fd);
+
+    if (gzclose(fd) != Z_OK) {
+        psError(PS_ERR_IO, true, "Failed to close specified file, %s\n", filename);
+        psFree(text);
+        return NULL;
+    }
+
+# else
 
     int fd = open(filename, O_RDONLY);
@@ -76,5 +142,4 @@
         return NULL;
     }
-
     psString text = psSlurpFD(fd);
 
@@ -84,4 +149,5 @@
         return NULL;
     }
+# endif
 
     return text;
