Index: /trunk/doc/reglookup-recover.1.docbook
===================================================================
--- /trunk/doc/reglookup-recover.1.docbook	(revision 137)
+++ /trunk/doc/reglookup-recover.1.docbook	(revision 138)
@@ -26,5 +26,4 @@
         reglookup-recover attempts to scour a Windows registry hive for 
         deleted data structures and outputs those found in a CSV-like format.
-        print them out to stdout in a CSV-like format.
     </para>
   </refsect1>
@@ -43,5 +42,5 @@
         <listitem>
 	  <para>
-	    Verbose output. (Currently does little to nothing.)
+	    Verbose output.
 	  </para>
         </listitem>
Index: /trunk/doc/reglookup.1.docbook
===================================================================
--- /trunk/doc/reglookup.1.docbook	(revision 137)
+++ /trunk/doc/reglookup.1.docbook	(revision 138)
@@ -137,5 +137,5 @@
         <listitem>
 	  <para>
-	    Verbose output. (Currently does little to nothing.)
+	    Verbose output.
 	  </para>
         </listitem>
@@ -298,7 +298,4 @@
     </para>
     <para>
-      Verbose output is not working.
-    </para>
-    <para>
       The SID conversions haven't been carefully checked for accuracy.
     </para>
Index: /trunk/include/regfi.h
===================================================================
--- /trunk/include/regfi.h	(revision 137)
+++ /trunk/include/regfi.h	(revision 138)
@@ -53,6 +53,10 @@
 
 /******************************************************************************/
-/* Macros */
- 
+
+/* regfi library error message types */
+#define REGFI_MSG_INFO  0x0001
+#define REGFI_MSG_WARN  0x0004
+#define REGFI_MSG_ERROR 0x0010
+
 /* Registry data types */
 #define REG_NONE                       0
@@ -281,7 +285,11 @@
   /* Run-time information */
   /************************/
-  int fd;	  /* file descriptor */
-
-  /* Experimental hbin lists */
+  /* file descriptor */
+  int fd;
+
+  /* For sanity checking (not part of the registry header) */
+  uint32 file_length;
+
+  /* Metadata about hbins */
   range_list* hbins;
 
@@ -289,6 +297,6 @@
   char* last_message;
 
-  /* For sanity checking (not part of the registry header) */
-  uint32 file_length;
+  /* Mask for error message types that will be stored. */
+  uint16 msg_mask;
 
 
@@ -359,4 +367,5 @@
  */
 char*                 regfi_get_messages(REGFI_FILE* file);
+void                  regfi_set_message_mask(REGFI_FILE* file, uint16 mask);
 
 REGFI_ITERATOR*       regfi_iterator_new(REGFI_FILE* fh);
@@ -458,4 +467,5 @@
 					      REGFI_SUBKEY_LIST** lists,
 					      bool strict);
-void                  regfi_add_message(REGFI_FILE* file, const char* fmt, ...);
+void                  regfi_add_message(REGFI_FILE* file, uint16 msg_type, 
+					const char* fmt, ...);
 #endif	/* _REGFI_H */
Index: /trunk/lib/regfi.c
===================================================================
--- /trunk/lib/regfi.c	(revision 137)
+++ /trunk/lib/regfi.c	(revision 138)
@@ -37,31 +37,49 @@
 /******************************************************************************
  ******************************************************************************/
-void regfi_add_message(REGFI_FILE* file, const char* fmt, ...)
+void regfi_add_message(REGFI_FILE* file, uint16 msg_type, const char* fmt, ...)
 {
   /* XXX: This function is not particularly efficient,
    *      but then it is mostly used during errors. 
    */
-  /* XXX: Should we add support for filtering by levels of severity? */
   uint32 buf_size, buf_used;
   char* new_msg;
   va_list args;
 
-  if(file->last_message == NULL)
-    buf_used = 0;
-  else
-    buf_used = strlen(file->last_message);
-
-  buf_size = buf_used+strlen(fmt)+2+128;
-  new_msg = realloc(file->last_message, buf_size);
-  if(new_msg == NULL)
-    /* XXX: should we report this? */
-    return;
-  
-  va_start(args, fmt);
-  vsnprintf(new_msg+buf_used, buf_size-buf_used, fmt, args);
-  va_end(args);
-  strncat(new_msg, "\n", buf_size-1);
-
-  file->last_message = new_msg;
+  if((file->msg_mask & msg_type) != 0)
+  {
+    if(file->last_message == NULL)
+      buf_used = 0;
+    else
+      buf_used = strlen(file->last_message);
+    
+    buf_size = buf_used+strlen(fmt)+160;
+    new_msg = realloc(file->last_message, buf_size);
+    if(new_msg == NULL)
+      /* XXX: should we report this? */
+      return;
+
+    switch (msg_type)
+    {
+    case REGFI_MSG_INFO:
+      strcpy(new_msg+buf_used, "INFO: ");
+      buf_used += 6;
+      break;
+    case REGFI_MSG_WARN:
+      strcpy(new_msg+buf_used, "WARN: ");
+      buf_used += 6;
+      break;
+    case REGFI_MSG_ERROR:
+      strcpy(new_msg+buf_used, "ERROR: ");
+      buf_used += 7;
+      break;
+    }
+
+    va_start(args, fmt);
+    vsnprintf(new_msg+buf_used, buf_size-buf_used, fmt, args);
+    va_end(args);
+    strncat(new_msg, "\n", buf_size-1);
+    
+    file->last_message = new_msg;
+  }
 }
 
@@ -75,4 +93,10 @@
 
   return ret_val;
+}
+
+
+void regfi_set_message_mask(REGFI_FILE* file, uint16 mask)
+{
+  file->msg_mask = mask;
 }
 
@@ -702,5 +726,5 @@
 		       &cell_length, &unalloc))
   {
-    regfi_add_message(file, "ERROR: Could not parse SK record cell"
+    regfi_add_message(file, REGFI_MSG_WARN, "Could not parse SK record cell"
 		      " at offset 0x%.8X.", offset);
     return NULL;
@@ -709,6 +733,6 @@
   if(sk_header[0] != 's' || sk_header[1] != 'k')
   {
-    regfi_add_message(file, "ERROR: Magic number mismatch in parsing SK record"
-		      " at offset 0x%.8X.", offset);
+    regfi_add_message(file, REGFI_MSG_WARN, "Magic number mismatch in parsing"
+		      " SK record at offset 0x%.8X.", offset);
     return NULL;
   }
@@ -729,6 +753,6 @@
      || (strict && ret_val->cell_size != (ret_val->cell_size & 0xFFFFFFF8)))
   {
-    regfi_add_message(file, "ERROR: Invalid cell size found while parsing SK"
-		      " record at offset 0x%.8X.", offset);
+    regfi_add_message(file, REGFI_MSG_WARN, "Invalid cell size found while"
+		      " parsing SK record at offset 0x%.8X.", offset);
     free(ret_val);
     return NULL;
@@ -747,6 +771,7 @@
   if(ret_val->desc_size + REGFI_SK_MIN_LENGTH > ret_val->cell_size)
   {
-    regfi_add_message(file, "ERROR: Security descriptor too large for cell"
-		      " while parsing SK record at offset 0x%.8X.", offset);
+    regfi_add_message(file, REGFI_MSG_ERROR, "Security descriptor too large for"
+		      " cell while parsing SK record at offset 0x%.8X.", 
+		      offset);
     free(ret_val);
     return NULL;
@@ -764,6 +789,7 @@
      || length != ret_val->desc_size)
   {
-    regfi_add_message(file, "ERROR: Failed to read security descriptor"
-		      " while parsing SK record at offset 0x%.8X.", offset);
+    regfi_add_message(file, REGFI_MSG_ERROR, "Failed to read security"
+		      " descriptor while parsing SK record at offset 0x%.8X.",
+		      offset);
     free(ret_val);
     return NULL;
@@ -772,6 +798,7 @@
   if(!(ret_val->sec_desc = winsec_parse_desc(sec_desc_buf, ret_val->desc_size)))
   {
-    regfi_add_message(file, "ERROR: Failed to parse security descriptor"
-		      " while parsing SK record at offset 0x%.8X.", offset);
+    regfi_add_message(file, REGFI_MSG_ERROR, "Failed to parse security"
+		      " descriptor while parsing SK record at offset 0x%.8X.",
+		      offset);
     free(sec_desc_buf);
     free(ret_val);
@@ -794,5 +821,5 @@
   if(!regfi_parse_cell(file->fd, offset, NULL, 0, &cell_length, &unalloc))
   {
-    regfi_add_message(file, "ERROR: Failed to read cell header"
+    regfi_add_message(file, REGFI_MSG_ERROR, "Failed to read cell header"
 		      " while parsing value list at offset 0x%.8X.", offset);
     return NULL;
@@ -807,5 +834,5 @@
   if((num_values * sizeof(uint32)) > cell_length-sizeof(uint32))
   {
-    regfi_add_message(file, "ERROR: Too many values found"
+    regfi_add_message(file, REGFI_MSG_ERROR, "Too many values found"
 		      " while parsing value list at offset 0x%.8X.", offset);
     return NULL;
@@ -820,5 +847,5 @@
   if((regfi_read(file->fd, (uint8*)ret_val, &length) != 0) || length != read_len)
   {
-    regfi_add_message(file, "ERROR: Failed to read value pointers"
+    regfi_add_message(file, REGFI_MSG_ERROR, "Failed to read value pointers"
 		      " while parsing value list at offset 0x%.8X.", offset);
     free(ret_val);
@@ -837,7 +864,7 @@
 	 || ((ret_val[i] & 0xFFFFFFF8) != ret_val[i]))
       {
-	regfi_add_message(file, "ERROR: Invalid value pointer (0x%.8X) found"
-			  " while parsing value list at offset 0x%.8X.", 
-			  ret_val[i], offset);
+	regfi_add_message(file, REGFI_MSG_ERROR, "Invalid value pointer"
+			  " (0x%.8X) found while parsing value list at offset"
+			  " 0x%.8X.", ret_val[i], offset);
 	free(ret_val);
 	return NULL;
@@ -934,5 +961,5 @@
   if ((nk = regfi_parse_nk(file, offset, max_length, true)) == NULL)
   {
-    regfi_add_message(file, "ERROR: Could not load NK record at"
+    regfi_add_message(file, REGFI_MSG_ERROR, "Could not load NK record at"
 		      " offset 0x%.8X.", offset);
     return NULL;
@@ -965,5 +992,5 @@
       if(strict && nk->values == NULL)
       {
-	regfi_add_message(file, "ERROR: Could not load value list"
+	regfi_add_message(file, REGFI_MSG_ERROR, "Could not load value list"
 			  " for NK record at offset 0x%.8X.",
 			  offset);
@@ -1111,8 +1138,9 @@
     rla = range_list_add(rb->hbins, hbin->file_off, hbin->block_size, hbin);
     hbin_off = hbin->file_off + hbin->block_size;
-    /*fprintf(stderr, "file_length=%.8X,hbin_off=%.8X,hbin->block_size=%.8X,hbin->next_block=%.8X\n", 
-      file_length, hbin_off, hbin->block_size, hbin->next_block);*/
     hbin = regfi_parse_hbin(rb, hbin_off, true);
   }
+
+  /* Default message mask */
+  rb->msg_mask = REGFI_MSG_ERROR|REGFI_MSG_WARN;
 
   /* success */
@@ -1661,5 +1689,5 @@
   if(lseek(file->fd, offset, SEEK_SET) == -1)
   {
-    regfi_add_message(file, "ERROR: Seek failed"
+    regfi_add_message(file, REGFI_MSG_ERROR, "Seek failed"
 		      " while parsing hbin at offset 0x%.8X.", offset);
     return NULL;
@@ -1673,5 +1701,5 @@
   if(lseek(file->fd, offset, SEEK_SET) == -1)
   {
-    regfi_add_message(file, "ERROR: Seek failed"
+    regfi_add_message(file, REGFI_MSG_ERROR, "Seek failed"
 		      " while parsing hbin at offset 0x%.8X.", offset);
     return NULL;
@@ -1685,8 +1713,8 @@
   if(strict && (memcmp(hbin->magic, "hbin", 4) != 0))
   {
-    /* XXX: add this back in when we have configurable verbosity. */
-    /*    regfi_add_message(file, "INFO: Magic number mismatch (%.2X %.2X %.2X %.2X)"
-		      " while parsing hbin at offset 0x%.8X.", hbin->magic[0],
-		      hbin->magic[1], hbin->magic[2], hbin->magic[3], offset); */
+    regfi_add_message(file, REGFI_MSG_INFO, "Magic number mismatch "
+		      "(%.2X %.2X %.2X %.2X) while parsing hbin at offset"
+		      " 0x%.8X.", hbin->magic[0], hbin->magic[1], 
+		      hbin->magic[2], hbin->magic[3], offset);
     free(hbin);
     return NULL;
@@ -1695,6 +1723,4 @@
   hbin->first_hbin_off = IVAL(hbin_header, 0x4);
   hbin->block_size = IVAL(hbin_header, 0x8);
-    /*fprintf(stderr, "hbin->block_size field => %.8X\n", IVAL(hbin_header, 0x8));*/
-  /*  hbin->block_size = IVAL(hbin_header, 0x8);*/
   /* this should be the same thing as hbin->block_size but just in case */
   hbin->next_block = IVAL(hbin_header, 0x1C);
@@ -1710,5 +1736,5 @@
      || (hbin->block_size & 0xFFFFF000) != hbin->block_size)
   {
-    regfi_add_message(file, "ERROR: The hbin offset is not aligned"
+    regfi_add_message(file, REGFI_MSG_ERROR, "The hbin offset is not aligned"
 		      " or runs off the end of the file"
 		      " while parsing hbin at offset 0x%.8X.", offset);
@@ -1736,5 +1762,5 @@
 		       &cell_length, &unalloc))
   {
-    regfi_add_message(file, "ERROR: Could not parse cell header"
+    regfi_add_message(file, REGFI_MSG_WARN, "Could not parse cell header"
 		      " while parsing NK record at offset 0x%.8X.", offset);
     return NULL;
@@ -1744,6 +1770,6 @@
   if((nk_header[0x0] != 'n') || (nk_header[0x1] != 'k'))
   {
-    regfi_add_message(file, "ERROR: Magic number mismatch in parsing NK record"
-		      " at offset 0x%.8X.", offset);
+    regfi_add_message(file, REGFI_MSG_WARN, "Magic number mismatch in parsing"
+		      " NK record at offset 0x%.8X.", offset);
     return NULL;
   }
@@ -1752,5 +1778,5 @@
   if(ret_val == NULL)
   {
-    regfi_add_message(file, "ERROR: Failed to allocate memory while"
+    regfi_add_message(file, REGFI_MSG_ERROR, "Failed to allocate memory while"
 		      " parsing NK record at offset 0x%.8X.", offset);
     return NULL;
@@ -1765,6 +1791,6 @@
      || (strict && ret_val->cell_size != (ret_val->cell_size & 0xFFFFFFF8)))
   {
-    regfi_add_message(file, "ERROR: A length check failed while parsing"
-		      " NK record at offset 0x%.8X.", offset);
+    regfi_add_message(file, REGFI_MSG_ERROR, "A length check failed while"
+		      " parsing NK record at offset 0x%.8X.", offset);
     free(ret_val);
     return NULL;
@@ -1782,7 +1808,7 @@
      && (ret_val->key_type != REGFI_NK_TYPE_UNKNOWN3))
   {
-    regfi_add_message(file, "WARN: Unknown key type (0x%.4X) while parsing"
-		      " NK record at offset 0x%.8X.", ret_val->key_type,
-		      offset);
+    regfi_add_message(file, REGFI_MSG_WARN, "Unknown key type (0x%.4X) while"
+		      " parsing NK record at offset 0x%.8X.", 
+		      ret_val->key_type, offset);
   }
 
@@ -1825,5 +1851,5 @@
     if(strict)
     {
-      regfi_add_message(file, "ERROR: Contents too large for cell"
+      regfi_add_message(file, REGFI_MSG_ERROR, "Contents too large for cell"
 			" while parsing NK record at offset 0x%.8X.", offset);
       free(ret_val);
@@ -1857,5 +1883,5 @@
      || length != ret_val->name_length)
   {
-    regfi_add_message(file, "ERROR: Failed to read key name"
+    regfi_add_message(file, REGFI_MSG_ERROR, "Failed to read key name"
 		      " while parsing NK record at offset 0x%.8X.", offset);
     free(ret_val->keyname);
@@ -1879,6 +1905,7 @@
     {
       ret_val->classname = NULL;
-      regfi_add_message(file, "WARN: Could not find hbin for class name"
-			" while parsing NK record at offset 0x%.8X.", offset);
+      regfi_add_message(file, REGFI_MSG_WARN, "Could not find hbin for class"
+			" name while parsing NK record at offset 0x%.8X.", 
+			offset);
     }
     /* XXX: Should add this back and make it more strict?
@@ -1887,11 +1914,5 @@
     */
   }
-  /*
-if(ret_val->key_type == 0x0000 || ret_val->key_type == 0x4020)
-{
-  fprintf(stderr, "INFO: keyname=%s,classname=%s,unalloc=%d,num_subkeys=%d,num_values=%d\n",
-	  ret_val->keyname,ret_val->classname,unalloc,ret_val->num_subkeys,ret_val->num_values);
-}
-  */
+
   return ret_val;
 }
@@ -1911,5 +1932,5 @@
     if(!regfi_parse_cell(file->fd, offset, NULL, 0, &cell_length, &unalloc))
     {
-      regfi_add_message(file, "ERROR: Could not parse cell header"
+      regfi_add_message(file, REGFI_MSG_WARN, "Could not parse cell header"
 			" while parsing class name at offset 0x%.8X.", offset);
 	return NULL;
@@ -1918,5 +1939,5 @@
     if((cell_length & 0xFFFFFFF8) != cell_length)
     {
-      regfi_add_message(file, "ERROR: Cell length not a multiple of 8"
+      regfi_add_message(file, REGFI_MSG_ERROR, "Cell length not a multiple of 8"
 			" while parsing class name at offset 0x%.8X.", offset);
       return NULL;
@@ -1925,6 +1946,7 @@
     if(cell_length > max_size)
     {
-      regfi_add_message(file, "WARN: Cell stretches past hbin boundary"
-			" while parsing class name at offset 0x%.8X.", offset);
+      regfi_add_message(file, REGFI_MSG_WARN, "Cell stretches past hbin "
+			"boundary while parsing class name at offset 0x%.8X.",
+			offset);
       if(strict)
 	return NULL;
@@ -1934,6 +1956,7 @@
     if((cell_length - 4) < *name_length)
     {
-      regfi_add_message(file, "WARN: Class name is larger than cell_length"
-			" while parsing class name at offset 0x%.8X.", offset);
+      regfi_add_message(file, REGFI_MSG_WARN, "Class name is larger than"
+			" cell_length while parsing class name at offset"
+			" 0x%.8X.", offset);
       if(strict)
 	return NULL;
@@ -1948,5 +1971,5 @@
 	 || length != *name_length)
       {
-	regfi_add_message(file, "ERROR: Could not read class name"
+	regfi_add_message(file, REGFI_MSG_ERROR, "Could not read class name"
 			  " while parsing class name at offset 0x%.8X.", offset);
 	free(ret_val);
@@ -1975,5 +1998,5 @@
 		       &cell_length, &unalloc))
   {
-    regfi_add_message(file, "ERROR: Could not parse cell header"
+    regfi_add_message(file, REGFI_MSG_WARN, "Could not parse cell header"
 		      " while parsing VK record at offset 0x%.8X.", offset);
     return NULL;
@@ -1992,5 +2015,5 @@
      || ret_val->cell_size != (ret_val->cell_size & 0xFFFFFFF8))
   {
-    regfi_add_message(file, "ERROR: Invalid cell size encountered"
+    regfi_add_message(file, REGFI_MSG_WARN, "Invalid cell size encountered"
 		      " while parsing VK record at offset 0x%.8X.", offset);
     free(ret_val);
@@ -2006,5 +2029,5 @@
      *      0xFFFF. 
      */
-    regfi_add_message(file, "ERROR: Magic number mismatch"
+    regfi_add_message(file, REGFI_MSG_WARN, "Magic number mismatch"
 		      " while parsing VK record at offset 0x%.8X.", offset);
     free(ret_val);
@@ -2025,6 +2048,7 @@
     if(ret_val->name_length + REGFI_VK_MIN_LENGTH + 4 > ret_val->cell_size)
     {
-      regfi_add_message(file, "WARN: Name too long for remaining cell space"
-			" while parsing VK record at offset 0x%.8X.", offset);
+      regfi_add_message(file, REGFI_MSG_WARN, "Name too long for remaining cell"
+			" space while parsing VK record at offset 0x%.8X.",
+			offset);
       if(strict)
       {
@@ -2052,5 +2076,5 @@
        || length != ret_val->name_length)
     {
-      regfi_add_message(file, "ERROR: Could not read value name"
+      regfi_add_message(file, REGFI_MSG_ERROR, "Could not read value name"
 			" while parsing VK record at offset 0x%.8X.", offset);
       free(ret_val->valuename);
@@ -2093,5 +2117,5 @@
       else
       {
-	regfi_add_message(file, "WARN: Could not find hbin for data"
+	regfi_add_message(file, REGFI_MSG_WARN, "Could not find hbin for data"
 			  " while parsing VK record at offset 0x%.8X.", offset);
 	ret_val->data = NULL;
@@ -2101,5 +2125,5 @@
     if(ret_val->data == NULL)
     {
-      regfi_add_message(file, "WARN: Could not parse data record"
+      regfi_add_message(file, REGFI_MSG_WARN, "Could not parse data record"
 			" while parsing VK record at offset 0x%.8X.", offset);
     }
@@ -2124,5 +2148,5 @@
     if(length > 4)
     {
-      regfi_add_message(file, "ERROR: Data in offset but length > 4"
+      regfi_add_message(file, REGFI_MSG_ERROR, "Data in offset but length > 4"
 			" while parsing data record at offset 0x%.8X.", 
 			offset);
@@ -2141,5 +2165,5 @@
 			 &cell_length, &unalloc))
     {
-      regfi_add_message(file, "ERROR: Could not parse cell while"
+      regfi_add_message(file, REGFI_MSG_WARN, "Could not parse cell while"
 			" parsing data record at offset 0x%.8X.", offset);
       return NULL;
@@ -2148,5 +2172,5 @@
     if((cell_length & 0xFFFFFFF8) != cell_length)
     {
-      regfi_add_message(file, "ERROR: Cell length not multiple of 8"
+      regfi_add_message(file, REGFI_MSG_WARN, "Cell length not multiple of 8"
 			" while parsing data record at offset 0x%.8X.",
 			offset);
@@ -2156,5 +2180,5 @@
     if(cell_length > max_size)
     {
-      regfi_add_message(file, "WARN: Cell extends past hbin boundary"
+      regfi_add_message(file, REGFI_MSG_WARN, "Cell extends past hbin boundary"
 			" while parsing data record at offset 0x%.8X.", 
 			offset);
@@ -2171,5 +2195,5 @@
        *      such as 53392.
        */
-      regfi_add_message(file, "WARN: Data length (0x%.8X) larger than"
+      regfi_add_message(file, REGFI_MSG_WARN, "Data length (0x%.8X) larger than"
 			" remaining cell length (0x%.8X)"
 			" while parsing data record at offset 0x%.8X.", 
@@ -2188,5 +2212,5 @@
        || read_length != length)
     {
-      regfi_add_message(file, "ERROR: Could not read data block while"
+      regfi_add_message(file, REGFI_MSG_ERROR, "Could not read data block while"
 			" parsing data record at offset 0x%.8X.", offset);
       free(ret_val);
Index: /trunk/src/common.c
===================================================================
--- /trunk/src/common.c	(revision 137)
+++ /trunk/src/common.c	(revision 138)
@@ -38,7 +38,7 @@
 }
 
-void printMsgs(REGFI_ITERATOR* iter)
-{
-  char* msgs = regfi_get_messages(iter->f);
+void printMsgs(REGFI_FILE* f)
+{
+  char* msgs = regfi_get_messages(f);
   if(msgs != NULL)
   {
@@ -46,4 +46,11 @@
     free(msgs);
   }
+}
+
+void clearMsgs(REGFI_FILE* f)
+{
+  char* msgs = regfi_get_messages(f);
+  if(msgs != NULL)
+    free(msgs);
 }
 
Index: /trunk/src/reglookup-recover.c
===================================================================
--- /trunk/src/reglookup-recover.c	(revision 137)
+++ /trunk/src/reglookup-recover.c	(revision 138)
@@ -2,5 +2,5 @@
  * This program attempts to recover deleted data structures in a registry hive.
  *
- * Copyright (C) 2008 Timothy D. Morgan
+ * Copyright (C) 2008-2009 Timothy D. Morgan
  *
  * This program is free software; you can redistribute it and/or modify
@@ -87,5 +87,5 @@
     quoted_name[0] = '\0';
 
-    fprintf(stderr, "WARNING: NULL key name in NK record at offset %.8X.\n",
+    fprintf(stderr, "WARN: NULL key name in NK record at offset %.8X.\n",
 	    nk->offset);
   }
@@ -125,5 +125,5 @@
   if(size > REGFI_VK_MAX_DATA_LENGTH)
   {
-    fprintf(stderr, "WARNING: value data size %d larger than "
+    fprintf(stderr, "WARN: value data size %d larger than "
 	    "%d, truncating...\n", size, REGFI_VK_MAX_DATA_LENGTH);
     size = REGFI_VK_MAX_DATA_LENGTH;
@@ -153,13 +153,13 @@
 
     if(conv_error == NULL)
-      fprintf(stderr, "WARNING: Could not quote value for '%s/%s'.  "
+      fprintf(stderr, "WARN: Could not quote value for '%s/%s'.  "
 	      "Memory allocation failure likely.\n", prefix, quoted_name);
     else if(print_verbose)
-      fprintf(stderr, "WARNING: Could not quote value for '%s/%s'.  "
+      fprintf(stderr, "WARN: Could not quote value for '%s/%s'.  "
 	      "Returned error: %s\n", prefix, quoted_name, conv_error);
   }
   /* XXX: should these always be printed? */
   else if(conv_error != NULL && print_verbose)
-    fprintf(stderr, "VERBOSE: While quoting value for '%s/%s', "
+    fprintf(stderr, "INFO: While quoting value for '%s/%s', "
 	    "warning returned: %s\n", prefix, quoted_name, conv_error);
 
@@ -279,4 +279,6 @@
       cur_ancestor = regfi_parse_nk(f, virt_offset+REGFI_REGF_SIZE, 
 				    max_length, true);
+      printMsgs(f);
+
       if(cur_ancestor == NULL)
 	virt_offset = REGFI_OFFSET_NONE;
@@ -426,4 +428,5 @@
   for(i=0; i < range_list_size(unalloc_cells); i++)
   {
+    printMsgs(f);
     cur_elem = range_list_get(unalloc_cells, i);
     for(j=0; cur_elem->length > REGFI_NK_MIN_LENGTH 
@@ -432,4 +435,6 @@
       key = regfi_parse_nk(f, cur_elem->offset+j,
 			   cur_elem->length-j, false);
+      printMsgs(f);
+
       if(key != NULL)
       {
@@ -587,4 +592,5 @@
   for(i=0; i < range_list_size(unalloc_cells); i++)
   {
+    printMsgs(f);
     cur_elem = range_list_get(unalloc_cells, i);
     for(j=0; j <= cur_elem->length; j+=8)
@@ -592,4 +598,6 @@
       vk = regfi_parse_vk(f, cur_elem->offset+j, 
 			   cur_elem->length-j, false);
+      printMsgs(f);
+
       if(vk != NULL)
       {
@@ -654,4 +662,5 @@
   for(i=0; i < range_list_size(unalloc_cells); i++)
   {
+    printMsgs(f);
     cur_elem = range_list_get(unalloc_cells, i);
     for(j=0; j <= cur_elem->length; j+=8)
@@ -659,4 +668,6 @@
       sk = regfi_parse_sk(f, cur_elem->offset+j, 
 			  cur_elem->length-j, false);
+      printMsgs(f);
+
       if(sk != NULL)
       {
@@ -741,4 +752,8 @@
     bailOut(EX_NOINPUT, "");
   }
+  if(print_verbose)
+    regfi_set_message_mask(f, REGFI_MSG_ERROR|REGFI_MSG_WARN|REGFI_MSG_INFO);
+  else
+    regfi_set_message_mask(f, REGFI_MSG_ERROR);
 
   if(print_header)
Index: /trunk/src/reglookup.c
===================================================================
--- /trunk/src/reglookup.c	(revision 137)
+++ /trunk/src/reglookup.c	(revision 138)
@@ -86,17 +86,26 @@
   }
 
-  quoted_value = data_to_ascii(vk->data, size, vk->type, &conv_error);
-  if(quoted_value == NULL)
-  {
-    if(conv_error == NULL)
-      fprintf(stderr, "WARN: Could not quote value for '%s/%s'.  "
-	      "Memory allocation failure likely.\n", prefix, quoted_name);
-    else if(print_verbose)
-      fprintf(stderr, "WARN: Could not quote value for '%s/%s'.  "
-	      "Returned error: %s\n", prefix, quoted_name, conv_error);
-  }
-  else if(conv_error != NULL && print_verbose)
-    fprintf(stderr, "VERBOSE: While quoting value for '%s/%s', "
-	    "warning returned: %s\n", prefix, quoted_name, conv_error);
+  if(vk->data == NULL)
+  {
+    if(print_verbose)
+      fprintf(stderr, "INFO: While quoting value for '%s/%s', "
+	      "data pointer was NULL.\n", prefix, quoted_name);
+  }
+  else
+  {
+    quoted_value = data_to_ascii(vk->data, size, vk->type, &conv_error);
+    if(quoted_value == NULL)
+    {
+      if(conv_error == NULL)
+	fprintf(stderr, "WARN: Could not quote value for '%s/%s'.  "
+		"Memory allocation failure likely.\n", prefix, quoted_name);
+      else
+	fprintf(stderr, "WARN: Could not quote value for '%s/%s'.  "
+		"Returned error: %s\n", prefix, quoted_name, conv_error);
+    }
+    else if(conv_error != NULL && print_verbose)
+      fprintf(stderr, "INFO: While quoting value for '%s/%s', "
+	      "warning returned: %s\n", prefix, quoted_name, conv_error);
+  }
 
   str_type = regfi_type_val2str(vk->type);
@@ -275,5 +284,5 @@
       printValue(value, prefix);
     value = regfi_iterator_next_value(iter);
-    printMsgs(iter);
+    printMsgs(iter->f);
   }
 }
@@ -333,5 +342,5 @@
       {
 	if(print_verbose)
-	  fprintf(stderr, "WARN: While converting classname"
+	  fprintf(stderr, "INFO: While converting classname"
 		  " for key '%s': %s.\n", full_path, error_msg);
 	free(error_msg);
@@ -341,5 +350,5 @@
       quoted_classname = empty_str;
 
-    printMsgs(iter);
+    printMsgs(iter->f);
     printf("%s,KEY,,%s,%s,%s,%s,%s,%s\n", full_path, mtime, 
 	   owner, group, sacl, dacl, quoted_classname);
@@ -372,5 +381,5 @@
   root = cur = regfi_iterator_cur_key(iter);
   sub = regfi_iterator_first_subkey(iter);
-  printMsgs(iter);
+  printMsgs(iter->f);
 
   if(root == NULL)
@@ -400,5 +409,5 @@
 	if(!regfi_iterator_up(iter))
 	{
-	  printMsgs(iter);
+	  printMsgs(iter->f);
 	  bailOut(EX_DATAERR, "ERROR: could not traverse iterator upward.\n");
 	}
@@ -407,5 +416,5 @@
 	if(cur == NULL)
 	{
-	  printMsgs(iter);
+	  printMsgs(iter->f);
 	  bailOut(EX_DATAERR, "ERROR: unexpected NULL for key.\n");
 	}
@@ -421,5 +430,5 @@
       if(!regfi_iterator_down(iter))
       {
-	printMsgs(iter);
+	printMsgs(iter->f);
 	bailOut(EX_DATAERR, "ERROR: could not traverse iterator downward.\n");
       }
@@ -429,9 +438,9 @@
       print_this = true;
     }
-    printMsgs(iter);
+    printMsgs(iter->f);
   } while(!((cur == root) && (sub == NULL)));
 
   if(print_verbose)
-    fprintf(stderr, "VERBOSE: Finished printing key tree.\n");
+    fprintf(stderr, "INFO: Finished printing key tree.\n");
 }
 
@@ -467,5 +476,5 @@
 
   if(print_verbose)
-    fprintf(stderr, "VERBOSE: Attempting to retrieve specified path: %s\n",
+    fprintf(stderr, "INFO: Attempting to retrieve specified path: %s\n",
 	    path_filter);
 
@@ -474,5 +483,5 @@
   {
     if(print_verbose)
-      fprintf(stderr, "VERBOSE: Found final path element as root key.\n");
+      fprintf(stderr, "INFO: Found final path element as root key.\n");
     free(tmp_path);
     return 2;
@@ -481,5 +490,5 @@
   if(!regfi_iterator_walk_path(iter, tmp_path))
   {
-    printMsgs(iter);
+    printMsgs(iter->f);
     free(tmp_path);
     return 0;
@@ -489,8 +498,8 @@
   {
     if(print_verbose)
-      fprintf(stderr, "VERBOSE: Found final path element as value.\n");
+      fprintf(stderr, "INFO: Found final path element as value.\n");
 
     value = regfi_iterator_cur_value(iter);
-    printMsgs(iter);
+    printMsgs(iter->f);
     tmp_path_joined = iter2Path(iter);
 
@@ -507,11 +516,11 @@
   else if(regfi_iterator_find_subkey(iter, path[i]))
   {
-    printMsgs(iter);
+    printMsgs(iter->f);
     if(print_verbose)
-      fprintf(stderr, "VERBOSE: Found final path element as key.\n");
+      fprintf(stderr, "INFO: Found final path element as key.\n");
 
     if(!regfi_iterator_down(iter))
     {
-      printMsgs(iter);
+      printMsgs(iter->f);
       bailOut(EX_DATAERR, "ERROR: Unexpected error on traversing path filter key.\n");
     }
@@ -519,8 +528,8 @@
     return 2;
   }
-  printMsgs(iter);
+  printMsgs(iter->f);
 
   if(print_verbose)
-    fprintf(stderr, "VERBOSE: Could not find last element of path.\n");
+    fprintf(stderr, "INFO: Could not find last element of path.\n");
 
   return 0;
@@ -616,4 +625,7 @@
   }
 
+  if(print_verbose)
+    regfi_set_message_mask(f, REGFI_MSG_INFO|REGFI_MSG_WARN|REGFI_MSG_ERROR);
+
   iter = regfi_iterator_new(f);
   if(iter == NULL)
@@ -634,5 +646,5 @@
   {
     retr_path_ret = retrievePath(iter, path);
-    printMsgs(iter);
+    printMsgs(iter->f);
     freePath(path);
 
