| 589 | } |
| 590 | |
| 591 | static dav_error * dav_propdb_map_namespaces( |
| 592 | dav_db *db, |
| 593 | const apr_array_header_t *namespaces, |
| 594 | dav_namespace_map **mapping) |
| 595 | { |
| 596 | dav_namespace_map *m = apr_palloc(db->pool, sizeof(*m)); |
| 597 | int i; |
| 598 | int *pmap; |
| 599 | const char **puri; |
| 600 | |
| 601 | /* |
| 602 | ** Iterate over the provided namespaces. If a namespace already appears |
| 603 | ** in our internal map of URI -> ns_id, then store that in the map. If |
| 604 | ** we don't know the namespace yet, then add it to the map and to our |
| 605 | ** table of known namespaces. |
| 606 | */ |
| 607 | m->ns_map = pmap = apr_palloc(db->pool, namespaces->nelts * sizeof(*pmap)); |
| 608 | for (i = namespaces->nelts, puri = (const char **)namespaces->elts; |
| 609 | i-- > 0; |
| 610 | ++puri, ++pmap) { |
| 611 | |
| 612 | const char *uri = *puri; |
| 613 | apr_size_t uri_len = strlen(uri); |
| 614 | long ns_id = (long)apr_hash_get(db->uri_index, uri, uri_len); |
| 615 | |
| 616 | if (ns_id == 0) { |
| 617 | dav_check_bufsize(db->pool, &db->ns_table, uri_len + 1); |
| 618 | memcpy(db->ns_table.buf + db->ns_table.cur_len, uri, uri_len + 1); |
| 619 | db->ns_table.cur_len += uri_len + 1; |
| 620 | |
| 621 | /* copy the uri in case the passed-in namespaces changes in |
| 622 | some way. */ |
| 623 | apr_hash_set(db->uri_index, apr_pstrdup(db->pool, uri), uri_len, |
| 624 | (void *)((long)(db->ns_count + 1))); |
| 625 | |
| 626 | db->ns_table_dirty = 1; |
| 627 | |
| 628 | *pmap = db->ns_count++; |
| 629 | } |
| 630 | else { |
| 631 | *pmap = ns_id - 1; |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | *mapping = m; |
| 636 | return NULL; |
| 637 | } |
| 638 | |
| 639 | static dav_error * dav_propdb_store(dav_db *db, const dav_prop_name *name, |
| 640 | const apr_xml_elem *elem, |
nothing calls this directly
no test coverage detected