Index: test/Makefile
===================================================================
--- test/Makefile	(revision 296)
+++ 	(revision )
@@ -1,25 +1,0 @@
-# $Id: Makefile 143 2009-02-13 03:24:27Z tim $
-
-################################################################################
-CC=gcc
-OPTS=-std=gnu99 -pedantic -Wall -ggdb
-INC:=-I../trunk/include -I../trunk/src -I/usr/local/include 
-LIB=-L/usr/local/lib -lm -lpthread -ltalloc
-
-REGFI_THREADTEST=regfi-threadtest
-OBJ=$(wildcard ../trunk/lib/*.o)
-FILES=$(REGFI_THREADTEST)
-
-all: deps $(FILES)
-
-deps:
-	cd ../trunk && scons libregfi
-
-$(REGFI_THREADTEST): regfi-threadtest.o
-	$(CC) $(CFLAGS) $(OPTS) $(LIB) -o $@ regfi-threadtest.o $(OBJ) $(EXTRA_OBJ)
-
-regfi-threadtest.o: regfi-threadtest.c
-	$(CC) $(CFLAGS) $(OPTS) $(INC) -c -o $@ regfi-threadtest.c
-
-clean:
-	rm -f *.o $(FILES)
Index: test/diff-reglookup
===================================================================
--- test/diff-reglookup	(revision 296)
+++ 	(revision )
@@ -1,49 +1,0 @@
-#!/bin/sh
-
-mkdir -p tmp
-TMP_DIR=tmp
-OUTPUT_DIR=tmp
-
-OLD=reglookup
-NEW=../trunk/build/bin/reglookup
-
-
-compareOneFile()
-{
-  echo "Comparing output on $BNAME, test case: $CASE" 1>&2
-
-  echo "  $OLD $OPTS $F" 1>&2
-  $OLD $OPTS $F > $TMP_DIR/old.csv
-
-  echo "  $NEW $OPTS $F" 1>&2
-  $NEW $OPTS $F > $TMP_DIR/new.csv
-
-  diff -ud $TMP_DIR/old.csv $TMP_DIR/new.csv > $OUTPUT_DIR/$CASE-${BNAME}.diff  
-  SIZE=`stat -c '%s' $OUTPUT_DIR/$CASE-${BNAME}.diff`
-  if [ "x$SIZE" = "x0" ]; then
-    rm $OUTPUT_DIR/$CASE-${BNAME}.diff
-  fi
-}
-
-for F in hives/*; do
-{
-  BNAME=`basename $F`
-
-  CASE=basic
-  OPTS=''
-  compareOneFile
-
-  CASE=security
-  OPTS='-s'
-  compareOneFile
-
-  CASE=type
-  OPTS='-t MULTI_SZ'
-  compareOneFile
-
-  CASE=security+type
-  OPTS='-s -t KEY'
-  compareOneFile
-} done
-
-rm $TMP_DIR/old.csv $TMP_DIR/new.csv
Index: test/diff-reglookup-recover
===================================================================
--- test/diff-reglookup-recover	(revision 296)
+++ 	(revision )
@@ -1,42 +1,0 @@
-#!/bin/sh
-
-mkdir -p tmp
-TMP_DIR=tmp
-OUTPUT_DIR=tmp
-
-OLD=reglookup-recover
-NEW=../trunk/build/bin/reglookup-recover
-
-
-compareOneFile()
-{
-  echo "Comparing output on $BNAME, test case: $CASE" 1>&2
-
-  echo "  $OLD $OPTS $F" 1>&2
-  $OLD $OPTS $F > $TMP_DIR/old.csv
-
-  echo "  $NEW $OPTS $F" 1>&2
-  $NEW $OPTS $F > $TMP_DIR/new.csv
-
-  diff -ud $TMP_DIR/old.csv $TMP_DIR/new.csv > $OUTPUT_DIR/$CASE-${BNAME}.diff  
-  SIZE=`stat -c '%s' $OUTPUT_DIR/$CASE-${BNAME}.diff`
-  if [ "x$SIZE" = "x0" ]; then
-    rm $OUTPUT_DIR/$CASE-${BNAME}.diff
-  fi
-}
-
-for F in hives/*; do
-{
-
-  BNAME=`basename $F`
-
-  CASE=basic
-  OPTS=''
-  compareOneFile
-
-  CASE=raw
-  OPTS='-r'
-  compareOneFile
-} done
-
-rm $TMP_DIR/old.csv $TMP_DIR/new.csv
Index: test/pyregfi-smoketest.py
===================================================================
--- test/pyregfi-smoketest.py	(revision 296)
+++ 	(revision )
@@ -1,339 +1,0 @@
-#!/usr/bin/env python3
-
-import sys
-import gc
-import io
-import time
-import threading
-import pyregfi
-
-
-
-pyregfi.setLogMask((pyregfi.LOG_TYPES.INFO, pyregfi.LOG_TYPES.WARN, pyregfi.LOG_TYPES.ERROR))
-
-# Uses the HiveIterator to walk all keys
-# Gathers various (meaningless) statistics to exercise simple attribute access
-# and to hopefully smoke out any bugs that can be identified by changing stats
-def iterTallyNames(hive, fh):
-    key_count = 0
-    key_lens = 0
-    key_rawlens = 0
-    value_count = 0
-    value_lens = 0
-    value_rawlens = 0
-
-    for k in hive:
-        key_count += 1
-        if k.name != None:
-            key_lens += len(k.name)
-        if k.name_raw != None:
-            key_rawlens += len(k.name_raw)
-
-        for v in k.values:
-            value_count += 1
-            if v.name != None:
-                value_lens += len(v.name)
-            if v.name_raw != None:
-                value_rawlens += len(v.name_raw)
-
-    print("  Counts: keys=%d, values=%d" % (key_count, value_count))
-    print("  Total name length: keys=%d, values=%d" % (key_lens, value_lens))
-    print("  Total raw name lengths: keys=%d, values=%d" % (key_rawlens, value_rawlens))
-
-
-# walks up parents to obtain path, rather than using downward links like iterator
-def getCurrentPath(key):
-    if key == None:
-        return ''
-    path = []
-    p = key
-    while p != None:
-        path.append(p.name)
-        p = p.get_parent()
-    path.reverse()
-    del path[0]
-
-    return path
-
-# For each key in the hive, this traverses the parent links up to the root, 
-# recording the path as it goes, and then uses the subtree/descend method
-# to find the same key again, verifying it is the same.  This test is currently
-# very slow because no key caching is used.
-def iterParentWalk(hive, fh):
-    i = 1
-    for k in hive:
-        path = getCurrentPath(k)
-        try:
-            hive_iter = hive.subtree(path)
-            if hive_iter.current_key() != k:
-                print("WARNING: k != current_key for path '%s'." % path)
-            else:
-                i += 1
-        except Exception as e:
-            print("WARNING: Could not descend to path '%s'.\nError:\n %s\n%s" % (path,e.args,e))
-    print("   Successfully tested paths on %d keys." % i)
-
-
-# Uses the HiveIterator to walk all keys
-# Gathers various (meaningless) statistics about data/data_raw attributes
-def iterTallyData(hive, fh):
-    data_stat = 0.0
-    dataraw_stat = 0.0
-    
-    for k in hive:
-        for v in k.values:
-            d = v.fetch_data()
-            if d == None:
-                data_stat += 0.1
-            elif hasattr(d, "__len__"):
-                data_stat += len(d)
-            else:
-                data_stat += d/2.0**64
-
-            d = v.fetch_raw_data()
-            if d == None:
-                dataraw_stat += 0.1
-            else:
-                dataraw_stat += len(d)
-
-    print("  Data stat: %f" % data_stat)
-    print("  Raw data stat: %f" % dataraw_stat)
-
-
-recurseKey_stat = 0.0
-recurseValue_stat = 0.0
-def checkValues(key):
-    global recurseKey_stat
-    global recurseValue_stat
-    recurseKey_stat += (key.mtime - key.max_bytes_subkeyname) * key.flags
-    for v in key.values:
-        recurseValue_stat += (v.data_off - v.data_size) / (1.0 + v.flags) + v.data_in_offset
-        try:
-            value = key.values[v.name]
-            if v != value:
-                print("WARNING: iterator value '%s' does not match dictionary value '%s'." 
-                      % (v.name, value.name))
-        except Exception as e:
-                print("WARNING: iterator value name '%s' is not retrievable via value list\n"
-                      % (v.name,))
-        
-
-def recurseTree(cur, operation):
-    for k in cur.subkeys:
-        key = cur.subkeys[k.name]
-        if k != key:
-            print("WARNING: iterator subkey '%s' does not match dictionary subkey '%s'." 
-                  % (k.name, key.name))
-        del key
-        operation(k)
-        recurseTree(k, operation)
-
-# Retrieves all keys by recursion, rather than the iterator, and validates
-# list dictionary access.  Also builds nonsensical statistics as an excuse
-# to access various base structure attributes.
-def recurseKeyTally(hive, fh):
-    checkValues(hive.root)
-    recurseTree(hive.root, checkValues)
-    print("  Key stat: %f" % recurseKey_stat)
-    print("  Value stat: %f" % recurseValue_stat)
-
-
-# Iterates hive gathering stats about security and classname records
-def iterFetchRelated(hive, fh):
-    security_stat = 0.0
-    classname_stat = 0.0
-    modified_stat = 0.0
-
-    for k in hive:
-        cn = k.fetch_classname()
-        if cn == None:
-            classname_stat += 0.000001
-        elif type(cn) == bytearray:
-            classname_stat += len(cn)/2**32
-        else:
-            classname_stat += len(cn)
-
-        modified_stat += k.modified
-        
-    print("  Security stat: %f" % security_stat)
-    print("  Classname stat: %f" % classname_stat)
-    print("  Modified stat: %f" % modified_stat)
-
-
-
-def iterIterWalk(hive, fh):
-    sk_stat = 0.0
-    v_stat = 0.0
-    iter = pyregfi.HiveIterator(hive)
-    for k in iter:
-        path = iter.current_path()
-        try:
-            hive_iter = hive.subtree(path[1:])
-            sk = hive_iter.first_subkey()
-            while sk != None:
-                ssk = hive_iter.find_subkey(sk.name)
-                if ssk != None:
-                    if ssk.name != None:
-                        sk_stat += len(ssk.name)
-                else:
-                    print("WARNING: ssk was None")
-                sk = hive_iter.next_subkey()
-
-            v = hive_iter.first_value()
-            while v != None:
-                vv = hive_iter.find_value(v.name)
-                if vv != None:
-                    if vv.name != None:
-                        v_stat += len(vv.name)
-                else:
-                    print("WARNING: vv was None")
-                v = hive_iter.next_value()
-
-        except Exception as e:
-            print("WARNING: Could not descend to path '%s'.\nError:\n %s\n%s" % (path[1:],e.args,e))
-    print("   Subkey stat: %f" % sk_stat)
-    print("   Value stat: %f" % v_stat)
-
-
-def iterCallbackIO(hive, fh):
-    fh.seek(0)
-    new_fh = io.BytesIO(fh.read())
-    new_hive = pyregfi.Hive(new_fh)
-    stat = 0
-    for k in new_hive:
-        stat += 1
-    print("  %d keys found" % stat)
-
-
-def threadIterMain(iter):
-    x = 0
-    try:
-        for k in iter:
-            #x += len(k.name) + len(k.subkeys)
-            pass
-    except Exception as e:
-        print("%s dying young: %s" % (threading.current_thread().name, repr(e)))
-        # Exceptions are thrown on iteration because python state gets out of 
-        # whack.  That's fine, because we're really just interested in finding
-        # segfaults.  People should not use iterators without locks, but it 
-        # should at least not segfault on them.
-        pass
-    print("%s finished" % threading.current_thread().name)
-
-def iterMultithread(hive, fh):
-    num_threads = 10
-    iter = pyregfi.HiveIterator(hive)
-    threads = []
-    for t in range(0,num_threads):
-        threads.append(threading.Thread(target=threadIterMain, args=(iter,)))
-    for t in threads:
-        t.start()
-    for t in threads:
-        t.join()
-
-
-def loopSecurity(hive, fh):
-    cur = hive.root.fetch_security()
-    first = cur
-    stat = 0
-    while True:
-        stat += len(cur.descriptor.owner)
-        stat += len(cur.descriptor.group)
-        if cur.descriptor.sacl:
-            stat += len(cur.descriptor.sacl)
-        if cur.descriptor.dacl:
-            stat += len(cur.descriptor.dacl)
-        
-        nxt = cur.next_security()
-        if first == nxt:
-            break
-        cur = nxt
-    print("  Security stat: %d" % stat)
-
-
-def iterSecurity(hive, fh):
-    stat = 0
-    for k in hive:
-        security = k.fetch_security()
-        stat += security.ref_count
-        stat += len(security.descriptor.owner)
-        stat += len(security.descriptor.group)
-        if security.descriptor.sacl:
-            for ace in security.descriptor.sacl:
-                stat += ace.flags
-                if ace.object:
-                    stat += ace.object.int
-                if ace.inherited_object:
-                    stat += ace.inherited_object.int
-
-        if security.descriptor.dacl:
-            for ace in security.descriptor.dacl:
-                stat += ace.flags
-                if ace.object:
-                    stat += ace.object.int
-                if ace.inherited_object:
-                    stat += ace.inherited_object.int
-    print("  Security stat: %d" % stat)
-
-
-tests = {
-    "iterTallyNames":iterTallyNames,
-    "iterParentWalk":iterParentWalk,
-    "iterTallyData":iterTallyData,
-    "recurseKeyTally":recurseKeyTally,
-    "iterFetchRelated":iterFetchRelated,
-    "iterIterWalk":iterIterWalk,
-    "iterCallbackIO":iterCallbackIO,
-    "iterMultithread":iterMultithread,
-    "loopSecurity":loopSecurity,
-    "iterSecurity":iterSecurity,
-    }
-
-def usage():
-    sys.stderr.write("USAGE: pyregfi-smoketest.py { test1[,test2[,...]] | * } hive1 [hive2 ...]\n")
-    sys.stderr.write("\tAvailable tests:\n")
-    for t in tests.keys():
-        sys.stderr.write("\t\t%s\n" % t)
-
-
-if len(sys.argv) < 3:
-    usage()
-    sys.exit(1)
-
-if sys.argv[1] == '*':
-    selected_tests = tests.keys()
-else:
-    selected_tests = sys.argv[1].split(',')
-    for st in selected_tests:
-        if st not in tests:
-            usage()
-            sys.stderr.write("ERROR: %s not a valid test type\n\n" % st)
-            sys.exit(1)
-
-files = []
-for f in sys.argv[2:]:
-    files.append((f, open(f,"rb")))
-
-
-start_time = time.time()
-for hname,fh in files:
-    #hive = pyregfi.Hive(fh)
-    hive = pyregfi.openHive(hname)
-    for tname in selected_tests:
-        t = tests[tname]
-        teststart = time.time()
-        tstr = "'%s' on '%s'" % (tname,hname)
-        print("##BEGIN %s:" % tstr)
-        t(hive, fh)
-        print("##END %s; runtime=%f; messages:" % (tstr, time.time() - teststart))
-        print(pyregfi.getLogMessages())
-        print
-        sys.stdout.flush()
-    fh.close()
-
-hive = None
-files = None
-tests = None
-gc.collect()
-print("### Tests Completed, runtime: %f ###" % (time.time() -  start_time))
-#print(gc.garbage)
Index: test/regfi-threadtest.c
===================================================================
--- test/regfi-threadtest.c	(revision 296)
+++ 	(revision )
@@ -1,239 +1,0 @@
-/*
- * A program to stress test regfi under multithreaded use.
- *
- * Copyright (C) 2005-2011 Timothy D. Morgan
- * Copyright (C) 2002 Richard Sharpe, rsharpe@richardsharpe.com
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 3 of the License.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  
- *
- * $Id: $
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include <time.h>
-#include <pthread.h>
-#include "regfi.h"
-#include "void_stack.h"
-
-/* Globals, influenced by command line parameters */
-bool print_verbose = false;
-const char* registry_file = NULL;
-
-/* Other globals */
-REGFI_FILE* f;
-
-
-/* XXX: A hack to share some functions with reglookup-recover.c.
- *      Should move these into a proper library at some point.
- */
-#include "common.c"
-
-static bool keysEqual(const REGFI_NK* x, const REGFI_NK* y)
-{
-  return (x != NULL && y != NULL && x->offset == y->offset);
-}
-
-void traverseValueList(REGFI_ITERATOR* iter)
-{
-  const REGFI_VK* value;
-  bool ret;
-
-  for(ret=regfi_iterator_first_value(iter); 
-      ret; 
-      ret=regfi_iterator_next_value(iter))
-  {
-    value = regfi_iterator_cur_value(iter);
-    printMsgs(iter->f);
-    regfi_free_record(iter->f, value);
-  }
-}
-
-
-void traverseKeyTree(REGFI_ITERATOR* iter)
-{
-  const REGFI_NK* root = NULL;
-  const REGFI_NK* cur = NULL;
-  const REGFI_NK* sub = NULL;
-  const REGFI_SK* sk;
-  bool print_this = true;
-
-  root = regfi_iterator_cur_key(iter);
-  regfi_reference_record(iter->f, root);
-  cur = root;
-  regfi_iterator_first_subkey(iter);
-  sub = regfi_iterator_cur_subkey(iter);
-  printMsgs(iter->f);
-
-  if(root == NULL)
-    bailOut(REGLOOKUP_EXIT_DATAERR, "ERROR: root cannot be NULL.\n");
-  
-  do
-  {
-    if(print_this)
-      traverseValueList(iter);
-    
-    if(sub == NULL)
-    {
-      if(!keysEqual(cur,root))
-      {
-	/* We're done with this sub-tree, going up and hitting other branches. */
-        regfi_free_record(iter->f, cur);
-        cur = NULL;
-	if(!regfi_iterator_up(iter))
-	{
-	  printMsgs(iter->f);
-	  bailOut(REGLOOKUP_EXIT_DATAERR, "ERROR: could not traverse iterator upward.\n");
-	}
-
-	cur = regfi_iterator_cur_key(iter);
-	/*	fprintf(stderr, "%s\n", cur->keyname);*/
-	printMsgs(iter->f);
-	if(cur == NULL)
-	  bailOut(REGLOOKUP_EXIT_DATAERR, "ERROR: unexpected NULL for key.\n");
-	sk = regfi_fetch_sk(iter->f, cur);
-	printMsgs(iter->f);
-        regfi_free_record(iter->f, sk);
-
-	regfi_iterator_next_subkey(iter);
-	sub = regfi_iterator_cur_subkey(iter);
-      }
-      print_this = false;
-    }
-    else
-    { /* We have unexplored sub-keys.  
-       * Let's move down and print this first sub-tree out. 
-       */
-      regfi_free_record(iter->f, cur);
-      cur = NULL;
-      if(!regfi_iterator_down(iter))
-      {
-	printMsgs(iter->f);
-	bailOut(REGLOOKUP_EXIT_DATAERR, "ERROR: could not traverse iterator downward.\n");
-      }
-
-      cur = regfi_iterator_cur_key(iter);
-      printMsgs(iter->f);
-      regfi_free_record(iter->f, sub);
-
-      regfi_iterator_first_subkey(iter);
-      sub = regfi_iterator_cur_subkey(iter);
-      printMsgs(iter->f);
-      print_this = true;
-    }
-    printMsgs(iter->f);
-  } while(!(keysEqual(cur,root) && (sub == NULL)));
-  if(cur != NULL)
-    regfi_free_record(iter->f, cur);
-  regfi_free_record(iter->f, root);
-
-  if(print_verbose)
-    fprintf(stderr, "INFO: Finished printing key tree.\n");
-}
-
-
-int num_iterations;
-void* threadLoop(void* file)
-{
-  REGFI_ITERATOR* iter;
-  int i;
-
-  regfi_log_set_mask(REGFI_LOG_INFO|REGFI_LOG_WARN|REGFI_LOG_ERROR);
-
-  iter = regfi_iterator_new((REGFI_FILE*)f);
-  if(iter == NULL)
-  {
-    printMsgs(f);
-    bailOut(REGLOOKUP_EXIT_OSERR, "ERROR: Couldn't create registry iterator.\n");
-  }
-
-  for(i=0; i< num_iterations; i++)
-  {
-    traverseKeyTree(iter);
-    regfi_iterator_to_root(iter);
-  }
-
-  regfi_iterator_free(iter);
-  fprintf(stderr, "INFO: thread finished\n");
-
-  return NULL;
-}
-
-
-static void usage(void)
-{
-  fprintf(stderr, "Usage: regfi-threadtest <REGISTRY_FILE>\n");
-  fprintf(stderr, "\n");
-}
-
-
-int main(int argc, char** argv)
-{
-  int fd, tret, i;
-  uint32_t argi, arge, num_threads;
-  pthread_t* threads;
-
-  num_threads = 10;
-  num_iterations = 2;
-
-  /* Process command line arguments */
-  if(argc < 2)
-  {
-    usage();
-    bailOut(REGLOOKUP_EXIT_USAGE, "ERROR: Requires at least one argument.\n");
-  }
-  
-  arge = argc-1;
-  for(argi = 1; argi < arge; argi++)
-  {
-    usage();
-    fprintf(stderr, "ERROR: Unrecognized option: %s\n", argv[argi]);
-    bailOut(REGLOOKUP_EXIT_USAGE, "");
-  }
-  registry_file = argv[argi];
-
-  regfi_log_set_mask(REGFI_LOG_INFO|REGFI_LOG_WARN|REGFI_LOG_ERROR);
-
-  fd = openHive(registry_file);
-  if(fd < 0)
-  {
-    fprintf(stderr, "ERROR: Couldn't open registry file: %s\n", registry_file);
-    bailOut(REGLOOKUP_EXIT_NOINPUT, "");
-  }
-
-  f = regfi_alloc(fd, REGFI_ENCODING_ASCII);
-  if(f == NULL)
-  {
-    close(fd);
-    bailOut(REGLOOKUP_EXIT_NOINPUT, "ERROR: Failed to create REGFI_FILE structure.\n");
-  }
-
-  threads = malloc(sizeof(pthread_t)*num_threads);
-  for(i=0; i<num_threads; i++)
-  {
-    tret = pthread_create(threads+i, NULL, threadLoop, (void*) f);
-  }
-  
-  for(i=0; i<num_threads; i++)
-    pthread_join(threads[i], NULL);
-
-  free(threads);
-  regfi_free(f);
-  close(fd);
-
-  return 0;
-}
