# HG changeset patch # User Olaf Wintermann # Date 1688287064 -7200 # Node ID c4993f0991e434f5179c92b61af531e886fdf03f # Parent 305ce525ad4ac4f537d85b0db1bc825e20299560 port cmd_tagop() to ucx 3 diff -r 305ce525ad4a -r c4993f0991e4 dav/sync.c --- a/dav/sync.c Sun Jun 25 11:50:50 2023 +0200 +++ b/dav/sync.c Sun Jul 02 10:37:44 2023 +0200 @@ -5242,10 +5242,6 @@ } int cmd_tagop(CmdArgs *args, int cmd) { - // TODO: port to ucx 3 - return 1; -#if 0 - SyncFile file; int ret = 0; char *path = args->argv[0]; @@ -5282,28 +5278,31 @@ char *tagcolor = NULL; // TODO: get color tags = sync_get_file_tags(file.dir, localres, NULL, NULL); - CxList *x = NULL; - UCX_FOREACH(elm, tags) { - DavTag *t = elm->data; + CxIterator i = cxListIterator(tags ? tags : cxEmptyList); + int x = -1; + cx_foreach(DavTag *, t, i) { if(cmd == CMD_TAG_LIST) { printf("%s\n", t->name); } else if(!strcmp(t->name, tag)) { - x = elm; + x = i.index; break; } } if(cmd == CMD_TAG_ADD) { - if(!x) { + if(x < 0) { DavTag *newtag = malloc(sizeof(DavTag)); newtag->name = tag; newtag->color = tagcolor; - tags = ucx_list_append(tags, newtag); + if(!tags) { + tags = cxLinkedListCreateSimple(CX_STORE_POINTERS); + } + cxListAdd(tags, newtag); store_tags = TRUE; } } else if(cmd == CMD_TAG_REMOVE) { - if(tags) { - tags = ucx_list_remove(tags, x); + if(x >= 0) { + cxListRemove(tags, x); } store_tags = TRUE; } @@ -5349,7 +5348,6 @@ free(file.path); return ret; -#endif } int isfileindir(SyncDirectory *dir, const char *path, SyncFile *f) {