Index: trunk/ippTools/src/pxdata.c.template
===================================================================
--- trunk/ippTools/src/pxdata.c.template	(revision 12095)
+++ trunk/ippTools/src/pxdata.c.template	(revision 14028)
@@ -32,5 +32,7 @@
 #include "pxdata.h"
 
-int test_f(const char *path);
+static psHash *cachedData = NULL;
+
+static int test_f(const char *path);
 
 psString pxDataGet(const char *filename)
@@ -50,31 +52,33 @@
     if (test_f(filepath)) {
         // if we do, slurp the file
-        psString text = psSlurpFilename(filepath);
-        if (!text) {
+        psString data = psSlurpFilename(filepath);
+        if (!data) {
             psError(PS_ERR_IO, false, "failed to slurp %s", filepath);
             psFree(filepath);
             return NULL;
         }
+        psTrace("pxdata", PS_LOG_INFO, "slupred %s", filepath);
         psFree(filepath);
 
-        return text;
+        return data;
     }
     psFree(filepath);
 
     // look under our share path
-    psStringAppend(&filepath, "%s/%s", "PKGDATADIR", filename);
+    psStringAppend(&filepath, "%s/%s", "/home/moanui/jhoblitt/jhroot/i686-pc-linux-gnu//share/ipptools", filename);
 
     // see if we have a valid filename
     if (test_f(filepath)) {
         // if we do, slurp the file
-        psString text = psSlurpFilename(filepath);
-        if (!text) {
+        psString data = psSlurpFilename(filepath);
+        if (!data) {
             psError(PS_ERR_IO, false, "failed to slurp %s", filepath);
             psFree(filepath);
             return NULL;
         }
+        psTrace("pxdata", PS_LOG_INFO, "slupred %s", filepath);
         psFree(filepath);
 
-        return text;
+        return data;
     }
     psFree(filepath);
@@ -86,5 +90,5 @@
 }
 
-int test_f(const char *path)
+static int test_f(const char *path)
 {
         // copied from coreutils 6.4 test.c licenced under GPL v2 
@@ -93,2 +97,41 @@
                    && S_ISREG (stat_buf.st_mode));
 }
+
+psString pxDataGetCached(const char *filename)
+{
+    bool persistence = p_psMemAllocatePersistent(true);
+
+    // make sure the cache is initalized
+    if (!cachedData) {
+        cachedData = psHashAlloc(10);
+    }
+
+    // look to see if we've cached this file
+    {
+        psString data = psHashLookup(cachedData, filename);
+        if (data) {
+            p_psMemAllocatePersistent(persistence);
+            return psStringCopy(data);
+        } 
+    }
+
+    // we didn't have a cached copy so we need to try to read the file
+    psString data = pxDataGet(filename);
+    if (!data) {
+        p_psMemAllocatePersistent(persistence);
+        psError(PS_ERR_IO, false, "pxDataGet(%s) failed", filename);
+        return NULL;
+    }
+
+    // store a copy of the file
+    if (!psHashAdd(cachedData, filename, data)) {
+        psFree(data);
+        p_psMemAllocatePersistent(persistence);
+        psError(PS_ERR_UNKNOWN, false, "psHashAdd() failed");
+        return NULL;
+    }
+
+    p_psMemAllocatePersistent(persistence);
+
+    return psStringCopy(data);
+}
