Index: trunk/src/reglookup.c
===================================================================
--- trunk/src/reglookup.c	(revision 39)
+++ trunk/src/reglookup.c	(revision 40)
@@ -29,4 +29,14 @@
 
 
+/* Globals, influenced by command line parameters */
+bool print_verbose = false;
+bool print_security = false;
+bool path_filter_enabled = false;
+bool type_filter_enabled = false;
+char* path_filter = NULL;
+int type_filter;
+char* registry_file = NULL;
+
+
 void bailOut(int code, char* message)
 {
@@ -131,8 +141,6 @@
 void printValue(REGF_VK_REC* vk, char* prefix)
 {
-  const char* str_type;
-  
-  str_type = type_val2str(vk->type);
-  printf("%s/%s:%s=\n", prefix, vk->valuename, str_type);
+  if(!type_filter_enabled || (vk->type == type_filter))
+    printf("%s/%s:%s=\n", prefix, vk->valuename, type_val2str(vk->type));
 }
 
@@ -154,4 +162,5 @@
   char* path;
   char* val_path;
+  int key_type = type_str2val("KEY");
 
   if((cur = (REGF_NK_REC*)void_stack_cur(nk_stack)) != NULL)
@@ -161,6 +170,8 @@
     
     if(strlen(path) > 0)
-      printf("%s%s:KEY\n", prefix, path);
-    printValueList(cur, path);
+      if(!type_filter_enabled || (key_type == type_filter))
+	printf("%s%s:KEY\n", prefix, path);
+    if(!type_filter_enabled || (key_type != type_filter))
+      printValueList(cur, path);
     while((cur = (REGF_NK_REC*)void_stack_cur(nk_stack)) != NULL)
     {
@@ -174,6 +185,8 @@
 	  val_path = (char*)malloc(strlen(prefix)+strlen(path)+1);
 	  sprintf(val_path, "%s%s", prefix, path);
-	  printf("%s:KEY\n", val_path);
-	  printValueList(sub, val_path);
+	  if(!type_filter_enabled || (key_type == type_filter))
+	    printf("%s:KEY\n", val_path);
+	  if(!type_filter_enabled || (key_type != type_filter))
+	    printValueList(sub, val_path);
 	  free(val_path);
 	  free(path);
@@ -275,5 +288,5 @@
 {
   fprintf(stderr, "Usage: readreg [-v] [-s]"
-	  " [-f <PREFIX_FILTER>] [-t <TYPE_FILTER>]"
+	  " [-p <PATH_FILTER>] [-t <TYPE_FILTER>]"
 	  " <REGISTRY_FILE>\n");
   /* XXX: replace version string with Subversion property? */
@@ -282,17 +295,8 @@
   fprintf(stderr, "\t-v\t sets verbose mode.\n");
   fprintf(stderr, "\t-s\t prints security descriptors.\n");
-  fprintf(stderr, "\t-f\t restricts output to elements below this path.\n");
-  fprintf(stderr, "\t-t\t restrict results to a specific data type.\n");
+  fprintf(stderr, "\t-p\t restrict output to elements below this path.\n");
+  fprintf(stderr, "\t-t\t restrict results to this specific data type.\n");
   fprintf(stderr, "\n");
 }
-
-/* Globals, influenced by command line parameters */
-bool print_verbose = false;
-bool print_security = false;
-bool prefix_filter_enabled = false;
-bool type_filter_enabled = false;
-char* prefix_filter = NULL;
-char* type_filter = NULL;
-char* registry_file = NULL;
 
 
@@ -315,15 +319,15 @@
   for(argi = 1; argi < argc; argi++)
   {
-    if (strcmp("-f", argv[argi]) == 0)
+    if (strcmp("-p", argv[argi]) == 0)
     {
       if(++argi > argc)
       {
 	usage();
-	bailOut(1, "ERROR: '-f' option requires parameter.\n");
-      }
-      if((prefix_filter = strdup(argv[argi])) == NULL)
+	bailOut(1, "ERROR: '-p' option requires parameter.\n");
+      }
+      if((path_filter = strdup(argv[argi])) == NULL)
 	bailOut(2, "ERROR: Memory allocation problem.\n");
 
-      prefix_filter_enabled = true;
+      path_filter_enabled = true;
     }
     else if (strcmp("-t", argv[argi]) == 0)
@@ -334,6 +338,9 @@
 	bailOut(1, "ERROR: '-t' option requires parameter.\n");
       }
-      if((prefix_filter = strdup(argv[argi])) == NULL)
-	bailOut(2, "ERROR: Memory allocation problem.\n");
+      if((type_filter = type_str2val(argv[argi])) == 0)
+      {
+	fprintf(stderr, "ERROR: Invalid type specified: %s.\n", argv[argi]);
+	bailOut(1, "");
+      }
 
       type_filter_enabled = true;
@@ -368,5 +375,5 @@
   if(void_stack_push(nk_stack, root))
   {
-    path_stack = path2Stack(prefix_filter);
+    path_stack = path2Stack(path_filter);
     if(void_stack_size(path_stack) < 1)
       printKeyTree(f, nk_stack, "");
