Changeset 200 for trunk/python2
- Timestamp:
- 06/03/10 01:08:20 (15 years ago)
- Location:
- trunk/python2/regfi
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python2/regfi/pyregfi.h
r199 r200 49 49 CLASS(KeyIterator, Object) 50 50 PRIVATE REGFI_ITERATOR *iter; 51 PRIVATE bool first_called;51 PRIVATE bool root_traversed; 52 52 53 53 KeyIterator METHOD(KeyIterator, Con, struct RegistryFile_t *file, char **path, … … 56 56 struct ValueIterator_t *METHOD(KeyIterator, list_values); 57 57 58 KeyIteratorMETHOD(KeyIterator, __iter__);59 REGFI_NK_REC *METHOD(KeyIterator, iternext);58 void METHOD(KeyIterator, __iter__); 59 BORROWED REGFI_NK_REC *METHOD(KeyIterator, iternext); 60 60 61 61 int METHOD(KeyIterator, down); … … 71 71 72 72 void METHOD(ValueIterator, __iter__); 73 R awDataMETHOD(ValueIterator, iternext);73 REGFI_VK_REC *METHOD(ValueIterator, iternext); 74 74 END_CLASS 75 75 -
trunk/python2/regfi/regfi.c
r199 r200 30 30 31 31 if(!self->reg) { 32 /*RaiseError(ERuntimeError, "REGFI Error: %s", regfi_log_get_str());*/32 RaiseError(ERuntimeError, "REGFI Error: %s", regfi_log_get_str()); 33 33 /*char* e = regfi_log_get_str();*/ 34 34 /*fprintf(stderr, "%p\n", e);*/ … … 61 61 } 62 62 63 static KeyIterator KeyIterator_Con(KeyIterator self, RegistryFile file, char **path, 64 REGFI_ENCODING encoding) { 63 static KeyIterator KeyIterator_Con(KeyIterator self, 64 RegistryFile file, 65 char **path, 66 REGFI_ENCODING encoding) 67 { 65 68 self->iter = regfi_iterator_new(file->reg, encoding); 66 69 … … 80 83 } 81 84 82 fprintf(stderr, "Con called\n"); 83 self->first_called = false; 85 self->root_traversed = false; 84 86 85 87 return self; … … 88 90 } 89 91 90 static KeyIterator KeyIterator__iter__(KeyIterator self) { 91 return self; 92 } 93 94 95 static const REGFI_NK_REC* KeyIterator_next(KeyIterator self) { 96 97 fprintf(stderr, "next called\n"); 98 99 if(!self->first_called) 92 static void KeyIterator__iter__(KeyIterator self) 93 { 94 return; 95 } 96 97 98 static const REGFI_NK_REC *KeyIterator_next(KeyIterator self) 99 { 100 if(!self->root_traversed) 101 self->root_traversed = true; 102 else if(!regfi_iterator_down(self->iter)) 100 103 { 101 regfi_iterator_first_subkey(self->iter); 102 self->first_called = true; 103 } 104 else 105 regfi_iterator_next_subkey(self->iter); 106 107 return regfi_iterator_cur_subkey(self->iter); 104 do 105 { 106 if(!regfi_iterator_up(self->iter)) 107 return NULL; 108 } while(!regfi_iterator_next_subkey(self->iter)); 109 110 /* XXX: This is an error condition. 111 * Probably should throw an exception or something. */ 112 if(!regfi_iterator_down(self->iter)) 113 return NULL; 114 } 115 116 regfi_iterator_first_subkey(self->iter); 117 return regfi_iterator_cur_key(self->iter); 108 118 } 109 119 110 120 111 121 static int KeyIterator_down(KeyIterator self) { 112 fprintf(stderr, "down cur_subkey: %d\n", self->iter->cur_subkey);113 122 int result = regfi_iterator_down(self->iter); 114 fprintf(stderr, "down result: %d\n", result);115 123 regfi_iterator_first_subkey(self->iter); 116 124 regfi_iterator_first_value(self->iter); … … 153 161 } 154 162 155 static ValueIteratorValueIterator__iter__(ValueIterator self) {156 return self;157 } 158 159 static R awDataValueIterator_iternext(ValueIterator self) {163 static void ValueIterator__iter__(ValueIterator self) { 164 return; 165 } 166 167 static REGFI_VK_REC* ValueIterator_iternext(ValueIterator self) { 160 168 RawData result; 161 169 const REGFI_DATA* data; … … 172 180 rec = regfi_iterator_cur_value(self->iter); 173 181 182 return rec; 183 174 184 if(!rec) return NULL; 175 185 … … 177 187 * Instead, make data fetching a method and parse it then. 178 188 */ 189 /* 179 190 data = (REGFI_DATA *)regfi_iterator_fetch_data(self->iter, rec); 180 191 if(!data) { … … 198 209 break; 199 210 } 211 */ 200 212 201 213 return result;
Note: See TracChangeset
for help on using the changeset viewer.