153 static TagConfig* parse_tagconfig(xmlNode *node) { |
153 static TagConfig* parse_tagconfig(xmlNode *node) { |
154 TagConfig conf; |
154 TagConfig conf; |
155 conf.store = TAG_STORE_XATTR; |
155 conf.store = TAG_STORE_XATTR; |
156 conf.local_format = TAG_FORMAT_TEXT; |
156 conf.local_format = TAG_FORMAT_TEXT; |
157 conf.server_format = TAG_FORMAT_XML; |
157 conf.server_format = TAG_FORMAT_XML; |
158 conf.scan = false; |
158 conf.xattr_name = NULL; |
|
159 conf.detect_changes = false; |
|
160 conf.conflict = TAG_NO_CONFLICT; |
159 xmlNode *c = node->children; |
161 xmlNode *c = node->children; |
160 |
162 |
161 // TODO: error handling |
163 // TODO: error handling |
162 while(c) { |
164 while(c) { |
163 if(c->type == XML_ELEMENT_NODE) { |
165 if(c->type == XML_ELEMENT_NODE) { |
182 conf.local_format = str2tagformat(value); |
184 conf.local_format = str2tagformat(value); |
183 } |
185 } |
184 } |
186 } |
185 attr = attr->next; |
187 attr = attr->next; |
186 } |
188 } |
187 } else if(xstreq(c->name, "scan")) { |
189 } else if(xstreq(c->name, "detect-changes")) { |
188 if(!value) { |
190 if(!value) { |
189 return NULL; |
191 return NULL; |
190 } |
192 } |
191 conf.scan = util_getboolean(value); |
193 conf.detect_changes = util_getboolean(value); |
|
194 } else if(xstreq(c->name, "xattr-name")) { |
|
195 if(!value) { |
|
196 return NULL; |
|
197 } |
|
198 conf.xattr_name = strdup(value); |
|
199 } else if(xstreq(c->name, "on-conflict")) { |
|
200 if(!value) { |
|
201 return NULL; |
|
202 } |
|
203 if(xstreq(value, "no_conflict")) { |
|
204 conf.conflict = TAG_NO_CONFLICT; |
|
205 } else if(xstreq(value, "keep_local")) { |
|
206 conf.conflict = TAG_KEEP_LOCAL; |
|
207 } else if(xstreq(value, "keep_remote")) { |
|
208 conf.conflict = TAG_KEEP_REMOTE; |
|
209 } else if(xstreq(value, "merge")) { |
|
210 conf.conflict = TAG_MERGE; |
|
211 } else { |
|
212 fprintf(stderr, "on-conflict: unknown value: %s\n", value); |
|
213 return NULL; |
|
214 } |
192 } |
215 } |
193 } |
216 } |
194 c = c->next; |
217 c = c->next; |
|
218 } |
|
219 |
|
220 if(conf.store == TAG_STORE_XATTR && !conf.xattr_name) { |
|
221 switch(conf.local_format) { |
|
222 default: |
|
223 case TAG_FORMAT_TEXT: |
|
224 case TAG_FORMAT_CSV: |
|
225 case TAG_FORMAT_XML: conf.xattr_name = strdup(DEFAULT_TAG_XATTR); break; |
|
226 case TAG_FORMAT_MACOS: conf.xattr_name = strdup(MACOS_TAG_XATTR); break; |
|
227 } |
195 } |
228 } |
196 |
229 |
197 TagConfig *tagconfig = malloc(sizeof(TagConfig)); |
230 TagConfig *tagconfig = malloc(sizeof(TagConfig)); |
198 *tagconfig = conf; |
231 *tagconfig = conf; |
199 return tagconfig; |
232 return tagconfig; |