r10656: BIG merge from trunk. Features not copied over
[ira/wip.git] / source3 / registry / regfio.c
index aebb1ebaed614f6e13a1ab6160331ba7871e04b9..954f4ae7bd0b6916984c3e783a429ef1d1f07bb4 100644 (file)
@@ -85,7 +85,7 @@ static int read_block( REGF_FILE *file, prs_struct *ps, uint32 file_offset, uint
        if ( (size_t)file_offset >= sbuf.st_size )
                return -1;
        
-       /* if block_size == 0, we are parsnig HBIN records and need 
+       /* if block_size == 0, we are parsing HBIN records and need 
           to read some of the header to get the block_size from there */
           
        if ( block_size == 0 ) {
@@ -533,7 +533,7 @@ static REGF_HBIN* read_hbin_block( REGF_FILE *file, off_t offset )
 }
 
 /*******************************************************************
- Input a randon offset and receive the correpsonding HBIN 
+ Input a random offset and receive the corresponding HBIN 
  block for it
 *******************************************************************/
 
@@ -549,7 +549,7 @@ static BOOL hbin_contains_offset( REGF_HBIN *hbin, uint32 offset )
 }
 
 /*******************************************************************
- Input a randon offset and receive the correpsonding HBIN 
+ Input a random offset and receive the corresponding HBIN 
  block for it
 *******************************************************************/
 
@@ -561,7 +561,7 @@ static REGF_HBIN* lookup_hbin_block( REGF_FILE *file, uint32 offset )
        /* start with the open list */
 
        for ( hbin=file->block_list; hbin; hbin=hbin->next ) {
-               DEBUG(10,("lookup_hbin_block: address = 0x%x [0x%x]\n", hbin->file_off, (uint32)hbin ));
+               DEBUG(10,("lookup_hbin_block: address = 0x%x [0x%lx]\n", hbin->file_off, (unsigned long)hbin ));
                if ( hbin_contains_offset( hbin, offset ) )
                        return hbin;
        }
@@ -1030,7 +1030,7 @@ static BOOL next_record( REGF_HBIN *hbin, const char *hdr, BOOL *eob )
        if ( curr_off == 0 )
                prs_set_offset( ps, HBIN_HEADER_REC_SIZE );
 
-       /* assume that the current offset is at the reacord header 
+       /* assume that the current offset is at the record header 
           and we need to backup to read the record size */
 
        curr_off -= sizeof(uint32);
@@ -1670,7 +1670,7 @@ static BOOL create_vk_record( REGF_FILE *file, REGF_VK_REC *vk, REGISTRY_VALUE *
 
 static int hashrec_cmp( REGF_HASH_REC *h1, REGF_HASH_REC *h2 )
 {
-       return strcmp( h1->fullname, h2->fullname );
+       return StrCaseCmp( h1->fullname, h2->fullname );
 }
 
 /*******************************************************************
@@ -1768,22 +1768,28 @@ static int hashrec_cmp( REGF_HASH_REC *h1, REGF_HASH_REC *h2 )
 
                        DLIST_ADD_END( file->sec_desc_list, nk->sec_desc, tmp );
 
-                       /* initialize offsets */
-
-                       nk->sec_desc->prev_sk_off = nk->sec_desc->sk_off;
-                       nk->sec_desc->next_sk_off = nk->sec_desc->sk_off;
-
-                       /* now update the offsets for us and the previous sd in the list */
+                       /* update the offsets for us and the previous sd in the list.
+                          if this is the first record, then just set the next and prev
+                          offsets to ourself. */
 
                        if ( nk->sec_desc->prev ) {
                                REGF_SK_REC *prev = nk->sec_desc->prev;
 
                                nk->sec_desc->prev_sk_off = prev->hbin_off + prev->hbin->first_hbin_off - HBIN_HDR_SIZE;
-                               prev->next_sk_off = nk->sk_off;
+                               prev->next_sk_off = nk->sec_desc->sk_off;
+
+                               /* the end must loop around to the front */
+                               nk->sec_desc->next_sk_off = file->sec_desc_list->sk_off;
+
+                               /* and first must loop around to the tail */
+                               file->sec_desc_list->prev_sk_off = nk->sec_desc->sk_off;
+                       } else {
+                               nk->sec_desc->prev_sk_off = nk->sec_desc->sk_off;
+                               nk->sec_desc->next_sk_off = nk->sec_desc->sk_off;
                        }
                }
 
-               /* dump the reference count */
+               /* bump the reference count +1 */
 
                nk->sk_off = nk->sec_desc->sk_off;
                nk->sec_desc->ref_count++;