~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to subversion/libsvn_ra_dav/ra_dav.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * ra_dav.h :  private declarations for the RA/DAV module
 
3
 *
 
4
 * ====================================================================
 
5
 * Copyright (c) 2000-2004 CollabNet.  All rights reserved.
 
6
 *
 
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.
 
12
 *
 
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
 * ====================================================================
 
17
 */
 
18
 
 
19
 
 
20
 
 
21
#ifndef SVN_LIBSVN_RA_DAV_H
 
22
#define SVN_LIBSVN_RA_DAV_H
 
23
 
 
24
#include <apr_pools.h>
 
25
#include <apr_tables.h>
 
26
 
 
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 */
 
31
 
 
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"
 
37
 
 
38
#ifdef __cplusplus
 
39
extern "C" {
 
40
#endif /* __cplusplus */
 
41
 
 
42
 
 
43
 
 
44
/* Rename these types and constants to abstract from Neon */
 
45
 
 
46
#define SVN_RA_DAV__XML_VALID   (0)
 
47
#define SVN_RA_DAV__XML_INVALID (-1)
 
48
#define SVN_RA_DAV__XML_DECLINE (-2)
 
49
 
 
50
#define SVN_RA_DAV__XML_CDATA   (1<<1)
 
51
#define SVN_RA_DAV__XML_COLLECT ((1<<2) | SVN_RA_DAV__XML_CDATA)
 
52
 
 
53
typedef int svn_ra_dav__xml_elmid;
 
54
 
 
55
/** XML element */
 
56
typedef struct {
 
57
  /** XML namespace. */
 
58
  const char *nspace;
 
59
 
 
60
  /** XML tag name. */
 
61
  const char *name;
 
62
 
 
63
  /** XML tag id to be passed to a handler. */
 
64
  svn_ra_dav__xml_elmid id;
 
65
 
 
66
  /** Processing flags for this namespace:tag.
 
67
   *
 
68
   * 0 (zero)                - regular element, may have children,
 
69
   * SVN_RA_DAV__XML_CDATA   - child-less element,
 
70
   * SVN_RA_DAV__XML_COLLECT - complete contents of such element must be
 
71
   *                           collected as CDATA, includes *_CDATA flag. */
 
72
  unsigned int flags;
 
73
 
 
74
} svn_ra_dav__xml_elm_t;
 
75
 
 
76
 
 
77
/** (Neon 0.23) Callback to validate a new child element.
 
78
 *
 
79
 * @a parent and @a child are element ids found in the array of
 
80
 * elements, @a userdata is a user baton. Returns:
 
81
 *
 
82
 * SVN_RA_DAV__XML_VALID   - this is a valid element processed by this
 
83
 *                           handler;
 
84
 * SVN_RA_DAV__XML_INVALID - this is not a valid element, parsing should
 
85
 *                           stop;
 
86
 * SVN_RA_DAV__XML_DECLINE - this handler doesn't know about this element,
 
87
 *                           someone else may handle it.
 
88
 * 
 
89
 * (See @a shim_xml_push_handler in util.c for more information.) */
 
90
typedef int svn_ra_dav__xml_validate_cb(void *userdata,
 
91
                                        svn_ra_dav__xml_elmid parent,
 
92
                                        svn_ra_dav__xml_elmid child);
 
93
 
 
94
/** (Neon 0.23) Callback to start parsing a new child element.
 
95
 *
 
96
 * @a userdata is a user baton. @elm is a member of elements array,
 
97
 * and @a atts is an array of name-value XML attributes.
 
98
 * See @c svn_ra_dav__xml_validate_cb for return values. 
 
99
 *
 
100
 * (See @a shim_xml_push_handler in util.c for more information.) */
 
101
typedef int svn_ra_dav__xml_startelm_cb(void *userdata,
 
102
                                        const svn_ra_dav__xml_elm_t *elm,
 
103
                                        const char **atts);
 
104
 
 
105
/** (Neon 0.23) Callback to finish parsing a child element.
 
106
 *
 
107
 * Callback for @c svn_ra_dav__xml_push_handler. @a userdata is a user
 
108
 * baton. @elm is a member of elements array, and @a cdata is the contents
 
109
 * of the element.
 
110
 * See @c svn_ra_dav__xml_validate_cb for return values.
 
111
 *
 
112
 * (See @a shim_xml_push_handler in util.c for more information.) */
 
113
typedef int svn_ra_dav__xml_endelm_cb(void *userdata,
 
114
                                      const svn_ra_dav__xml_elm_t *elm,
 
115
                                      const char *cdata);
 
116
 
 
117
 
 
118
 
 
119
 
 
120
 
 
121
/* Context for neon request hooks; shared by the neon callbacks in
 
122
   session.c.  */
 
123
struct lock_request_baton
 
124
{
 
125
  /* The method neon is about to execute. */
 
126
  const char *method;
 
127
 
 
128
  /* The current working revision of item being locked. */
 
129
  svn_revnum_t current_rev;
 
130
 
 
131
  /* Whether client is "forcing" a lock or unlock. */
 
132
  svn_boolean_t force;
 
133
 
 
134
  /* The creation-date returned for newly created lock. */
 
135
  apr_time_t creation_date;
 
136
 
 
137
  /* The person who created the lock. */
 
138
  const char *lock_owner;
 
139
 
 
140
  /* A parser for handling <D:error> responses from mod_dav_svn. */
 
141
  ne_xml_parser *error_parser;
 
142
 
 
143
  /* If <D:error> is returned, here's where the parsed result goes. */
 
144
  svn_error_t *err;
 
145
 
 
146
  /* A place for allocating fields in this structure. */
 
147
  apr_pool_t *pool;
 
148
};
 
149
 
 
150
 
 
151
typedef struct {
 
152
  apr_pool_t *pool;
 
153
  const char *url;                      /* original, unparsed session url */
 
154
  ne_uri root;                          /* parsed version of above */
 
155
  const char *repos_root;               /* URL for repository root */
 
156
 
 
157
  ne_session *sess;                     /* HTTP session to server */
 
158
  ne_session *sess2;
 
159
 
 
160
  const svn_ra_callbacks_t *callbacks;  /* callbacks to get auth data */
 
161
  void *callback_baton;
 
162
 
 
163
  svn_auth_iterstate_t *auth_iterstate; /* state of authentication retries */
 
164
  const char *auth_username;            /* last authenticated username used */
 
165
 
 
166
  svn_boolean_t compression;            /* should we use http compression? */
 
167
  const char *uuid;                     /* repository UUID */
 
168
 
 
169
  
 
170
  struct lock_request_baton *lrb;       /* used by lock/unlock */
 
171
 
 
172
} svn_ra_dav__session_t;
 
173
 
 
174
 
 
175
/* Id used with ne_set_session_private() and ne_get_session_private()
 
176
   to retrieve the userdata (which is currently the RA session baton!) */
 
177
#define SVN_RA_NE_SESSION_ID   "SVN"
 
178
 
 
179
 
 
180
#ifdef SVN_DEBUG
 
181
#define DEBUG_CR "\n"
 
182
#else
 
183
#define DEBUG_CR ""
 
184
#endif
 
185
 
 
186
 
 
187
/** vtable function prototypes */
 
188
 
 
189
svn_error_t *svn_ra_dav__get_latest_revnum(svn_ra_session_t *session,
 
190
                                           svn_revnum_t *latest_revnum,
 
191
                                           apr_pool_t *pool);
 
192
 
 
193
svn_error_t *svn_ra_dav__get_dated_revision (svn_ra_session_t *session,
 
194
                                             svn_revnum_t *revision,
 
195
                                             apr_time_t timestamp,
 
196
                                             apr_pool_t *pool);
 
197
 
 
198
svn_error_t *svn_ra_dav__change_rev_prop (svn_ra_session_t *session,
 
199
                                          svn_revnum_t rev,
 
200
                                          const char *name,
 
201
                                          const svn_string_t *value,
 
202
                                          apr_pool_t *pool);
 
203
 
 
204
svn_error_t *svn_ra_dav__rev_proplist (svn_ra_session_t *session,
 
205
                                       svn_revnum_t rev,
 
206
                                       apr_hash_t **props,
 
207
                                       apr_pool_t *pool);
 
208
 
 
209
svn_error_t *svn_ra_dav__rev_prop (svn_ra_session_t *session,
 
210
                                   svn_revnum_t rev,
 
211
                                   const char *name,
 
212
                                   svn_string_t **value,
 
213
                                   apr_pool_t *pool);
 
214
 
 
215
svn_error_t * svn_ra_dav__get_commit_editor(
 
216
  svn_ra_session_t *session,
 
217
  const svn_delta_editor_t **editor,
 
218
  void **edit_baton,
 
219
  const char *log_msg,
 
220
  svn_commit_callback_t callback,
 
221
  void *callback_baton,
 
222
  apr_hash_t *lock_tokens,
 
223
  svn_boolean_t keep_locks,
 
224
  apr_pool_t *pool);
 
225
 
 
226
svn_error_t * svn_ra_dav__get_file(
 
227
  svn_ra_session_t *session,
 
228
  const char *path,
 
229
  svn_revnum_t revision,
 
230
  svn_stream_t *stream,
 
231
  svn_revnum_t *fetched_rev,
 
232
  apr_hash_t **props,
 
233
  apr_pool_t *pool);
 
234
 
 
235
svn_error_t *svn_ra_dav__get_dir(
 
236
  svn_ra_session_t *session,
 
237
  const char *path,
 
238
  svn_revnum_t revision,
 
239
  apr_hash_t **dirents,
 
240
  svn_revnum_t *fetched_rev,
 
241
  apr_hash_t **props,
 
242
  apr_pool_t *pool);
 
243
 
 
244
svn_error_t * svn_ra_dav__abort_commit(
 
245
 void *session_baton,
 
246
 void *edit_baton);
 
247
 
 
248
svn_error_t * svn_ra_dav__do_update(
 
249
  svn_ra_session_t *session,
 
250
  const svn_ra_reporter2_t **reporter,
 
251
  void **report_baton,
 
252
  svn_revnum_t revision_to_update_to,
 
253
  const char *update_target,
 
254
  svn_boolean_t recurse,
 
255
  const svn_delta_editor_t *wc_update,
 
256
  void *wc_update_baton,
 
257
  apr_pool_t *pool);
 
258
 
 
259
svn_error_t * svn_ra_dav__do_status(
 
260
  svn_ra_session_t *session,
 
261
  const svn_ra_reporter2_t **reporter,
 
262
  void **report_baton,
 
263
  const char *status_target,
 
264
  svn_revnum_t revision,
 
265
  svn_boolean_t recurse,
 
266
  const svn_delta_editor_t *wc_status,
 
267
  void *wc_status_baton,
 
268
  apr_pool_t *pool);
 
269
 
 
270
svn_error_t * svn_ra_dav__do_switch(
 
271
  svn_ra_session_t *session,
 
272
  const svn_ra_reporter2_t **reporter,
 
273
  void **report_baton,
 
274
  svn_revnum_t revision_to_update_to,
 
275
  const char *update_target,
 
276
  svn_boolean_t recurse,
 
277
  const char *switch_url,
 
278
  const svn_delta_editor_t *wc_update,
 
279
  void *wc_update_baton,
 
280
  apr_pool_t *pool);
 
281
 
 
282
svn_error_t * svn_ra_dav__do_diff(
 
283
  svn_ra_session_t *session,
 
284
  const svn_ra_reporter2_t **reporter,
 
285
  void **report_baton,
 
286
  svn_revnum_t revision,
 
287
  const char *diff_target,
 
288
  svn_boolean_t recurse,
 
289
  svn_boolean_t ignore_ancestry,
 
290
  const char *versus_url,
 
291
  const svn_delta_editor_t *wc_diff,
 
292
  void *wc_diff_baton,
 
293
  apr_pool_t *pool);
 
294
 
 
295
svn_error_t * svn_ra_dav__get_log(
 
296
  svn_ra_session_t *session,
 
297
  const apr_array_header_t *paths,
 
298
  svn_revnum_t start,
 
299
  svn_revnum_t end,
 
300
  int limit,
 
301
  svn_boolean_t discover_changed_paths,
 
302
  svn_boolean_t strict_node_history,
 
303
  svn_log_message_receiver_t receiver,
 
304
  void *receiver_baton,
 
305
  apr_pool_t *pool);
 
306
 
 
307
svn_error_t *svn_ra_dav__do_check_path(
 
308
  svn_ra_session_t *session,
 
309
  const char *path,
 
310
  svn_revnum_t revision,
 
311
  svn_node_kind_t *kind,
 
312
  apr_pool_t *pool);
 
313
 
 
314
svn_error_t *svn_ra_dav__do_stat(
 
315
  svn_ra_session_t *session,
 
316
  const char *path,
 
317
  svn_revnum_t revision,
 
318
  svn_dirent_t **dirent,
 
319
  apr_pool_t *pool);
 
320
 
 
321
svn_error_t *svn_ra_dav__get_file_revs (svn_ra_session_t *session,
 
322
                                        const char *path,
 
323
                                        svn_revnum_t start,
 
324
                                        svn_revnum_t end,
 
325
                                        svn_ra_file_rev_handler_t handler,
 
326
                                        void *handler_baton,
 
327
                                        apr_pool_t *pool);
 
328
 
 
329
 
 
330
/*
 
331
** SVN_RA_DAV__LP_*: local properties for RA/DAV
 
332
**
 
333
** ra_dav stores properties on the client containing information needed
 
334
** to operate against the SVN server. Some of this informations is strictly
 
335
** necessary to store, and some is simply stored as a cached value.
 
336
*/
 
337
 
 
338
#define SVN_RA_DAV__LP_NAMESPACE SVN_PROP_WC_PREFIX "ra_dav:"
 
339
 
 
340
/* store the URL where Activities can be created */
 
341
/* ### should fix the name to be "activity-coll" at some point */
 
342
#define SVN_RA_DAV__LP_ACTIVITY_COLL SVN_RA_DAV__LP_NAMESPACE "activity-url"
 
343
 
 
344
/* store the URL of the version resource (from the DAV:checked-in property) */
 
345
#define SVN_RA_DAV__LP_VSN_URL          SVN_RA_DAV__LP_NAMESPACE "version-url"
 
346
 
 
347
 
 
348
/*
 
349
** SVN_RA_DAV__PROP_*: properties that we fetch from the server
 
350
**
 
351
** These are simply symbolic names for some standard properties that we fetch.
 
352
*/
 
353
#define SVN_RA_DAV__PROP_BASELINE_COLLECTION    "DAV:baseline-collection"
 
354
#define SVN_RA_DAV__PROP_CHECKED_IN     "DAV:checked-in"
 
355
#define SVN_RA_DAV__PROP_VCC            "DAV:version-controlled-configuration"
 
356
#define SVN_RA_DAV__PROP_VERSION_NAME   "DAV:version-name"
 
357
#define SVN_RA_DAV__PROP_CREATIONDATE   "DAV:creationdate"
 
358
#define SVN_RA_DAV__PROP_CREATOR_DISPLAYNAME "DAV:creator-displayname"
 
359
#define SVN_RA_DAV__PROP_GETCONTENTLENGTH "DAV:getcontentlength"
 
360
 
 
361
#define SVN_RA_DAV__PROP_BASELINE_RELPATH \
 
362
    SVN_DAV_PROP_NS_DAV "baseline-relative-path"
 
363
 
 
364
#define SVN_RA_DAV__PROP_MD5_CHECKSUM SVN_DAV_PROP_NS_DAV "md5-checksum"
 
365
 
 
366
#define SVN_RA_DAV__PROP_REPOSITORY_UUID SVN_DAV_PROP_NS_DAV "repository-uuid"
 
367
 
 
368
 
 
369
typedef struct {
 
370
  /* what is the URL for this resource */
 
371
  const char *url;
 
372
 
 
373
  /* is this resource a collection? (from the DAV:resourcetype element) */
 
374
  int is_collection;
 
375
 
 
376
  /* PROPSET: NAME -> VALUE (const char * -> const svn_string_t *) */
 
377
  apr_hash_t *propset;
 
378
 
 
379
  /* --- only used during response processing --- */
 
380
  /* when we see a DAV:href element, what element is the parent? */
 
381
  int href_parent;
 
382
 
 
383
  apr_pool_t *pool;
 
384
 
 
385
} svn_ra_dav_resource_t;
 
386
 
 
387
/* ### WARNING: which_props can only identify properties which props.c
 
388
   ### knows about. see the elem_definitions[] array. */
 
389
 
 
390
/* fetch a bunch of properties from the server. */
 
391
svn_error_t * svn_ra_dav__get_props(apr_hash_t **results,
 
392
                                    ne_session *sess,
 
393
                                    const char *url,
 
394
                                    int depth,
 
395
                                    const char *label,
 
396
                                    const ne_propname *which_props,
 
397
                                    apr_pool_t *pool);
 
398
 
 
399
/* fetch a single resource's props from the server. */
 
400
svn_error_t * svn_ra_dav__get_props_resource(svn_ra_dav_resource_t **rsrc,
 
401
                                             ne_session *sess,
 
402
                                             const char *url,
 
403
                                             const char *label,
 
404
                                             const ne_propname *which_props,
 
405
                                             apr_pool_t *pool);
 
406
 
 
407
/* fetch a single resource's starting props from the server. */
 
408
svn_error_t * svn_ra_dav__get_starting_props(svn_ra_dav_resource_t **rsrc,
 
409
                                             ne_session *sess,
 
410
                                             const char *url,
 
411
                                             const char *label,
 
412
                                             apr_pool_t *pool);
 
413
 
 
414
/* Shared helper func: given a public URL which may not exist in HEAD,
 
415
   use SESS to search up parent directories until we can retrieve a
 
416
   *RSRC (allocated in POOL) containing a standard set of "starting"
 
417
   props: {VCC, resourcetype, baseline-relative-path}.  
 
418
 
 
419
   Also return *MISSING_PATH (allocated in POOL), which is the
 
420
   trailing portion of the URL that did not exist.  If an error
 
421
   occurs, *MISSING_PATH isn't changed. */
 
422
svn_error_t * 
 
423
svn_ra_dav__search_for_starting_props(svn_ra_dav_resource_t **rsrc,
 
424
                                      const char **missing_path,
 
425
                                      ne_session *sess,
 
426
                                      const char *url,
 
427
                                      apr_pool_t *pool);
 
428
 
 
429
/* fetch a single property from a single resource */
 
430
svn_error_t * svn_ra_dav__get_one_prop(const svn_string_t **propval,
 
431
                                       ne_session *sess,
 
432
                                       const char *url,
 
433
                                       const char *label,
 
434
                                       const ne_propname *propname,
 
435
                                       apr_pool_t *pool);
 
436
 
 
437
/* Get various Baseline-related information for a given "public" URL.
 
438
 
 
439
   Given a Neon session SESS and a URL, return whether the URL is a
 
440
   directory in *IS_DIR.  IS_DIR may be NULL if this flag is unneeded.
 
441
 
 
442
   REVISION may be SVN_INVALID_REVNUM to indicate that the operation
 
443
   should work against the latest (HEAD) revision, or whether it should
 
444
   return information about that specific revision.
 
445
 
 
446
   If BC_URL is not NULL, then it will be filled in with the URL for
 
447
   the Baseline Collection for the specified revision, or the HEAD.
 
448
 
 
449
   If BC_RELATIVE is not NULL, then it will be filled in with a
 
450
   relative pathname for the baselined resource corresponding to the
 
451
   revision of the resource specified by URL.
 
452
 
 
453
   If LATEST_REV is not NULL, then it will be filled in with the revision
 
454
   that this information corresponds to. Generally, this will be the same
 
455
   as the REVISION parameter, unless we are working against the HEAD. In
 
456
   that case, the HEAD revision number is returned.
 
457
 
 
458
   Allocation for BC_URL->data, BC_RELATIVE->data, and temporary data,
 
459
   will occur in POOL.
 
460
 
 
461
   Note: a Baseline Collection is a complete tree for a specified Baseline.
 
462
   DeltaV baselines correspond one-to-one to Subversion revisions. Thus,
 
463
   the entire state of a revision can be found in a Baseline Collection.
 
464
*/
 
465
svn_error_t *svn_ra_dav__get_baseline_info(svn_boolean_t *is_dir,
 
466
                                           svn_string_t *bc_url,
 
467
                                           svn_string_t *bc_relative,
 
468
                                           svn_revnum_t *latest_rev,
 
469
                                           ne_session *sess,
 
470
                                           const char *url,
 
471
                                           svn_revnum_t revision,
 
472
                                           apr_pool_t *pool);
 
473
 
 
474
/* Fetch a baseline resource populated with specific properties.
 
475
   
 
476
   Given a Neon session SESS and a URL, set *BLN_RSRC to a baseline of
 
477
   REVISION, populated with whatever properties are specified by
 
478
   WHICH_PROPS.  To fetch all properties, pass NULL for WHICH_PROPS.
 
479
 
 
480
   If BC_RELATIVE is not NULL, then it will be filled in with a
 
481
   relative pathname for the baselined resource corresponding to the
 
482
   revision of the resource specified by URL.
 
483
*/
 
484
svn_error_t *svn_ra_dav__get_baseline_props(svn_string_t *bc_relative,
 
485
                                            svn_ra_dav_resource_t **bln_rsrc,
 
486
                                            ne_session *sess,
 
487
                                            const char *url,
 
488
                                            svn_revnum_t revision,
 
489
                                            const ne_propname *which_props,
 
490
                                            apr_pool_t *pool);
 
491
 
 
492
/* Fetch the repository's unique Version-Controlled-Configuration url.
 
493
   
 
494
   Given a Neon session SESS and a URL, set *VCC to the url of the
 
495
   repository's version-controlled-configuration resource.
 
496
 */
 
497
svn_error_t *svn_ra_dav__get_vcc(const char **vcc,
 
498
                                 ne_session *sess,
 
499
                                 const char *url,
 
500
                                 apr_pool_t *pool);
 
501
 
 
502
/* Issue a PROPPATCH request on URL, transmitting PROP_CHANGES (a hash
 
503
   of const svn_string_t * values keyed on Subversion user-visible
 
504
   property names) and PROP_DELETES (an array of property names to
 
505
   delete).  Send any extra request headers in EXTRA_HEADERS. Use POOL
 
506
   for all allocations.  */
 
507
svn_error_t *svn_ra_dav__do_proppatch (svn_ra_dav__session_t *ras,
 
508
                                       const char *url,
 
509
                                       apr_hash_t *prop_changes,
 
510
                                       apr_array_header_t *prop_deletes,
 
511
                                       apr_hash_t *extra_headers,
 
512
                                       apr_pool_t *pool);
 
513
 
 
514
extern const ne_propname svn_ra_dav__vcc_prop;
 
515
extern const ne_propname svn_ra_dav__checked_in_prop;
 
516
 
 
517
 
 
518
 
 
519
 
 
520
/* send an OPTIONS request to fetch the activity-collection-set */
 
521
svn_error_t * svn_ra_dav__get_activity_collection(
 
522
  const svn_string_t **activity_coll,
 
523
  svn_ra_dav__session_t *ras,
 
524
  const char *url,
 
525
  apr_pool_t *pool);
 
526
 
 
527
 
 
528
/* Call ne_set_request_body_pdovider on REQ with a provider function
 
529
 * that pulls data from BODY_FILE.
 
530
 */
 
531
svn_error_t *svn_ra_dav__set_neon_body_provider(ne_request *req,
 
532
                                                apr_file_t *body_file);
 
533
 
 
534
 
 
535
/** Find a given element in the table of elements.
 
536
 *
 
537
 * The table of XML elements @a table is searched until element identified by
 
538
 * namespace @a nspace and name @a name is found. If no elements are found,
 
539
 * tries to find and return element identified by @c ELEM_unknown. If that is
 
540
 * not found, returns NULL pointer. */
 
541
const svn_ra_dav__xml_elm_t *
 
542
svn_ra_dav__lookup_xml_elem(const svn_ra_dav__xml_elm_t *table,
 
543
                            const char *nspace,
 
544
                            const char *name);
 
545
 
 
546
 
 
547
/* Send a METHOD request (e.g., "MERGE", "REPORT", "PROPFIND") to URL
 
548
 * in session SESS, and parse the response.  If BODY is non-null, it is
 
549
 * the body of the request, else use the contents of file BODY_FILE
 
550
 * as the body.
 
551
 *
 
552
 * VALIDATE_CB, STARTELM_CB, and ENDELM_CB are Neon validation, start
 
553
 * element, and end element handlers, respectively, from Neon > 0.24.
 
554
 * BATON is passed to each as userdata.
 
555
 *
 
556
 * SET_PARSER is a callback function which, if non-NULL, is called
 
557
 * with the XML parser and BATON.  This is useful for providers of
 
558
 * validation and element handlers which require access to the parser.
 
559
 *
 
560
 * EXTRA_HEADERS is a hash of (const char *) key/value pairs to be
 
561
 * inserted as extra headers in the request.  Can be NULL.
 
562
 *
 
563
 * STATUS_CODE is an optional 'out' parameter; if non-NULL, then set
 
564
 * *STATUS_CODE to the http status code returned by the server.
 
565
 *
 
566
 * If SPOOL_RESPONSE is set, the request response will be cached to
 
567
 * disk in a tmpfile (in full), then read back and parsed.
 
568
 *
 
569
 * Use POOL for any temporary allocation.
 
570
 */
 
571
svn_error_t *
 
572
svn_ra_dav__parsed_request(ne_session *sess,
 
573
                           const char *method,
 
574
                           const char *url,
 
575
                           const char *body,
 
576
                           apr_file_t *body_file,
 
577
                           void set_parser (ne_xml_parser *parser,
 
578
                                            void *baton),
 
579
                           ne_xml_startelm_cb *startelm_cb,
 
580
                           ne_xml_cdata_cb *cdata_cb,
 
581
                           ne_xml_endelm_cb *endelm_cb,
 
582
                           void *baton,
 
583
                           apr_hash_t *extra_headers,
 
584
                           int *status_code,
 
585
                           svn_boolean_t spool_response,
 
586
                           apr_pool_t *pool);
 
587
  
 
588
 
 
589
/* Same as svn_ra_dav__parsed_request, except:
 
590
 *
 
591
 * ELEMENTS is the set of xml elements to recognize in the response.
 
592
 *
 
593
 * The callbacks VALIDATE_CB, STARTELM_CB, and ENDELM_CB, are written
 
594
 * for the Neon <= 0.23 API.
 
595
 */
 
596
svn_error_t *
 
597
svn_ra_dav__parsed_request_compat(ne_session *sess,
 
598
                                  const char *method,
 
599
                                  const char *url,
 
600
                                  const char *body,
 
601
                                  apr_file_t *body_file,
 
602
                                  void set_parser (ne_xml_parser *parser,
 
603
                                                   void *baton),
 
604
                                  const svn_ra_dav__xml_elm_t *elements, 
 
605
                                  svn_ra_dav__xml_validate_cb validate_cb,
 
606
                                  svn_ra_dav__xml_startelm_cb startelm_cb, 
 
607
                                  svn_ra_dav__xml_endelm_cb endelm_cb,
 
608
                                  void *baton,
 
609
                                  apr_hash_t *extra_headers,
 
610
                                  int *status_code,
 
611
                                  svn_boolean_t spool_response,
 
612
                                  apr_pool_t *pool);
 
613
 
 
614
 
 
615
/* ### add SVN_RA_DAV_ to these to prefix conflicts with (sys) headers? */
 
616
enum {
 
617
  /* Redefine Neon elements */
 
618
  /* With the new API, we need to be able to use element id also as a return
 
619
   * value from the new `startelm' callback, hence all element ids must be
 
620
   * positive. Root element id is the only id that is not positive, it's zero.
 
621
   * `Root state' is never returned by a callback, it's only passed into it.
 
622
   * Therefore, negative element ids are forbidden from now on. */
 
623
  ELEM_unknown = 1, /* was (-1), see above why it's (1) now */
 
624
  ELEM_root = NE_XML_STATEROOT, /* (0) */
 
625
  ELEM_UNUSED = 100,
 
626
  ELEM_207_first = ELEM_UNUSED,
 
627
  ELEM_multistatus = ELEM_207_first,
 
628
  ELEM_response = ELEM_207_first + 1,
 
629
  ELEM_responsedescription = ELEM_207_first + 2,
 
630
  ELEM_href = ELEM_207_first + 3,
 
631
  ELEM_propstat = ELEM_207_first + 4,
 
632
  ELEM_prop = ELEM_207_first + 5, /* `prop' tag in the DAV namespace */
 
633
  ELEM_status = ELEM_207_first + 6,
 
634
  ELEM_207_UNUSED = ELEM_UNUSED + 100,
 
635
  ELEM_PROPS_UNUSED = ELEM_207_UNUSED + 100,
 
636
 
 
637
  /* DAV elements */
 
638
  ELEM_activity_coll_set = ELEM_207_UNUSED,
 
639
  ELEM_baseline,
 
640
  ELEM_baseline_coll,
 
641
  ELEM_checked_in,
 
642
  ELEM_collection,
 
643
  ELEM_comment,
 
644
  ELEM_creationdate,
 
645
  ELEM_creator_displayname,
 
646
  ELEM_ignored_set,
 
647
  ELEM_merge_response,
 
648
  ELEM_merged_set,
 
649
  ELEM_options_response,
 
650
  ELEM_set_prop,
 
651
  ELEM_remove_prop,
 
652
  ELEM_resourcetype,
 
653
  ELEM_get_content_length,
 
654
  ELEM_updated_set,
 
655
  ELEM_vcc,
 
656
  ELEM_version_name,
 
657
  ELEM_error,
 
658
 
 
659
  /* SVN elements */
 
660
  ELEM_absent_directory,
 
661
  ELEM_absent_file,
 
662
  ELEM_add_directory,
 
663
  ELEM_add_file,
 
664
  ELEM_baseline_relpath, 
 
665
  ELEM_md5_checksum,
 
666
  ELEM_deleted_path,  /* used in log reports */
 
667
  ELEM_replaced_path,  /* used in log reports */
 
668
  ELEM_added_path,    /* used in log reports */
 
669
  ELEM_modified_path,  /* used in log reports */
 
670
  ELEM_delete_entry,
 
671
  ELEM_fetch_file,
 
672
  ELEM_fetch_props,
 
673
  ELEM_txdelta,
 
674
  ELEM_log_date,
 
675
  ELEM_log_item,
 
676
  ELEM_log_report,
 
677
  ELEM_open_directory,
 
678
  ELEM_open_file,
 
679
  ELEM_target_revision,
 
680
  ELEM_update_report,
 
681
  ELEM_resource_walk,
 
682
  ELEM_resource,
 
683
  ELEM_SVN_prop, /* `prop' tag in the Subversion namespace */
 
684
  ELEM_dated_rev_report,
 
685
  ELEM_name_version_name,
 
686
  ELEM_name_creationdate,
 
687
  ELEM_name_creator_displayname,
 
688
  ELEM_svn_error,
 
689
  ELEM_human_readable,
 
690
  ELEM_repository_uuid,
 
691
  ELEM_get_locations_report,
 
692
  ELEM_location,
 
693
  ELEM_file_revs_report,
 
694
  ELEM_file_rev,
 
695
  ELEM_rev_prop,
 
696
  ELEM_get_locks_report,
 
697
  ELEM_lock,
 
698
  ELEM_lock_path,
 
699
  ELEM_lock_token,
 
700
  ELEM_lock_owner,
 
701
  ELEM_lock_comment,
 
702
  ELEM_lock_creationdate,
 
703
  ELEM_lock_expirationdate
 
704
};
 
705
 
 
706
/* ### docco */
 
707
svn_error_t * svn_ra_dav__merge_activity(
 
708
    svn_revnum_t *new_rev,
 
709
    const char **committed_date,
 
710
    const char **committed_author,
 
711
    svn_ra_dav__session_t *ras,
 
712
    const char *repos_url,
 
713
    const char *activity_url,
 
714
    apr_hash_t *valid_targets,
 
715
    apr_hash_t *lock_tokens,
 
716
    svn_boolean_t keep_locks,
 
717
    svn_boolean_t disable_merge_response,
 
718
    apr_pool_t *pool);
 
719
 
 
720
 
 
721
/* Make a buffer for repeated use with svn_stringbuf_set().
 
722
   ### it would be nice to start this buffer with N bytes, but there isn't
 
723
   ### really a way to do that in the string interface (yet), short of
 
724
   ### initializing it with a fake string (and copying it) */
 
725
#define MAKE_BUFFER(p) svn_stringbuf_ncreate("", 0, (p))
 
726
 
 
727
void svn_ra_dav__copy_href(svn_stringbuf_t *dst, const char *src);
 
728
 
 
729
 
 
730
 
 
731
/* If RAS contains authentication info, attempt to store it via client
 
732
   callbacks.  */
 
733
svn_error_t *
 
734
svn_ra_dav__maybe_store_auth_info (svn_ra_dav__session_t *ras);
 
735
 
 
736
 
 
737
/* Like svn_ra_dav__maybe_store_auth_info(), but conditional on ERR.
 
738
 
 
739
   Attempt to store auth info only if ERR is NULL or if ERR->apr_err
 
740
   is not SVN_ERR_RA_NOT_AUTHORIZED.  If ERR is not null, return it no
 
741
   matter what, otherwise return the result of the attempt (if any) to
 
742
   store auth info, else return SVN_NO_ERROR. */
 
743
svn_error_t *
 
744
svn_ra_dav__maybe_store_auth_info_after_result(svn_error_t *err,
 
745
                                               svn_ra_dav__session_t *ras);
 
746
 
 
747
 
 
748
/* Create an error object for an error from neon in the given session,
 
749
   where the return code from neon was RETCODE, and CONTEXT describes
 
750
   what was being attempted.  Do temporary allocations in POOL. */
 
751
svn_error_t *svn_ra_dav__convert_error(ne_session *sess,
 
752
                                       const char *context,
 
753
                                       int retcode,
 
754
                                       apr_pool_t *pool);
 
755
 
 
756
 
 
757
/* Given a neon REQUEST and SESSION, run the request; if CODE_P is
 
758
   non-null, return the http status code in *CODE_P.  Return any
 
759
   resulting error (from neon, a <D:error> body response, or any
 
760
   non-2XX status code) as an svn_error_t, otherwise return NULL.  
 
761
   The request will be freed either way.
 
762
 
 
763
   SESSION, METHOD, and URL are required as well, as they are used to
 
764
   describe the possible error.  The error will be allocated in POOL.
 
765
 
 
766
   OKAY_1 and OKAY_2 are the "acceptable" result codes. Anything other
 
767
   than one of these will generate an error. OKAY_1 should always be
 
768
   specified (e.g. as 200); use 0 for OKAY_2 if a second result code is
 
769
   not allowed.
 
770
 
 
771
   ### not super sure on this "okay" stuff, but it means that the request
 
772
   ### dispatching code can generate much better errors than the callers
 
773
   ### when something goes wrong. if we need more than two, then we could
 
774
   ### add another param, switch to an array, or do something entirely
 
775
   ### different...
 
776
 */
 
777
svn_error_t *
 
778
svn_ra_dav__request_dispatch(int *code_p,
 
779
                             ne_request *request,
 
780
                             ne_session *session,
 
781
                             const char *method,
 
782
                             const char *url,
 
783
                             int okay_1,
 
784
                             int okay_2,
 
785
                             apr_pool_t *pool);
 
786
 
 
787
 
 
788
/* Give PARSER the ability to parse a mod_dav_svn <D:error> response
 
789
   body in the case of a non-2XX response to REQUEST.  If a <D:error>
 
790
   response is detected, then set *ERR to the parsed error.
 
791
*/
 
792
void
 
793
svn_ra_dav__add_error_handler(ne_request *request,
 
794
                              ne_xml_parser *parser,
 
795
                              svn_error_t **err,
 
796
                              apr_pool_t *pool);
 
797
 
 
798
 
 
799
/*
 
800
 * Implements the get_locations RA layer function. */
 
801
svn_error_t *
 
802
svn_ra_dav__get_locations (svn_ra_session_t *session,
 
803
                           apr_hash_t **locations,
 
804
                           const char *path,
 
805
                           svn_revnum_t peg_revision,
 
806
                           apr_array_header_t *location_revisions,
 
807
                           apr_pool_t *pool);
 
808
 
 
809
 
 
810
/*
 
811
 * Implements the get_locks RA layer function. */
 
812
svn_error_t *
 
813
svn_ra_dav__get_locks(svn_ra_session_t *session,
 
814
                      apr_hash_t **locks,
 
815
                      const char *path,
 
816
                      apr_pool_t *pool);
 
817
 
 
818
/*
 
819
 * Implements the get_lock RA layer function. */
 
820
svn_error_t *
 
821
svn_ra_dav__get_lock(svn_ra_session_t *session,
 
822
                     svn_lock_t **lock,
 
823
                     const char *path,
 
824
                     apr_pool_t *pool);
 
825
 
 
826
 
 
827
/* Helper function.  Loop over LOCK_TOKENS and assemble all keys and
 
828
   values into a stringbuf allocated in POOL.  The string will be of
 
829
   the form
 
830
 
 
831
    <S:lock-token-list xmlns:S="svn:">
 
832
      <S:lock>
 
833
        <S:lock-path>path</S:lock-path>
 
834
        <S:lock-token>token</S:lock-token>
 
835
      </S:lock>
 
836
      [...]
 
837
    </S:lock-token-list>
 
838
 
 
839
   Callers can then send this in the request bodies, as a way of
 
840
   reliably marshalling potentially unbounded lists of locks.  (We do
 
841
   this because httpd has limits on how much data can be sent in 'If:'
 
842
   headers.)
 
843
 */
 
844
svn_error_t *
 
845
svn_ra_dav__assemble_locktoken_body(svn_stringbuf_t **body,
 
846
                                    apr_hash_t *lock_tokens,
 
847
                                    apr_pool_t *pool);
 
848
 
 
849
 
 
850
#ifdef __cplusplus
 
851
}
 
852
#endif /* __cplusplus */
 
853
 
 
854
#endif  /* SVN_LIBSVN_RA_DAV_H */