46 free(tag->name); |
48 free(tag->name); |
47 if(tag->color) { |
49 if(tag->color) { |
48 free(tag->color); |
50 free(tag->color); |
49 } |
51 } |
50 free(tag); |
52 free(tag); |
|
53 } |
|
54 |
|
55 void free_taglist(UcxList *list) { |
|
56 ucx_list_free_content(list, (ucx_destructor)free_dav_tag); |
|
57 ucx_list_free(list); |
51 } |
58 } |
52 |
59 |
53 int compare_tagname(DavTag* left, DavTag* right, void* ignorecase) { |
60 int compare_tagname(DavTag* left, DavTag* right, void* ignorecase) { |
54 sstr_t leftname = sstr(left->name); |
61 sstr_t leftname = sstr(left->name); |
55 sstr_t rightname = sstr(right->name); |
62 sstr_t rightname = sstr(right->name); |
357 return NULL; |
364 return NULL; |
358 } |
365 } |
359 #endif |
366 #endif |
360 |
367 |
361 |
368 |
|
369 int compare_taglists(UcxList *tags1, UcxList *tags2) { |
|
370 if(!tags1) { |
|
371 return tags2 ? 0 : 1; |
|
372 } |
|
373 if(!tags2) { |
|
374 return tags1 ? 0 : 1; |
|
375 } |
|
376 |
|
377 UcxMap *map1 = ucx_map_new(32); |
|
378 UCX_FOREACH(elm, tags1) { |
|
379 DavTag *t = elm->data; |
|
380 ucx_map_cstr_put(map1, t->name, t); |
|
381 } |
|
382 |
|
383 int equal = 1; |
|
384 int i = 0; |
|
385 UCX_FOREACH(elm, tags2) { |
|
386 DavTag *t = elm->data; |
|
387 if(!ucx_map_cstr_get(map1, t->name)) { |
|
388 equal = 0; |
|
389 break; |
|
390 } |
|
391 i++; |
|
392 } |
|
393 |
|
394 if(i != map1->count) { |
|
395 equal = 0; |
|
396 } |
|
397 ucx_map_free(map1); |
|
398 return equal; |
|
399 } |
|
400 |
362 /* ----------- ----------- tag filter ---------------------- */ |
401 /* ----------- ----------- tag filter ---------------------- */ |
363 |
402 |
364 static size_t rtrimskip(scstr_t str, size_t skip) { |
403 static size_t rtrimskip(scstr_t str, size_t skip) { |
365 while (skip < str.length && isspace(str.ptr[skip])) skip++; |
404 while (skip < str.length && isspace(str.ptr[skip])) skip++; |
366 return skip; |
405 return skip; |