Index: trunk/lib/regfi.c
===================================================================
--- trunk/lib/regfi.c	(revision 167)
+++ trunk/lib/regfi.c	(revision 168)
@@ -24,4 +24,6 @@
  */
 
+/** @file */
+
 #include "regfi.h"
 
@@ -39,10 +41,10 @@
 /******************************************************************************
  ******************************************************************************/
-void regfi_add_message(REGFI_FILE* file, uint16 msg_type, const char* fmt, ...)
+void regfi_add_message(REGFI_FILE* file, uint16_t msg_type, const char* fmt, ...)
 {
   /* XXX: This function is not particularly efficient,
    *      but then it is mostly used during errors. 
    */
-  uint32 buf_size, buf_used;
+  uint32_t buf_size, buf_used;
   char* new_msg;
   va_list args;
@@ -98,5 +100,5 @@
 
 
-void regfi_set_message_mask(REGFI_FILE* file, uint16 mask)
+void regfi_set_message_mask(REGFI_FILE* file, uint16_t mask)
 {
   file->msg_mask = mask;
@@ -154,5 +156,5 @@
 /* Security descriptor formatting functions  */
 
-const char* regfi_ace_type2str(uint8 type)
+const char* regfi_ace_type2str(uint8_t type)
 {
   static const char* map[7] 
@@ -174,5 +176,5 @@
  *   http://msdn2.microsoft.com/en-us/library/aa772242.aspx
  */
-char* regfi_ace_flags2str(uint8 flags)
+char* regfi_ace_flags2str(uint8_t flags)
 {
   static const char* flag_map[32] = 
@@ -189,6 +191,6 @@
   char* ret_val = malloc(35*sizeof(char));
   char* fo = ret_val;
-  uint32 i;
-  uint8 f;
+  uint32_t i;
+  uint8_t f;
 
   if(ret_val == NULL)
@@ -223,7 +225,7 @@
 
 
-char* regfi_ace_perms2str(uint32 perms)
-{
-  uint32 i, p;
+char* regfi_ace_perms2str(uint32_t perms)
+{
+  uint32_t i, p;
   /* This is more than is needed by a fair margin. */
   char* ret_val = malloc(350*sizeof(char));
@@ -304,7 +306,7 @@
 char* regfi_sid2str(WINSEC_DOM_SID* sid)
 {
-  uint32 i, size = WINSEC_MAX_SUBAUTHS*11 + 24;
-  uint32 left = size;
-  uint8 comps = sid->num_auths;
+  uint32_t i, size = WINSEC_MAX_SUBAUTHS*11 + 24;
+  uint32_t left = size;
+  uint8_t comps = sid->num_auths;
   char* ret_val = malloc(size);
   
@@ -326,5 +328,5 @@
 char* regfi_get_acl(WINSEC_ACL* acl)
 {
-  uint32 i, extra, size = 0;
+  uint32_t i, extra, size = 0;
   const char* type_str;
   char* flags_str;
@@ -425,8 +427,8 @@
  * returned as 0, then EOF was encountered immediately
  *****************************************************************************/
-uint32 regfi_read(int fd, uint8* buf, uint32* length)
-{
-  uint32 rsize = 0;
-  uint32 rret = 0;
+uint32_t regfi_read(int fd, uint8_t* buf, uint32_t* length)
+{
+  uint32_t rsize = 0;
+  uint32_t rret = 0;
 
   do
@@ -449,10 +451,10 @@
  *
  *****************************************************************************/
-bool regfi_parse_cell(int fd, uint32 offset, uint8* hdr, uint32 hdr_len,
-		      uint32* cell_length, bool* unalloc)
-{
-  uint32 length;
-  int32 raw_length;
-  uint8 tmp[4];
+bool regfi_parse_cell(int fd, uint32_t offset, uint8_t* hdr, uint32_t hdr_len,
+		      uint32_t* cell_length, bool* unalloc)
+{
+  uint32_t length;
+  int32_t raw_length;
+  uint8_t tmp[4];
 
   if(lseek(fd, offset, SEEK_SET) == -1)
@@ -493,5 +495,5 @@
  * The offset is a virtual file offset.
  ******************************************************************************/
-static bool regfi_offset_in_hbin(const REGFI_HBIN* hbin, uint32 voffset)
+static bool regfi_offset_in_hbin(const REGFI_HBIN* hbin, uint32_t voffset)
 {
   if(!hbin)
@@ -511,5 +513,5 @@
  * block for it.  NULL if one doesn't exist.
  ******************************************************************************/
-const REGFI_HBIN* regfi_lookup_hbin(REGFI_FILE* file, uint32 offset)
+const REGFI_HBIN* regfi_lookup_hbin(REGFI_FILE* file, uint32_t offset)
 {
   return (const REGFI_HBIN*)range_list_find_data(file->hbins, offset);
@@ -523,5 +525,5 @@
  * (Since cells can only be ~2^31 in size, this works out.)
  ******************************************************************************/
-int32 regfi_calc_maxsize(REGFI_FILE* file, uint32 offset)
+int32_t regfi_calc_maxsize(REGFI_FILE* file, uint32_t offset)
 {
   const REGFI_HBIN* hbin = regfi_lookup_hbin(file, offset);
@@ -535,6 +537,6 @@
 /******************************************************************************
  ******************************************************************************/
-REGFI_SUBKEY_LIST* regfi_load_subkeylist(REGFI_FILE* file, uint32 offset, 
-					 uint32 num_keys, uint32 max_size, 
+REGFI_SUBKEY_LIST* regfi_load_subkeylist(REGFI_FILE* file, uint32_t offset, 
+					 uint32_t num_keys, uint32_t max_size, 
 					 bool strict)
 {
@@ -568,12 +570,12 @@
 /******************************************************************************
  ******************************************************************************/
-REGFI_SUBKEY_LIST* regfi_load_subkeylist_aux(REGFI_FILE* file, uint32 offset, 
-					     uint32 max_size, bool strict,
-					     uint8 depth_left)
+REGFI_SUBKEY_LIST* regfi_load_subkeylist_aux(REGFI_FILE* file, uint32_t offset, 
+					     uint32_t max_size, bool strict,
+					     uint8_t depth_left)
 {
   REGFI_SUBKEY_LIST* ret_val;
   REGFI_SUBKEY_LIST** sublists;
-  uint32 i, num_sublists, off;
-  int32 sublist_maxsize;
+  uint32_t i, num_sublists, off;
+  int32_t sublist_maxsize;
 
   if(depth_left == 0)
@@ -616,11 +618,11 @@
 /******************************************************************************
  ******************************************************************************/
-REGFI_SUBKEY_LIST* regfi_parse_subkeylist(REGFI_FILE* file, uint32 offset, 
-					  uint32 max_size, bool strict)
+REGFI_SUBKEY_LIST* regfi_parse_subkeylist(REGFI_FILE* file, uint32_t offset, 
+					  uint32_t max_size, bool strict)
 {
   REGFI_SUBKEY_LIST* ret_val;
-  uint32 i, cell_length, length, elem_size, read_len;
-  uint8* elements = NULL;
-  uint8 buf[REGFI_SUBKEY_LIST_MIN_LEN];
+  uint32_t i, cell_length, length, elem_size, read_len;
+  uint8_t* elements = NULL;
+  uint8_t buf[REGFI_SUBKEY_LIST_MIN_LEN];
   bool unalloc;
   bool recursive_type;
@@ -647,8 +649,8 @@
   {
     recursive_type = true;
-    elem_size = sizeof(uint32);
+    elem_size = sizeof(uint32_t);
   }
   else if(buf[0] == 'l' && buf[1] == 'i')
-    elem_size = sizeof(uint32);
+    elem_size = sizeof(uint32_t);
   else if((buf[0] == 'l') && (buf[1] == 'f' || buf[1] == 'h'))
     elem_size = sizeof(REGFI_SUBKEY_LIST_ELEM);
@@ -676,5 +678,5 @@
 
   length = elem_size*ret_val->num_children;
-  if(cell_length - REGFI_SUBKEY_LIST_MIN_LEN - sizeof(uint32) < length)
+  if(cell_length - REGFI_SUBKEY_LIST_MIN_LEN - sizeof(uint32_t) < length)
   {
     regfi_add_message(file, REGFI_MSG_WARN, "Number of elements too large for"
@@ -683,5 +685,5 @@
     if(strict)
       goto fail;
-    length = cell_length - REGFI_SUBKEY_LIST_MIN_LEN - sizeof(uint32);
+    length = cell_length - REGFI_SUBKEY_LIST_MIN_LEN - sizeof(uint32_t);
   }
 
@@ -691,5 +693,5 @@
     goto fail;
 
-  elements = (uint8*)malloc(length);
+  elements = (uint8_t*)malloc(length);
   if(elements == NULL)
     goto fail;
@@ -699,5 +701,5 @@
     goto fail;
 
-  if(elem_size == sizeof(uint32))
+  if(elem_size == sizeof(uint32_t))
   {
     for (i=0; i < ret_val->num_children; i++)
@@ -729,9 +731,9 @@
 /*******************************************************************
  *******************************************************************/
-REGFI_SUBKEY_LIST* regfi_merge_subkeylists(uint16 num_lists, 
+REGFI_SUBKEY_LIST* regfi_merge_subkeylists(uint16_t num_lists, 
 					   REGFI_SUBKEY_LIST** lists,
 					   bool strict)
 {
-  uint32 i,j,k;
+  uint32_t i,j,k;
   REGFI_SUBKEY_LIST* ret_val;
 
@@ -785,11 +787,11 @@
  *
  ******************************************************************************/
-REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32 offset, uint32 max_size, 
+REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32_t offset, uint32_t max_size, 
 			     bool strict)
 {
   REGFI_SK_REC* ret_val;
-  uint8* sec_desc_buf = NULL;
-  uint32 cell_length, length;
-  uint8 sk_header[REGFI_SK_MIN_LENGTH];
+  uint8_t* sec_desc_buf = NULL;
+  uint32_t cell_length, length;
+  uint8_t sk_header[REGFI_SK_MIN_LENGTH];
   bool unalloc = false;
 
@@ -855,5 +857,5 @@
   }
 
-  sec_desc_buf = (uint8*)malloc(ret_val->desc_size);
+  sec_desc_buf = (uint8_t*)malloc(ret_val->desc_size);
   if(sec_desc_buf == NULL)
     goto fail;
@@ -889,9 +891,9 @@
 
 
-REGFI_VALUE_LIST* regfi_parse_valuelist(REGFI_FILE* file, uint32 offset, 
-					uint32 num_values, bool strict)
+REGFI_VALUE_LIST* regfi_parse_valuelist(REGFI_FILE* file, uint32_t offset, 
+					uint32_t num_values, bool strict)
 {
   REGFI_VALUE_LIST* ret_val;
-  uint32 i, cell_length, length, read_len;
+  uint32_t i, cell_length, length, read_len;
   bool unalloc;
 
@@ -912,5 +914,5 @@
   }
 
-  if((num_values * sizeof(uint32)) > cell_length-sizeof(uint32))
+  if((num_values * sizeof(uint32_t)) > cell_length-sizeof(uint32_t))
   {
     regfi_add_message(file, REGFI_MSG_WARN, "Too many values found"
@@ -918,8 +920,8 @@
     if(strict)
       return NULL;
-    num_values = cell_length/sizeof(uint32) - sizeof(uint32);
-  }
-
-  read_len = num_values*sizeof(uint32);
+    num_values = cell_length/sizeof(uint32_t) - sizeof(uint32_t);
+  }
+
+  read_len = num_values*sizeof(uint32_t);
   ret_val = talloc(NULL, REGFI_VALUE_LIST);
   if(ret_val == NULL)
@@ -935,5 +937,5 @@
 
   length = read_len;
-  if((regfi_read(file->fd, (uint8*)ret_val->elements, &length) != 0) 
+  if((regfi_read(file->fd, (uint8_t*)ret_val->elements, &length) != 0) 
      || length != read_len)
   {
@@ -973,9 +975,9 @@
 /******************************************************************************
  ******************************************************************************/
-REGFI_VK_REC* regfi_load_value(REGFI_FILE* file, uint32 offset, 
+REGFI_VK_REC* regfi_load_value(REGFI_FILE* file, uint32_t offset, 
 			       REGFI_ENCODING output_encoding, bool strict)
 {
   REGFI_VK_REC* ret_val = NULL;
-  int32 max_size, tmp_size;
+  int32_t max_size, tmp_size;
   REGFI_ENCODING from_encoding;
 
@@ -1003,5 +1005,5 @@
   {
     ret_val->valuename_raw = talloc_realloc(ret_val, ret_val->valuename_raw,
-					    uint8, ret_val->name_length+1);
+					    uint8_t, ret_val->name_length+1);
     ret_val->valuename_raw[ret_val->name_length] = '\0';
     ret_val->valuename = (char*)ret_val->valuename_raw;
@@ -1038,11 +1040,11 @@
  * If !strict, the list may contain NULLs, VK records may point to NULL.
  ******************************************************************************/
-REGFI_VALUE_LIST* regfi_load_valuelist(REGFI_FILE* file, uint32 offset, 
-				       uint32 num_values, uint32 max_size,
+REGFI_VALUE_LIST* regfi_load_valuelist(REGFI_FILE* file, uint32_t offset, 
+				       uint32_t num_values, uint32_t max_size,
 				       bool strict)
 {
-  uint32 usable_num_values;
-
-  if((num_values+1) * sizeof(uint32) > max_size)
+  uint32_t usable_num_values;
+
+  if((num_values+1) * sizeof(uint32_t) > max_size)
   {
     regfi_add_message(file, REGFI_MSG_WARN, "Number of values indicated by"
@@ -1052,5 +1054,5 @@
     if(strict)
       return NULL;
-    usable_num_values = max_size/sizeof(uint32) - sizeof(uint32);
+    usable_num_values = max_size/sizeof(uint32_t) - sizeof(uint32_t);
   }
   else
@@ -1065,10 +1067,10 @@
  *
  ******************************************************************************/
-REGFI_NK_REC* regfi_load_key(REGFI_FILE* file, uint32 offset, 
+REGFI_NK_REC* regfi_load_key(REGFI_FILE* file, uint32_t offset, 
 			     REGFI_ENCODING output_encoding, bool strict)
 {
   REGFI_NK_REC* nk;
-  uint32 off;
-  int32 max_size, tmp_size;
+  uint32_t off;
+  int32_t max_size, tmp_size;
   REGFI_ENCODING from_encoding;
 
@@ -1097,5 +1099,5 @@
   if(from_encoding == output_encoding)
   {
-    nk->keyname_raw = talloc_realloc(nk, nk->keyname_raw, uint8, nk->name_length+1);
+    nk->keyname_raw = talloc_realloc(nk, nk->keyname_raw, uint8_t, nk->name_length+1);
     nk->keyname_raw[nk->name_length] = '\0';
     nk->keyname = (char*)nk->keyname_raw;
@@ -1196,8 +1198,8 @@
 /******************************************************************************
  ******************************************************************************/
-const REGFI_SK_REC* regfi_load_sk(REGFI_FILE* file, uint32 offset, bool strict)
+const REGFI_SK_REC* regfi_load_sk(REGFI_FILE* file, uint32_t offset, bool strict)
 {
   REGFI_SK_REC* ret_val = NULL;
-  int32 max_size;
+  int32_t max_size;
   void* failure_ptr = NULL;
   
@@ -1240,7 +1242,7 @@
 {
   REGFI_NK_REC* nk = NULL;
-  uint32 cell_length;
-  uint32 cur_offset = hbin->file_off+REGFI_HBIN_HEADER_SIZE;
-  uint32 hbin_end = hbin->file_off+hbin->block_size;
+  uint32_t cell_length;
+  uint32_t cur_offset = hbin->file_off+REGFI_HBIN_HEADER_SIZE;
+  uint32_t hbin_end = hbin->file_off+hbin->block_size;
   bool unalloc;
 
@@ -1301,5 +1303,5 @@
   REGFI_FILE* rb;
   REGFI_HBIN* hbin = NULL;
-  uint32 hbin_off, file_length, cache_secret;
+  uint32_t hbin_off, file_length, cache_secret;
   bool rla;
 
@@ -1397,5 +1399,5 @@
   REGFI_NK_REC* nk = NULL;
   REGFI_HBIN* hbin;
-  uint32 root_offset, i, num_hbins;
+  uint32_t root_offset, i, num_hbins;
   
   if(!file)
@@ -1584,5 +1586,5 @@
   REGFI_NK_REC* subkey;
   bool found = false;
-  uint32 old_subkey = i->cur_subkey;
+  uint32_t old_subkey = i->cur_subkey;
 
   if(subkey_name == NULL)
@@ -1618,5 +1620,5 @@
 bool regfi_iterator_walk_path(REGFI_ITERATOR* i, const char** path)
 {
-  uint32 x;
+  uint32_t x;
   if(path == NULL)
     return false;
@@ -1671,5 +1673,5 @@
 REGFI_NK_REC* regfi_iterator_cur_subkey(REGFI_ITERATOR* i)
 {
-  uint32 nk_offset;
+  uint32_t nk_offset;
 
   /* see if there is anything left to report */
@@ -1708,5 +1710,5 @@
   REGFI_VK_REC* cur;
   bool found = false;
-  uint32 old_value = i->cur_value;
+  uint32_t old_value = i->cur_value;
 
   /* XXX: cur->valuename can be NULL in the registry.  
@@ -1754,5 +1756,5 @@
 {
   REGFI_VK_REC* ret_val = NULL;
-  uint32 voffset;
+  uint32_t voffset;
 
   if(i->cur_key->values != NULL && i->cur_key->values->elements != NULL)
@@ -1791,9 +1793,9 @@
 {
   REGFI_CLASSNAME* ret_val;
-  uint8* raw;
+  uint8_t* raw;
   char* interpreted;
-  uint32 offset;
-  int32 conv_size, max_size;
-  uint16 parse_length;
+  uint32_t offset;
+  int32_t conv_size, max_size;
+  uint16_t parse_length;
 
   if(key->classname_off == REGFI_OFFSET_NONE || key->classname_length == 0)
@@ -1935,10 +1937,10 @@
  *****************************************************************************/
 bool regfi_interpret_data(REGFI_FILE* file, REGFI_ENCODING string_encoding,
-			  uint32 type, REGFI_DATA* data)
-{
-  uint8** tmp_array;
-  uint8* tmp_str;
-  int32 tmp_size;
-  uint32 i, j, array_size;
+			  uint32_t type, REGFI_DATA* data)
+{
+  uint8_t** tmp_array;
+  uint8_t* tmp_str;
+  int32_t tmp_size;
+  uint32_t i, j, array_size;
 
   if(data == NULL)
@@ -1951,5 +1953,5 @@
   /* REG_LINK is a symbolic link, stored as a unicode string. */
   case REG_LINK:
-    tmp_str = talloc_array(NULL, uint8, data->size);
+    tmp_str = talloc_array(NULL, uint8_t, data->size);
     if(tmp_str == NULL)
     {
@@ -1974,5 +1976,5 @@
     }
 
-    tmp_str = talloc_realloc(NULL, tmp_str, uint8, tmp_size);
+    tmp_str = talloc_realloc(NULL, tmp_str, uint8_t, tmp_size);
     data->interpreted.string = tmp_str;
     data->interpreted_size = tmp_size;
@@ -2010,10 +2012,10 @@
     }
     data->interpreted.qword = 
-      (uint64)IVAL(data->raw, 0) + (((uint64)IVAL(data->raw, 4))<<32);
+      (uint64_t)IVAL(data->raw, 0) + (((uint64_t)IVAL(data->raw, 4))<<32);
     data->interpreted_size = 8;
     break;
     
   case REG_MULTI_SZ:
-    tmp_str = talloc_array(NULL, uint8, data->size);
+    tmp_str = talloc_array(NULL, uint8_t, data->size);
     if(tmp_str == NULL)
     {
@@ -2042,5 +2044,5 @@
 
     array_size = tmp_size+1;
-    tmp_array = talloc_array(NULL, uint8*, array_size);
+    tmp_array = talloc_array(NULL, uint8_t*, array_size);
     if(tmp_array == NULL)
     {
@@ -2058,5 +2060,5 @@
     }
     tmp_array[j] = NULL;
-    tmp_array = talloc_realloc(NULL, tmp_array, uint8*, j+1);
+    tmp_array = talloc_realloc(NULL, tmp_array, uint8_t*, j+1);
     data->interpreted.multiple_string = tmp_array;
     /* XXX: how meaningful is this?  should we store number of strings instead? */
@@ -2107,7 +2109,7 @@
  * On error, returns a negative errno code.
  *****************************************************************************/
-int32 regfi_conv_charset(const char* input_charset, const char* output_charset,
-			 uint8* input, char* output, 
-			 uint32 input_len, uint32 output_max)
+int32_t regfi_conv_charset(const char* input_charset, const char* output_charset,
+			 uint8_t* input, char* output, 
+			 uint32_t input_len, uint32_t output_max)
 {
   iconv_t conv_desc;
@@ -2144,7 +2146,7 @@
  * buffer must be at least the size of a regf header (4096 bytes).
  *******************************************************************/
-static uint32 regfi_compute_header_checksum(uint8* buffer)
-{
-  uint32 checksum, x;
+static uint32_t regfi_compute_header_checksum(uint8_t* buffer)
+{
+  uint32_t checksum, x;
   int i;
 
@@ -2167,6 +2169,6 @@
 REGFI_FILE* regfi_parse_regf(int fd, bool strict)
 {
-  uint8 file_header[REGFI_REGF_SIZE];
-  uint32 length;
+  uint8_t file_header[REGFI_REGF_SIZE];
+  uint32_t length;
   REGFI_FILE* ret_val;
 
@@ -2243,9 +2245,9 @@
  * along with it's associated cells.
  ******************************************************************************/
-REGFI_HBIN* regfi_parse_hbin(REGFI_FILE* file, uint32 offset, bool strict)
+REGFI_HBIN* regfi_parse_hbin(REGFI_FILE* file, uint32_t offset, bool strict)
 {
   REGFI_HBIN *hbin;
-  uint8 hbin_header[REGFI_HBIN_HEADER_SIZE];
-  uint32 length;
+  uint8_t hbin_header[REGFI_HBIN_HEADER_SIZE];
+  uint32_t length;
   
   if(offset >= file->file_length)
@@ -2315,10 +2317,10 @@
 /*******************************************************************
  *******************************************************************/
-REGFI_NK_REC* regfi_parse_nk(REGFI_FILE* file, uint32 offset, 
-			     uint32 max_size, bool strict)
-{
-  uint8 nk_header[REGFI_NK_MIN_LENGTH];
+REGFI_NK_REC* regfi_parse_nk(REGFI_FILE* file, uint32_t offset, 
+			     uint32_t max_size, bool strict)
+{
+  uint8_t nk_header[REGFI_NK_MIN_LENGTH];
   REGFI_NK_REC* ret_val;
-  uint32 length,cell_length;
+  uint32_t length,cell_length;
   bool unalloc = false;
 
@@ -2432,5 +2434,5 @@
   }
 
-  ret_val->keyname_raw = talloc_array(ret_val, uint8, ret_val->name_length);
+  ret_val->keyname_raw = talloc_array(ret_val, uint8_t, ret_val->name_length);
   if(ret_val->keyname_raw == NULL)
   {
@@ -2441,5 +2443,5 @@
   /* Don't need to seek, should be at the right offset */
   length = ret_val->name_length;
-  if((regfi_read(file->fd, (uint8*)ret_val->keyname_raw, &length) != 0)
+  if((regfi_read(file->fd, (uint8_t*)ret_val->keyname_raw, &length) != 0)
      || length != ret_val->name_length)
   {
@@ -2454,10 +2456,10 @@
 
 
-uint8* regfi_parse_classname(REGFI_FILE* file, uint32 offset, 
-			     uint16* name_length, uint32 max_size, bool strict)
-{
-  uint8* ret_val = NULL;
-  uint32 length;
-  uint32 cell_length;
+uint8_t* regfi_parse_classname(REGFI_FILE* file, uint32_t offset, 
+			     uint16_t* name_length, uint32_t max_size, bool strict)
+{
+  uint8_t* ret_val = NULL;
+  uint32_t length;
+  uint32_t cell_length;
   bool unalloc = false;
 
@@ -2499,5 +2501,5 @@
     }
     
-    ret_val = talloc_array(NULL, uint8, *name_length);
+    ret_val = talloc_array(NULL, uint8_t, *name_length);
     if(ret_val != NULL)
     {
@@ -2520,10 +2522,10 @@
 /******************************************************************************
 *******************************************************************************/
-REGFI_VK_REC* regfi_parse_vk(REGFI_FILE* file, uint32 offset, 
-			     uint32 max_size, bool strict)
+REGFI_VK_REC* regfi_parse_vk(REGFI_FILE* file, uint32_t offset, 
+			     uint32_t max_size, bool strict)
 {
   REGFI_VK_REC* ret_val;
-  uint8 vk_header[REGFI_VK_MIN_LENGTH];
-  uint32 raw_data_size, length, cell_length;
+  uint8_t vk_header[REGFI_VK_MIN_LENGTH];
+  uint32_t raw_data_size, length, cell_length;
   bool unalloc = false;
 
@@ -2604,5 +2606,5 @@
       cell_length+=8;
 
-    ret_val->valuename_raw = talloc_array(ret_val, uint8, ret_val->name_length);
+    ret_val->valuename_raw = talloc_array(ret_val, uint8_t, ret_val->name_length);
     if(ret_val->valuename_raw == NULL)
     {
@@ -2612,5 +2614,5 @@
 
     length = ret_val->name_length;
-    if((regfi_read(file->fd, (uint8*)ret_val->valuename_raw, &length) != 0)
+    if((regfi_read(file->fd, (uint8_t*)ret_val->valuename_raw, &length) != 0)
        || length != ret_val->name_length)
     {
@@ -2638,11 +2640,11 @@
  *
  ******************************************************************************/
-REGFI_BUFFER regfi_load_data(REGFI_FILE* file, uint32 voffset,
-			     uint32 length, bool data_in_offset,
+REGFI_BUFFER regfi_load_data(REGFI_FILE* file, uint32_t voffset,
+			     uint32_t length, bool data_in_offset,
 			     bool strict)
 {
   REGFI_BUFFER ret_val;
-  uint32 cell_length, offset;
-  int32 max_size;
+  uint32_t cell_length, offset;
+  int32_t max_size;
   bool unalloc;
   
@@ -2744,9 +2746,9 @@
  * Parses the common case data records stored in a single cell.
  ******************************************************************************/
-REGFI_BUFFER regfi_parse_data(REGFI_FILE* file, uint32 offset,
-			      uint32 length, bool strict)
+REGFI_BUFFER regfi_parse_data(REGFI_FILE* file, uint32_t offset,
+			      uint32_t length, bool strict)
 {
   REGFI_BUFFER ret_val;
-  uint32 read_length;
+  uint32_t read_length;
 
   ret_val.buf = NULL;
@@ -2760,5 +2762,5 @@
   }
 
-  if((ret_val.buf = talloc_array(NULL, uint8, length)) == NULL)
+  if((ret_val.buf = talloc_array(NULL, uint8_t, length)) == NULL)
     return ret_val;
   ret_val.len = length;
@@ -2783,9 +2785,9 @@
  *
  ******************************************************************************/
-REGFI_BUFFER regfi_parse_little_data(REGFI_FILE* file, uint32 voffset,
-				     uint32 length, bool strict)
+REGFI_BUFFER regfi_parse_little_data(REGFI_FILE* file, uint32_t voffset,
+				     uint32_t length, bool strict)
 {
   REGFI_BUFFER ret_val;
-  uint8 i;
+  uint8_t i;
 
   ret_val.buf = NULL;
@@ -2800,10 +2802,10 @@
   }
 
-  if((ret_val.buf = talloc_array(NULL, uint8, length)) == NULL)
+  if((ret_val.buf = talloc_array(NULL, uint8_t, length)) == NULL)
     return ret_val;
   ret_val.len = length;
   
   for(i = 0; i < length; i++)
-    ret_val.buf[i] = (uint8)((voffset >> i*8) & 0xFF);
+    ret_val.buf[i] = (uint8_t)((voffset >> i*8) & 0xFF);
 
   return ret_val;
@@ -2812,13 +2814,13 @@
 /******************************************************************************
 *******************************************************************************/
-REGFI_BUFFER regfi_parse_big_data_header(REGFI_FILE* file, uint32 offset, 
-					 uint32 max_size, bool strict)
+REGFI_BUFFER regfi_parse_big_data_header(REGFI_FILE* file, uint32_t offset, 
+					 uint32_t max_size, bool strict)
 {
   REGFI_BUFFER ret_val;
-  uint32 cell_length;
+  uint32_t cell_length;
   bool unalloc;
 
   /* XXX: do something with unalloc? */
-  ret_val.buf = (uint8*)talloc_array(NULL, uint8, REGFI_BIG_DATA_MIN_LENGTH);
+  ret_val.buf = (uint8_t*)talloc_array(NULL, uint8_t, REGFI_BIG_DATA_MIN_LENGTH);
   if(ret_val.buf == NULL)
     goto fail;
@@ -2866,11 +2868,11 @@
  *
  ******************************************************************************/
-uint32* regfi_parse_big_data_indirect(REGFI_FILE* file, uint32 offset,
-				      uint16 num_chunks, bool strict)
-{
-  uint32* ret_val;
-  uint32 indirect_length;
-  int32 max_size;
-  uint16 i;
+uint32_t* regfi_parse_big_data_indirect(REGFI_FILE* file, uint32_t offset,
+				      uint16_t num_chunks, bool strict)
+{
+  uint32_t* ret_val;
+  uint32_t indirect_length;
+  int32_t max_size;
+  uint16_t i;
   bool unalloc;
 
@@ -2878,13 +2880,13 @@
 
   max_size = regfi_calc_maxsize(file, offset);
-  if((max_size < 0) || (num_chunks*sizeof(uint32) + 4 > max_size))
-    return NULL;
-
-  ret_val = (uint32*)talloc_array(NULL, uint32, num_chunks);
+  if((max_size < 0) || (num_chunks*sizeof(uint32_t) + 4 > max_size))
+    return NULL;
+
+  ret_val = (uint32_t*)talloc_array(NULL, uint32_t, num_chunks);
   if(ret_val == NULL)
     goto fail;
 
-  if(!regfi_parse_cell(file->fd, offset, (uint8*)ret_val,
-		       num_chunks*sizeof(uint32),
+  if(!regfi_parse_cell(file->fd, offset, (uint8_t*)ret_val,
+		       num_chunks*sizeof(uint32_t),
 		       &indirect_length, &unalloc))
   {
@@ -2898,5 +2900,5 @@
   for(i=0; i<num_chunks; i++)
   {
-    ret_val[i] = IVAL(ret_val, i*sizeof(uint32));
+    ret_val[i] = IVAL(ret_val, i*sizeof(uint32_t));
     if((ret_val[i] & 0x00000007) != 0)
       goto fail;
@@ -2924,10 +2926,10 @@
  *  No data in range_list elements.
  ******************************************************************************/
-range_list* regfi_parse_big_data_cells(REGFI_FILE* file, uint32* offsets,
-				       uint16 num_chunks, bool strict)
-{
-  uint32 cell_length, chunk_offset;
+range_list* regfi_parse_big_data_cells(REGFI_FILE* file, uint32_t* offsets,
+				       uint16_t num_chunks, bool strict)
+{
+  uint32_t cell_length, chunk_offset;
   range_list* ret_val;
-  uint16 i;
+  uint16_t i;
   bool unalloc;
   
@@ -2965,12 +2967,12 @@
 *******************************************************************************/
 REGFI_BUFFER regfi_load_big_data(REGFI_FILE* file, 
-				 uint32 offset, uint32 data_length, 
-				 uint32 cell_length, range_list* used_ranges,
+				 uint32_t offset, uint32_t data_length, 
+				 uint32_t cell_length, range_list* used_ranges,
 				 bool strict)
 {
   REGFI_BUFFER ret_val;
-  uint16 num_chunks, i;
-  uint32 read_length, data_left, tmp_len, indirect_offset;
-  uint32* indirect_ptrs = NULL;
+  uint16_t num_chunks, i;
+  uint32_t read_length, data_left, tmp_len, indirect_offset;
+  uint32_t* indirect_ptrs = NULL;
   REGFI_BUFFER bd_header;
   range_list* bd_cells = NULL;
@@ -3048,5 +3050,5 @@
     }
 
-    if(lseek(file->fd, cell_info->offset+sizeof(uint32), SEEK_SET) == -1)
+    if(lseek(file->fd, cell_info->offset+sizeof(uint32_t), SEEK_SET) == -1)
     {
       regfi_add_message(file, REGFI_MSG_WARN, "Could not seek to chunk while "
@@ -3095,5 +3097,5 @@
   REGFI_HBIN* hbin;
   const range_list_element* hbins_elem;
-  uint32 i, num_hbins, curr_off, cell_len;
+  uint32_t i, num_hbins, curr_off, cell_len;
   bool is_unalloc;
 
@@ -3142,2 +3144,103 @@
   return ret_val;
 }
+
+
+/* From lib/time.c */
+
+/****************************************************************************
+ Put a 8 byte filetime from a time_t
+ This takes real GMT as input and converts to kludge-GMT
+****************************************************************************/
+void regfi_unix2nt_time(REGFI_NTTIME *nt, time_t t)
+{
+  double d;
+  
+  if (t==0) 
+  {
+    nt->low = 0;
+    nt->high = 0;
+    return;
+  }
+  
+  if (t == TIME_T_MAX) 
+  {
+    nt->low = 0xffffffff;
+    nt->high = 0x7fffffff;
+    return;
+  }		
+  
+  if (t == -1) 
+  {
+    nt->low = 0xffffffff;
+    nt->high = 0xffffffff;
+    return;
+  }		
+  
+  /* this converts GMT to kludge-GMT */
+  /* XXX: This was removed due to difficult dependency requirements.  
+   *      So far, times appear to be correct without this adjustment, but 
+   *      that may be proven wrong with adequate testing. 
+   */
+  /* t -= TimeDiff(t) - get_serverzone(); */
+  
+  d = (double)(t);
+  d += TIME_FIXUP_CONSTANT;
+  d *= 1.0e7;
+  
+  nt->high = (uint32_t)(d * (1.0/(4.0*(double)(1<<30))));
+  nt->low  = (uint32_t)(d - ((double)nt->high)*4.0*(double)(1<<30));
+}
+
+
+/****************************************************************************
+ Interpret an 8 byte "filetime" structure to a time_t
+ It's originally in "100ns units since jan 1st 1601"
+
+ An 8 byte value of 0xffffffffffffffff will be returned as (time_t)0.
+
+ It appears to be kludge-GMT (at least for file listings). This means
+ its the GMT you get by taking a localtime and adding the
+ serverzone. This is NOT the same as GMT in some cases. This routine
+ converts this to real GMT.
+****************************************************************************/
+time_t regfi_nt2unix_time(const REGFI_NTTIME* nt)
+{
+  double d;
+  time_t ret;
+  /* The next two lines are a fix needed for the 
+     broken SCO compiler. JRA. */
+  time_t l_time_min = TIME_T_MIN;
+  time_t l_time_max = TIME_T_MAX;
+  
+  if (nt->high == 0 || (nt->high == 0xffffffff && nt->low == 0xffffffff))
+    return(0);
+  
+  d = ((double)nt->high)*4.0*(double)(1<<30);
+  d += (nt->low&0xFFF00000);
+  d *= 1.0e-7;
+  
+  /* now adjust by 369 years to make the secs since 1970 */
+  d -= TIME_FIXUP_CONSTANT;
+  
+  if (d <= l_time_min)
+    return (l_time_min);
+  
+  if (d >= l_time_max)
+    return (l_time_max);
+  
+  ret = (time_t)(d+0.5);
+  
+  /* this takes us from kludge-GMT to real GMT */
+  /* XXX: This was removed due to difficult dependency requirements.  
+   *      So far, times appear to be correct without this adjustment, but 
+   *      that may be proven wrong with adequate testing. 
+   */
+  /*
+    ret -= get_serverzone();
+    ret += LocTimeDiff(ret);
+  */
+
+  return(ret);
+}
+
+/* End of stuff from lib/time.c */
