#ifndef TAGS_H
#define TAGS_H
#include <cx/string.h>
#include <cx/buffer.h>
#include <cx/list.h>
#include <libidav/webdav.h>
#ifdef __cplusplus
extern "C" {
#endif
#define DAV_SYNC_TAGFILTER_OFF 0
#define DAV_SYNC_TAGFILTER_AND 1
#define DAV_SYNC_TAGFILTER_OR 2
#define DAV_SYNC_TAGFILTER_ONE 3
#define DAV_SYNC_TAGFILTER_NONE 4
#define DAV_SYNC_TAGFILTER_SCOPE_RESOURCE 1
#define DAV_SYNC_TAGFILTER_SCOPE_COLLECTION 2
typedef struct DavTag {
char *name;
char *color;
} DavTag;
typedef struct SyncTagFilter SyncTagFilter;
struct SyncTagFilter {
int scope;
int mode;
CxList* tags;
size_t subfilter_count;
SyncTagFilter** subfilters;
};
void free_dav_tag(DavTag* tag);
void free_taglist(CxList *list);
int compare_tagname(DavTag* left, DavTag* right, void* ignorecase);
CxMap* taglist2map(CxList *tags);
CxList* parse_text_taglist(const char *buf, size_t length);
CxBuffer* create_text_taglist(CxList *tags);
CxList* parse_csv_taglist(const char *buf, size_t length);
CxBuffer* create_csv_taglist(CxList *tags);
CxList* parse_dav_xml_taglist(DavXmlNode *taglistnode);
DavXmlNode* create_xml_taglist(CxList *tags);
CxList* parse_macos_taglist(const char *buf, size_t length);
CxBuffer* create_macos_taglist(CxList *tags);
int compare_taglists(CxList *tags1, CxList *tags2);
char* create_tags_hash(CxList *tags);
CxList* merge_tags(CxList *tags1, CxList *tags2);
void add_tag_colors(CxList *taglist, CxList *colored);
SyncTagFilter* parse_tagfilter_string(const char* filterstring, int scope);
void free_tagfilter(SyncTagFilter* filter);
int matches_tagfilter(CxList *dav_tags, SyncTagFilter *tagfilter);
#ifdef __cplusplus
}
#endif
#endif