~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/libsvn_ra_serf/ra_serf.h

  • Committer: Package Import Robot
  • Author(s): James McCoy, Peter Samuelson, James McCoy
  • Date: 2014-01-12 19:48:33 UTC
  • mfrom: (0.2.10)
  • Revision ID: package-import@ubuntu.com-20140112194833-w3axfwksn296jn5x
Tags: 1.8.5-1
[ Peter Samuelson ]
* New upstream release.  (Closes: #725787) Rediff patches:
  - Remove apr-abi1 (applied upstream), rename apr-abi2 to apr-abi
  - Remove loosen-sqlite-version-check (shouldn't be needed)
  - Remove java-osgi-metadata (applied upstream)
  - svnmucc prompts for a changelog if none is provided. (Closes: #507430)
  - Remove fix-bdb-version-detection, upstream uses "apu-config --dbm-libs"
  - Remove ruby-test-wc (applied upstream)
  - Fix “svn diff -r N file” when file has svn:mime-type set.
    (Closes: #734163)
  - Support specifying an encoding for mod_dav_svn's environment in which
    hooks are run.  (Closes: #601544)
  - Fix ordering of “svnadmin dump” paths with certain APR versions.
    (Closes: #687291)
  - Provide a better error message when authentication fails with an
    svn+ssh:// URL.  (Closes: #273874)
  - Updated Polish translations.  (Closes: #690815)

[ James McCoy ]
* Remove all traces of libneon, replaced by libserf.
* patches/sqlite_3.8.x_workaround: Upstream fix for wc-queries-test test
  failurse.
* Run configure with --with-apache-libexecdir, which allows removing part of
  patches/rpath.
* Re-enable auth-test as upstream has fixed the problem of picking up
  libraries from the environment rather than the build tree.
  (Closes: #654172)
* Point LD_LIBRARY_PATH at the built auth libraries when running the svn
  command during the build.  (Closes: #678224)
* Add a NEWS entry describing how to configure mod_dav_svn to understand
  UTF-8.  (Closes: #566148)
* Remove ancient transitional package, libsvn-ruby.
* Enable compatibility with Sqlite3 versions back to Wheezy.
* Enable hardening flags.  (Closes: #734918)
* patches/build-fixes: Enable verbose build logs.
* Build against the default ruby version.  (Closes: #722393)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
 
28
28
#include <serf.h>
29
 
#include <expat.h>
 
29
#include <expat.h>  /* for XML_Parser  */
30
30
#include <apr_uri.h>
31
31
 
32
32
#include "svn_types.h"
39
39
#include "svn_dirent_uri.h"
40
40
 
41
41
#include "private/svn_dav_protocol.h"
 
42
#include "private/svn_subr_private.h"
 
43
#include "private/svn_editor.h"
42
44
 
43
45
#include "blncache.h"
44
46
 
48
50
 
49
51
 
50
52
/* Enforce the minimum version of serf. */
51
 
#if !SERF_VERSION_AT_LEAST(0, 7, 1)
52
 
#error Please update your version of serf to at least 0.7.1.
 
53
#if !SERF_VERSION_AT_LEAST(1, 2, 1)
 
54
#error Please update your version of serf to at least 1.2.1.
53
55
#endif
54
56
 
55
57
/** Use this to silence compiler warnings about unused parameters. */
56
58
#define UNUSED_CTX(x) ((void)(x))
57
59
 
58
 
/** Our User-Agent string. */
59
 
#define USER_AGENT "SVN/" SVN_VER_NUMBER " serf/" \
60
 
                   APR_STRINGIFY(SERF_MAJOR_VERSION) "." \
61
 
                   APR_STRINGIFY(SERF_MINOR_VERSION) "." \
62
 
                   APR_STRINGIFY(SERF_PATCH_VERSION)
 
60
/** Wait duration (in microseconds) used in calls to serf_context_run() */
 
61
#define SVN_RA_SERF__CONTEXT_RUN_DURATION 500000
 
62
 
63
63
 
64
64
 
65
65
/* Forward declarations. */
73
73
  /* Bucket allocator for this connection. */
74
74
  serf_bucket_alloc_t *bkt_alloc;
75
75
 
76
 
  /* Host name */
77
 
  const char *hostname;
78
 
 
79
 
  /* Are we using ssl */
80
 
  svn_boolean_t using_ssl;
81
 
  int server_cert_failures; /* Collected cert failures in chain */
82
 
 
83
 
  /* Should we ask for compressed responses? */
84
 
  svn_boolean_t using_compression;
 
76
  /* Collected cert failures in chain.  */
 
77
  int server_cert_failures;
85
78
 
86
79
  /* What was the last HTTP status code we got on this connection? */
87
80
  int last_status_code;
93
86
 
94
87
  svn_ra_serf__session_t *session;
95
88
 
96
 
  /* user agent string */
97
 
  const char *useragent;
98
 
 
99
89
} svn_ra_serf__connection_t;
100
90
 
 
91
/** Maximum value we'll allow for the http-max-connections config option.
 
92
 *
 
93
 * Note: minimum 2 connections are required for ra_serf to function
 
94
 * correctly!
 
95
 */
 
96
#define SVN_RA_SERF__MAX_CONNECTIONS_LIMIT 8
 
97
 
101
98
/*
102
99
 * The master serf RA session.
103
100
 *
110
107
  /* The current context */
111
108
  serf_context_t *context;
112
109
 
 
110
  /* The maximum number of connections we'll use for parallelized
 
111
     fetch operations (updates, etc.) */
 
112
  apr_int64_t max_connections;
 
113
 
113
114
  /* Are we using ssl */
114
115
  svn_boolean_t using_ssl;
115
116
 
116
117
  /* Should we ask for compressed responses? */
117
118
  svn_boolean_t using_compression;
118
119
 
 
120
  /* The user agent string */
 
121
  const char *useragent;
 
122
 
119
123
  /* The current connection */
120
 
  svn_ra_serf__connection_t **conns;
 
124
  svn_ra_serf__connection_t *conns[SVN_RA_SERF__MAX_CONNECTIONS_LIMIT];
121
125
  int num_conns;
122
126
  int cur_conn;
123
127
 
129
133
  apr_uri_t repos_root;
130
134
  const char *repos_root_str;
131
135
 
 
136
  /* The server is not Apache/mod_dav_svn (directly) and only supports
 
137
     HTTP/1.0. Thus, we cannot send chunked requests.  */
 
138
  svn_boolean_t http10;
 
139
 
 
140
  /* Should we use Transfer-Encoding: chunked for HTTP/1.1 servers. */
 
141
  svn_boolean_t using_chunked_requests;
 
142
 
 
143
  /* Do we need to detect whether the connection supports chunked requests?
 
144
     i.e. is there a (reverse) proxy that does not support them?  */
 
145
  svn_boolean_t detect_chunking;
 
146
 
132
147
  /* Our Version-Controlled-Configuration; may be NULL until we know it. */
133
148
  const char *vcc_url;
134
149
 
148
163
  svn_cancel_func_t cancel_func;
149
164
  void *cancel_baton;
150
165
 
 
166
  /* Ev2 shim callbacks */
 
167
  svn_delta_shim_callbacks_t *shim_callbacks;
 
168
 
151
169
  /* Error that we've received but not yet returned upstream. */
152
170
  svn_error_t *pending_error;
153
171
 
168
186
  const char *activity_collection_url;
169
187
 
170
188
  /* Are we using a proxy? */
171
 
  int using_proxy;
 
189
  svn_boolean_t using_proxy;
172
190
 
173
191
  const char *proxy_username;
174
192
  const char *proxy_password;
182
200
  const char *uuid;
183
201
 
184
202
  /* Connection timeout value */
185
 
  long timeout;
 
203
  apr_interval_time_t timeout;
186
204
 
187
205
  /* HTTPv1 flags */
188
206
  svn_tristate_t supports_deadprop_count;
209
227
  const char *vtxn_stub;        /* for accessing transactions (i.e. txnprops) */
210
228
  const char *vtxn_root_stub;   /* for accessing TXN/PATH pairs */
211
229
 
 
230
  /* Hash mapping const char * server-supported POST types to
 
231
     disinteresting-but-non-null values. */
 
232
  apr_hash_t *supported_posts;
 
233
 
212
234
  /*** End HTTP v2 stuff ***/
213
235
 
214
236
  svn_ra_serf__blncache_t *blncache;
 
237
 
 
238
  /* Trisate flag that indicates user preference for using bulk updates
 
239
     (svn_tristate_true) with all the properties and content in the
 
240
     update-report response. If svn_tristate_false, request a skelta
 
241
     update-report with inlined properties. If svn_tristate_unknown then use
 
242
     server preference. */
 
243
  svn_tristate_t bulk_updates;
 
244
 
 
245
  /* Indicates if the server wants bulk update requests (Prefer) or only
 
246
     accepts skelta requests (Off). If this value is On both options are
 
247
     allowed. */
 
248
  const char *server_allows_bulk;
 
249
 
 
250
  /* Indicates if the server supports sending inlined props in update editor
 
251
   * in skelta mode (send-all == 'false'). */
 
252
  svn_boolean_t supports_inline_props;
 
253
 
 
254
  /* Indicates whether the server supports issuing replay REPORTs
 
255
     against rev resources (children of `rev_stub', elsestruct). */
 
256
  svn_boolean_t supports_rev_rsrc_replay;
215
257
};
216
258
 
217
259
#define SVN_RA_SERF__HAVE_HTTPV2_SUPPORT(sess) ((sess)->me_resource != NULL)
276
318
  { NULL }
277
319
};
278
320
 
279
 
static const svn_ra_serf__dav_props_t vcc_props[] =
280
 
{
281
 
  { "DAV:", "version-controlled-configuration" },
282
 
  { NULL }
283
 
};
284
 
 
285
321
static const svn_ra_serf__dav_props_t check_path_props[] =
286
322
{
287
323
  { "DAV:", "resourcetype" },
288
324
  { NULL }
289
325
};
290
326
 
291
 
static const svn_ra_serf__dav_props_t uuid_props[] =
292
 
{
293
 
  { SVN_DAV_PROP_NS_DAV, "repository-uuid" },
294
 
  { NULL }
295
 
};
296
 
 
297
 
static const svn_ra_serf__dav_props_t repos_root_props[] =
298
 
{
299
 
  { SVN_DAV_PROP_NS_DAV, "baseline-relative-path" },
300
 
  { NULL }
301
 
};
302
 
 
303
 
static const svn_ra_serf__dav_props_t href_props[] =
304
 
{
305
 
  { "DAV:", "href" },
 
327
static const svn_ra_serf__dav_props_t type_and_checksum_props[] =
 
328
{
 
329
  { "DAV:", "resourcetype" },
 
330
  { SVN_DAV_PROP_NS_DAV, "sha1-checksum" },
306
331
  { NULL }
307
332
};
308
333
 
309
334
/* WC props compatibility with ra_neon. */
310
 
#define SVN_RA_SERF__WC_NAMESPACE SVN_PROP_WC_PREFIX "ra_dav:"
311
 
#define SVN_RA_SERF__WC_ACTIVITY_URL SVN_RA_SERF__WC_NAMESPACE "activity-url"
312
 
#define SVN_RA_SERF__WC_CHECKED_IN_URL SVN_RA_SERF__WC_NAMESPACE "version-url"
 
335
#define SVN_RA_SERF__WC_CHECKED_IN_URL SVN_PROP_WC_PREFIX "ra_dav:version-url"
313
336
 
314
337
/** Serf utility functions **/
315
338
 
320
343
                        void *baton,
321
344
                        apr_pool_t *pool);
322
345
 
323
 
serf_bucket_t*
324
 
svn_ra_serf__accept_response(serf_request_t *request,
325
 
                             serf_bucket_t *stream,
326
 
                             void *acceptor_baton,
327
 
                             apr_pool_t *pool);
328
 
 
329
346
void
330
347
svn_ra_serf__conn_closed(serf_connection_t *conn,
331
348
                         void *closed_baton,
352
369
                                   const char *cert_path,
353
370
                                   const char **password);
354
371
 
355
 
/*
356
 
 * Create a REQUEST with an associated REQ_BKT in the SESSION.
357
 
 *
358
 
 * If HDRS_BKT is not-NULL, it will be set to a headers_bucket that
359
 
 * corresponds to the new request.
360
 
 *
361
 
 * The request will be METHOD at URL.
362
 
 *
363
 
 * If BODY_BKT is not-NULL, it will be sent as the request body.
364
 
 *
365
 
 * If CONTENT_TYPE is not-NULL, it will be sent as the Content-Type header.
366
 
 */
367
 
svn_error_t *
368
 
svn_ra_serf__setup_serf_req(serf_request_t *request,
369
 
                            serf_bucket_t **req_bkt, serf_bucket_t **hdrs_bkt,
370
 
                            svn_ra_serf__connection_t *conn,
371
 
                            const char *method, const char *url,
372
 
                            serf_bucket_t *body_bkt, const char *content_type);
373
372
 
374
373
/*
375
374
 * This function will run the serf context in SESS until *DONE is TRUE.
384
383
(*svn_ra_serf__response_handler_t)(serf_request_t *request,
385
384
                                   serf_bucket_t *response,
386
385
                                   void *handler_baton,
387
 
                                   apr_pool_t *pool);
388
 
 
389
 
/* Callback for setting up a complete serf request */
390
 
typedef svn_error_t *
391
 
(*svn_ra_serf__request_setup_t)(serf_request_t *request,
392
 
                                void *setup_baton,
393
 
                                serf_bucket_t **req_bkt,
394
 
                                serf_response_acceptor_t *acceptor,
395
 
                                void **acceptor_baton,
396
 
                                svn_ra_serf__response_handler_t *handler,
397
 
                                void **handler_baton,
398
 
                                apr_pool_t *pool);
 
386
                                   apr_pool_t *scratch_pool);
399
387
 
400
388
/* Callback for when a request body is needed. */
 
389
/* ### should pass a scratch_pool  */
401
390
typedef svn_error_t *
402
391
(*svn_ra_serf__request_body_delegate_t)(serf_bucket_t **body_bkt,
403
392
                                        void *baton,
404
393
                                        serf_bucket_alloc_t *alloc,
405
 
                                        apr_pool_t *pool);
 
394
                                        apr_pool_t *request_pool);
406
395
 
407
396
/* Callback for when request headers are needed. */
 
397
/* ### should pass a scratch_pool  */
408
398
typedef svn_error_t *
409
399
(*svn_ra_serf__request_header_delegate_t)(serf_bucket_t *headers,
410
400
                                          void *baton,
411
 
                                          apr_pool_t *pool);
 
401
                                          apr_pool_t *request_pool);
412
402
 
413
403
/* Callback for when a response has an error. */
414
404
typedef svn_error_t *
417
407
                                 int status_code,
418
408
                                 void *baton);
419
409
 
 
410
/* ### we should reorder the types in this file.  */
 
411
typedef struct svn_ra_serf__server_error_t svn_ra_serf__server_error_t;
 
412
 
420
413
/*
421
414
 * Structure that can be passed to our default handler to guide the
422
415
 * execution of the request through its lifecycle.
431
424
  /* The content-type of the request body. */
432
425
  const char *body_type;
433
426
 
 
427
  /* If TRUE then default Accept-Encoding request header is not configured for
 
428
     request. If FALSE then 'gzip' accept encoding will be used if compression
 
429
     enabled. */
 
430
  svn_boolean_t custom_accept_encoding;
 
431
 
 
432
  /* Has the request/response been completed?  */
 
433
  svn_boolean_t done;
 
434
 
 
435
  /* If we captured an error from the server, then this will be non-NULL.
 
436
     It will be allocated from HANDLER_POOL.  */
 
437
  svn_ra_serf__server_error_t *server_error;
 
438
 
434
439
  /* The handler and baton pair for our handler. */
435
440
  svn_ra_serf__response_handler_t response_handler;
436
441
  void *response_baton;
437
442
 
 
443
  /* When REPONSE_HANDLER is invoked, the following fields will be set
 
444
     based on the response header. HANDLER_POOL must be non-NULL for these
 
445
     values to be filled in. SLINE.REASON and LOCATION will be allocated
 
446
     within HANDLER_POOL.  */
 
447
  serf_status_line sline;  /* The parsed Status-Line  */
 
448
  const char *location;  /* The Location: header, if any  */
 
449
 
438
450
  /* The handler and baton pair to be executed when a non-recoverable error
439
451
   * is detected.  If it is NULL in the presence of an error, an abort() may
440
452
   * be triggered.
442
454
  svn_ra_serf__response_error_t response_error;
443
455
  void *response_error_baton;
444
456
 
445
 
  /* This function and baton will be executed when the request is about
446
 
   * to be delivered by serf.
447
 
   *
448
 
   * This just passes through serf's raw request creation parameters.
449
 
   * None of the other parameters will be utilized if this field is set.
450
 
   */
451
 
  svn_ra_serf__request_setup_t setup;
452
 
  void *setup_baton;
453
 
 
454
457
  /* This function and baton pair allows for custom request headers to
455
458
   * be set.
456
459
   *
475
478
  /* The connection and session to be used for this request. */
476
479
  svn_ra_serf__connection_t *conn;
477
480
  svn_ra_serf__session_t *session;
 
481
 
 
482
  /* Internal flag to indicate we've parsed the headers.  */
 
483
  svn_boolean_t reading_body;
 
484
 
 
485
  /* When this flag will be set, the core handler will discard any unread
 
486
     portion of the response body. The registered response handler will
 
487
     no longer be called.  */
 
488
  svn_boolean_t discard_body;
 
489
 
 
490
  /* Pool for allocating SLINE.REASON and LOCATION. If this pool is NULL,
 
491
     then the requestor does not care about SLINE and LOCATION.  */
 
492
  apr_pool_t *handler_pool;
 
493
 
478
494
} svn_ra_serf__handler_t;
479
495
 
 
496
 
 
497
/* Run one request and process the response.
 
498
 
 
499
   Similar to context_run_wait(), but this creates the request for HANDLER
 
500
   and then waits for it to complete.
 
501
 
 
502
   WARNING: context_run_wait() does NOT create a request, whereas this
 
503
   function DOES. Avoid a double-create.  */
 
504
svn_error_t *
 
505
svn_ra_serf__context_run_one(svn_ra_serf__handler_t *handler,
 
506
                             apr_pool_t *scratch_pool);
 
507
 
 
508
 
480
509
/*
481
510
 * Helper function to queue a request in the @a handler's connection.
482
511
 */
514
543
 */
515
544
typedef svn_error_t *
516
545
(*svn_ra_serf__xml_start_element_t)(svn_ra_serf__xml_parser_t *parser,
517
 
                                    void *baton,
518
546
                                    svn_ra_serf__dav_props_t name,
519
 
                                    const char **attrs);
 
547
                                    const char **attrs,
 
548
                                    apr_pool_t *scratch_pool);
520
549
 
521
550
/* Callback invoked with @a baton by our XML @a parser when an element with
522
551
 * the @a name is closed.
523
552
 */
524
553
typedef svn_error_t *
525
554
(*svn_ra_serf__xml_end_element_t)(svn_ra_serf__xml_parser_t *parser,
526
 
                                  void *baton,
527
 
                                  svn_ra_serf__dav_props_t name);
 
555
                                  svn_ra_serf__dav_props_t name,
 
556
                                  apr_pool_t *scratch_pool);
528
557
 
529
558
/* Callback invoked with @a baton by our XML @a parser when a CDATA portion
530
559
 * of @a data with size @a len is encountered.
531
560
 *
532
561
 * This may be invoked multiple times for the same tag.
533
 
 *
534
 
 * @see svn_ra_serf__expand_string
535
562
 */
536
563
typedef svn_error_t *
537
564
(*svn_ra_serf__xml_cdata_chunk_handler_t)(svn_ra_serf__xml_parser_t *parser,
538
 
                                          void *baton,
539
565
                                          const char *data,
540
 
                                          apr_size_t len);
 
566
                                          apr_size_t len,
 
567
                                          apr_pool_t *scratch_pool);
541
568
 
542
569
/*
543
570
 * Helper structure associated with handle_xml_parser handler that will
547
574
  /* Temporary allocations should be made in this pool. */
548
575
  apr_pool_t *pool;
549
576
 
 
577
  /* What kind of response are we parsing? If set, this should typically
 
578
     define the report name.  */
 
579
  const char *response_type;
 
580
 
550
581
  /* Caller-specific data passed to the start, end, cdata callbacks.  */
551
582
  void *user_data;
552
583
 
568
599
  /* Our previously used states (will be reused). */
569
600
  svn_ra_serf__xml_state_t *free_state;
570
601
 
571
 
  /* If non-NULL, the status code of the response will be stored here.
572
 
   *
573
 
   * If this is NULL and an error is received, an abort will be triggered.
574
 
   */
575
 
  int *status_code;
576
 
 
577
 
  /* If non-NULL, this is the value of the response's Location header.
578
 
   */
579
 
  const char *location;
580
 
 
581
602
  /* If non-NULL, this value will be set to TRUE when the response is
582
603
   * completed.
583
604
   */
630
651
 
631
652
     See libsvn_ra_serf/util.c  */
632
653
  struct svn_ra_serf__pending_t *pending;
633
 
 
634
 
  /* Response restart support */
635
 
  const void *headers_baton; /* Last pointer to headers */
636
 
  apr_off_t skip_size; /* Number of bytes to skip */
637
 
  apr_off_t read_size; /* Number of bytes read from response */
638
654
};
639
655
 
 
656
 
 
657
/* v2 of the XML parsing functions  */
 
658
 
 
659
/* The XML parsing context.  */
 
660
typedef struct svn_ra_serf__xml_context_t svn_ra_serf__xml_context_t;
 
661
 
 
662
 
 
663
/* An opaque structure for the XML parse element/state.  */
 
664
typedef struct svn_ra_serf__xml_estate_t svn_ra_serf__xml_estate_t;
 
665
 
 
666
/* Called just after the parser moves into ENTERED_STATE. The tag causing
 
667
   the transition is passed in TAG.
 
668
 
 
669
   This callback is applied to a parsing context by using the
 
670
   svn_ra_serf__xml_context_customize() function.
 
671
 
 
672
   NOTE: this callback, when set, will be invoked on *every* transition.
 
673
   The callback must examine ENTERED_STATE to determine if any action
 
674
   must be taken. The original state is not provided, but must be derived
 
675
   from ENTERED_STATE and/or the TAG causing the transition (if needed).  */
 
676
typedef svn_error_t *
 
677
(*svn_ra_serf__xml_opened_t)(svn_ra_serf__xml_estate_t *xes,
 
678
                             void *baton,
 
679
                             int entered_state,
 
680
                             const svn_ra_serf__dav_props_t *tag,
 
681
                             apr_pool_t *scratch_pool);
 
682
 
 
683
 
 
684
/* Called just before the parser leaves LEAVING_STATE.
 
685
 
 
686
   If cdata collection was enabled for this state, then CDATA will be
 
687
   non-NULL and contain the collected cdata.
 
688
 
 
689
   If attribute collection was enabled for this state, then ATTRS will
 
690
   contain the attributes collected for this element only, along with
 
691
   any values stored via svn_ra_serf__xml_note().
 
692
 
 
693
   Use svn_ra_serf__xml_gather_since() to gather up data from outer states.
 
694
 
 
695
   ATTRS is char* -> char*.
 
696
 
 
697
   Temporary allocations may be made in SCRATCH_POOL.  */
 
698
typedef svn_error_t *
 
699
(*svn_ra_serf__xml_closed_t)(svn_ra_serf__xml_estate_t *xes,
 
700
                             void *baton,
 
701
                             int leaving_state,
 
702
                             const svn_string_t *cdata,
 
703
                             apr_hash_t *attrs,
 
704
                             apr_pool_t *scratch_pool);
 
705
 
 
706
 
 
707
/* Called for all states that are not using the builtin cdata collection.
 
708
   This callback is (only) appropriate for unbounded-size cdata content.
 
709
 
 
710
   CURRENT_STATE may be used to decide what to do with the data.
 
711
 
 
712
   Temporary allocations may be made in SCRATCH_POOL.  */
 
713
typedef svn_error_t *
 
714
(*svn_ra_serf__xml_cdata_t)(svn_ra_serf__xml_estate_t *xes,
 
715
                            void *baton,
 
716
                            int current_state,
 
717
                            const char *data,
 
718
                            apr_size_t len,
 
719
                            apr_pool_t *scratch_pool);
 
720
 
 
721
 
 
722
/* State transition table.
 
723
 
 
724
   When the XML Context is constructed, it is in state 0. User states are
 
725
   positive integers.
 
726
 
 
727
   In a list of transitions, use { 0 } to indicate the end. Specifically,
 
728
   the code looks for NS == NULL.
 
729
 
 
730
   ### more docco
 
731
*/
 
732
typedef struct svn_ra_serf__xml_transition_t {
 
733
  /* This transition applies when in this state  */
 
734
  int from_state;
 
735
 
 
736
  /* And when this tag is observed  */
 
737
  const char *ns;
 
738
  const char *name;
 
739
 
 
740
  /* Moving to this state  */
 
741
  int to_state;
 
742
 
 
743
  /* Should the cdata of NAME be collected? Note that CUSTOM_CLOSE should
 
744
     be TRUE in order to capture this cdata.  */
 
745
  svn_boolean_t collect_cdata;
 
746
 
 
747
  /* Which attributes of NAME should be collected? Terminate with NULL.
 
748
     Maximum of 10 attributes may be collected. Note that attribute
 
749
     namespaces are ignored at this time.
 
750
 
 
751
     Attribute names beginning with "?" are optional. Other names must
 
752
     exist on the element, or SVN_ERR_XML_ATTRIB_NOT_FOUND will be raised.  */
 
753
  const char *collect_attrs[11];
 
754
 
 
755
  /* When NAME is closed, should the callback be invoked?  */
 
756
  svn_boolean_t custom_close;
 
757
 
 
758
} svn_ra_serf__xml_transition_t;
 
759
 
 
760
 
 
761
/* Construct an XML parsing context, based on the TTABLE transition table.
 
762
   As content is parsed, the CLOSED_CB callback will be invoked according
 
763
   to the definition in the table.
 
764
 
 
765
   If OPENED_CB is not NULL, then it will be invoked for *every* tag-open
 
766
   event. The callback will need to use the ENTERED_STATE and TAG parameters
 
767
   to decide what it would like to do.
 
768
 
 
769
   If CDATA_CB is not NULL, then it will be called for all cdata that is
 
770
   not be automatically collected (based on the transition table record's
 
771
   COLLECT_CDATA flag). It will be called in every state, so the callback
 
772
   must examine the CURRENT_STATE parameter to decide what to do.
 
773
 
 
774
   The same BATON value will be passed to all three callbacks.
 
775
 
 
776
   The context will be created within RESULT_POOL.  */
 
777
svn_ra_serf__xml_context_t *
 
778
svn_ra_serf__xml_context_create(
 
779
  const svn_ra_serf__xml_transition_t *ttable,
 
780
  svn_ra_serf__xml_opened_t opened_cb,
 
781
  svn_ra_serf__xml_closed_t closed_cb,
 
782
  svn_ra_serf__xml_cdata_t cdata_cb,
 
783
  void *baton,
 
784
  apr_pool_t *result_pool);
 
785
 
 
786
/* Destroy all subpools for this structure. */
 
787
void
 
788
svn_ra_serf__xml_context_destroy(
 
789
  svn_ra_serf__xml_context_t *xmlctx);
 
790
 
 
791
/* Construct a handler with the response function/baton set up to parse
 
792
   a response body using the given XML context. The handler and its
 
793
   internal structures are allocated in RESULT_POOL.
 
794
 
 
795
   This also initializes HANDLER_POOL to the given RESULT_POOL.  */
 
796
svn_ra_serf__handler_t *
 
797
svn_ra_serf__create_expat_handler(svn_ra_serf__xml_context_t *xmlctx,
 
798
                                  apr_pool_t *result_pool);
 
799
 
 
800
 
 
801
/* Allocated within XES->STATE_POOL. Changes are not allowd (callers
 
802
   should make a deep copy if they need to make changes).
 
803
 
 
804
   The resulting hash maps char* names to char* values.  */
 
805
apr_hash_t *
 
806
svn_ra_serf__xml_gather_since(svn_ra_serf__xml_estate_t *xes,
 
807
                              int stop_state);
 
808
 
 
809
 
 
810
/* Attach the NAME/VALUE pair onto this/parent state identified by STATE.
 
811
   The name and value will be copied into the target state's pool.
 
812
 
 
813
   These values will be available to the CLOSED_CB for the target state,
 
814
   or part of the gathered state via xml_gather_since().
 
815
 
 
816
   Typically, this function is used by a child state's close callback,
 
817
   or within an opening callback to store additional data.
 
818
 
 
819
   Note: if the state is not found, then a programmer error has occurred,
 
820
   so the function will invoke SVN_ERR_MALFUNCTION().  */
 
821
void
 
822
svn_ra_serf__xml_note(svn_ra_serf__xml_estate_t *xes,
 
823
                      int state,
 
824
                      const char *name,
 
825
                      const char *value);
 
826
 
 
827
 
 
828
/* Returns XES->STATE_POOL for allocating structures that should live
 
829
   as long as the state identified by XES.
 
830
 
 
831
   Note: a state pool is created upon demand, so only use this function
 
832
   when memory is required for a given state.  */
 
833
apr_pool_t *
 
834
svn_ra_serf__xml_state_pool(svn_ra_serf__xml_estate_t *xes);
 
835
 
 
836
 
 
837
/* Any XML parser may be used. When an opening tag is seen, call this
 
838
   function to feed the information into XMLCTX.  */
 
839
svn_error_t *
 
840
svn_ra_serf__xml_cb_start(svn_ra_serf__xml_context_t *xmlctx,
 
841
                          const char *raw_name,
 
842
                          const char *const *attrs);
 
843
 
 
844
 
 
845
/* When a close tag is seen, call this function to feed the information
 
846
   into XMLCTX.  */
 
847
svn_error_t *
 
848
svn_ra_serf__xml_cb_end(svn_ra_serf__xml_context_t *xmlctx,
 
849
                        const char *raw_name);
 
850
 
 
851
 
 
852
/* When cdata is parsed by the wrapping XML parser, call this function to
 
853
   feed the cdata into the XMLCTX.  */
 
854
svn_error_t *
 
855
svn_ra_serf__xml_cb_cdata(svn_ra_serf__xml_context_t *xmlctx,
 
856
                          const char *data,
 
857
                          apr_size_t len);
 
858
 
 
859
 
640
860
/*
641
861
 * Parses a server-side error message into a local Subversion error.
642
862
 */
643
 
typedef struct svn_ra_serf__server_error_t {
 
863
struct svn_ra_serf__server_error_t {
644
864
  /* Our local representation of the error. */
645
865
  svn_error_t *error;
646
866
 
647
 
  /* Have we checked to see if there's an XML error in this response? */
648
 
  svn_boolean_t init;
649
 
 
650
 
  /* Was there an XML error response? */
651
 
  svn_boolean_t has_xml_response;
652
 
 
653
867
  /* Are we done with the response? */
654
868
  svn_boolean_t done;
655
869
 
667
881
 
668
882
  /* XML parser and namespace used to parse the remote response */
669
883
  svn_ra_serf__xml_parser_t parser;
670
 
} svn_ra_serf__server_error_t;
671
 
 
672
 
/* A simple request context that can be passed to handle_status_only. */
673
 
typedef struct svn_ra_serf__simple_request_context_t {
674
 
  apr_pool_t *pool;
675
 
 
676
 
  /* The HTTP status code of the response */
677
 
  int status;
678
 
 
679
 
  /* The HTTP status line of the response */
680
 
  const char *reason;
681
 
 
682
 
  /* The Location header value of the response, or NULL if there
683
 
     wasn't one. */
684
 
  const char *location;
685
 
 
686
 
  /* This value is set to TRUE when the response is completed. */
687
 
  svn_boolean_t done;
688
 
 
689
 
  /* If an error occurred, this value will be initialized. */
690
 
  svn_ra_serf__server_error_t server_error;
691
 
} svn_ra_serf__simple_request_context_t;
692
 
 
693
 
/*
694
 
 * Serf handler for @a request / @a response pair that takes in a
695
 
 * @a baton (@see svn_ra_serf__simple_request_context_t).
696
 
 * Implements svn_ra_serf__response_handler_t.
697
 
 *
698
 
 * Temporary allocations are made in @a pool.
699
 
 */
700
 
svn_error_t *
701
 
svn_ra_serf__handle_status_only(serf_request_t *request,
702
 
                                serf_bucket_t *response,
703
 
                                void *baton,
704
 
                                apr_pool_t *pool);
 
884
};
 
885
 
705
886
 
706
887
/*
707
888
 * Handler that discards the entire @a response body associated with a
718
899
                                 void *baton,
719
900
                                 apr_pool_t *pool);
720
901
 
721
 
/*
722
 
 * Handler that retrieves the embedded XML error response from the
723
 
 * the @a response body associated with a @a request.
724
 
 * Implements svn_ra_serf__response_handler_t.
725
 
 *
726
 
 * All temporary allocations will be made in a @a pool.
727
 
 */
728
 
svn_error_t *
729
 
svn_ra_serf__handle_server_error(serf_request_t *request,
730
 
                                 serf_bucket_t *response,
731
 
                                 apr_pool_t *pool);
732
902
 
733
903
/*
734
904
 * Handler that retrieves the embedded XML multistatus response from the
735
 
 * the @a RESPONSE body associated with a @a REQUEST. *DONE is set to TRUE.
 
905
 * the @a RESPONSE body associated with a @a REQUEST.
 
906
 *
736
907
 * Implements svn_ra_serf__response_handler_t.
737
908
 *
738
 
 * The @a BATON should be of type svn_ra_serf__simple_request_context_t.
 
909
 * The @a BATON should be of type svn_ra_serf__handler_t. When the request
 
910
 * is complete, the handler's DONE flag will be set to TRUE.
739
911
 *
740
 
 * All temporary allocations will be made in a @a pool.
 
912
 * All temporary allocations will be made in a @a scratch_pool.
741
913
 */
742
914
svn_error_t *
743
915
svn_ra_serf__handle_multistatus_only(serf_request_t *request,
744
916
                                     serf_bucket_t *response,
745
917
                                     void *baton,
746
 
                                     apr_pool_t *pool);
 
918
                                     apr_pool_t *scratch_pool);
 
919
 
 
920
 
 
921
/* Handler that expects an empty body.
 
922
 
 
923
   If a body IS present, and it is text/xml, then it will be parsed for
 
924
   a server-side error.
 
925
 
 
926
   BATON should be the svn_ra_serf__handler_t running REQUEST.
 
927
 
 
928
   Status line information will be in HANDLER->SLINE.
 
929
 
 
930
   Any parsed errors will be left in HANDLER->SERVER_ERROR. That member
 
931
   may be NULL if no body was present, or a problem occurred trying to
 
932
   parse the body.
 
933
 
 
934
   All temporary allocations will be made in SCRATCH_POOL.  */
 
935
svn_error_t *
 
936
svn_ra_serf__expect_empty_body(serf_request_t *request,
 
937
                               serf_bucket_t *response,
 
938
                               void *baton,
 
939
                               apr_pool_t *scratch_pool);
 
940
 
747
941
 
748
942
/*
749
943
 * This function will feed the RESPONSE body into XMLP.  When parsing is
772
966
                                      void *baton,
773
967
                                      apr_pool_t *pool);
774
968
 
775
 
/* Return the value of the RESPONSE's Location header if any, or NULL
776
 
 * otherwise.  All allocations will be made in POOL.
777
 
 */
778
 
const char *
779
 
svn_ra_serf__response_get_location(serf_bucket_t *response,
780
 
                                   apr_pool_t *pool);
781
969
 
782
970
/** XML helper functions. **/
783
971
 
797
985
 
798
986
svn_error_t *
799
987
svn_ra_serf__process_pending(svn_ra_serf__xml_parser_t *parser,
 
988
                             svn_boolean_t *network_eof,
800
989
                             apr_pool_t *scratch_pool);
801
990
 
802
991
 
823
1012
                                    serf_bucket_alloc_t *bkt_alloc);
824
1013
 
825
1014
/*
826
 
 * Add the appropriate serf buckets to AGG_BUCKET representing xml tag open
827
 
 * with name TAG.
 
1015
 * Add the appropriate serf buckets to AGG_BUCKET representing the XML
 
1016
 * open tag with name TAG.
828
1017
 *
829
1018
 * Take the tag's attributes from varargs, a NULL-terminated list of
830
 
 * alternating <tt>char *</tt> key and <tt>char *</tt> val.  Do xml-escaping
831
 
 * on each val. Attribute will be ignored if it's value is NULL.
 
1019
 * alternating <tt>char *</tt> key and <tt>char *</tt> val.  Attribute
 
1020
 * will be ignored if it's value is NULL.
 
1021
 *
 
1022
 * NOTE: Callers are responsible for XML-escaping attribute values as
 
1023
 * necessary.
832
1024
 *
833
1025
 * The bucket will be allocated from BKT_ALLOC.
834
1026
 */
863
1055
 * Look up the @a attrs array for namespace definitions and add each one
864
1056
 * to the @a ns_list of namespaces.
865
1057
 *
866
 
 * New namespaces will be allocated in @a pool.
 
1058
 * New namespaces will be allocated in RESULT_POOL.
867
1059
 */
868
1060
void
869
1061
svn_ra_serf__define_ns(svn_ra_serf__ns_t **ns_list,
870
 
                       const char **attrs,
871
 
                       apr_pool_t *pool);
 
1062
                       const char *const *attrs,
 
1063
                       apr_pool_t *result_pool);
872
1064
 
873
1065
/*
874
1066
 * Look up @a name in the @a ns_list list for previously declared namespace
879
1071
 */
880
1072
void
881
1073
svn_ra_serf__expand_ns(svn_ra_serf__dav_props_t *returned_prop_name,
882
 
                       svn_ra_serf__ns_t *ns_list,
 
1074
                       const svn_ra_serf__ns_t *ns_list,
883
1075
                       const char *name);
884
1076
 
885
 
/*
886
 
 * Expand the string represented by @a cur with a current size of @a
887
 
 * cur_len by appending @a new with a size of @a new_len.
888
 
 *
889
 
 * The reallocated string is made in @a pool.
890
 
 */
891
 
void
892
 
svn_ra_serf__expand_string(const char **cur, apr_size_t *cur_len,
893
 
                           const char *new, apr_size_t new_len,
894
 
                           apr_pool_t *pool);
895
1077
 
896
1078
/** PROPFIND-related functions **/
897
1079
 
898
 
/* Opaque structure representing PROPFINDs. */
899
 
typedef struct svn_ra_serf__propfind_context_t svn_ra_serf__propfind_context_t;
900
 
 
901
 
/*
902
 
 * Returns a flag representing whether the PROPFIND @a ctx is completed.
903
 
 */
904
 
svn_boolean_t
905
 
svn_ra_serf__propfind_is_done(svn_ra_serf__propfind_context_t *ctx);
906
 
 
907
 
/*
908
 
 * Returns the response status code of the PROPFIND @a ctx.
909
 
 */
910
 
int
911
 
svn_ra_serf__propfind_status_code(svn_ra_serf__propfind_context_t *ctx);
912
 
 
913
1080
/*
914
1081
 * This function will deliver a PROP_CTX PROPFIND request in the SESS
915
1082
 * serf context for the properties listed in LOOKUP_PROPS at URL for
919
1086
 * expected to call svn_ra_serf__wait_for_props().
920
1087
 */
921
1088
svn_error_t *
922
 
svn_ra_serf__deliver_props(svn_ra_serf__propfind_context_t **prop_ctx,
 
1089
svn_ra_serf__deliver_props(svn_ra_serf__handler_t **propfind_handler,
923
1090
                           apr_hash_t *prop_vals,
924
1091
                           svn_ra_serf__session_t *sess,
925
1092
                           svn_ra_serf__connection_t *conn,
931
1098
                           apr_pool_t *pool);
932
1099
 
933
1100
/*
934
 
 * This helper function will block until the PROP_CTX indicates that is done
935
 
 * or another error is returned.
 
1101
 * This helper function will block until PROPFIND_HANDLER indicates that is
 
1102
 * done or another error is returned.
936
1103
 */
937
1104
svn_error_t *
938
 
svn_ra_serf__wait_for_props(svn_ra_serf__propfind_context_t *prop_ctx,
939
 
                            svn_ra_serf__session_t *sess,
940
 
                            apr_pool_t *pool);
 
1105
svn_ra_serf__wait_for_props(svn_ra_serf__handler_t *handler,
 
1106
                            apr_pool_t *scratch_pool);
941
1107
 
942
1108
/* This is a blocking version of deliver_props.
943
1109
 
959
1125
                            apr_pool_t *result_pool,
960
1126
                            apr_pool_t *scratch_pool);
961
1127
 
 
1128
 
 
1129
/* Using CONN, fetch the properties specified by WHICH_PROPS using CONN
 
1130
   for URL at REVISION. The resulting properties are placed into a 2-level
 
1131
   hash in RESULTS, mapping NAMESPACE -> hash<PROPNAME, PROPVALUE>, which
 
1132
   is allocated in RESULT_POOL.
 
1133
 
 
1134
   If REVISION is SVN_INVALID_REVNUM, then the properties are fetched
 
1135
   from HEAD for URL.
 
1136
 
 
1137
   This function performs the request synchronously.
 
1138
 
 
1139
   Temporary allocations are made in SCRATCH_POOL.  */
 
1140
svn_error_t *
 
1141
svn_ra_serf__fetch_node_props(apr_hash_t **results,
 
1142
                              svn_ra_serf__connection_t *conn,
 
1143
                              const char *url,
 
1144
                              svn_revnum_t revision,
 
1145
                              const svn_ra_serf__dav_props_t *which_props,
 
1146
                              apr_pool_t *result_pool,
 
1147
                              apr_pool_t *scratch_pool);
 
1148
 
 
1149
 
 
1150
/* Using CONN, fetch a DAV: property from the resource identified by URL
 
1151
   within REVISION. The PROPNAME may be one of:
 
1152
 
 
1153
     "checked-in"
 
1154
     "href"
 
1155
 
 
1156
   The resulting value will be allocated in RESULT_POOL, and may be NULL
 
1157
   if the property does not exist (note: "href" always exists).
 
1158
 
 
1159
   This function performs the request synchronously.
 
1160
 
 
1161
   Temporary allocations are made in SCRATCH_POOL.  */
 
1162
svn_error_t *
 
1163
svn_ra_serf__fetch_dav_prop(const char **value,
 
1164
                            svn_ra_serf__connection_t *conn,
 
1165
                            const char *url,
 
1166
                            svn_revnum_t revision,
 
1167
                            const char *propname,
 
1168
                            apr_pool_t *result_pool,
 
1169
                            apr_pool_t *scratch_pool);
 
1170
 
 
1171
 
962
1172
/* Set PROPS for PATH at REV revision with a NS:NAME VAL.
963
1173
 *
964
1174
 * The POOL governs allocation.
987
1197
                            void *baton,
988
1198
                            apr_pool_t *pool);
989
1199
 
 
1200
 
 
1201
/* Like walk_all_props(), but a 2-level hash.  */
 
1202
svn_error_t *
 
1203
svn_ra_serf__walk_node_props(apr_hash_t *props,
 
1204
                             svn_ra_serf__walker_visitor_t walker,
 
1205
                             void *baton,
 
1206
                             apr_pool_t *scratch_pool);
 
1207
 
 
1208
 
990
1209
typedef svn_error_t *
991
1210
(*svn_ra_serf__path_rev_walker_t)(void *baton,
992
1211
                                  const char *path, apr_ssize_t path_len,
1025
1244
                             apr_pool_t *scratch_pool);
1026
1245
 
1027
1246
 
1028
 
/* PROPS is nested hash tables mapping REV -> PATH -> NS -> NAME -> VALUE.
1029
 
   This function takes the tree of tables identified by PATH and REVISION
1030
 
   (resulting in NS:NAME:VALUE hashes) and flattens them into a set of
 
1247
/* PROPS is nested hash tables mapping NS -> NAME -> VALUE.
 
1248
   This function takes the NS:NAME:VALUE hashes and flattens them into a set of
1031
1249
   names to VALUE. The names are composed of NS:NAME, with specific
1032
1250
   rewrite from wire names (DAV) to SVN names. This mapping is managed
1033
1251
   by the svn_ra_serf__set_baton_props() function.
1040
1258
svn_error_t *
1041
1259
svn_ra_serf__flatten_props(apr_hash_t **flat_props,
1042
1260
                           apr_hash_t *props,
1043
 
                           const char *path,
1044
 
                           svn_revnum_t revision,
1045
1261
                           apr_pool_t *result_pool,
1046
1262
                           apr_pool_t *scratch_pool);
1047
1263
 
1082
1298
 
1083
1299
svn_error_t *
1084
1300
svn_ra_serf__get_resource_type(svn_node_kind_t *kind,
1085
 
                               apr_hash_t *props,
1086
 
                               const char *url,
1087
 
                               svn_revnum_t revision);
 
1301
                               apr_hash_t *props);
1088
1302
 
1089
1303
 
1090
1304
/** MERGE-related functions **/
1091
1305
 
1092
 
typedef struct svn_ra_serf__merge_context_t svn_ra_serf__merge_context_t;
1093
 
 
1094
 
svn_boolean_t*
1095
 
svn_ra_serf__merge_get_done_ptr(svn_ra_serf__merge_context_t *ctx);
1096
 
 
1097
 
svn_commit_info_t*
1098
 
svn_ra_serf__merge_get_commit_info(svn_ra_serf__merge_context_t *ctx);
1099
 
 
1100
 
int
1101
 
svn_ra_serf__merge_get_status(svn_ra_serf__merge_context_t *ctx);
1102
 
 
1103
1306
void
1104
1307
svn_ra_serf__merge_lock_token_list(apr_hash_t *lock_tokens,
1105
1308
                                   const char *parent,
1113
1316
   client.  If KEEP_LOCKS is set, instruct the server to not release
1114
1317
   locks set on the paths included in this commit.  */
1115
1318
svn_error_t *
1116
 
svn_ra_serf__merge_create_req(svn_ra_serf__merge_context_t **merge_ctx,
1117
 
                              svn_ra_serf__session_t *session,
1118
 
                              svn_ra_serf__connection_t *conn,
1119
 
                              const char *merge_resource_url,
1120
 
                              apr_hash_t *lock_tokens,
1121
 
                              svn_boolean_t keep_locks,
1122
 
                              apr_pool_t *pool);
 
1319
svn_ra_serf__run_merge(const svn_commit_info_t **commit_info,
 
1320
                       int *response_code,
 
1321
                       svn_ra_serf__session_t *session,
 
1322
                       svn_ra_serf__connection_t *conn,
 
1323
                       const char *merge_resource_url,
 
1324
                       apr_hash_t *lock_tokens,
 
1325
                       svn_boolean_t keep_locks,
 
1326
                       apr_pool_t *result_pool,
 
1327
                       apr_pool_t *scratch_pool);
 
1328
 
1123
1329
 
1124
1330
/** OPTIONS-related functions **/
1125
1331
 
1126
 
typedef struct svn_ra_serf__options_context_t svn_ra_serf__options_context_t;
1127
 
 
1128
 
/* Is this OPTIONS-request done yet? */
1129
 
svn_boolean_t*
1130
 
svn_ra_serf__get_options_done_ptr(svn_ra_serf__options_context_t *ctx);
1131
 
 
1132
 
const char *
1133
 
svn_ra_serf__options_get_activity_collection(svn_ra_serf__options_context_t *ctx);
1134
 
 
1135
 
svn_revnum_t
1136
 
svn_ra_serf__options_get_youngest_rev(svn_ra_serf__options_context_t *ctx);
1137
 
 
1138
 
/* Create an OPTIONS request.  When run, ask for an
1139
 
   activity-collection-set in the request body (retrievable via
1140
 
   accessor above) and also parse the server's capability headers into
1141
 
   the SESSION->capabilites hash. */
1142
 
svn_error_t *
1143
 
svn_ra_serf__create_options_req(svn_ra_serf__options_context_t **opt_ctx,
1144
 
                                svn_ra_serf__session_t *session,
1145
 
                                svn_ra_serf__connection_t *conn,
1146
 
                                const char *path,
1147
 
                                apr_pool_t *pool);
 
1332
/* When running with a proxy, we may need to detect and correct for problems.
 
1333
   This probing function will send a simple OPTIONS request to detect problems
 
1334
   with the connection.  */
 
1335
svn_error_t *
 
1336
svn_ra_serf__probe_proxy(svn_ra_serf__session_t *serf_sess,
 
1337
                         apr_pool_t *scratch_pool);
 
1338
 
 
1339
 
 
1340
/* On HTTPv2 connections, run an OPTIONS request over CONN to fetch the
 
1341
   current youngest revnum, returning it in *YOUNGEST.
 
1342
 
 
1343
   (the revnum is headers of the OPTIONS response)
 
1344
 
 
1345
   This function performs the request synchronously.
 
1346
 
 
1347
   All temporary allocations will be made in SCRATCH_POOL.  */
 
1348
svn_error_t *
 
1349
svn_ra_serf__v2_get_youngest_revnum(svn_revnum_t *youngest,
 
1350
                                    svn_ra_serf__connection_t *conn,
 
1351
                                    apr_pool_t *scratch_pool);
 
1352
 
 
1353
 
 
1354
/* On HTTPv1 connections, run an OPTIONS request over CONN to fetch the
 
1355
   activity collection set and return it in *ACTIVITY_URL, allocated
 
1356
   from RESULT_POOL.
 
1357
 
 
1358
   (the activity-collection-set is in the body of the OPTIONS response)
 
1359
 
 
1360
   This function performs the request synchronously.
 
1361
 
 
1362
   All temporary allocations will be made in SCRATCH_POOL.  */
 
1363
svn_error_t *
 
1364
svn_ra_serf__v1_get_activity_collection(const char **activity_url,
 
1365
                                        svn_ra_serf__connection_t *conn,
 
1366
                                        apr_pool_t *result_pool,
 
1367
                                        apr_pool_t *scratch_pool);
 
1368
 
1148
1369
 
1149
1370
/* Set @a VCC_URL to the default VCC for our repository based on @a
1150
1371
 * ORIG_PATH for the session @a SESSION, ensuring that the VCC URL and
1184
1405
                               svn_ra_serf__connection_t *conn,
1185
1406
                               apr_pool_t *pool);
1186
1407
 
1187
 
/* Set *BC_URL to the baseline collection url, and set *BC_RELATIVE to
1188
 
 * the path relative to that url for URL in REVISION using SESSION.
1189
 
 * BC_RELATIVE will be URI decoded.
1190
 
 *
1191
 
 * REVISION may be SVN_INVALID_REVNUM (to mean "the current HEAD
1192
 
 * revision").  If URL is NULL, use SESSION's session url.
1193
 
 *
1194
 
 * If LATEST_REVNUM is not NULL, set it to the baseline revision. If
1195
 
 * REVISION was set to SVN_INVALID_REVNUM, this will return the current
1196
 
 * HEAD revision.
1197
 
 *
1198
 
 * If non-NULL, use CONN for communications with the server;
1199
 
 * otherwise, use the default connection.
1200
 
 *
1201
 
 * Use POOL for all allocations.
1202
 
 */
1203
 
svn_error_t *
1204
 
svn_ra_serf__get_baseline_info(const char **bc_url,
1205
 
                               const char **bc_relative,
1206
 
                               svn_ra_serf__session_t *session,
1207
 
                               svn_ra_serf__connection_t *conn,
1208
 
                               const char *url,
1209
 
                               svn_revnum_t revision,
1210
 
                               svn_revnum_t *latest_revnum,
1211
 
                               apr_pool_t *pool);
 
1408
 
 
1409
/* Using the default connection in SESSION (conns[0]), get the youngest
 
1410
   revnum from the server, returning it in *YOUNGEST.
 
1411
 
 
1412
   This function operates synchronously.
 
1413
 
 
1414
   All temporary allocations are performed in SCRATCH_POOL.  */
 
1415
svn_error_t *
 
1416
svn_ra_serf__get_youngest_revnum(svn_revnum_t *youngest,
 
1417
                                 svn_ra_serf__session_t *session,
 
1418
                                 apr_pool_t *scratch_pool);
 
1419
 
 
1420
 
 
1421
/* Generate a revision-stable URL.
 
1422
 
 
1423
   The RA APIs all refer to user/public URLs that float along with the
 
1424
   youngest revision. In many cases, we do NOT want to work with that URL
 
1425
   since it can change from one moment to the next. Especially if we
 
1426
   attempt to operation against multiple floating URLs -- we could end up
 
1427
   referring to two separate revisions.
 
1428
 
 
1429
   The DAV RA provider(s) solve this by generating a URL that is specific
 
1430
   to a revision by using a URL into a "baseline collection".
 
1431
 
 
1432
   For a specified SESSION, with an optional CONN (if NULL, then the
 
1433
   session's default connection will be used; specifically SESSION->conns[0]),
 
1434
   generate a revision-stable URL for URL at REVISION. If REVISION is
 
1435
   SVN_INVALID_REVNUM, then the stable URL will refer to the youngest
 
1436
   revision at the time this function was called.
 
1437
 
 
1438
   If URL is NULL, then the session root will be used.
 
1439
 
 
1440
   The stable URL will be placed into *STABLE_URL, allocated from RESULT_POOL.
 
1441
 
 
1442
   If LATEST_REVNUM is not NULL, then the revision used will be placed into
 
1443
   *LATEST_REVNUM. That will be equal to youngest, or the given REVISION.
 
1444
 
 
1445
   This function operates synchronously, if any communication to the server
 
1446
   is required. Communication is needed if REVISION is SVN_INVALID_REVNUM
 
1447
   (to get the current youngest revnum), or if the specified REVISION is not
 
1448
   (yet) in our cache of baseline collections.
 
1449
 
 
1450
   All temporary allocations are performed in SCRATCH_POOL.  */
 
1451
svn_error_t *
 
1452
svn_ra_serf__get_stable_url(const char **stable_url,
 
1453
                            svn_revnum_t *latest_revnum,
 
1454
                            svn_ra_serf__session_t *session,
 
1455
                            svn_ra_serf__connection_t *conn,
 
1456
                            const char *url,
 
1457
                            svn_revnum_t revision,
 
1458
                            apr_pool_t *result_pool,
 
1459
                            apr_pool_t *scratch_pool);
 
1460
 
1212
1461
 
1213
1462
/** RA functions **/
1214
1463
 
 
1464
/* Implements svn_ra__vtable_t.get_log(). */
1215
1465
svn_error_t *
1216
1466
svn_ra_serf__get_log(svn_ra_session_t *session,
1217
1467
                     const apr_array_header_t *paths,
1226
1476
                     void *receiver_baton,
1227
1477
                     apr_pool_t *pool);
1228
1478
 
 
1479
/* Implements svn_ra__vtable_t.get_locations(). */
1229
1480
svn_error_t *
1230
1481
svn_ra_serf__get_locations(svn_ra_session_t *session,
1231
1482
                           apr_hash_t **locations,
1234
1485
                           const apr_array_header_t *location_revisions,
1235
1486
                           apr_pool_t *pool);
1236
1487
 
 
1488
/* Implements svn_ra__vtable_t.get_location_segments(). */
1237
1489
svn_error_t *
1238
1490
svn_ra_serf__get_location_segments(svn_ra_session_t *session,
1239
1491
                                   const char *path,
1244
1496
                                   void *receiver_baton,
1245
1497
                                   apr_pool_t *pool);
1246
1498
 
 
1499
/* Implements svn_ra__vtable_t.do_diff(). */
1247
1500
svn_error_t *
1248
1501
svn_ra_serf__do_diff(svn_ra_session_t *session,
1249
1502
                     const svn_ra_reporter3_t **reporter,
1258
1511
                     void *diff_baton,
1259
1512
                     apr_pool_t *pool);
1260
1513
 
 
1514
/* Implements svn_ra__vtable_t.do_status(). */
1261
1515
svn_error_t *
1262
1516
svn_ra_serf__do_status(svn_ra_session_t *ra_session,
1263
1517
                       const svn_ra_reporter3_t **reporter,
1269
1523
                       void *status_baton,
1270
1524
                       apr_pool_t *pool);
1271
1525
 
 
1526
/* Implements svn_ra__vtable_t.do_update(). */
1272
1527
svn_error_t *
1273
1528
svn_ra_serf__do_update(svn_ra_session_t *ra_session,
1274
1529
                       const svn_ra_reporter3_t **reporter,
1277
1532
                       const char *update_target,
1278
1533
                       svn_depth_t depth,
1279
1534
                       svn_boolean_t send_copyfrom_args,
 
1535
                       svn_boolean_t ignore_ancestry,
1280
1536
                       const svn_delta_editor_t *update_editor,
1281
1537
                       void *update_baton,
1282
 
                       apr_pool_t *pool);
 
1538
                       apr_pool_t *result_pool,
 
1539
                       apr_pool_t *scratch_pool);
1283
1540
 
 
1541
/* Implements svn_ra__vtable_t.do_switch(). */
1284
1542
svn_error_t *
1285
1543
svn_ra_serf__do_switch(svn_ra_session_t *ra_session,
1286
1544
                       const svn_ra_reporter3_t **reporter,
1289
1547
                       const char *switch_target,
1290
1548
                       svn_depth_t depth,
1291
1549
                       const char *switch_url,
 
1550
                       svn_boolean_t send_copyfrom_args,
 
1551
                       svn_boolean_t ignore_ancestry,
1292
1552
                       const svn_delta_editor_t *switch_editor,
1293
1553
                       void *switch_baton,
1294
 
                       apr_pool_t *pool);
 
1554
                       apr_pool_t *result_pool,
 
1555
                       apr_pool_t *scratch_pool);
1295
1556
 
 
1557
/* Implements svn_ra__vtable_t.get_file_revs(). */
1296
1558
svn_error_t *
1297
1559
svn_ra_serf__get_file_revs(svn_ra_session_t *session,
1298
1560
                           const char *path,
1303
1565
                           void *handler_baton,
1304
1566
                           apr_pool_t *pool);
1305
1567
 
 
1568
/* Implements svn_ra__vtable_t.get_dated_revision(). */
1306
1569
svn_error_t *
1307
1570
svn_ra_serf__get_dated_revision(svn_ra_session_t *session,
1308
1571
                                svn_revnum_t *revision,
1309
1572
                                apr_time_t tm,
1310
1573
                                apr_pool_t *pool);
1311
1574
 
 
1575
/* Implements svn_ra__vtable_t.get_commit_editor(). */
1312
1576
svn_error_t *
1313
1577
svn_ra_serf__get_commit_editor(svn_ra_session_t *session,
1314
1578
                               const svn_delta_editor_t **editor,
1320
1584
                               svn_boolean_t keep_locks,
1321
1585
                               apr_pool_t *pool);
1322
1586
 
 
1587
/* Implements svn_ra__vtable_t.get_file(). */
1323
1588
svn_error_t *
1324
1589
svn_ra_serf__get_file(svn_ra_session_t *session,
1325
1590
                      const char *path,
1329
1594
                      apr_hash_t **props,
1330
1595
                      apr_pool_t *pool);
1331
1596
 
 
1597
/* Implements svn_ra__vtable_t.change_rev_prop(). */
1332
1598
svn_error_t *
1333
1599
svn_ra_serf__change_rev_prop(svn_ra_session_t *session,
1334
1600
                             svn_revnum_t rev,
1337
1603
                             const svn_string_t *value,
1338
1604
                             apr_pool_t *pool);
1339
1605
 
 
1606
/* Implements svn_ra__vtable_t.replay(). */
1340
1607
svn_error_t *
1341
1608
svn_ra_serf__replay(svn_ra_session_t *ra_session,
1342
1609
                    svn_revnum_t revision,
1346
1613
                    void *edit_baton,
1347
1614
                    apr_pool_t *pool);
1348
1615
 
 
1616
/* Implements svn_ra__vtable_t.replay_range(). */
1349
1617
svn_error_t *
1350
1618
svn_ra_serf__replay_range(svn_ra_session_t *ra_session,
1351
1619
                          svn_revnum_t start_revision,
1357
1625
                          void *replay_baton,
1358
1626
                          apr_pool_t *pool);
1359
1627
 
 
1628
/* Implements svn_ra__vtable_t.lock(). */
1360
1629
svn_error_t *
1361
1630
svn_ra_serf__lock(svn_ra_session_t *ra_session,
1362
1631
                  apr_hash_t *path_revs,
1366
1635
                  void *lock_baton,
1367
1636
                  apr_pool_t *pool);
1368
1637
 
 
1638
/* Implements svn_ra__vtable_t.unlock(). */
1369
1639
svn_error_t *
1370
1640
svn_ra_serf__unlock(svn_ra_session_t *ra_session,
1371
1641
                    apr_hash_t *path_tokens,
1374
1644
                    void *lock_baton,
1375
1645
                    apr_pool_t *pool);
1376
1646
 
 
1647
/* Implements svn_ra__vtable_t.get_lock(). */
1377
1648
svn_error_t *
1378
1649
svn_ra_serf__get_lock(svn_ra_session_t *ra_session,
1379
1650
                      svn_lock_t **lock,
1380
1651
                      const char *path,
1381
1652
                      apr_pool_t *pool);
1382
1653
 
 
1654
/* Implements svn_ra__vtable_t.get_locks(). */
1383
1655
svn_error_t *
1384
1656
svn_ra_serf__get_locks(svn_ra_session_t *ra_session,
1385
1657
                       apr_hash_t **locks,
1387
1659
                       svn_depth_t depth,
1388
1660
                       apr_pool_t *pool);
1389
1661
 
1390
 
svn_error_t * svn_ra_serf__get_mergeinfo(
1391
 
  svn_ra_session_t *ra_session,
1392
 
  apr_hash_t **mergeinfo,
1393
 
  const apr_array_header_t *paths,
1394
 
  svn_revnum_t revision,
1395
 
  svn_mergeinfo_inheritance_t inherit,
1396
 
  svn_boolean_t include_descendants,
1397
 
  apr_pool_t *pool);
 
1662
/* Request a mergeinfo-report from the URL attached to SESSION,
 
1663
   and fill in the MERGEINFO hash with the results.
 
1664
 
 
1665
   Implements svn_ra__vtable_t.get_mergeinfo().
 
1666
 */
 
1667
svn_error_t *
 
1668
svn_ra_serf__get_mergeinfo(svn_ra_session_t *ra_session,
 
1669
                           apr_hash_t **mergeinfo,
 
1670
                           const apr_array_header_t *paths,
 
1671
                           svn_revnum_t revision,
 
1672
                           svn_mergeinfo_inheritance_t inherit,
 
1673
                           svn_boolean_t include_descendants,
 
1674
                           apr_pool_t *pool);
1398
1675
 
1399
1676
/* Exchange capabilities with the server, by sending an OPTIONS
1400
1677
 * request announcing the client's capabilities, and by filling
1413
1690
                                   const char **corrected_url,
1414
1691
                                   apr_pool_t *pool);
1415
1692
 
1416
 
/* Implements the has_capability RA layer function. */
 
1693
/* Implements svn_ra__vtable_t.has_capability(). */
1417
1694
svn_error_t *
1418
1695
svn_ra_serf__has_capability(svn_ra_session_t *ra_session,
1419
1696
                            svn_boolean_t *has,
1420
1697
                            const char *capability,
1421
1698
                            apr_pool_t *pool);
1422
1699
 
1423
 
/* Implements the get_deleted_rev RA layer function. */
 
1700
/* Implements svn_ra__vtable_t.get_deleted_rev(). */
1424
1701
svn_error_t *
1425
1702
svn_ra_serf__get_deleted_rev(svn_ra_session_t *session,
1426
1703
                             const char *path,
1429
1706
                             svn_revnum_t *revision_deleted,
1430
1707
                             apr_pool_t *pool);
1431
1708
 
 
1709
/* Implements the get_inherited_props RA layer function. */
 
1710
svn_error_t * svn_ra_serf__get_inherited_props(svn_ra_session_t *session,
 
1711
                                               apr_array_header_t **iprops,
 
1712
                                               const char *path,
 
1713
                                               svn_revnum_t revision,
 
1714
                                               apr_pool_t *result_pool,
 
1715
                                               apr_pool_t *scratch_pool);
 
1716
 
 
1717
/* Implements svn_ra__vtable_t.get_repos_root(). */
 
1718
svn_error_t *
 
1719
svn_ra_serf__get_repos_root(svn_ra_session_t *ra_session,
 
1720
                            const char **url,
 
1721
                            apr_pool_t *pool);
 
1722
 
 
1723
/* Implements svn_ra__vtable_t.register_editor_shim_callbacks(). */
 
1724
svn_error_t *
 
1725
svn_ra_serf__register_editor_shim_callbacks(svn_ra_session_t *session,
 
1726
                                    svn_delta_shim_callbacks_t *callbacks);
 
1727
 
1432
1728
/*** Authentication handler declarations ***/
1433
1729
 
1434
1730
/**
1451
1747
 * where it necessary.
1452
1748
 */
1453
1749
svn_error_t *
1454
 
svn_ra_serf__error_on_status(int status_code,
 
1750
svn_ra_serf__error_on_status(serf_status_line sline,
1455
1751
                             const char *path,
1456
1752
                             const char *location);
1457
1753
 
 
1754
/* ###? */
 
1755
svn_error_t *
 
1756
svn_ra_serf__copy_into_spillbuf(svn_spillbuf_t **spillbuf,
 
1757
                                serf_bucket_t *bkt,
 
1758
                                apr_pool_t *result_pool,
 
1759
                                apr_pool_t *scratch_pool);
 
1760
 
 
1761
/* ###? */
 
1762
serf_bucket_t *
 
1763
svn_ra_serf__create_sb_bucket(svn_spillbuf_t *spillbuf,
 
1764
                              serf_bucket_alloc_t *allocator,
 
1765
                              apr_pool_t *result_pool,
 
1766
                              apr_pool_t *scratch_pool);
 
1767
 
 
1768
/** Wrap STATUS from an serf function. If STATUS is not serf error code,
 
1769
  * this is equivalent to svn_error_wrap_apr().
 
1770
 */
 
1771
svn_error_t *
 
1772
svn_ra_serf__wrap_err(apr_status_t status,
 
1773
                      const char *fmt,
 
1774
                      ...);
 
1775
 
 
1776
 
 
1777
#if defined(SVN_DEBUG)
 
1778
/* Wrapper macros to collect file and line information */
 
1779
#define svn_ra_serf__wrap_err \
 
1780
  (svn_error__locate(__FILE__,__LINE__), (svn_ra_serf__wrap_err))
 
1781
 
 
1782
#endif
 
1783
 
1458
1784
#ifdef __cplusplus
1459
1785
}
1460
1786
#endif /* __cplusplus */