1485 print_resource_error(sn, res->path); |
1485 print_resource_error(sn, res->path); |
1486 return -1; |
1486 return -1; |
1487 } |
1487 } |
1488 |
1488 |
1489 char *namespace = cmd_getoption(a, "namespace"); |
1489 char *namespace = cmd_getoption(a, "namespace"); |
|
1490 char *xml = cmd_getoption(a, "xml"); |
|
1491 |
1490 char *property = a->argv[1]; |
1492 char *property = a->argv[1]; |
1491 char *value = a->argc > 2 ? a->argv[2] : stdin2str(); |
1493 char *value = a->argc > 2 ? a->argv[2] : stdin2str(); |
1492 |
1494 |
1493 if(namespace) { |
|
1494 dav_set_string_property_ns(res, namespace, property, value); |
|
1495 } else { |
|
1496 dav_set_string_property(res, property, value); |
|
1497 } |
|
1498 |
|
1499 int ret = 0; |
1495 int ret = 0; |
1500 if(dav_store(res)) { |
1496 if(xml) { |
1501 print_resource_error(sn, res->path); |
1497 DavXmlNode *xmlvalue = dav_parse_xml(sn, value, strlen(value)); |
1502 fprintf(stderr, "Cannot set property.\n"); |
1498 if(xmlvalue) { |
1503 ret = -1; |
1499 if(namespace) { |
1504 } |
1500 dav_set_property_ns(res, namespace, property, xmlvalue->children); |
|
1501 } else { |
|
1502 dav_set_property(res, property, xmlvalue->children); |
|
1503 } |
|
1504 } else { |
|
1505 fprintf(stderr, "Error: property content is not valid xml\n"); |
|
1506 ret = 1; |
|
1507 } |
|
1508 } else { |
|
1509 if(namespace) { |
|
1510 dav_set_string_property_ns(res, namespace, property, value); |
|
1511 } else { |
|
1512 dav_set_string_property(res, property, value); |
|
1513 } |
|
1514 } |
|
1515 |
|
1516 if(ret == 0) { |
|
1517 if(dav_store(res)) { |
|
1518 print_resource_error(sn, res->path); |
|
1519 fprintf(stderr, "Cannot set property.\n"); |
|
1520 ret = -1; |
|
1521 } |
|
1522 } else |
1505 |
1523 |
1506 free(path); |
1524 free(path); |
|
1525 dav_session_destroy(sn); |
1507 return ret; |
1526 return ret; |
1508 } |
1527 } |
1509 |
1528 |
1510 int cmd_remove_property(CmdArgs *a) { |
1529 int cmd_remove_property(CmdArgs *a) { |
1511 if(a->argc < 2) { |
1530 if(a->argc < 2) { |