Fix compiler warning due to missing function prototype.
[svn.git] / subversion / libsvn_ra_neon / ra_neon.h
blob39ff00903c07895e474e0d141c36e7dda5a6c77c
1 /*
2 * ra_neon.h : Private declarations for the Neon-based DAV RA module.
4 * ====================================================================
5 * Copyright (c) 2000-2008 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
21 #ifndef SVN_LIBSVN_RA_NEON_H
22 #define SVN_LIBSVN_RA_NEON_H
24 #include <apr_pools.h>
25 #include <apr_tables.h>
27 #include <ne_request.h>
28 #include <ne_uri.h>
29 #include <ne_207.h> /* for NE_ELM_207_UNUSED */
30 #include <ne_props.h> /* for ne_propname */
32 #include "svn_types.h"
33 #include "svn_string.h"
34 #include "svn_delta.h"
35 #include "svn_ra.h"
36 #include "svn_dav.h"
38 #include "private/svn_dav_protocol.h"
39 #include "svn_private_config.h"
41 #ifdef __cplusplus
42 extern "C" {
43 #endif /* __cplusplus */
47 /* Rename these types and constants to abstract from Neon */
49 #define SVN_RA_NEON__XML_DECLINE NE_XML_DECLINE
50 #define SVN_RA_NEON__XML_INVALID NE_XML_ABORT
52 #define SVN_RA_NEON__XML_CDATA (1<<1)
53 #define SVN_RA_NEON__XML_COLLECT ((1<<2) | SVN_RA_NEON__XML_CDATA)
55 typedef int svn_ra_neon__xml_elmid;
57 /** XML element */
58 typedef struct {
59 /** XML namespace. */
60 const char *nspace;
62 /** XML tag name. */
63 const char *name;
65 /** XML tag id to be passed to a handler. */
66 svn_ra_neon__xml_elmid id;
68 /** Processing flags for this namespace:tag.
70 * 0 (zero) - regular element, may have children,
71 * SVN_RA_NEON__XML_CDATA - child-less element,
72 * SVN_RA_NEON__XML_COLLECT - complete contents of such element must be
73 * collected as CDATA, includes *_CDATA flag. */
74 unsigned int flags;
76 } svn_ra_neon__xml_elm_t;
80 typedef struct {
81 apr_pool_t *pool;
82 svn_stringbuf_t *url; /* original, unparsed session url */
83 ne_uri root; /* parsed version of above */
84 const char *repos_root; /* URL for repository root */
86 ne_session *ne_sess; /* HTTP session to server */
87 ne_session *ne_sess2;
88 svn_boolean_t main_session_busy; /* TRUE when requests should be created
89 and issued on sess2; currently
90 only used by fetch.c */
92 const svn_ra_callbacks2_t *callbacks; /* callbacks to get auth data */
93 void *callback_baton;
95 svn_auth_iterstate_t *auth_iterstate; /* state of authentication retries */
96 const char *auth_username; /* last authenticated username used */
98 svn_auth_iterstate_t *p11pin_iterstate; /* state of PKCS#11 pin retries */
100 svn_boolean_t compression; /* should we use http compression? */
102 /* Both of these function as caches, and are NULL when uninitialized
103 or cleared: */
104 const char *vcc; /* version-controlled-configuration */
105 const char *uuid; /* repository UUID */
107 svn_ra_progress_notify_func_t progress_func;
108 void *progress_baton;
110 /* Maps SVN_RA_CAPABILITY_foo keys to "yes" or "no" values.
111 If a capability is not yet discovered, it is absent from the table.
112 The table itself is allocated in the svn_ra_neon__session_t's pool;
113 keys and values must have at least that lifetime. Most likely
114 the keys and values are constants anyway (and sufficiently
115 well-informed internal code may just compare against those
116 constants' addresses, therefore). */
117 apr_hash_t *capabilities;
118 } svn_ra_neon__session_t;
121 typedef struct {
122 ne_request *ne_req; /* neon request structure */
123 ne_session *ne_sess; /* neon session structure */
124 svn_ra_neon__session_t *sess; /* DAV session structure */
125 const char *method;
126 const char *url;
127 int rv; /* Return value from
128 ne_request_dispatch() or -1 if
129 not dispatched yet. */
130 int code; /* HTTP return code, or 0 if none */
131 const char *code_desc; /* Textual description of CODE */
132 svn_error_t *err; /* error encountered while executing
133 the request */
134 svn_boolean_t marshalled_error; /* TRUE if the error was server-side */
135 apr_pool_t *pool; /* where this struct is allocated */
136 apr_pool_t *iterpool; /* iteration pool
137 for use within callbacks */
138 } svn_ra_neon__request_t;
141 /* Statement macro to set the request error,
142 * making sure we don't leak any in case we encounter more than one error.
144 * Sets the 'err' field of REQ to the value obtained by evaluating NEW_ERR.
146 #define SVN_RA_NEON__REQ_ERR(req, new_err) \
147 do { \
148 svn_error_t *svn_err__tmp = (new_err); \
149 if ((req)->err && !(req)->marshalled_error) \
150 svn_error_clear(svn_err__tmp); \
151 else if (svn_err__tmp) \
153 svn_error_clear((req)->err); \
154 (req)->err = svn_err__tmp; \
155 (req)->marshalled_error = FALSE; \
157 } while (0)
160 /* Allocate an internal request structure allocated in a newly created
161 * subpool of POOL. Create an associated neon request with the parameters
162 * given.
164 * When a request is being dispatched on the primary Neon session,
165 * the request is allocated to the secondary neon session of SESS.
167 * Register a pool cleanup for any allocated Neon resources.
169 svn_ra_neon__request_t *
170 svn_ra_neon__request_create(svn_ra_neon__session_t *sess,
171 const char *method, const char *url,
172 apr_pool_t *pool);
175 /* Our version of ne_block_reader, which returns an
176 * svn_error_t * instead of an int. */
177 typedef svn_error_t *(*svn_ra_neon__block_reader)(void *baton,
178 const char *data,
179 size_t len);
181 /* Add a response body reader function to REQ.
183 * Use the associated session parameters to determine the use of
184 * compression.
186 * Register a pool cleanup on the pool of REQ to clean up any allocated
187 * Neon resources.
189 void
190 svn_ra_neon__add_response_body_reader(svn_ra_neon__request_t *req,
191 ne_accept_response accpt,
192 svn_ra_neon__block_reader reader,
193 void *userdata);
196 /* Destroy request REQ and any associated resources */
197 #define svn_ra_neon__request_destroy(req) svn_pool_destroy((req)->pool)
199 #ifdef SVN_DEBUG
200 #define DEBUG_CR "\n"
201 #else
202 #define DEBUG_CR ""
203 #endif
206 /** vtable function prototypes */
208 svn_error_t *svn_ra_neon__get_latest_revnum(svn_ra_session_t *session,
209 svn_revnum_t *latest_revnum,
210 apr_pool_t *pool);
212 svn_error_t *svn_ra_neon__get_dated_revision(svn_ra_session_t *session,
213 svn_revnum_t *revision,
214 apr_time_t timestamp,
215 apr_pool_t *pool);
217 svn_error_t *svn_ra_neon__change_rev_prop(svn_ra_session_t *session,
218 svn_revnum_t rev,
219 const char *name,
220 const svn_string_t *value,
221 apr_pool_t *pool);
223 svn_error_t *svn_ra_neon__rev_proplist(svn_ra_session_t *session,
224 svn_revnum_t rev,
225 apr_hash_t **props,
226 apr_pool_t *pool);
228 svn_error_t *svn_ra_neon__rev_prop(svn_ra_session_t *session,
229 svn_revnum_t rev,
230 const char *name,
231 svn_string_t **value,
232 apr_pool_t *pool);
234 svn_error_t * svn_ra_neon__get_commit_editor(svn_ra_session_t *session,
235 const svn_delta_editor_t **editor,
236 void **edit_baton,
237 apr_hash_t *revprop_table,
238 svn_commit_callback2_t callback,
239 void *callback_baton,
240 apr_hash_t *lock_tokens,
241 svn_boolean_t keep_locks,
242 apr_pool_t *pool);
244 svn_error_t * svn_ra_neon__get_file(svn_ra_session_t *session,
245 const char *path,
246 svn_revnum_t revision,
247 svn_stream_t *stream,
248 svn_revnum_t *fetched_rev,
249 apr_hash_t **props,
250 apr_pool_t *pool);
252 svn_error_t *svn_ra_neon__get_dir(svn_ra_session_t *session,
253 apr_hash_t **dirents,
254 svn_revnum_t *fetched_rev,
255 apr_hash_t **props,
256 const char *path,
257 svn_revnum_t revision,
258 apr_uint32_t dirent_fields,
259 apr_pool_t *pool);
261 svn_error_t * svn_ra_neon__abort_commit(void *session_baton,
262 void *edit_baton);
264 svn_error_t * svn_ra_neon__get_mergeinfo(svn_ra_session_t *session,
265 apr_hash_t **mergeinfo,
266 const apr_array_header_t *paths,
267 svn_revnum_t revision,
268 svn_mergeinfo_inheritance_t inherit,
269 svn_boolean_t include_descendants,
270 apr_pool_t *pool);
272 svn_error_t * svn_ra_neon__do_update(svn_ra_session_t *session,
273 const svn_ra_reporter3_t **reporter,
274 void **report_baton,
275 svn_revnum_t revision_to_update_to,
276 const char *update_target,
277 svn_depth_t depth,
278 svn_boolean_t send_copyfrom_args,
279 const svn_delta_editor_t *wc_update,
280 void *wc_update_baton,
281 apr_pool_t *pool);
283 svn_error_t * svn_ra_neon__do_status(svn_ra_session_t *session,
284 const svn_ra_reporter3_t **reporter,
285 void **report_baton,
286 const char *status_target,
287 svn_revnum_t revision,
288 svn_depth_t depth,
289 const svn_delta_editor_t *wc_status,
290 void *wc_status_baton,
291 apr_pool_t *pool);
293 svn_error_t * svn_ra_neon__do_switch(svn_ra_session_t *session,
294 const svn_ra_reporter3_t **reporter,
295 void **report_baton,
296 svn_revnum_t revision_to_update_to,
297 const char *update_target,
298 svn_depth_t depth,
299 const char *switch_url,
300 const svn_delta_editor_t *wc_update,
301 void *wc_update_baton,
302 apr_pool_t *pool);
304 svn_error_t * svn_ra_neon__do_diff(svn_ra_session_t *session,
305 const svn_ra_reporter3_t **reporter,
306 void **report_baton,
307 svn_revnum_t revision,
308 const char *diff_target,
309 svn_depth_t depth,
310 svn_boolean_t ignore_ancestry,
311 svn_boolean_t text_deltas,
312 const char *versus_url,
313 const svn_delta_editor_t *wc_diff,
314 void *wc_diff_baton,
315 apr_pool_t *pool);
317 svn_error_t * svn_ra_neon__get_log(svn_ra_session_t *session,
318 const apr_array_header_t *paths,
319 svn_revnum_t start,
320 svn_revnum_t end,
321 int limit,
322 svn_boolean_t discover_changed_paths,
323 svn_boolean_t strict_node_history,
324 svn_boolean_t include_merged_revisions,
325 const apr_array_header_t *revprops,
326 svn_log_entry_receiver_t receiver,
327 void *receiver_baton,
328 apr_pool_t *pool);
330 svn_error_t *svn_ra_neon__do_check_path(svn_ra_session_t *session,
331 const char *path,
332 svn_revnum_t revision,
333 svn_node_kind_t *kind,
334 apr_pool_t *pool);
336 svn_error_t *svn_ra_neon__do_stat(svn_ra_session_t *session,
337 const char *path,
338 svn_revnum_t revision,
339 svn_dirent_t **dirent,
340 apr_pool_t *pool);
342 svn_error_t *svn_ra_neon__get_file_revs(svn_ra_session_t *session,
343 const char *path,
344 svn_revnum_t start,
345 svn_revnum_t end,
346 svn_boolean_t include_merged_revisions,
347 svn_file_rev_handler_t handler,
348 void *handler_baton,
349 apr_pool_t *pool);
353 ** SVN_RA_NEON__LP_*: local properties for RA/DAV
355 ** ra_neon and ra_serf store properties on the client containing information needed
356 ** to operate against the SVN server. Some of this informations is strictly
357 ** necessary to store, and some is simply stored as a cached value.
360 #define SVN_RA_NEON__LP_NAMESPACE SVN_PROP_WC_PREFIX "ra_dav:"
362 /* store the URL where Activities can be created */
363 /* ### should fix the name to be "activity-coll" at some point */
364 #define SVN_RA_NEON__LP_ACTIVITY_COLL SVN_RA_NEON__LP_NAMESPACE "activity-url"
366 /* store the URL of the version resource (from the DAV:checked-in property) */
367 #define SVN_RA_NEON__LP_VSN_URL SVN_RA_NEON__LP_NAMESPACE "version-url"
371 ** SVN_RA_NEON__PROP_*: properties that we fetch from the server
373 ** These are simply symbolic names for some standard properties that we fetch.
375 #define SVN_RA_NEON__PROP_BASELINE_COLLECTION "DAV:baseline-collection"
376 #define SVN_RA_NEON__PROP_CHECKED_IN "DAV:checked-in"
377 #define SVN_RA_NEON__PROP_VCC "DAV:version-controlled-configuration"
378 #define SVN_RA_NEON__PROP_VERSION_NAME "DAV:" SVN_DAV__VERSION_NAME
379 #define SVN_RA_NEON__PROP_CREATIONDATE "DAV:creationdate"
380 #define SVN_RA_NEON__PROP_CREATOR_DISPLAYNAME "DAV:creator-displayname"
381 #define SVN_RA_NEON__PROP_GETCONTENTLENGTH "DAV:getcontentlength"
383 #define SVN_RA_NEON__PROP_BASELINE_RELPATH \
384 SVN_DAV_PROP_NS_DAV "baseline-relative-path"
386 #define SVN_RA_NEON__PROP_MD5_CHECKSUM SVN_DAV_PROP_NS_DAV "md5-checksum"
388 #define SVN_RA_NEON__PROP_REPOSITORY_UUID SVN_DAV_PROP_NS_DAV "repository-uuid"
390 #define SVN_RA_NEON__PROP_DEADPROP_COUNT SVN_DAV_PROP_NS_DAV "deadprop-count"
392 typedef struct {
393 /* what is the URL for this resource */
394 const char *url;
396 /* is this resource a collection? (from the DAV:resourcetype element) */
397 int is_collection;
399 /* PROPSET: NAME -> VALUE (const char * -> const svn_string_t *) */
400 apr_hash_t *propset;
402 /* --- only used during response processing --- */
403 /* when we see a DAV:href element, what element is the parent? */
404 int href_parent;
406 apr_pool_t *pool;
408 } svn_ra_neon__resource_t;
410 /* ### WARNING: which_props can only identify properties which props.c
411 ### knows about. see the elem_definitions[] array. */
413 /* fetch a bunch of properties from the server. */
414 svn_error_t * svn_ra_neon__get_props(apr_hash_t **results,
415 svn_ra_neon__session_t *sess,
416 const char *url,
417 int depth,
418 const char *label,
419 const ne_propname *which_props,
420 apr_pool_t *pool);
422 /* fetch a single resource's props from the server. */
423 svn_error_t * svn_ra_neon__get_props_resource(svn_ra_neon__resource_t **rsrc,
424 svn_ra_neon__session_t *sess,
425 const char *url,
426 const char *label,
427 const ne_propname *which_props,
428 apr_pool_t *pool);
430 /* fetch a single resource's starting props from the server.
432 Cache the version-controlled-configuration in SESS->vcc, and the
433 repository uuid in SESS->uuid. */
434 svn_error_t * svn_ra_neon__get_starting_props(svn_ra_neon__resource_t **rsrc,
435 svn_ra_neon__session_t *sess,
436 const char *url,
437 const char *label,
438 apr_pool_t *pool);
440 /* Shared helper func: given a public URL which may not exist in HEAD,
441 use SESS to search up parent directories until we can retrieve a
442 *RSRC (allocated in POOL) containing a standard set of "starting"
443 props: {VCC, resourcetype, baseline-relative-path}.
445 Also return *MISSING_PATH (allocated in POOL), which is the
446 trailing portion of the URL that did not exist. If an error
447 occurs, *MISSING_PATH isn't changed.
449 Cache the version-controlled-configuration in SESS->vcc, and the
450 repository uuid in SESS->uuid. */
451 svn_error_t *
452 svn_ra_neon__search_for_starting_props(svn_ra_neon__resource_t **rsrc,
453 const char **missing_path,
454 svn_ra_neon__session_t *sess,
455 const char *url,
456 apr_pool_t *pool);
458 /* fetch a single property from a single resource */
459 svn_error_t * svn_ra_neon__get_one_prop(const svn_string_t **propval,
460 svn_ra_neon__session_t *sess,
461 const char *url,
462 const char *label,
463 const ne_propname *propname,
464 apr_pool_t *pool);
466 /* Get various Baseline-related information for a given "public" URL.
468 Given a session SESS and a URL, return whether the URL is a
469 directory in *IS_DIR. IS_DIR may be NULL if this flag is unneeded.
471 REVISION may be SVN_INVALID_REVNUM to indicate that the operation
472 should work against the latest (HEAD) revision, or whether it should
473 return information about that specific revision.
475 If BC_URL is not NULL, then it will be filled in with the URL for
476 the Baseline Collection for the specified revision, or the HEAD.
478 If BC_RELATIVE is not NULL, then it will be filled in with a
479 relative pathname for the baselined resource corresponding to the
480 revision of the resource specified by URL.
482 If LATEST_REV is not NULL, then it will be filled in with the revision
483 that this information corresponds to. Generally, this will be the same
484 as the REVISION parameter, unless we are working against the HEAD. In
485 that case, the HEAD revision number is returned.
487 Allocation for BC_URL->data, BC_RELATIVE->data, and temporary data,
488 will occur in POOL.
490 Note: a Baseline Collection is a complete tree for a specified Baseline.
491 DeltaV baselines correspond one-to-one to Subversion revisions. Thus,
492 the entire state of a revision can be found in a Baseline Collection.
494 svn_error_t *svn_ra_neon__get_baseline_info(svn_boolean_t *is_dir,
495 svn_string_t *bc_url,
496 svn_string_t *bc_relative,
497 svn_revnum_t *latest_rev,
498 svn_ra_neon__session_t *sess,
499 const char *url,
500 svn_revnum_t revision,
501 apr_pool_t *pool);
503 /* Fetch a baseline resource populated with specific properties.
505 Given a session SESS and a URL, set *BLN_RSRC to a baseline of
506 REVISION, populated with whatever properties are specified by
507 WHICH_PROPS. To fetch all properties, pass NULL for WHICH_PROPS.
509 If BC_RELATIVE is not NULL, then it will be filled in with a
510 relative pathname for the baselined resource corresponding to the
511 revision of the resource specified by URL.
513 svn_error_t *svn_ra_neon__get_baseline_props(svn_string_t *bc_relative,
514 svn_ra_neon__resource_t **bln_rsrc,
515 svn_ra_neon__session_t *sess,
516 const char *url,
517 svn_revnum_t revision,
518 const ne_propname *which_props,
519 apr_pool_t *pool);
521 /* Fetch the repository's unique Version-Controlled-Configuration url.
523 Given a session SESS and a URL, set *VCC to the url of the
524 repository's version-controlled-configuration resource.
526 svn_error_t *svn_ra_neon__get_vcc(const char **vcc,
527 svn_ra_neon__session_t *sess,
528 const char *url,
529 apr_pool_t *pool);
531 /* Issue a PROPPATCH request on URL, transmitting PROP_CHANGES (a hash
532 of const svn_string_t * values keyed on Subversion user-visible
533 property names) and PROP_DELETES (an array of property names to
534 delete). Send any extra request headers in EXTRA_HEADERS. Use POOL
535 for all allocations. */
536 svn_error_t *svn_ra_neon__do_proppatch(svn_ra_neon__session_t *ras,
537 const char *url,
538 apr_hash_t *prop_changes,
539 apr_array_header_t *prop_deletes,
540 apr_hash_t *extra_headers,
541 apr_pool_t *pool);
543 extern const ne_propname svn_ra_neon__vcc_prop;
544 extern const ne_propname svn_ra_neon__checked_in_prop;
549 /* send an OPTIONS request to fetch the activity-collection-set */
550 svn_error_t * svn_ra_neon__get_activity_collection
551 (const svn_string_t **activity_coll,
552 svn_ra_neon__session_t *ras,
553 const char *url,
554 apr_pool_t *pool);
557 /* Call ne_set_request_body_pdovider on REQ with a provider function
558 * that pulls data from BODY_FILE.
560 svn_error_t *svn_ra_neon__set_neon_body_provider(svn_ra_neon__request_t *req,
561 apr_file_t *body_file);
564 #define SVN_RA_NEON__DEPTH_ZERO 0
565 #define SVN_RA_NEON__DEPTH_ONE 1
566 #define SVN_RA_NEON__DEPTH_INFINITE -1
567 /* Add a 'Depth' header to a hash of headers.
569 * DEPTH is one of the above defined SVN_RA_NEON__DEPTH_* values.
571 void
572 svn_ra_neon__add_depth_header(apr_hash_t *extra_headers, int depth);
574 /** Find a given element in the table of elements.
576 * The table of XML elements @a table is searched until element identified by
577 * namespace @a nspace and name @a name is found. If no elements are found,
578 * tries to find and return element identified by @c ELEM_unknown. If that is
579 * not found, returns NULL pointer. */
580 const svn_ra_neon__xml_elm_t *
581 svn_ra_neon__lookup_xml_elem(const svn_ra_neon__xml_elm_t *table,
582 const char *nspace,
583 const char *name);
587 /* Collect CDATA into a stringbuf.
589 * BATON points to a struct of which the first element is
590 * assumed to be an svn_stringbuf_t *.
592 svn_error_t *
593 svn_ra_neon__xml_collect_cdata(void *baton, int state,
594 const char *cdata, size_t len);
597 /* Our equivalent of ne_xml_startelm_cb, the difference being that it
598 * returns errors in a svn_error_t, and returns the element type via
599 * ELEM. To ignore the element *ELEM should be set to
600 * SVN_RA_NEON__XML_DECLINE and SVN_NO_ERROR should be returned.
601 * *ELEM can be set to SVN_RA_NEON__XML_INVALID to indicate invalid XML
602 * (and abort the parse).
604 typedef svn_error_t * (*svn_ra_neon__startelm_cb_t)(int *elem,
605 void *baton,
606 int parent,
607 const char *nspace,
608 const char *name,
609 const char **atts);
611 /* Our equivalent of ne_xml_cdata_cb, the difference being that it returns
612 * errors in a svn_error_t.
614 typedef svn_error_t * (*svn_ra_neon__cdata_cb_t)(void *baton,
615 int state,
616 const char *cdata,
617 size_t len);
619 /* Our equivalent of ne_xml_endelm_cb, the difference being that it returns
620 * errors in a svn_error_t.
622 typedef svn_error_t * (*svn_ra_neon__endelm_cb_t)(void *baton,
623 int state,
624 const char *nspace,
625 const char *name);
628 /* Create a Neon xml parser with callbacks STARTELM_CB, ENDELM_CB and
629 * CDATA_CB. The created parser wraps the Neon callbacks and marshals any
630 * errors returned by the callbacks through the Neon layer. Any errors
631 * raised will be returned by svn_ra_neon__request_dispatch() unless
632 * an earlier error occurred.
634 * Register a pool cleanup on the pool of REQ to clean up any allocated
635 * Neon resources.
637 * ACCPT indicates whether the parser wants read the response body
638 * or not. Pass NULL for ACCPT when you don't want the returned parser
639 * to be attached to REQ.
641 ne_xml_parser *
642 svn_ra_neon__xml_parser_create(svn_ra_neon__request_t *req,
643 ne_accept_response accpt,
644 svn_ra_neon__startelm_cb_t startelm_cb,
645 svn_ra_neon__cdata_cb_t cdata_cb,
646 svn_ra_neon__endelm_cb_t endelm_cb,
647 void *baton);
649 /* Send a METHOD request (e.g., "MERGE", "REPORT", "PROPFIND") to URL
650 * in session SESS, and parse the response. If BODY is non-null, it is
651 * the body of the request, else use the contents of file BODY_FILE
652 * as the body.
654 * STARTELM_CB, CDATA_CB and ENDELM_CB are start element, cdata and end
655 * element handlers, respectively. BATON is passed to each as userdata.
657 * SET_PARSER is a callback function which, if non-NULL, is called
658 * with the XML parser and BATON. This is useful for providers of
659 * validation and element handlers which require access to the parser.
661 * EXTRA_HEADERS is a hash of (const char *) key/value pairs to be
662 * inserted as extra headers in the request. Can be NULL.
664 * STATUS_CODE is an optional 'out' parameter; if non-NULL, then set
665 * *STATUS_CODE to the http status code returned by the server. This
666 * can be set to a useful value even when the function returns an error
667 * however it is not always set when an error is returned. So any caller
668 * wishing to check *STATUS_CODE when an error has been returned must
669 * initialise *STATUS_CODE before calling the function.
671 * If SPOOL_RESPONSE is set, the request response will be cached to
672 * disk in a tmpfile (in full), then read back and parsed.
674 * Use POOL for any temporary allocation.
676 svn_error_t *
677 svn_ra_neon__parsed_request(svn_ra_neon__session_t *sess,
678 const char *method,
679 const char *url,
680 const char *body,
681 apr_file_t *body_file,
682 void set_parser(ne_xml_parser *parser,
683 void *baton),
684 svn_ra_neon__startelm_cb_t startelm_cb,
685 svn_ra_neon__cdata_cb_t cdata_cb,
686 svn_ra_neon__endelm_cb_t endelm_cb,
687 void *baton,
688 apr_hash_t *extra_headers,
689 int *status_code,
690 svn_boolean_t spool_response,
691 apr_pool_t *pool);
694 /* ### add SVN_RA_NEON_ to these to prefix conflicts with (sys) headers? */
695 enum {
696 /* Redefine Neon elements */
697 /* With the new API, we need to be able to use element id also as a return
698 * value from the new `startelm' callback, hence all element ids must be
699 * positive. Root element id is the only id that is not positive, it's zero.
700 * `Root state' is never returned by a callback, it's only passed into it.
701 * Therefore, negative element ids are forbidden from now on. */
702 ELEM_unknown = 1, /* was (-1), see above why it's (1) now */
703 ELEM_root = NE_XML_STATEROOT, /* (0) */
704 ELEM_UNUSED = 100,
705 ELEM_207_first = ELEM_UNUSED,
706 ELEM_multistatus = ELEM_207_first,
707 ELEM_response = ELEM_207_first + 1,
708 ELEM_responsedescription = ELEM_207_first + 2,
709 ELEM_href = ELEM_207_first + 3,
710 ELEM_propstat = ELEM_207_first + 4,
711 ELEM_prop = ELEM_207_first + 5, /* `prop' tag in the DAV namespace */
712 ELEM_status = ELEM_207_first + 6,
713 ELEM_207_UNUSED = ELEM_UNUSED + 100,
714 ELEM_PROPS_UNUSED = ELEM_207_UNUSED + 100,
716 /* DAV elements */
717 ELEM_activity_coll_set = ELEM_207_UNUSED,
718 ELEM_baseline,
719 ELEM_baseline_coll,
720 ELEM_checked_in,
721 ELEM_collection,
722 ELEM_comment,
723 ELEM_revprop,
724 ELEM_creationdate,
725 ELEM_creator_displayname,
726 ELEM_ignored_set,
727 ELEM_merge_response,
728 ELEM_merged_set,
729 ELEM_options_response,
730 ELEM_set_prop,
731 ELEM_remove_prop,
732 ELEM_resourcetype,
733 ELEM_get_content_length,
734 ELEM_updated_set,
735 ELEM_vcc,
736 ELEM_version_name,
737 ELEM_post_commit_err,
738 ELEM_error,
740 /* SVN elements */
741 ELEM_absent_directory,
742 ELEM_absent_file,
743 ELEM_add_directory,
744 ELEM_add_file,
745 ELEM_baseline_relpath,
746 ELEM_md5_checksum,
747 ELEM_deleted_path, /* used in log reports */
748 ELEM_replaced_path, /* used in log reports */
749 ELEM_added_path, /* used in log reports */
750 ELEM_modified_path, /* used in log reports */
751 ELEM_delete_entry,
752 ELEM_fetch_file,
753 ELEM_fetch_props,
754 ELEM_txdelta,
755 ELEM_log_date,
756 ELEM_log_item,
757 ELEM_log_report,
758 ELEM_open_directory,
759 ELEM_open_file,
760 ELEM_target_revision,
761 ELEM_update_report,
762 ELEM_resource_walk,
763 ELEM_resource,
764 ELEM_SVN_prop, /* `prop' tag in the Subversion namespace */
765 ELEM_dated_rev_report,
766 ELEM_name_version_name,
767 ELEM_name_creationdate,
768 ELEM_name_creator_displayname,
769 ELEM_svn_error,
770 ELEM_human_readable,
771 ELEM_repository_uuid,
772 ELEM_get_locations_report,
773 ELEM_location,
774 ELEM_get_location_segments_report,
775 ELEM_location_segment,
776 ELEM_file_revs_report,
777 ELEM_file_rev,
778 ELEM_rev_prop,
779 ELEM_get_locks_report,
780 ELEM_lock,
781 ELEM_lock_path,
782 ELEM_lock_token,
783 ELEM_lock_owner,
784 ELEM_lock_comment,
785 ELEM_lock_creationdate,
786 ELEM_lock_expirationdate,
787 ELEM_lock_discovery,
788 ELEM_lock_activelock,
789 ELEM_lock_type,
790 ELEM_lock_scope,
791 ELEM_lock_depth,
792 ELEM_lock_timeout,
793 ELEM_editor_report,
794 ELEM_open_root,
795 ELEM_apply_textdelta,
796 ELEM_change_file_prop,
797 ELEM_change_dir_prop,
798 ELEM_close_file,
799 ELEM_close_directory,
800 ELEM_deadprop_count,
801 ELEM_mergeinfo_report,
802 ELEM_mergeinfo_item,
803 ELEM_mergeinfo_path,
804 ELEM_mergeinfo_info,
805 ELEM_has_children,
806 ELEM_merged_revision
809 /* ### docco */
810 svn_error_t * svn_ra_neon__merge_activity(svn_revnum_t *new_rev,
811 const char **committed_date,
812 const char **committed_author,
813 const char **post_commit_err,
814 svn_ra_neon__session_t *ras,
815 const char *repos_url,
816 const char *activity_url,
817 apr_hash_t *valid_targets,
818 apr_hash_t *lock_tokens,
819 svn_boolean_t keep_locks,
820 svn_boolean_t disable_merge_response,
821 apr_pool_t *pool);
824 /* Make a buffer for repeated use with svn_stringbuf_set().
825 ### it would be nice to start this buffer with N bytes, but there isn't
826 ### really a way to do that in the string interface (yet), short of
827 ### initializing it with a fake string (and copying it) */
828 #define MAKE_BUFFER(p) svn_stringbuf_ncreate("", 0, (p))
830 svn_error_t *
831 svn_ra_neon__copy_href(svn_stringbuf_t *dst, const char *src,
832 apr_pool_t *pool);
836 /* If RAS contains authentication info, attempt to store it via client
837 callbacks and using POOL for temporary allocations. */
838 svn_error_t *
839 svn_ra_neon__maybe_store_auth_info(svn_ra_neon__session_t *ras,
840 apr_pool_t *pool);
843 /* Like svn_ra_neon__maybe_store_auth_info(), but conditional on ERR.
845 Attempt to store auth info only if ERR is NULL or if ERR->apr_err
846 is not SVN_ERR_RA_NOT_AUTHORIZED. If ERR is not null, return it no
847 matter what, otherwise return the result of the attempt (if any) to
848 store auth info, else return SVN_NO_ERROR. */
849 svn_error_t *
850 svn_ra_neon__maybe_store_auth_info_after_result(svn_error_t *err,
851 svn_ra_neon__session_t *ras,
852 apr_pool_t *pool);
855 /* Create an error of type SVN_ERR_RA_DAV_MALFORMED_DATA for cases where
856 we recieve an element we didn't expect to see. */
857 #define UNEXPECTED_ELEMENT(ns, elem) \
858 (ns ? svn_error_createf(SVN_ERR_RA_DAV_MALFORMED_DATA, \
859 NULL, \
860 _("Got unexpected element %s:%s"), \
861 ns, \
862 elem) \
863 : svn_error_createf(SVN_ERR_RA_DAV_MALFORMED_DATA, \
864 NULL, \
865 _("Got unexpected element %s"), \
866 elem))
868 /* Create an error of type SVN_ERR_RA_DAV_MALFORMED_DATA for cases where
869 we don't receive a necessary attribute. */
870 #define MISSING_ATTR(ns, elem, attr) \
871 (ns ? svn_error_createf(SVN_ERR_RA_DAV_MALFORMED_DATA, \
872 NULL, \
873 _("Missing attribute '%s' on element %s:%s"), \
874 attr, \
875 ns, \
876 elem) \
877 : svn_error_createf(SVN_ERR_RA_DAV_MALFORMED_DATA, \
878 NULL, \
879 _("Missing attribute '%s' on element %s"), \
880 attr, \
881 elem))
883 /* Given a REQUEST, run it; if CODE_P is
884 non-null, return the http status code in *CODE_P. Return any
885 resulting error (from Neon, a <D:error> body response, or any
886 non-2XX status code) as an svn_error_t, otherwise return SVN_NO_ERROR.
888 EXTRA_HEADERS is a hash with (key -> value) of
889 (const char * -> const char *) where the key is the HTTP header name.
891 BODY is a null terminated string containing an in-memory request
892 body. Use svn_ra_neon__set_neon_body_provider() if you want the
893 request body to be read from a file. For requests which have no
894 body at all, consider passing the empty string ("") instead of
895 NULL, as this will cause Neon to generate a "Content-Length: 0"
896 header (which is important to some proxies).
898 OKAY_1 and OKAY_2 are the "acceptable" result codes. Anything other
899 than one of these will generate an error. OKAY_1 should always be
900 specified (e.g. as 200); use 0 for OKAY_2 if a second result code is
901 not allowed.
904 svn_error_t *
905 svn_ra_neon__request_dispatch(int *code_p,
906 svn_ra_neon__request_t *request,
907 apr_hash_t *extra_headers,
908 const char *body,
909 int okay_1,
910 int okay_2,
911 apr_pool_t *pool);
913 /* A layer over SVN_RA_NEON__REQUEST_DISPATCH() adding a
914 207 response parser to extract relevant (error) information.
916 Don't use this function if you're expecting 207 as a valid response.
918 BODY may be NULL if the request doesn't have a body. */
919 svn_error_t *
920 svn_ra_neon__simple_request(int *code,
921 svn_ra_neon__session_t *ras,
922 const char *method,
923 const char *url,
924 apr_hash_t *extra_headers,
925 const char *body,
926 int okay_1, int okay_2, apr_pool_t *pool);
929 /* Convenience statement macro for setting headers in a hash */
930 #define svn_ra_neon__set_header(hash, hdr, val) \
931 apr_hash_set((hash), (hdr), APR_HASH_KEY_STRING, (val))
934 /* Helper function layered over SVN_RA_NEON__SIMPLE_REQUEST() to issue
935 a HTTP COPY request.
937 DEPTH is one of the SVN_RA_NEON__DEPTH_* constants. */
938 svn_error_t *
939 svn_ra_neon__copy(svn_ra_neon__session_t *ras,
940 svn_boolean_t overwrite,
941 int depth,
942 const char *src,
943 const char *dst,
944 apr_pool_t *pool);
946 /* Return the Location HTTP header or NULL if none was sent.
948 * Do allocations in POOL.
950 const char *
951 svn_ra_neon__request_get_location(svn_ra_neon__request_t *request,
952 apr_pool_t *pool);
956 * Implements the get_locations RA layer function. */
957 svn_error_t *
958 svn_ra_neon__get_locations(svn_ra_session_t *session,
959 apr_hash_t **locations,
960 const char *path,
961 svn_revnum_t peg_revision,
962 apr_array_header_t *location_revisions,
963 apr_pool_t *pool);
967 * Implements the get_location_segments RA layer function. */
968 svn_error_t *
969 svn_ra_neon__get_location_segments(svn_ra_session_t *session,
970 const char *path,
971 svn_revnum_t peg_revision,
972 svn_revnum_t start_rev,
973 svn_revnum_t end_rev,
974 svn_location_segment_receiver_t receiver,
975 void *receiver_baton,
976 apr_pool_t *pool);
979 * Implements the get_locks RA layer function. */
980 svn_error_t *
981 svn_ra_neon__get_locks(svn_ra_session_t *session,
982 apr_hash_t **locks,
983 const char *path,
984 apr_pool_t *pool);
987 * Implements the lock RA layer function. */
988 svn_error_t *
989 svn_ra_neon__lock(svn_ra_session_t *session,
990 apr_hash_t *path_revs,
991 const char *comment,
992 svn_boolean_t force,
993 svn_ra_lock_callback_t lock_func,
994 void *lock_baton,
995 apr_pool_t *pool);
998 * Implements the unlock RA layer function. */
999 svn_error_t *
1000 svn_ra_neon__unlock(svn_ra_session_t *session,
1001 apr_hash_t *path_tokens,
1002 svn_boolean_t force,
1003 svn_ra_lock_callback_t lock_func,
1004 void *lock_baton,
1005 apr_pool_t *pool);
1008 * Internal implementation of get_lock RA layer function. */
1009 svn_error_t *
1010 svn_ra_neon__get_lock_internal(svn_ra_neon__session_t *session,
1011 svn_lock_t **lock,
1012 const char *path,
1013 apr_pool_t *pool);
1016 * Implements the get_lock RA layer function. */
1017 svn_error_t *
1018 svn_ra_neon__get_lock(svn_ra_session_t *session,
1019 svn_lock_t **lock,
1020 const char *path,
1021 apr_pool_t *pool);
1024 * Implements the replay RA layer function. */
1025 svn_error_t *
1026 svn_ra_neon__replay(svn_ra_session_t *session,
1027 svn_revnum_t revision,
1028 svn_revnum_t low_water_mark,
1029 svn_boolean_t send_deltas,
1030 const svn_delta_editor_t *editor,
1031 void *edit_baton,
1032 apr_pool_t *pool);
1035 * Implements the replay_range RA layer function. */
1036 svn_error_t *
1037 svn_ra_neon__replay_range(svn_ra_session_t *session,
1038 svn_revnum_t start_revision,
1039 svn_revnum_t end_revision,
1040 svn_revnum_t low_water_mark,
1041 svn_boolean_t send_deltas,
1042 svn_ra_replay_revstart_callback_t revstart_func,
1043 svn_ra_replay_revfinish_callback_t revfinish_func,
1044 void *replay_baton,
1045 apr_pool_t *pool);
1048 * Implements the has_capability RA layer function. */
1049 svn_error_t *
1050 svn_ra_neon__has_capability(svn_ra_session_t *session,
1051 svn_boolean_t *has,
1052 const char *capability,
1053 apr_pool_t *pool);
1056 /* Helper function. Loop over LOCK_TOKENS and assemble all keys and
1057 values into a stringbuf allocated in POOL. The string will be of
1058 the form
1060 <S:lock-token-list xmlns:S="svn:">
1061 <S:lock>
1062 <S:lock-path>path</S:lock-path>
1063 <S:lock-token>token</S:lock-token>
1064 </S:lock>
1065 [...]
1066 </S:lock-token-list>
1068 Callers can then send this in the request bodies, as a way of
1069 reliably marshalling potentially unbounded lists of locks. (We do
1070 this because httpd has limits on how much data can be sent in 'If:'
1071 headers.)
1073 svn_error_t *
1074 svn_ra_neon__assemble_locktoken_body(svn_stringbuf_t **body,
1075 apr_hash_t *lock_tokens,
1076 apr_pool_t *pool);
1079 #ifdef __cplusplus
1081 #endif /* __cplusplus */
1083 #endif /* SVN_LIBSVN_RA_NEON_H */