Changeset 199 for trunk/python2
- Timestamp:
- 06/02/10 21:53:31 (14 years ago)
- Location:
- trunk/python2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python2/SConstruct
r198 r199 29 29 nenv.config = config 30 30 if config.DEBUG: 31 nenv.Append(CFLAGS = "-ggdb - pedantic -Wall -std=gnu99")31 nenv.Append(CFLAGS = "-ggdb -O0 -pedantic -Wall -std=gnu99") 32 32 nenv.Append(CPPPATH=['../include', 'include']) 33 33 nenv.python_cppflags = '-I/usr/include/python2.5_d' -
trunk/python2/regfi/pyregfi.h
r198 r199 49 49 CLASS(KeyIterator, Object) 50 50 PRIVATE REGFI_ITERATOR *iter; 51 PRIVATE const REGFI_NK_REC *next_item;51 PRIVATE bool first_called; 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 voidMETHOD(KeyIterator, __iter__);58 KeyIterator METHOD(KeyIterator, __iter__); 59 59 REGFI_NK_REC *METHOD(KeyIterator, iternext); 60 61 int METHOD(KeyIterator, down); 62 int METHOD(KeyIterator, up); 60 63 END_CLASS 61 64 62 65 /** This is an iterator for reading values from the registry */ 63 66 CLASS(ValueIterator, Object) 64 PRIVATE REGFI_ITERATOR *iter; 65 PRIVATE const REGFI_VK_REC *next_item; 67 PRIVATE REGFI_ITERATOR *iter; 68 PRIVATE bool first_called; 69 70 ValueIterator METHOD(ValueIterator, Con, KeyIterator key); 66 71 67 ValueIterator METHOD(ValueIterator, Con, KeyIterator key); 68 69 void METHOD(ValueIterator, __iter__); 70 RawData METHOD(ValueIterator, iternext); 72 void METHOD(ValueIterator, __iter__); 73 RawData METHOD(ValueIterator, iternext); 71 74 END_CLASS 72 75 -
trunk/python2/regfi/regfi.c
r198 r199 58 58 59 59 regfi_iterator_free(this->iter); 60 if(this->next_item) {61 regfi_free_record(this->next_item);62 }63 64 60 return 0; 65 61 } … … 76 72 talloc_set_destructor((void*)self, KeyIterator_dest); 77 73 78 / / Traverse to the path74 /* Traverse to the path */ 79 75 if(path[0]) { 80 76 if(!regfi_iterator_walk_path(self->iter, (const char **)path)) { … … 84 80 } 85 81 86 // Get the first key in the list87 self-> next_item = regfi_iterator_first_subkey(self->iter);82 fprintf(stderr, "Con called\n"); 83 self->first_called = false; 88 84 89 85 return self; … … 92 88 } 93 89 94 static void KeyIterator__iter__(KeyIterator self) { 95 if(self->next_item) { 96 regfi_free_record(self->next_item); 97 }; 98 99 self->next_item = regfi_iterator_first_subkey(self->iter); 100 } 90 static KeyIterator KeyIterator__iter__(KeyIterator self) { 91 return self; 92 } 93 101 94 102 95 static const REGFI_NK_REC* KeyIterator_next(KeyIterator self) { 103 const REGFI_NK_REC* result; 104 105 if(!self->next_item) return NULL; 106 107 result = self->next_item; 108 109 self->next_item = regfi_iterator_next_subkey(self->iter); 110 96 97 fprintf(stderr, "next called\n"); 98 99 if(!self->first_called) 100 { 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); 108 } 109 110 111 static int KeyIterator_down(KeyIterator self) { 112 fprintf(stderr, "down cur_subkey: %d\n", self->iter->cur_subkey); 113 int result = regfi_iterator_down(self->iter); 114 fprintf(stderr, "down result: %d\n", result); 115 regfi_iterator_first_subkey(self->iter); 116 regfi_iterator_first_value(self->iter); 111 117 return result; 118 } 119 120 static int KeyIterator_up(KeyIterator self) { 121 return regfi_iterator_up(self->iter); 112 122 } 113 123 … … 119 129 VMETHOD(Con) = KeyIterator_Con; 120 130 VMETHOD(iternext) = KeyIterator_next; 131 VMETHOD(down) = KeyIterator_down; 132 VMETHOD(up) = KeyIterator_up; 121 133 VMETHOD(__iter__) = KeyIterator__iter__; 122 134 VMETHOD(list_values) = KeyIterator_list_values; … … 126 138 ValueIterator this = (ValueIterator)self; 127 139 128 if(this->next_item) regfi_free_record(this->next_item);140 talloc_unlink(this, this->iter); 129 141 130 142 return 0; … … 136 148 talloc_reference(self, self->iter); 137 149 138 self->next_item = regfi_iterator_first_value(self->iter);139 140 150 talloc_set_destructor((void *)self, ValueIterator_dest); 141 151 … … 143 153 } 144 154 145 static void ValueIterator__iter__(ValueIterator self) { 146 if(self->next_item) regfi_free_record(self->next_item); 147 148 self->next_item = regfi_iterator_first_value(self->iter); 155 static ValueIterator ValueIterator__iter__(ValueIterator self) { 156 return self; 149 157 } 150 158 151 159 static RawData ValueIterator_iternext(ValueIterator self) { 152 160 RawData result; 153 const REGFI_DATA *data; 154 const REGFI_VK_REC *rec = self->next_item; 161 const REGFI_DATA* data; 162 const REGFI_VK_REC* rec; 163 164 if(!self->first_called) 165 { 166 regfi_iterator_first_value(self->iter); 167 self->first_called = true; 168 } 169 else 170 regfi_iterator_next_value(self->iter); 171 172 rec = regfi_iterator_cur_value(self->iter); 155 173 156 174 if(!rec) return NULL; 157 175 176 /* XXX: shouldn't parse data here every time we walk over a value. 177 * Instead, make data fetching a method and parse it then. 178 */ 158 179 data = (REGFI_DATA *)regfi_iterator_fetch_data(self->iter, rec); 159 180 if(!data) { … … 162 183 } 163 184 164 switch( self->next_item->type) {185 switch(rec->type) { 165 186 case REG_EXPAND_SZ: 166 187 case REG_SZ: … … 178 199 } 179 200 180 181 /* if(self->next_item) {182 regfi_free_record(self->next_item);183 };184 */185 186 self->next_item = regfi_iterator_next_value(self->iter);187 188 201 return result; 189 202 error: … … 255 268 256 269 void pyregfi_init() { 270 regfi_init(); 257 271 INIT_CLASS(RegistryFile); 258 259 } 272 } -
trunk/python2/utils.py
r198 r199 267 267 """ Implementation from Richard Levitte email to 268 268 org.tigris.scons.dev dated Jan 26, 2006 7:05:10 am.""" 269 python_cppflags = distutils.util.split_quoted( 270 "-I"+sysconfig.get_python_inc()) 269 python_cppflags = "-I"+sysconfig.get_python_inc() 271 270 272 271 def PythonModule(self, libname, lib_objs=[], **kwargs):
Note: See TracChangeset
for help on using the changeset viewer.