Index: trunk/Makefile
===================================================================
--- trunk/Makefile	(revision 87)
+++ trunk/Makefile	(revision 88)
@@ -11,10 +11,10 @@
 
 CC=gcc
-OPTS=-std=gnu89 -pedantic -Wall -ggdb
+OPTS=-std=gnu89 -pedantic -Wall
 INC=-I/usr/local/include
 LIB=-L/usr/local/lib
 
 UNAME := $(shell uname)
-ifeq ($(UNAME),FreeBSD) 	
+ifneq ($(UNAME),Linux) 	
   LIB:=$(LIB) -liconv
 endif
Index: trunk/src/reglookup.c
===================================================================
--- trunk/src/reglookup.c	(revision 87)
+++ trunk/src/reglookup.c	(revision 88)
@@ -24,4 +24,5 @@
 
 #include <stdlib.h>
+#include <sysexits.h>
 #include <stdio.h>
 #include <string.h>
@@ -409,5 +410,5 @@
       copy = (char*)malloc((next-cur+1)*sizeof(char));
       if(copy == NULL)
-	bailOut(2, "ERROR: Memory allocation problem.\n");
+	bailOut(EX_OSERR, "ERROR: Memory allocation problem.\n");
 	  
       memcpy(copy, cur, next-cur);
@@ -417,5 +418,5 @@
 	ret_val[ret_cur] = NULL;
       else
-	bailOut(2, "ERROR: Registry maximum depth exceeded.\n");
+	bailOut(EX_DATAERR, "ERROR: Registry maximum depth exceeded.\n");
     }
     cur = next+1;
@@ -430,5 +431,5 @@
       ret_val[ret_cur] = NULL;
     else
-      bailOut(2, "ERROR: Registry maximum depth exceeded.\n");
+      bailOut(EX_DATAERR, "ERROR: Registry maximum depth exceeded.\n");
   }
 
@@ -575,4 +576,11 @@
    */
   quoted_name = quote_string(vk->valuename, common_special_chars);
+  if (quoted_name == NULL)
+  {
+    quoted_name = malloc(1*sizeof(char));
+    if(quoted_name == NULL)
+      bailOut(EX_OSERR, "ERROR: Could not allocate sufficient memory.\n");
+    quoted_name[0] = '\0';
+  }
 
   if(quoted_value == NULL)
@@ -693,5 +701,5 @@
   
   if(root == NULL)
-    bailOut(3, "ERROR: root cannot be NULL.\n");
+    bailOut(EX_DATAERR, "ERROR: root cannot be NULL.\n");
   
   do
@@ -701,5 +709,5 @@
       path = iter2Path(iter);
       if(path == NULL)
-	bailOut(2, "ERROR: Could not construct iterator's path.\n");
+	bailOut(EX_OSERR, "ERROR: Could not construct iterator's path.\n");
       
       if(!type_filter_enabled || (key_type == type_filter))
@@ -717,9 +725,9 @@
 	/* We're done with this sub-tree, going up and hitting other branches. */
 	if(!regfi_iterator_up(iter))
-	  bailOut(3, "ERROR: could not traverse iterator upward.\n");
+	  bailOut(EX_DATAERR, "ERROR: could not traverse iterator upward.\n");
 	
 	cur = regfi_iterator_cur_key(iter);
 	if(cur == NULL)
-	  bailOut(3, "ERROR: unexpected NULL for key.\n");
+	  bailOut(EX_DATAERR, "ERROR: unexpected NULL for key.\n");
 	
 	sub = regfi_iterator_next_subkey(iter);
@@ -732,5 +740,5 @@
        */
       if(!regfi_iterator_down(iter))
-	bailOut(3, "ERROR: could not traverse iterator downward.\n");
+	bailOut(EX_DATAERR, "ERROR: could not traverse iterator downward.\n");
 
       cur = sub;
@@ -802,5 +810,5 @@
 
     if((value == NULL) || (tmp_path_joined == NULL))
-      bailOut(2, "ERROR: Unexpected error before printValue.\n");
+      bailOut(EX_OSERR, "ERROR: Unexpected error before printValue.\n");
 
     printValue(value, tmp_path_joined);
@@ -816,5 +824,5 @@
 
     if(!regfi_iterator_down(iter))
-      bailOut(2, "ERROR: Unexpected error on traversing path filter key.\n");
+      bailOut(EX_DATAERR, "ERROR: Unexpected error on traversing path filter key.\n");
 
     return 2;
@@ -858,5 +866,5 @@
   {
     usage();
-    bailOut(1, "ERROR: Requires at least one argument.\n");
+    bailOut(EX_USAGE, "ERROR: Requires at least one argument.\n");
   }
   
@@ -869,8 +877,8 @@
       {
 	usage();
-	bailOut(1, "ERROR: '-p' option requires parameter.\n");
+	bailOut(EX_USAGE, "ERROR: '-p' option requires parameter.\n");
       }
       if((path_filter = strdup(argv[argi])) == NULL)
-	bailOut(2, "ERROR: Memory allocation problem.\n");
+	bailOut(EX_OSERR, "ERROR: Memory allocation problem.\n");
 
       path_filter_enabled = true;
@@ -881,10 +889,10 @@
       {
 	usage();
-	bailOut(1, "ERROR: '-t' option requires parameter.\n");
+	bailOut(EX_USAGE, "ERROR: '-t' option requires parameter.\n");
       }
       if((type_filter = regfi_type_str2val(argv[argi])) < 0)
       {
 	fprintf(stderr, "ERROR: Invalid type specified: %s.\n", argv[argi]);
-	bailOut(1, "");
+	bailOut(EX_USAGE, "");
       }
       type_filter_enabled = true;
@@ -904,9 +912,9 @@
       usage();
       fprintf(stderr, "ERROR: Unrecognized option: %s\n", argv[argi]);
-      bailOut(1, "");
+      bailOut(EX_USAGE, "");
     }
   }
   if((registry_file = strdup(argv[argi])) == NULL)
-    bailOut(2, "ERROR: Memory allocation problem.\n");
+    bailOut(EX_OSERR, "ERROR: Memory allocation problem.\n");
 
   f = regfi_open(registry_file);
@@ -914,10 +922,10 @@
   {
     fprintf(stderr, "ERROR: Couldn't open registry file: %s\n", registry_file);
-    bailOut(3, "");
+    bailOut(EX_NOINPUT, "");
   }
 
   iter = regfi_iterator_new(f);
   if(iter == NULL)
-    bailOut(3, "ERROR: Couldn't create registry iterator.\n");
+    bailOut(EX_OSERR, "ERROR: Couldn't create registry iterator.\n");
 
   if(print_header)
@@ -942,5 +950,5 @@
       printKeyTree(iter);
     else if(retr_path_ret != 0)
-      bailOut(4, "ERROR: Unknown error occurred in retrieving path.\n");
+      bailOut(EX_DATAERR, "ERROR: Unknown error occurred in retrieving path.\n");
   }
   else
