137 ret = load_key(node); |
137 ret = load_key(node); |
138 } else if (xstreq(node->name, "http-proxy")) { |
138 } else if (xstreq(node->name, "http-proxy")) { |
139 ret = load_proxy(ctx->http_proxy, node, HTTP_PROXY); |
139 ret = load_proxy(ctx->http_proxy, node, HTTP_PROXY); |
140 } else if (xstreq(node->name, "https-proxy")) { |
140 } else if (xstreq(node->name, "https-proxy")) { |
141 ret = load_proxy(ctx->https_proxy, node, HTTPS_PROXY); |
141 ret = load_proxy(ctx->https_proxy, node, HTTPS_PROXY); |
|
142 } else if (xstreq(node->name, "namespace")) { |
|
143 ret = load_namespace(node); |
142 } else { |
144 } else { |
143 fprintf(stderr, "Unknown config element: %s\n", node->name); |
145 fprintf(stderr, "Unknown config element: %s\n", node->name); |
144 ret = 1; |
146 ret = 1; |
145 } |
147 } |
146 } |
148 } |
494 k.ptr = data; |
496 k.ptr = data; |
495 k.length = r; |
497 k.length = r; |
496 |
498 |
497 fclose(file); |
499 fclose(file); |
498 return k; |
500 return k; |
499 } |
501 } |
|
502 |
|
503 static char* get_attr_content(xmlNode *node) { |
|
504 // TODO: remove code duplication (util_xml_get_text) |
|
505 while(node) { |
|
506 if(node->type == XML_TEXT_NODE) { |
|
507 return (char*)node->content; |
|
508 } |
|
509 node = node->next; |
|
510 } |
|
511 return NULL; |
|
512 } |
|
513 |
|
514 int load_namespace(const xmlNode *node) { |
|
515 const char *prefix = NULL; |
|
516 const char *uri = NULL; |
|
517 |
|
518 xmlAttr *attr = node->properties; |
|
519 while(attr) { |
|
520 if(attr->type == XML_ATTRIBUTE_NODE) { |
|
521 char *value = get_attr_content(attr->children); |
|
522 if(!value) { |
|
523 print_error( |
|
524 node->line, |
|
525 "missing value for attribute %s\n", (char*)attr->name); |
|
526 return 1; |
|
527 } |
|
528 if(xstreq(attr->name, "prefix")) { |
|
529 prefix = value; |
|
530 } else if(xstreq(attr->name, "uri")) { |
|
531 uri = value; |
|
532 } else { |
|
533 print_error( |
|
534 node->line, |
|
535 "unknown attribute %s\n", (char*)attr->name); |
|
536 return 1; |
|
537 } |
|
538 } |
|
539 attr = attr->next; |
|
540 } |
|
541 |
|
542 if(!prefix) { |
|
543 print_error(node->line, "missing prefix attribute\n"); |
|
544 return 1; |
|
545 } |
|
546 if(!uri) { |
|
547 print_error(node->line, "missing uri attribute\n"); |
|
548 return 1; |
|
549 } |
|
550 |
|
551 if(dav_get_namespace(context, prefix)) { |
|
552 fprintf(stderr, "Error: namespace prefix '%s' already used\n", prefix); |
|
553 return 1; |
|
554 } |
|
555 |
|
556 return dav_add_namespace(context, prefix, uri); |
|
557 } |
500 |
558 |
501 Repository* get_repository(sstr_t name) { |
559 Repository* get_repository(sstr_t name) { |
502 if(!name.ptr) { |
560 if(!name.ptr) { |
503 return NULL; |
561 return NULL; |
504 } |
562 } |