libidav/resource.c

changeset 361
b6f2462ee055
parent 355
5da2cf15eb44
child 441
99c26b1b7327
equal deleted inserted replaced
355:5da2cf15eb44 361:b6f2462ee055
1 /* 1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 * 3 *
4 * Copyright 2016 Olaf Wintermann. All rights reserved. 4 * Copyright 2018 Olaf Wintermann. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met: 7 * modification, are permitted provided that the following conditions are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
473 } 473 }
474 // no property update 474 // no property update
475 return property; 475 return property;
476 } 476 }
477 477
478 void dav_set_property(DavResource *res, char *name, char *value) { 478 void dav_set_string_property(DavResource *res, char *name, char *value) {
479 char *pns; 479 char *pns;
480 char *pname; 480 char *pname;
481 dav_get_property_namespace_str(res->session->context, name, &pns, &pname); 481 dav_get_property_namespace_str(res->session->context, name, &pns, &pname);
482 dav_set_property_ns(res, pns, pname, value); 482 dav_set_string_property_ns(res, pns, pname, value);
483 } 483 }
484 484
485 void dav_set_property_ns(DavResource *res, char *ns, char *name, char *value) { 485 void dav_set_string_property_ns(DavResource *res, char *ns, char *name, char *value) {
486 UcxAllocator *a = res->session->mp->allocator; 486 UcxAllocator *a = res->session->mp->allocator;
487 DavResourceData *data = res->data; 487 DavResourceData *data = res->data;
488 488
489 DavProperty *property = dav_session_malloc( 489 DavProperty *property = dav_session_malloc(
490 res->session, 490 res->session,
491 sizeof(DavProperty)); 491 sizeof(DavProperty));
492 property->name = dav_session_strdup(res->session, name); 492 property->name = dav_session_strdup(res->session, name);
493 property->value = dav_text_node(res->session, value); 493 property->value = dav_text_node(res->session, value);
494
495 DavNamespace *namespace = dav_session_malloc(
496 res->session,
497 sizeof(DavNamespace));
498 namespace->prefix = NULL;
499 namespace->name = dav_session_strdup(res->session, ns);
500 property->ns = namespace;
501
502 data->set = ucx_list_append_a(a, data->set, property);
503 }
504
505 void dav_set_property(DavResource *res, char *name, DavXmlNode *value) {
506 char *pns;
507 char *pname;
508 dav_get_property_namespace_str(res->session->context, name, &pns, &pname);
509 dav_set_property_ns(res, pns, pname, value);
510 }
511
512 void dav_set_property_ns(DavResource *res, char *ns, char *name, DavXmlNode *value) {
513 UcxAllocator *a = res->session->mp->allocator;
514 DavResourceData *data = res->data;
515
516 DavProperty *property = dav_session_malloc(
517 res->session,
518 sizeof(DavProperty));
519 property->name = dav_session_strdup(res->session, name);
520 property->value = value; // TODO: copy node?
494 521
495 DavNamespace *namespace = dav_session_malloc( 522 DavNamespace *namespace = dav_session_malloc(
496 res->session, 523 res->session,
497 sizeof(DavNamespace)); 524 sizeof(DavNamespace));
498 namespace->prefix = NULL; 525 namespace->prefix = NULL;

mercurial