MCPcopy Create free account
hub / github.com/apache/httpd / dav_lock_get_activelock

Function dav_lock_get_activelock

modules/dav/main/util_lock.c:42–163  ·  view source on GitHub ↗

** dav_lock_get_activelock: Returns a containing ** an activelock element for every item in the lock_discovery tree */

Source from the content-addressed store, hash-verified

40** an activelock element for every item in the lock_discovery tree
41*/
42DAV_DECLARE(const char *) dav_lock_get_activelock(request_rec *r,
43 dav_lock *lock,
44 dav_buffer *pbuf)
45{
46 dav_lock *lock_scan;
47 const dav_hooks_locks *hooks = DAV_GET_HOOKS_LOCKS(r);
48 int count = 0;
49 dav_buffer work_buf = { 0 };
50 apr_pool_t *p = r->pool;
51
52 /* If no locks or no lock provider, there are no locks */
53 if (lock == NULL || hooks == NULL) {
54 /*
55 ** Since resourcediscovery is defined with (activelock)*,
56 ** <D:activelock/> shouldn't be necessary for an empty lock.
57 */
58 return "";
59 }
60
61 /*
62 ** Note: it could be interesting to sum the lengths of the owners
63 ** and locktokens during this loop. However, the buffer
64 ** mechanism provides some rough padding so that we don't
65 ** really need to have an exact size. Further, constructing
66 ** locktoken strings could be relatively expensive.
67 */
68 for (lock_scan = lock; lock_scan != NULL; lock_scan = lock_scan->next)
69 count++;
70
71 /* if a buffer was not provided, then use an internal buffer */
72 if (pbuf == NULL)
73 pbuf = &work_buf;
74
75 /* reset the length before we start appending stuff */
76 pbuf->cur_len = 0;
77
78 /* prep the buffer with a "good" size */
79 dav_check_bufsize(p, pbuf, count * 300);
80
81 for (; lock != NULL; lock = lock->next) {
82 char tmp[100];
83
84#if DAV_DEBUG
85 if (lock->rectype == DAV_LOCKREC_INDIRECT_PARTIAL) {
86 /* ### crap. design error */
87 dav_buffer_append(p, pbuf,
88 "DESIGN ERROR: attempted to product an "
89 "activelock element from a partial, indirect "
90 "lock record. Creating an XML parsing error "
91 "to ease detection of this situation: <");
92 }
93#endif
94
95 dav_buffer_append(p, pbuf, "<D:activelock>" DEBUG_CR "<D:locktype>");
96 switch (lock->type) {
97 case DAV_LOCKTYPE_WRITE:
98 dav_buffer_append(p, pbuf, "<D:write/>");
99 break;

Callers 3

dav_method_lockFunction · 0.85
dav_insert_corepropFunction · 0.85
mod_dav.hFile · 0.85

Calls 2

dav_check_bufsizeFunction · 0.85
dav_buffer_appendFunction · 0.85

Tested by

no test coverage detected