Index: trunk/test/Makefile
===================================================================
--- trunk/test/Makefile	(revision 30)
+++ trunk/test/Makefile	(revision 31)
@@ -3,17 +3,21 @@
 ################################################################################
 
+CC=gcc
+OPTS=-ggdb -std=gnu89 -pedantic -Wall
+
 REGFIO_O=../lib/regfio.o
 LIB_REGFIO_O=lib-regfio.o
 LIB_REGFIO=lib-regfio
-FILES=$(LIB_REGFIO) $(REGFIO_O)
+FILES=$(LIB_REGFIO) $(LIB_REGFIO_O)
 
 all: $(FILES)
-
-$(REGFIO_O): ../lib/regfio.c
-	$(CC) $(CFLAGS) $(OPTS) -c -o $@ ../lib/regfio.c
 
 $(LIB_REGFIO_O): lib-regfio.c
 	$(CC) $(CFLAGS) $(OPTS) -c -o $@ lib-regfio.c
 
-$(LIB_REGFIO): 	$(LIB_REGFIO_O) $(REGFIO_O)
-	$(CC) $(CFLAGS) $(OPTS) -o $@ $(LIB_REGFIO_O) $(REGFIO_O) ../lib/smb_deps.c
+$(LIB_REGFIO): 	$(LIB_REGFIO_O) $(REGFIO_O) ../lib/smb_deps.o ../lib/void_stack.o
+	$(CC) $(CFLAGS) $(OPTS) -o $@ $(LIB_REGFIO_O) $(REGFIO_O) ../lib/smb_deps.o ../lib/void_stack.o
+
+
+clean:
+	rm -f $(FILES)
Index: trunk/test/lib-regfio.c
===================================================================
--- trunk/test/lib-regfio.c	(revision 30)
+++ trunk/test/lib-regfio.c	(revision 31)
@@ -1,4 +1,4 @@
 /*
- * A utility to test functionality of Gerald Carter''s regio interface.
+ * A utility to test functionality of Gerald Carter''s regfio interface.
  *
  * Copyright (C) 2005 Timothy D. Morgan
@@ -25,26 +25,85 @@
 #include <string.h>
 #include "../include/regfio.h"
+#include "../include/void_stack.h"
 
-void printKeyTree(REGF_FILE* f,  REGF_NK_REC* cur, char* prefix)
+
+char* getStackPath(void_stack* nk_stack)
 {
+  REGF_NK_REC* cur;
+  unsigned int buf_left = 127;
+  unsigned int buf_len = buf_left+1;
+  unsigned int name_len = 0;
+  unsigned int grow_amt;
+  char* buf; 
+  char* new_buf;
+  void_stack_iterator* iter;
+  
+  buf = (char*)malloc((buf_len)*sizeof(char));
+  if (buf == NULL)
+    return NULL;
+  buf[0] = '\0';
+
+  iter = void_stack_iterator_new(nk_stack);
+  if (iter == NULL)
+  {
+    free(buf);
+    return NULL;
+  }
+
+  while((cur = void_stack_iterator_next(iter)) != NULL)
+  {
+    name_len = strlen(cur->keyname);
+    if(name_len+1 > buf_left)
+    {
+      grow_amt = (unsigned int)(buf_len/3);
+      buf_len += name_len+1+grow_amt-buf_left;
+      if((new_buf = realloc(buf, buf_len)) == NULL)
+      {
+	free(buf);
+	free(iter);
+	return NULL;
+      }
+      buf = new_buf;
+      buf_left = grow_amt + name_len + 1;
+    }
+    strncpy(buf+(buf_len-buf_left-1), cur->keyname, name_len);
+    buf_left -= name_len;
+    buf[buf_len-buf_left-1] = '/';
+    buf_left -= 1;
+    buf[buf_len-buf_left-1] = '\0';
+  }
+
+  return buf;
+}
+
+
+void printKeyTree(REGF_FILE* f,  void_stack* nk_stack)
+{
+  REGF_NK_REC* cur;
   REGF_NK_REC* sub;
-  char* sub_prefix;
+  char* path;
 
-  if(prefix != NULL)
+  while((cur = (REGF_NK_REC*)void_stack_cur(nk_stack)) != NULL)
   {
-    sub_prefix = (char*)zalloc(strlen(prefix)+strlen(cur->keyname)+2);
-    strcpy(sub_prefix, prefix);
-    strcat(sub_prefix, "/");
+    if((sub = regfio_fetch_subkey(f, cur)) != NULL)
+    {
+      path = getStackPath(nk_stack);
+      if(path != NULL)
+      {
+	printf("%s%s:KEY\n", path, sub->keyname);
+	free(path);
+      }
+      void_stack_push(nk_stack, sub);
+    }
+    else
+    {
+      cur = void_stack_pop(nk_stack);
+      /* XXX: This is just a shallow free.  Need to write deep free
+       * routines to replace the Samba code for this. 
+       */ 
+      if(cur != NULL)
+	free(cur);
+    }
   }
-  else
-    sub_prefix = (char*)zalloc(strlen(cur->keyname)+2);
-
-  strcat(sub_prefix, cur->keyname);
-
-  printf("%s:KEY\n", sub_prefix);
-  while ((sub = regfio_fetch_subkey(f, cur)) != NULL)
-    printKeyTree(f, sub, sub_prefix);
-
-  free(sub_prefix);
 }
 
@@ -52,4 +111,8 @@
 int main(int argc, char** argv)
 {
+  void_stack* nk_stack;
+  REGF_FILE* f;
+  REGF_NK_REC* root;
+
   if(argc < 2)
   {
@@ -58,8 +121,12 @@
   }
 
-  REGF_FILE* f = regfio_open( argv[1] );
-  REGF_NK_REC* root = regfio_rootkey(f);
+  f = regfio_open( argv[1] );
+  root = regfio_rootkey(f);
 
-  printKeyTree(f, root, NULL);
+  nk_stack = void_stack_new(1024);
+  if(void_stack_push(nk_stack, root))
+    printKeyTree(f, nk_stack);
+  void_stack_destroy(nk_stack);
+
   regfio_close(f);
 /*
