dav/scfg.c

changeset 534
9a4857d6444e
parent 526
e3c0440bd599
child 536
877f7c4a203b
equal deleted inserted replaced
533:5b9f20aa88c2 534:9a4857d6444e
248 TagConfig *tagconfig = malloc(sizeof(TagConfig)); 248 TagConfig *tagconfig = malloc(sizeof(TagConfig));
249 *tagconfig = conf; 249 *tagconfig = conf;
250 return tagconfig; 250 return tagconfig;
251 } 251 }
252 252
253 static SplitConfig* parse_split(xmlNode *node) {
254 char *pattern = NULL;
255 char *minsize = NULL;
256 char *blocksize = NULL;
257
258 xmlNode *c = node->children;
259 while(c) {
260 char *value = util_xml_get_text(c);
261 if(xstreq(c->name, "pattern")) {
262 pattern = value;
263 } else if(xstreq(c->name, "minsize")) {
264 minsize = value;
265 } else if(xstreq(c->name, "blocksize")) {
266 blocksize = value;
267 }
268 c = c->next;
269 }
270
271 uint64_t sz = 0;
272 if(!blocksize) {
273 fprintf(stderr, "splitconfig: no blocksize specified\n");
274 return NULL;
275 }
276 size_t bsz_len = strlen(blocksize);
277 if(bsz_len < 2) {
278 fprintf(stderr, "splitconfig: blocksize too small\n");
279 return NULL;
280 }
281
282 if(!util_szstrtouint(blocksize, &sz)) {
283 fprintf(stderr, "splitconfig: blocksize is not a number\n");
284 return NULL;
285 }
286
287 if(!pattern && !minsize) {
288 fprintf(stderr, "splitconfig: pattern or minsize must be specified\n");
289 return NULL;
290 }
291
292 int64_t minsz = -1;
293 if(minsize) {
294 uint64_t m;
295 if(!util_szstrtouint(minsize, &m)) {
296 fprintf(stderr, "splitconfig: minsize is not a number\n");
297 return NULL;
298 }
299 minsz = (int64_t)m;
300 }
301
302 SplitConfig *sc = calloc(1, sizeof(SplitConfig));
303 sc->pattern = pattern ? strdup(pattern) : NULL;
304 sc->minsize = minsz;
305 sc->blocksize = (size_t)sz;
306 return sc;
307 }
308
309 static UcxList* parse_splitconfig(xmlNode *node, int *error) {
310 UcxList *splitconfig = NULL;
311 int err = 0;
312 xmlNode *c = node->children;
313 while(c) {
314 if(c->type == XML_ELEMENT_NODE && xstreq(c->name, "split")) {
315 SplitConfig *sc = parse_split(c);
316 if(sc) {
317 splitconfig = ucx_list_append(splitconfig, sc);
318 } else {
319 err = 1;
320 break;
321 }
322 }
323 c = c->next;
324 }
325
326 if(error) {
327 *error = err;
328 }
329 return splitconfig;
330 }
331
253 static Versioning* parse_versioning_config(xmlNode *node) { 332 static Versioning* parse_versioning_config(xmlNode *node) {
254 Versioning v; 333 Versioning v;
255 v.always = FALSE; 334 v.always = FALSE;
256 v.type = VERSIONING_SIMPLE; 335 v.type = VERSIONING_SIMPLE;
257 v.collection = "/.dav-version-history"; 336 v.collection = "/.dav-version-history";
297 TagConfig *tagconfig = NULL; 376 TagConfig *tagconfig = NULL;
298 Versioning *versioning = NULL; 377 Versioning *versioning = NULL;
299 UcxList *include = NULL; 378 UcxList *include = NULL;
300 UcxList *exclude = NULL; 379 UcxList *exclude = NULL;
301 UcxList *tagfilter = NULL; 380 UcxList *tagfilter = NULL;
381 UcxList *splitconfig = NULL;
302 int max_retry = 0; 382 int max_retry = 0;
303 int allow_cmd = SYNC_CMD_PULL | SYNC_CMD_PUSH 383 int allow_cmd = SYNC_CMD_PULL | SYNC_CMD_PUSH
304 | SYNC_CMD_ARCHIVE | SYNC_CMD_RESTORE; 384 | SYNC_CMD_ARCHIVE | SYNC_CMD_RESTORE;
305 bool backuppull = false; 385 bool backuppull = false;
306 bool lockpull = false; 386 bool lockpull = false;
339 } 419 }
340 } else if(xstreq(node->name, "database")) { 420 } else if(xstreq(node->name, "database")) {
341 database = value; 421 database = value;
342 } else if(xstreq(node->name, "tagconfig")) { 422 } else if(xstreq(node->name, "tagconfig")) {
343 tagconfig = parse_tagconfig(node); 423 tagconfig = parse_tagconfig(node);
424 } else if(xstreq(node->name, "splitconfig")) {
425 int err = 0;
426 splitconfig = parse_splitconfig(node, &err);
427 if(err) {
428 return 1;
429 }
344 } else if(xstreq(node->name, "metadata")) { 430 } else if(xstreq(node->name, "metadata")) {
345 char *error = NULL; 431 char *error = NULL;
346 metadata = parse_finfo_settings(value, &error); 432 metadata = parse_finfo_settings(value, &error);
347 if(error) { 433 if(error) {
348 print_error(node->line, "unknown metadata: %s\n", error); 434 print_error(node->line, "unknown metadata: %s\n", error);

mercurial