- Timestamp:
- 06/02/10 21:53:31 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/regfi.c
r193 r199 1848 1848 1849 1849 /* XXX: this alloc/free of each sub key might be a bit excessive */ 1850 subkey = (REGFI_NK_REC*)regfi_iterator_first_subkey(i);1851 while((subkey != NULL)&& (found == false))1850 regfi_iterator_first_subkey(i); 1851 while((subkey = regfi_iterator_cur_subkey(i)) != NULL && (found == false)) 1852 1852 { 1853 1853 if(subkey->keyname != NULL … … 1857 1857 { 1858 1858 talloc_unlink(NULL, subkey); 1859 subkey = (REGFI_NK_REC*)regfi_iterator_next_subkey(i);1859 regfi_iterator_next_subkey(i); 1860 1860 } 1861 1861 } … … 1918 1918 /****************************************************************************** 1919 1919 *****************************************************************************/ 1920 const REGFI_NK_REC*regfi_iterator_first_subkey(REGFI_ITERATOR* i)1920 bool regfi_iterator_first_subkey(REGFI_ITERATOR* i) 1921 1921 { 1922 1922 i->cur_subkey = 0; 1923 return regfi_iterator_cur_subkey(i); 1923 1924 return ((i->cur_key != NULL) && (i->cur_key->subkeys_off!=REGFI_OFFSET_NONE) 1925 && (i->cur_subkey < i->cur_key->num_subkeys)); 1924 1926 } 1925 1927 … … 1931 1933 uint32_t nk_offset; 1932 1934 1933 /* see if there is anything left to report */ 1934 if (!(i->cur_key) || (i->cur_key->subkeys_off==REGFI_OFFSET_NONE) 1935 || (i->cur_subkey >= i->cur_key->num_subkeys)) 1936 return NULL; 1937 1938 nk_offset = i->cur_key->subkeys->elements[i->cur_subkey].offset; 1939 1940 return regfi_load_key(i->f, nk_offset+REGFI_REGF_SIZE, 1941 i->string_encoding, true); 1935 if((i->cur_key != NULL) && (i->cur_key->subkeys_off!=REGFI_OFFSET_NONE) 1936 && (i->cur_subkey < i->cur_key->num_subkeys)) 1937 { 1938 nk_offset = i->cur_key->subkeys->elements[i->cur_subkey].offset; 1939 1940 return regfi_load_key(i->f, nk_offset+REGFI_REGF_SIZE, 1941 i->string_encoding, true); 1942 } 1943 1944 return NULL; 1942 1945 } 1943 1946 … … 1945 1948 /****************************************************************************** 1946 1949 *****************************************************************************/ 1947 /* XXX: some way of indicating reason for failure should be added. */ 1948 const REGFI_NK_REC* regfi_iterator_next_subkey(REGFI_ITERATOR* i) 1949 { 1950 const REGFI_NK_REC* subkey; 1951 1950 bool regfi_iterator_next_subkey(REGFI_ITERATOR* i) 1951 { 1952 1952 i->cur_subkey++; 1953 subkey = regfi_iterator_cur_subkey(i); 1954 1955 if(subkey == NULL) 1956 i->cur_subkey--; 1957 1958 return subkey; 1953 1954 return ((i->cur_key != NULL) && (i->cur_key->subkeys_off!=REGFI_OFFSET_NONE) 1955 && (i->cur_subkey < i->cur_key->num_subkeys)); 1959 1956 } 1960 1957 … … 1974 1971 return false; 1975 1972 1976 cur =regfi_iterator_first_value(i);1977 while((cur != NULL)&& (found == false))1973 regfi_iterator_first_value(i); 1974 while((cur = regfi_iterator_cur_value(i)) != NULL && (found == false)) 1978 1975 { 1979 1976 if((cur->valuename != NULL) … … 1983 1980 { 1984 1981 regfi_free_record(cur); 1985 cur =regfi_iterator_next_value(i);1982 regfi_iterator_next_value(i); 1986 1983 } 1987 1984 } … … 2000 1997 /****************************************************************************** 2001 1998 *****************************************************************************/ 2002 const REGFI_VK_REC*regfi_iterator_first_value(REGFI_ITERATOR* i)1999 bool regfi_iterator_first_value(REGFI_ITERATOR* i) 2003 2000 { 2004 2001 i->cur_value = 0; 2005 return regfi_iterator_cur_value(i); 2002 return (i->cur_key->values != NULL && i->cur_key->values->elements != NULL 2003 && (i->cur_value < i->cur_key->values->num_values)); 2006 2004 } 2007 2005 … … 2014 2012 uint32_t voffset; 2015 2013 2016 if(i->cur_key->values != NULL && i->cur_key->values->elements != NULL) 2017 { 2018 if(i->cur_value < i->cur_key->values->num_values) 2019 { 2020 voffset = i->cur_key->values->elements[i->cur_value]; 2021 ret_val = regfi_load_value(i->f, voffset+REGFI_REGF_SIZE, 2022 i->string_encoding, true); 2023 } 2014 if(i->cur_key->values != NULL && i->cur_key->values->elements != NULL 2015 && (i->cur_value < i->cur_key->values->num_values)) 2016 { 2017 voffset = i->cur_key->values->elements[i->cur_value]; 2018 ret_val = regfi_load_value(i->f, voffset+REGFI_REGF_SIZE, 2019 i->string_encoding, true); 2024 2020 } 2025 2021 … … 2030 2026 /****************************************************************************** 2031 2027 *****************************************************************************/ 2032 const REGFI_VK_REC* regfi_iterator_next_value(REGFI_ITERATOR* i) 2033 { 2034 const REGFI_VK_REC* ret_val; 2035 2028 bool regfi_iterator_next_value(REGFI_ITERATOR* i) 2029 { 2036 2030 i->cur_value++; 2037 ret_val = regfi_iterator_cur_value(i); 2038 if(ret_val == NULL) 2039 i->cur_value--; 2040 2041 return ret_val; 2031 return (i->cur_key->values != NULL && i->cur_key->values->elements != NULL 2032 && (i->cur_value < i->cur_key->values->num_values)); 2042 2033 } 2043 2034
Note: See TracChangeset
for help on using the changeset viewer.