Index: trunk/include/regfio.h
===================================================================
--- trunk/include/regfio.h	(revision 52)
+++ trunk/include/regfio.h	(revision 53)
@@ -102,17 +102,16 @@
 struct regf_hbin;
 typedef struct regf_hbin {
-	struct regf_hbin *prev, *next;
-	uint32 file_off;		/* my offset in the registry file */
-	uint32 free_off;		/* offset to free space within the hbin record */
-	uint32 free_size;		/* amount of data left in the block */
-	int ref_count;			/* how many active records are pointing to this block (not used currently) */
+  struct regf_hbin* prev;
+  struct regf_hbin* next;
+  uint32 file_off;       /* my offset in the registry file */
+  uint32 free_off;       /* offset to free space within the hbin record */
+  uint32 free_size;      /* amount of data left in the block */
+  int    ref_count;      /* how many active records are pointing to this block (not used currently) */
 	
-	char   header[HBIN_HDR_SIZE];	/* "hbin" */
-	uint32 first_hbin_off;		/* offset from first hbin block */
-	uint32 block_size;		/* block size of this blockually a multiple of 4096Kb) */
-
-	prs_struct ps;			/* data */
-
-	bool dirty;			/* has this hbin block been modified? */
+  uint8  header[HBIN_HDR_SIZE]; /* "hbin" */
+  uint32 first_hbin_off; /* offset from first hbin block */
+  uint32 block_size;     /* block size of this blockually a multiple of 4096Kb) */
+  prs_struct ps;	       /* data */
+  bool dirty;            /* has this hbin block been modified? */
 } REGF_HBIN;
 
@@ -120,16 +119,16 @@
 
 typedef struct {
-	uint32 nk_off;
-	uint8 keycheck[sizeof(uint32)];
+  uint32 nk_off;
+  uint8 keycheck[sizeof(uint32)];
 } REGF_HASH_REC;
 
 typedef struct {
-	REGF_HBIN *hbin;	/* pointer to HBIN record (in memory) containing this nk record */
-	uint32 hbin_off;	/* offset from beginning of this hbin block */
-	uint32 rec_size;	/* ((start_offset - end_offset) & 0xfffffff8) */
-
-	char header[REC_HDR_SIZE];
-	uint16 num_keys;
-	REGF_HASH_REC *hashes;
+  REGF_HBIN *hbin;	/* pointer to HBIN record (in memory) containing this nk record */
+  uint32 hbin_off;	/* offset from beginning of this hbin block */
+  uint32 rec_size;	/* ((start_offset - end_offset) & 0xfffffff8) */
+  
+  uint8 header[REC_HDR_SIZE];
+  uint16 num_keys;
+  REGF_HASH_REC *hashes;
 } REGF_LF_REC;
 
@@ -137,16 +136,16 @@
 
 typedef struct {
-	REGF_HBIN *hbin;	/* pointer to HBIN record (in memory) containing this nk record */
-	uint32 hbin_off;	/* offset from beginning of this hbin block */
-	uint32 rec_size;	/* ((start_offset - end_offset) & 0xfffffff8) */
-	uint32 rec_off;		/* offset stored in the value list */
-	
-	char header[REC_HDR_SIZE];
-	char *valuename;
-	uint32 data_size;
-	uint32 data_off;
-	uint8  *data;
-	uint32 type;
-	uint16 flag;
+  REGF_HBIN *hbin;	/* pointer to HBIN record (in memory) containing this nk record */
+  uint32 hbin_off;	/* offset from beginning of this hbin block */
+  uint32 rec_size;	/* ((start_offset - end_offset) & 0xfffffff8) */
+  uint32 rec_off;		/* offset stored in the value list */
+  
+  uint8  header[REC_HDR_SIZE];
+  char*  valuename;
+  uint32 data_size;
+  uint32 data_off;
+  uint8* data;
+  uint32 type;
+  uint16 flag;
 } REGF_VK_REC;
 
@@ -156,18 +155,18 @@
 
 typedef struct _regf_sk_rec {
-	struct _regf_sk_rec *next, *prev;
-	REGF_HBIN *hbin;	/* pointer to HBIN record (in memory) containing this nk record */
-	uint32 hbin_off;	/* offset from beginning of this hbin block */
-	uint32 rec_size;	/* ((start_offset - end_offset) & 0xfffffff8) */
-
-	uint32 sk_off;		/* offset parsed from NK record used as a key
+  struct _regf_sk_rec *next, *prev;
+  REGF_HBIN *hbin;	/* pointer to HBIN record (in memory) containing this nk record */
+  uint32 hbin_off;	/* offset from beginning of this hbin block */
+  uint32 rec_size;	/* ((start_offset - end_offset) & 0xfffffff8) */
+  
+  uint32 sk_off;		/* offset parsed from NK record used as a key
 				   to lookup reference to this SK record */
-
-	char header[REC_HDR_SIZE];
-	uint32 prev_sk_off;
-	uint32 next_sk_off;
-	uint32 ref_count;
-	uint32 size;
-	SEC_DESC *sec_desc;
+  
+  uint8  header[REC_HDR_SIZE];
+  uint32 prev_sk_off;
+  uint32 next_sk_off;
+  uint32 ref_count;
+  uint32 size;
+  SEC_DESC *sec_desc;
 } REGF_SK_REC;
 
@@ -175,43 +174,43 @@
 
 typedef struct {
-	REGF_HBIN *hbin;	/* pointer to HBIN record (in memory) containing this nk record */
-	uint32 hbin_off;	/* offset from beginning of this hbin block */
-	uint32 subkey_index;	/* index to next subkey record to return */
-	uint32 rec_size;	/* ((start_offset - end_offset) & 0xfffffff8) */
-	
-	/* header information */
-	
-	char header[REC_HDR_SIZE];
-	uint16 key_type;
-	NTTIME mtime;
-	uint32 parent_off;	/* back pointer in registry hive */
-	uint32 classname_off;	
-	char *classname;
-	char *keyname;
-
-	/* max lengths */
-
-	uint32 max_bytes_subkeyname;		/* max subkey name * 2 */
-	uint32 max_bytes_subkeyclassname;	/* max subkey classname length (as if) */
-	uint32 max_bytes_valuename;		/* max valuename * 2 */
-	uint32 max_bytes_value;			/* max value data size */
-
-	/* unknowns */
-
-	uint32 unk_index;			/* nigel says run time index ? */
-	
-	/* children */
-	
-	uint32 num_subkeys;
-	uint32 subkeys_off;	/* hash records that point to NK records */	
-	uint32 num_values;
-	uint32 values_off;	/* value lists which point to VK records */
-	uint32 sk_off;		/* offset to SK record */
-	
-	/* link in the other records here */
-	
-	REGF_LF_REC subkeys;
-	REGF_VK_REC *values;
-	REGF_SK_REC *sec_desc;
+  REGF_HBIN *hbin;	/* pointer to HBIN record (in memory) containing this nk record */
+  uint32 hbin_off;	/* offset from beginning of this hbin block */
+  uint32 subkey_index;	/* index to next subkey record to return */
+  uint32 rec_size;	/* ((start_offset - end_offset) & 0xfffffff8) */
+  
+  /* header information */
+  
+  uint8  header[REC_HDR_SIZE];
+  uint16 key_type;
+  NTTIME mtime;
+  uint32 parent_off;	/* back pointer in registry hive */
+  uint32 classname_off;	
+  char *classname;
+  char *keyname;
+  
+  /* max lengths */
+  
+  uint32 max_bytes_subkeyname;		/* max subkey name * 2 */
+  uint32 max_bytes_subkeyclassname;	/* max subkey classname length (as if) */
+  uint32 max_bytes_valuename;		/* max valuename * 2 */
+  uint32 max_bytes_value;			/* max value data size */
+  
+  /* unknowns */
+  
+  uint32 unk_index;			/* nigel says run time index ? */
+  
+  /* children */
+  
+  uint32 num_subkeys;
+  uint32 subkeys_off;	/* hash records that point to NK records */	
+  uint32 num_values;
+  uint32 values_off;	/* value lists which point to VK records */
+  uint32 sk_off;		/* offset to SK record */
+  
+  /* link in the other records here */
+  
+  REGF_LF_REC subkeys;
+  REGF_VK_REC *values;
+  REGF_SK_REC *sec_desc;
 	
 } REGF_NK_REC;
@@ -220,31 +219,31 @@
  
 typedef struct {
-	/* run time information */
-
-	int fd;				/* file descriptor */
-	int open_flags;			/* flags passed to the open() call */
-	void *mem_ctx;		/* memory context for run-time file access information */
-	REGF_HBIN *block_list;		/* list of open hbin blocks */
-
-	/* file format information */
-
-	char   header[REGF_HDR_SIZE];	/* "regf" */
-	uint32 data_offset;		/* offset to record in the first (or any?) hbin block */
-	uint32 last_block;		/* offset to last hbin block in file */
-	uint32 checksum;		/* XOR of bytes 0x0000 - 0x01FB */
-	NTTIME mtime;
-	
-	REGF_SK_REC *sec_desc_list;	/* list of security descriptors referenced by NK records */
-
-	/* unknowns used to simply writing */
-	
-	uint32 unknown1;
-	uint32 unknown2;
-	uint32 unknown3;
-	uint32 unknown4;
-	uint32 unknown5;
-	uint32 unknown6;
-	
+  /* run time information */
+  
+  int fd;				/* file descriptor */
+  int open_flags;			/* flags passed to the open() call */
+  void *mem_ctx;		/* memory context for run-time file access information */
+  REGF_HBIN *block_list;		/* list of open hbin blocks */
+  
+  /* file format information */
+  
+  uint8  header[REGF_HDR_SIZE];	/* "regf" */
+  uint32 data_offset;		/* offset to record in the first (or any?) hbin block */
+  uint32 last_block;		/* offset to last hbin block in file */
+  uint32 checksum;		/* XOR of bytes 0x0000 - 0x01FB */
+  NTTIME mtime;
+  
+  REGF_SK_REC *sec_desc_list;	/* list of security descriptors referenced by NK records */
+  
+  /* unknowns used to simply writing */
+  
+  uint32 unknown1;
+  uint32 unknown2;
+  uint32 unknown3;
+  uint32 unknown4;
+  uint32 unknown5;
+  uint32 unknown6;
 } REGF_FILE;
+
 
 /* Function Declarations */
@@ -253,4 +252,9 @@
 int           regfio_type_str2val(const char* str);
 
+char*         regfio_get_sacl(SEC_DESC *sec_desc);
+char*         regfio_get_dacl(SEC_DESC *sec_desc);
+char*         regfio_get_owner(SEC_DESC *sec_desc);
+char*         regfio_get_group(SEC_DESC *sec_desc);
+
 REGF_FILE*    regfio_open( const char *filename );
 int           regfio_close( REGF_FILE *r );
Index: trunk/include/smb_deps.h
===================================================================
--- trunk/include/smb_deps.h	(revision 52)
+++ trunk/include/smb_deps.h	(revision 53)
@@ -184,5 +184,6 @@
 		     uint16 *data16, uint32 ptr_uint16, uint32 start_offset);
 bool prs_uint8(const char *name, prs_struct *ps, int depth, uint8 *data8);
-bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth, uint8 *data8s, int len);
+bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth, 
+		uint8* data8s, int len);
 bool prs_set_offset(prs_struct *ps, uint32 offset);
 
Index: trunk/lib/regfio.c
===================================================================
--- trunk/lib/regfio.c	(revision 52)
+++ trunk/lib/regfio.c	(revision 53)
@@ -29,10 +29,4 @@
 
 
-/*******************************************************************
- *
- * TODO : Right now this code basically ignores classnames.
- *
- ******************************************************************/
-
 /* Registry types mapping */
 const VAL_STR reg_type_names[] = 
@@ -79,4 +73,179 @@
 
 
+/* Security descriptor parsing functions  */
+
+const char* regfio_ace_type2str(uint8 type)
+{
+  static const char* map[7] 
+    = {"ALLOW", "DENY", "AUDIT", "ALARM", 
+       "ALLOW CPD", "OBJ ALLOW", "OBJ DENY"};
+  if(type < 7)
+    return map[type];
+  else
+    /* XXX: would be nice to return the unknown integer value.  
+     *      However, as it is a const string, it can't be free()ed later on, 
+     *      so that would need to change. 
+     */
+    return "UNKNOWN";
+}
+
+
+/* XXX: this could probably be more efficient */
+char* regfio_ace_flags2str(uint8 flags)
+{
+  char* flg_output = malloc(21*sizeof(char));
+  int some = 0;
+
+  if(flg_output == NULL)
+    return NULL;
+
+  flg_output[0] = '\0';
+  if (!flags)
+    return flg_output;
+
+  if (flags & 0x01) {
+    if (some) strcat(flg_output, " ");
+    some = 1;
+    strcat(flg_output, "OI");
+  }
+  if (flags & 0x02) {
+    if (some) strcat(flg_output, " ");
+    some = 1;
+    strcat(flg_output, "CI");
+  }
+  if (flags & 0x04) {
+    if (some) strcat(flg_output, " ");
+    some = 1;
+    strcat(flg_output, "NP");
+  }
+  if (flags & 0x08) {
+    if (some) strcat(flg_output, " ");
+    some = 1;
+    strcat(flg_output, "IO");
+  }
+  if (flags & 0x10) {
+    if (some) strcat(flg_output, " ");
+    some = 1;
+    strcat(flg_output, "IA");
+  }
+  if (flags == 0xF) {
+    if (some) strcat(flg_output, " ");
+    some = 1;
+    strcat(flg_output, "VI");
+  }
+
+  return flg_output;
+}
+
+
+char* regfio_ace_perms2str(uint32 perms)
+{
+  char* ret_val = malloc(9*sizeof(char));
+  if(ret_val == NULL)
+    return NULL;
+
+  /* XXX: this should probably be parsed better */
+  sprintf(ret_val, "%.8X", perms);
+
+  return ret_val;
+}
+
+
+char* regfio_sid2str(DOM_SID* sid)
+{
+  uint32 i, size = MAXSUBAUTHS*11 + 24;
+  uint32 left = size;
+  uint8 comps = sid->num_auths;
+  char* ret_val = malloc(size);
+  
+  if(ret_val == NULL)
+    return NULL;
+
+  if(comps > MAXSUBAUTHS)
+    comps = MAXSUBAUTHS;
+
+  left -= sprintf(ret_val, "S-%u-%u", sid->sid_rev_num, sid->id_auth[5]);
+
+  for (i = 0; i < comps; i++) 
+    left -= snprintf(ret_val+(size-left), left, "-%u", sid->sub_auths[i]);
+
+  return ret_val;
+}
+
+
+char* regfio_get_acl(SEC_ACL* acl)
+{
+  uint32 i, extra, size = 0;
+  const char* type_str;
+  char* flags_str;
+  char* perms_str;
+  char* sid_str;
+  char* ret_val = NULL;
+  char* ace_delim = "";
+  char field_delim = ':';
+
+  for (i = 0; i < acl->num_aces; i++)
+  {
+    sid_str = regfio_sid2str(&acl->ace[i].trustee);
+    type_str = regfio_ace_type2str(acl->ace[i].type);
+    perms_str = regfio_ace_perms2str(acl->ace[i].info.mask);
+    flags_str = regfio_ace_flags2str(acl->ace[i].flags);
+    
+    if(flags_str == NULL || perms_str == NULL 
+       || type_str == NULL || sid_str == NULL)
+      return NULL;
+
+    /* XXX: this is slow */
+    extra = strlen(sid_str) + strlen(type_str) 
+          + strlen(perms_str) + strlen(flags_str)+5;
+    ret_val = realloc(ret_val, size+extra);
+    if(ret_val == NULL)
+      return NULL;
+    size += snprintf(ret_val+size, extra, "%s%s%c%s%c%s%c%s",
+		     ace_delim,sid_str,
+		     field_delim,type_str,
+		     field_delim,perms_str,
+		     field_delim,flags_str);
+    ace_delim = "|";
+    free(sid_str);
+    free(perms_str);
+    free(flags_str);
+  }
+
+  return ret_val;
+}
+
+
+char* regfio_get_sacl(SEC_DESC *sec_desc)
+{
+  if (sec_desc->sacl)
+    return regfio_get_acl(sec_desc->sacl);
+  else
+    return NULL;
+}
+
+
+char* regfio_get_dacl(SEC_DESC *sec_desc)
+{
+  if (sec_desc->dacl)
+    return regfio_get_acl(sec_desc->dacl);
+  else
+    return NULL;
+}
+
+
+char* regfio_get_owner(SEC_DESC *sec_desc)
+{
+  return regfio_sid2str(sec_desc->owner_sid);
+}
+
+
+char* regfio_get_group(SEC_DESC *sec_desc)
+{
+  return regfio_sid2str(sec_desc->grp_sid);
+}
+
+
+
 /*******************************************************************
  *******************************************************************/
@@ -117,5 +286,5 @@
     /* make sure this is an hbin header */
 
-    if ( strncmp( hdr, "hbin", HBIN_HDR_SIZE ) != 0 ) {
+    if ( strncmp( (char*)hdr, "hbin", HBIN_HDR_SIZE ) != 0 ) {
       /*DEBUG(0,("read_block: invalid block header!\n"));*/
       return -1;
@@ -161,9 +330,10 @@
 /*******************************************************************
  *******************************************************************/
-static bool prs_regf_block( const char *desc, prs_struct *ps, int depth, REGF_FILE *file )
+static bool prs_regf_block(const char *desc, prs_struct *ps, 
+			   int depth, REGF_FILE *file)
 {
   depth++;
 	
-  if ( !prs_uint8s( true, "header", ps, depth, file->header, sizeof( file->header )) )
+  if(!prs_uint8s(true, "header", ps, depth, file->header, sizeof(file->header)))
     return false;
 	
@@ -220,5 +390,6 @@
 /*******************************************************************
  *******************************************************************/
-static bool prs_hbin_block( const char *desc, prs_struct *ps, int depth, REGF_HBIN *hbin )
+static bool prs_hbin_block(const char *desc, prs_struct *ps, 
+			   int depth, REGF_HBIN *hbin)
 {
   uint32 block_size2;
@@ -226,5 +397,5 @@
   depth++;
 	
-  if ( !prs_uint8s( true, "header", ps, depth, hbin->header, sizeof( hbin->header )) )
+  if(!prs_uint8s(true, "header", ps, depth, hbin->header, sizeof(hbin->header)))
     return false;
 
@@ -336,8 +507,8 @@
 	return false;
 
-    if ( !prs_uint8s( true, "name", ps, depth, nk->keyname, name_length) )
-      return false;
-
-    if ( ps->io ) 
+    if(!prs_uint8s(true, "name", ps, depth, (uint8*)nk->keyname, name_length))
+      return false;
+
+    if(ps->io)
       nk->keyname[name_length] = '\0';
   }
@@ -583,5 +754,6 @@
 /*******************************************************************
  *******************************************************************/
-static bool hbin_prs_lf_records( const char *desc, REGF_HBIN *hbin, int depth, REGF_NK_REC *nk )
+static bool hbin_prs_lf_records(const char *desc, REGF_HBIN *hbin, 
+				int depth, REGF_NK_REC *nk)
 {
   int i;
@@ -609,5 +781,6 @@
     return false;
 
-  if ( !prs_uint8s( true, "header", &hbin->ps, depth, lf->header, sizeof( lf->header )) )
+  if(!prs_uint8s(true, "header", &hbin->ps, depth, 
+		 lf->header, sizeof(lf->header)))
     return false;
 		
@@ -662,5 +835,5 @@
     return false;
 
-  if ( !prs_uint8s( true, "header", ps, depth, sk->header, sizeof( sk->header )) )
+  if (!prs_uint8s(true, "header", ps, depth, sk->header, sizeof(sk->header)))
     return false;
   if ( !prs_uint16( "tag", ps, depth, &tag))
@@ -743,5 +916,6 @@
 	return false;
     }
-    if ( !prs_uint8s( true, "name", ps, depth, vk->valuename, name_length ) )
+    if ( !prs_uint8s(true, "name", ps, depth, 
+		     (uint8*)vk->valuename, name_length) )
       return false;
   }
@@ -1017,5 +1191,5 @@
 static bool next_record( REGF_HBIN *hbin, const char *hdr, bool *eob )
 {
-  char header[REC_HDR_SIZE] = "";
+  uint8 header[REC_HDR_SIZE] = "";
   uint32 record_size;
   uint32 curr_off, block_size;
Index: trunk/lib/smb_deps.c
===================================================================
--- trunk/lib/smb_deps.c	(revision 52)
+++ trunk/lib/smb_deps.c	(revision 53)
@@ -427,5 +427,6 @@
  Stream an array of uint8s. Length is number of uint8s.
  ********************************************************************/
-bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth, uint8 *data8s, int len)
+bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth, 
+		uint8* data8s, int len)
 {
 	int i;
Index: trunk/src/reglookup.c
===================================================================
--- trunk/src/reglookup.c	(revision 52)
+++ trunk/src/reglookup.c	(revision 53)
@@ -146,7 +146,4 @@
   {
   case REG_SZ:
-    if (print_verbose)
-      fprintf(stderr, "Len: %d\n", len);
-    
     ascii_max = sizeof(char)*len;
     ascii = malloc(ascii_max+4);
@@ -263,166 +260,4 @@
 
   return NULL;
-}
-
-
-/* Security descriptor print functions  */
-/* XXX: these functions should be moved out into regfio library */
-const char* ace_type2str(uint8 type)
-{
-  static const char* map[7] 
-    = {"ALLOW", "DENY", "AUDIT", "ALARM", 
-       "ALLOW CPD", "OBJ ALLOW", "OBJ DENY"};
-  if(type < 7)
-    return map[type];
-  else
-    return "UNKNOWN";
-}
-
-
-char* ace_flags2str(uint8 flags)
-{
-  char* flg_output = malloc(21*sizeof(char));
-  int some = 0;
-
-  if(flg_output == NULL)
-    return NULL;
-
-  flg_output[0] = '\0';
-  if (!flags)
-    return flg_output;
-
-  if (flags & 0x01) {
-    if (some) strcat(flg_output, " ");
-    some = 1;
-    strcat(flg_output, "OI");
-  }
-  if (flags & 0x02) {
-    if (some) strcat(flg_output, " ");
-    some = 1;
-    strcat(flg_output, "CI");
-  }
-  if (flags & 0x04) {
-    if (some) strcat(flg_output, " ");
-    some = 1;
-    strcat(flg_output, "NP");
-  }
-  if (flags & 0x08) {
-    if (some) strcat(flg_output, " ");
-    some = 1;
-    strcat(flg_output, "IO");
-  }
-  if (flags & 0x10) {
-    if (some) strcat(flg_output, " ");
-    some = 1;
-    strcat(flg_output, "IA");
-  }
-  if (flags == 0xF) {
-    if (some) strcat(flg_output, " ");
-    some = 1;
-    strcat(flg_output, "VI");
-  }
-
-  return flg_output;
-}
-
-
-char* ace_perms2str(uint32 perms)
-{
-  char* ret_val = malloc(9*sizeof(char));
-  sprintf(ret_val, "%.8X", perms);
-
-  return ret_val;
-}
-
-
-char* sid2str(DOM_SID* sid)
-{
-  uint32 i, size = MAXSUBAUTHS*11 + 24;
-  uint32 left = size;
-  uint8 comps = sid->num_auths;
-  char* ret_val = malloc(size);
-  
-  if(ret_val == NULL)
-    return NULL;
-
-  if(comps > MAXSUBAUTHS)
-    comps = MAXSUBAUTHS;
-
-  left -= sprintf(ret_val, "S-%u-%u", sid->sid_rev_num, sid->id_auth[5]);
-
-  for (i = 0; i < comps; i++) 
-    left -= snprintf(ret_val+(size-left), left, "-%u", sid->sub_auths[i]);
-
-  return ret_val;
-}
-
-
-char* get_acl(SEC_ACL* acl)
-{
-  uint32 i, extra, size = 0;
-  const char* type_str;
-  char* flags_str;
-  char* perms_str;
-  char* sid_str;
-  char* ret_val = NULL;
-  char* ace_delim = "";
-  char field_delim = ':';
-
-  for (i = 0; i < acl->num_aces; i++)
-  {
-    /* XXX: check for NULL */
-    sid_str = sid2str(&acl->ace[i].trustee);
-    type_str = ace_type2str(acl->ace[i].type);
-    perms_str = ace_perms2str(acl->ace[i].info.mask);
-    flags_str = ace_flags2str(acl->ace[i].flags);
-
-    /* XXX: this is slow */
-    extra = strlen(sid_str) + strlen(type_str) 
-          + strlen(perms_str) + strlen(flags_str)+5;
-    ret_val = realloc(ret_val, size+extra);
-    if(ret_val == NULL)
-      return NULL;
-    size += snprintf(ret_val+size, extra, "%s%s%c%s%c%s%c%s",
-		     ace_delim,sid_str,
-		     field_delim,type_str,
-		     field_delim,perms_str,
-		     field_delim,flags_str);
-    ace_delim = "|";
-    free(sid_str);
-    free(perms_str);
-    free(flags_str);
-  }
-
-  return ret_val;
-}
-
-
-char* get_sacl(SEC_DESC *sec_desc)
-{
-  if (sec_desc->sacl)
-    return get_acl(sec_desc->sacl);
-  else
-    return NULL;
-}
-
-
-char* get_dacl(SEC_DESC *sec_desc)
-{
-  if (sec_desc->dacl)
-    return get_acl(sec_desc->dacl);
-  else
-    return NULL;
-}
-
-
-char* get_owner(SEC_DESC *sec_desc)
-{
-  return sid2str(sec_desc->owner_sid);
-}
-
-
-char* get_group(SEC_DESC *sec_desc)
-{
-  return sid2str(sec_desc->grp_sid);
 }
 
@@ -607,8 +442,8 @@
   if(print_security)
   {
-    owner = get_owner(k->sec_desc->sec_desc);
-    group = get_group(k->sec_desc->sec_desc);
-    sacl = get_sacl(k->sec_desc->sec_desc);
-    dacl = get_dacl(k->sec_desc->sec_desc);
+    owner = regfio_get_owner(k->sec_desc->sec_desc);
+    group = regfio_get_group(k->sec_desc->sec_desc);
+    sacl = regfio_get_sacl(k->sec_desc->sec_desc);
+    dacl = regfio_get_dacl(k->sec_desc->sec_desc);
     if(owner == NULL)
       owner = empty_str;
@@ -709,4 +544,5 @@
   uint32 prefix_len;
   char* cur_str = NULL;
+  char* path = NULL;
   bool found_cur = true;
   uint32 i;
@@ -754,6 +590,8 @@
        && strcasecmp(sub->values[i].valuename, cur_str) == 0)
     {
-      /* XXX: fix mem leak with stack2Path return value */
-      printValue(&sub->values[i], stack2Path(nk_stack));
+      path = stack2Path(nk_stack);
+      printValue(&sub->values[i], path);
+      if(path != NULL)
+	free(path);
       return 0;
     }
@@ -788,5 +626,5 @@
 	  " <REGISTRY_FILE>\n");
   /* XXX: replace version string with Subversion property? */
-  fprintf(stderr, "Version: 0.2\n");
+  fprintf(stderr, "Version: 0.2.1\n");
   fprintf(stderr, "Options:\n");
   fprintf(stderr, "\t-v\t sets verbose mode.\n");
