dav/pwd.c

changeset 654
8f2b8f2a5cde
parent 653
f503c272bd70
child 731
e0358fa1a3b1
equal deleted inserted replaced
653:f503c272bd70 654:8f2b8f2a5cde
189 if(password) free(password); 189 if(password) free(password);
190 190
191 return ret; 191 return ret;
192 } 192 }
193 193
194 static int remove_list_entries(PwdStore *s, const char *id) {
195 int ret = 0;
196
197 UcxList *loc_entry = NULL;
198 UcxList *noloc_entry = NULL;
199 UCX_FOREACH(elm, s->locations) {
200 PwdIndexEntry *ie = elm->data;
201 if(!strcmp(ie->id, id)) {
202 loc_entry = elm;
203 ret = 1;
204 break;
205 }
206 }
207 UCX_FOREACH(elm, s->noloc) {
208 PwdIndexEntry *ie = elm->data;
209 if(!strcmp(ie->id, id)) {
210 noloc_entry = elm;
211 ret = 1;
212 break;
213 }
214 }
215
216 if(loc_entry) {
217 s->locations = ucx_list_remove(s->locations, loc_entry);
218 }
219 if(noloc_entry) {
220 s->noloc = ucx_list_remove(s->noloc, noloc_entry);
221 }
222
223 return ret;
224 }
225
226 void pwdstore_remove_entry(PwdStore *s, const char *id) {
227 while(remove_list_entries(s, id)) {}
228
229 PwdIndexEntry *i = ucx_map_cstr_remove(s->index, id);
230 PwdEntry *e = ucx_map_cstr_remove(s->ids, id);
231
232 if(i) {
233 ucx_list_free_content(i->locations, free);
234 ucx_list_free(i->locations);
235 free(i->id);
236 free(i);
237 }
238 if(e) {
239 free(e->id);
240 free(e->user);
241 free(e->password);
242 free(e);
243 }
244 }
245
194 int pwdstore_getindex(PwdStore *s) { 246 int pwdstore_getindex(PwdStore *s) {
195 uint32_t netindexlen; 247 uint32_t netindexlen;
196 248
197 // set the position to the last 4 bytes of the header 249 // set the position to the last 4 bytes of the header
198 // for reading index length 250 // for reading index length

mercurial