Index: /trunk/psLib/src/sys/Makefile.am
===================================================================
--- /trunk/psLib/src/sys/Makefile.am	(revision 8993)
+++ /trunk/psLib/src/sys/Makefile.am	(revision 8994)
@@ -12,4 +12,5 @@
 	psLogMsg.c     \
 	psMemory.c     \
+	psSlurp.c      \
 	psString.c     \
 	psTrace.c
@@ -36,4 +37,5 @@
 	psLogMsg.h     \
 	psMemory.h     \
+	psSlurp.h      \
 	psString.h     \
 	psTrace.h      \
Index: /trunk/psLib/src/sys/psSlurp.c
===================================================================
--- /trunk/psLib/src/sys/psSlurp.c	(revision 8994)
+++ /trunk/psLib/src/sys/psSlurp.c	(revision 8994)
@@ -0,0 +1,64 @@
+/** @file  psSlurp.c
+ *
+ *  @brief Contains functions for slurping files
+ *
+ *  @author Joshua Hoblitt, University of Hawaii
+ *
+ *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-27 00:43:31 $
+ *
+ *  Copyright 2006 University of Hawaii
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+
+#include "psError.h"
+#include "psSlurp.h"
+#include "psMemory.h"
+
+# define SLURP_SIZE 1024
+
+psString psSlurp(int fd)
+{
+    FILE *stream = fdopen(fd, "r");
+
+    return psSlurpFile(stream);
+}
+
+psString psSlurpFile(FILE *stream)
+{
+    psString str    = NULL;
+    size_t strSize  = 1; // bytes allocated -  make sure there is room for '\0'
+    size_t used     = 0; // bytes actually used
+
+    for (;;) {
+        // increase the allocated string size
+        strSize += SLURP_SIZE;
+        str = psRealloc(str, strSize);
+
+        // read a block from the stream
+        size_t bytes = fread(str + used, 1, SLURP_SIZE, stream);
+        used += bytes;
+
+        // is this the end of the file or an error?
+        if (bytes != SLURP_SIZE) {
+            if (feof(stream)) {
+                // eof
+                break;
+            }
+            // else - it's an error
+            psError(PS_ERR_UNKNOWN, true, "slurp failed");
+            psFree(str);
+            return NULL;
+        }
+    }
+
+    // append '\0' to the end of the string
+    str[used + 1] = '\0';
+
+    return str;
+}
Index: /trunk/psLib/src/sys/psSlurp.h
===================================================================
--- /trunk/psLib/src/sys/psSlurp.h	(revision 8994)
+++ /trunk/psLib/src/sys/psSlurp.h	(revision 8994)
@@ -0,0 +1,5 @@
+#include <stdio.h>
+#include <pslib.h>
+
+psString psSlurp(int fd);
+psString psSlurpFile(FILE *stream);
