~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
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
#error Please update your version of serf to at least 1.2.1.
55
55
#endif
56
56
 
57
 
/** Use this to silence compiler warnings about unused parameters. */
58
 
#define UNUSED_CTX(x) ((void)(x))
59
 
 
60
57
/** Wait duration (in microseconds) used in calls to serf_context_run() */
61
58
#define SVN_RA_SERF__CONTEXT_RUN_DURATION 500000
62
59
 
99
96
 * The master serf RA session.
100
97
 *
101
98
 * This is stored in the ra session ->priv field.
 
99
 *
 
100
 * ### Check ra_serf_dup_session when adding fields.
102
101
 */
103
102
struct svn_ra_serf__session_t {
104
103
  /* Pool for allocations during this session */
105
104
  apr_pool_t *pool;
 
105
  apr_hash_t *config; /* For duplicating */
106
106
 
107
107
  /* The current context */
108
108
  serf_context_t *context;
154
154
  /* Callback functions to get info from WC */
155
155
  const svn_ra_callbacks2_t *wc_callbacks;
156
156
  void *wc_callback_baton;
 
157
  svn_auth_baton_t *auth_baton;
157
158
 
158
159
  /* Callback function to send progress info to the client */
159
160
  svn_ra_progress_notify_func_t progress_func;
263
264
 */
264
265
typedef struct svn_ra_serf__dav_props_t {
265
266
  /* Element namespace */
266
 
  const char *namespace;
 
267
  const char *xmlns;
267
268
  /* Element name */
268
269
  const char *name;
269
270
} svn_ra_serf__dav_props_t;
270
271
 
271
 
/*
272
 
 * Structure which represents an XML namespace.
273
 
 */
274
 
typedef struct ns_t {
275
 
  /* The assigned name. */
276
 
  const char *namespace;
277
 
  /* The full URL for this namespace. */
278
 
  const char *url;
279
 
  /* The next namespace in our list. */
280
 
  struct ns_t *next;
281
 
} svn_ra_serf__ns_t;
282
 
 
283
 
/*
284
 
 * An incredibly simple list.
285
 
 */
286
 
typedef struct ra_serf_list_t {
287
 
  void *data;
288
 
  struct ra_serf_list_t *next;
289
 
} svn_ra_serf__list_t;
290
 
 
291
272
/** DAV property sets **/
292
273
 
293
274
static const svn_ra_serf__dav_props_t base_props[] =
378
359
                              svn_ra_serf__session_t *sess,
379
360
                              apr_pool_t *scratch_pool);
380
361
 
 
362
/* Run the context once. Manage waittime_left to handle timing out when
 
363
   nothing happens over the session->timout.
 
364
 */
 
365
svn_error_t *
 
366
svn_ra_serf__context_run(svn_ra_serf__session_t *sess,
 
367
                         apr_interval_time_t *waittime_left,
 
368
                         apr_pool_t *scratch_pool);
 
369
 
 
370
 
 
371
 
381
372
/* Callback for response handlers */
382
373
typedef svn_error_t *
383
374
(*svn_ra_serf__response_handler_t)(serf_request_t *request,
385
376
                                   void *handler_baton,
386
377
                                   apr_pool_t *scratch_pool);
387
378
 
 
379
/* Callback when the request is done */
 
380
typedef svn_error_t *
 
381
(*svn_ra_serf__response_done_delegate_t)(serf_request_t *request,
 
382
                                         void *done_baton,
 
383
                                         apr_pool_t *scratch_pool);
 
384
 
388
385
/* Callback for when a request body is needed. */
389
 
/* ### should pass a scratch_pool  */
390
386
typedef svn_error_t *
391
387
(*svn_ra_serf__request_body_delegate_t)(serf_bucket_t **body_bkt,
392
388
                                        void *baton,
393
389
                                        serf_bucket_alloc_t *alloc,
394
 
                                        apr_pool_t *request_pool);
 
390
                                        apr_pool_t *request_pool,
 
391
                                        apr_pool_t *scratch_pool);
395
392
 
396
393
/* Callback for when request headers are needed. */
397
 
/* ### should pass a scratch_pool  */
398
394
typedef svn_error_t *
399
395
(*svn_ra_serf__request_header_delegate_t)(serf_bucket_t *headers,
400
396
                                          void *baton,
401
 
                                          apr_pool_t *request_pool);
 
397
                                          apr_pool_t *request_pool,
 
398
                                          apr_pool_t *scratch_pool);
402
399
 
403
400
/* Callback for when a response has an error. */
404
401
typedef svn_error_t *
413
410
/*
414
411
 * Structure that can be passed to our default handler to guide the
415
412
 * execution of the request through its lifecycle.
 
413
 *
 
414
 * Use svn_ra_serf__create_handler() to create instances of this struct.
416
415
 */
417
416
typedef struct svn_ra_serf__handler_t {
418
417
  /* The HTTP method string of the request */
429
428
     enabled. */
430
429
  svn_boolean_t custom_accept_encoding;
431
430
 
 
431
  /* If TRUE then default DAV: capabilities request headers is not configured
 
432
     for request. */
 
433
  svn_boolean_t no_dav_headers;
 
434
 
 
435
  /* If TRUE doesn't fail requests on HTTP error statuses like 405, 408, 500
 
436
     (see util.c response_done()) */
 
437
  svn_boolean_t no_fail_on_http_failure_status;
 
438
 
 
439
  /* If TRUE doesn't fail requests on HTTP redirect statuses like 301, 307 */
 
440
  svn_boolean_t no_fail_on_http_redirect_status;
 
441
 
432
442
  /* Has the request/response been completed?  */
433
443
  svn_boolean_t done;
 
444
  svn_boolean_t scheduled; /* Is the request scheduled in a context */
434
445
 
435
446
  /* If we captured an error from the server, then this will be non-NULL.
436
447
     It will be allocated from HANDLER_POOL.  */
447
458
  serf_status_line sline;  /* The parsed Status-Line  */
448
459
  const char *location;  /* The Location: header, if any  */
449
460
 
 
461
  /* This function and baton pair allows handling the completion of request.
 
462
   *
 
463
   * The default handler is responsible for the HTTP failure processing.
 
464
   *
 
465
   * If no_fail_on_http_failure_status is not TRUE, then the callback will
 
466
   * return recorded server errors or if there is none and the http status
 
467
   * specifies an error returns an error for that.
 
468
   *
 
469
   * The default baton is the handler itself.
 
470
   */
 
471
  svn_ra_serf__response_done_delegate_t done_delegate;
 
472
  void *done_delegate_baton;
 
473
 
450
474
  /* The handler and baton pair to be executed when a non-recoverable error
451
475
   * is detected.  If it is NULL in the presence of an error, an abort() may
452
476
   * be triggered.
490
514
  /* Pool for allocating SLINE.REASON and LOCATION. If this pool is NULL,
491
515
     then the requestor does not care about SLINE and LOCATION.  */
492
516
  apr_pool_t *handler_pool;
493
 
 
494
517
} svn_ra_serf__handler_t;
495
518
 
496
519
 
511
534
 */
512
535
void svn_ra_serf__request_create(svn_ra_serf__handler_t *handler);
513
536
 
514
 
/* XML helper callbacks. */
515
 
 
516
 
typedef struct svn_ra_serf__xml_state_t {
517
 
  /* A numeric value that represents the current state in parsing.
518
 
   *
519
 
   * Value 0 is reserved for use as the default state.
520
 
   */
521
 
  int current_state;
522
 
 
523
 
  /* Private pointer set by the parsing code. */
524
 
  void *private;
525
 
 
526
 
  /* Allocations should be made in this pool to match the lifetime of the
527
 
   * state.
528
 
   */
529
 
  apr_pool_t *pool;
530
 
 
531
 
  /* The currently-declared namespace for this state. */
532
 
  svn_ra_serf__ns_t *ns_list;
533
 
 
534
 
  /* Our previous states. */
535
 
  struct svn_ra_serf__xml_state_t *prev;
536
 
} svn_ra_serf__xml_state_t;
537
 
 
538
 
/* Forward declaration of the XML parser structure. */
539
 
typedef struct svn_ra_serf__xml_parser_t svn_ra_serf__xml_parser_t;
540
 
 
541
 
/* Callback invoked with @a baton by our XML @a parser when an element with
542
 
 * the @a name containing @a attrs is opened.
543
 
 */
544
 
typedef svn_error_t *
545
 
(*svn_ra_serf__xml_start_element_t)(svn_ra_serf__xml_parser_t *parser,
546
 
                                    svn_ra_serf__dav_props_t name,
547
 
                                    const char **attrs,
548
 
                                    apr_pool_t *scratch_pool);
549
 
 
550
 
/* Callback invoked with @a baton by our XML @a parser when an element with
551
 
 * the @a name is closed.
552
 
 */
553
 
typedef svn_error_t *
554
 
(*svn_ra_serf__xml_end_element_t)(svn_ra_serf__xml_parser_t *parser,
555
 
                                  svn_ra_serf__dav_props_t name,
556
 
                                  apr_pool_t *scratch_pool);
557
 
 
558
 
/* Callback invoked with @a baton by our XML @a parser when a CDATA portion
559
 
 * of @a data with size @a len is encountered.
560
 
 *
561
 
 * This may be invoked multiple times for the same tag.
562
 
 */
563
 
typedef svn_error_t *
564
 
(*svn_ra_serf__xml_cdata_chunk_handler_t)(svn_ra_serf__xml_parser_t *parser,
565
 
                                          const char *data,
566
 
                                          apr_size_t len,
567
 
                                          apr_pool_t *scratch_pool);
568
 
 
569
 
/*
570
 
 * Helper structure associated with handle_xml_parser handler that will
571
 
 * specify how an XML response will be processed.
572
 
 */
573
 
struct svn_ra_serf__xml_parser_t {
574
 
  /* Temporary allocations should be made in this pool. */
575
 
  apr_pool_t *pool;
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
 
 
581
 
  /* Caller-specific data passed to the start, end, cdata callbacks.  */
582
 
  void *user_data;
583
 
 
584
 
  /* Callback invoked when a tag is opened. */
585
 
  svn_ra_serf__xml_start_element_t start;
586
 
 
587
 
  /* Callback invoked when a tag is closed. */
588
 
  svn_ra_serf__xml_end_element_t end;
589
 
 
590
 
  /* Callback invoked when a cdata chunk is received. */
591
 
  svn_ra_serf__xml_cdata_chunk_handler_t cdata;
592
 
 
593
 
  /* Our associated expat-based XML parser. */
594
 
  XML_Parser xmlp;
595
 
 
596
 
  /* Our current state. */
597
 
  svn_ra_serf__xml_state_t *state;
598
 
 
599
 
  /* Our previously used states (will be reused). */
600
 
  svn_ra_serf__xml_state_t *free_state;
601
 
 
602
 
  /* If non-NULL, this value will be set to TRUE when the response is
603
 
   * completed.
604
 
   */
605
 
  svn_boolean_t *done;
606
 
 
607
 
  /* If non-NULL, when this parser completes, it will add done_item to
608
 
   * the list.
609
 
   */
610
 
  svn_ra_serf__list_t **done_list;
611
 
 
612
 
  /* A pointer to the item that will be inserted into the list upon
613
 
   * completeion.
614
 
   */
615
 
  svn_ra_serf__list_t *done_item;
616
 
 
617
 
  /* If this flag is TRUE, errors during parsing will be ignored.
618
 
   *
619
 
   * This is mainly used when we are processing an error XML response to
620
 
   * avoid infinite loops.
621
 
   */
622
 
  svn_boolean_t ignore_errors;
623
 
 
624
 
  /* If an error occurred, this value will be non-NULL. */
625
 
  svn_error_t *error;
626
 
 
627
 
  /* Deciding whether to pause, or not, is performed within the parsing
628
 
     callbacks. If a callback decides to set this flag, then the loop
629
 
     driving the parse (generally, a series of calls to serf_context_run())
630
 
     is going to need to coordinate the un-pausing of the parser by
631
 
     processing pending content. Thus, deciding to pause the parser is a
632
 
     coordinate effort rather than merely setting this flag.
633
 
 
634
 
     When an XML parsing callback sets this flag, note that additional
635
 
     elements may be parsed (as the current buffer is consumed). At some
636
 
     point, the flag will be recognized and arriving network content will
637
 
     be stashed away in the PENDING structure (see below).
638
 
 
639
 
     At some point, the controlling loop should clear this value. The
640
 
     underlying network processing will note the change and begin passing
641
 
     content into the XML callbacks.
642
 
 
643
 
     Note that the controlling loop should also process pending content
644
 
     since the arriving network content will typically finish first.  */
645
 
  svn_boolean_t paused;
646
 
 
647
 
  /* While the XML parser is paused, content arriving from the server
648
 
     must be saved locally. We cannot stop reading, or the server may
649
 
     decide to drop the connection. The content will be stored in memory
650
 
     up to a certain limit, and will then be spilled over to disk.
651
 
 
652
 
     See libsvn_ra_serf/util.c  */
653
 
  struct svn_ra_serf__pending_t *pending;
654
 
};
655
 
 
656
 
 
657
537
/* v2 of the XML parsing functions  */
658
538
 
659
539
/* The XML parsing context.  */
719
599
                            apr_pool_t *scratch_pool);
720
600
 
721
601
 
 
602
/* Magic state value for the initial state in a svn_ra_serf__xml_transition_t
 
603
   table */
 
604
#define XML_STATE_INITIAL 0
 
605
 
722
606
/* State transition table.
723
607
 
724
608
   When the XML Context is constructed, it is in state 0. User states are
727
611
   In a list of transitions, use { 0 } to indicate the end. Specifically,
728
612
   the code looks for NS == NULL.
729
613
 
 
614
   The initial state for each transition table is XML_STATE_INITIAL.
 
615
 
730
616
   ### more docco
731
617
*/
732
618
typedef struct svn_ra_serf__xml_transition_t {
757
643
 
758
644
} svn_ra_serf__xml_transition_t;
759
645
 
 
646
/* Constructor for svn_ra_serf__handler_t. Initializes a new handler
 
647
   with default settings for SESSION. */
 
648
svn_ra_serf__handler_t *
 
649
svn_ra_serf__create_handler(svn_ra_serf__session_t *session,
 
650
                            apr_pool_t *result_pool);
760
651
 
761
652
/* Construct an XML parsing context, based on the TTABLE transition table.
762
653
   As content is parsed, the CLOSED_CB callback will be invoked according
783
674
  void *baton,
784
675
  apr_pool_t *result_pool);
785
676
 
786
 
/* Destroy all subpools for this structure. */
787
 
void
788
 
svn_ra_serf__xml_context_destroy(
789
 
  svn_ra_serf__xml_context_t *xmlctx);
 
677
/* Verifies if the parsing completed successfully and destroys
 
678
   all subpools. */
 
679
svn_error_t *
 
680
svn_ra_serf__xml_context_done(svn_ra_serf__xml_context_t *xmlctx);
790
681
 
791
682
/* Construct a handler with the response function/baton set up to parse
792
683
   a response body using the given XML context. The handler and its
793
684
   internal structures are allocated in RESULT_POOL.
794
685
 
 
686
   As part of the handling the http status value is compared to 200, or
 
687
   if EXPECTED_STATUS is not NULL to all the values in EXPECTED_STATUS.
 
688
   EXPECTED_STATUS is expected to be a list of integers ending with a 0
 
689
   that lives at least as long as RESULT_POOL. If the status doesn't
 
690
   match the request has failed and will be parsed as en error response.
 
691
 
795
692
   This also initializes HANDLER_POOL to the given RESULT_POOL.  */
796
693
svn_ra_serf__handler_t *
797
 
svn_ra_serf__create_expat_handler(svn_ra_serf__xml_context_t *xmlctx,
 
694
svn_ra_serf__create_expat_handler(svn_ra_serf__session_t *session,
 
695
                                  svn_ra_serf__xml_context_t *xmlctx,
 
696
                                  const int *expected_status,
798
697
                                  apr_pool_t *result_pool);
799
698
 
800
699
 
833
732
apr_pool_t *
834
733
svn_ra_serf__xml_state_pool(svn_ra_serf__xml_estate_t *xes);
835
734
 
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
 
 
860
735
/*
861
736
 * Parses a server-side error message into a local Subversion error.
862
737
 */
863
738
struct svn_ra_serf__server_error_t {
864
 
  /* Our local representation of the error. */
865
 
  svn_error_t *error;
866
 
 
867
 
  /* Are we done with the response? */
868
 
  svn_boolean_t done;
869
 
 
870
 
  /* Have we seen an error tag? */
871
 
  svn_boolean_t in_error;
872
 
 
873
 
  /* Have we seen a HTTP "412 Precondition Failed" error? */
874
 
  svn_boolean_t contains_precondition_error;
875
 
 
876
 
  /* Should we be collecting the XML cdata? */
877
 
  svn_boolean_t collect_cdata;
878
 
 
879
 
  /* Collected cdata. NULL if cdata not needed. */
880
 
  svn_stringbuf_t *cdata;
 
739
  apr_pool_t *pool;
881
740
 
882
741
  /* XML parser and namespace used to parse the remote response */
883
 
  svn_ra_serf__xml_parser_t parser;
 
742
  svn_ra_serf__xml_context_t *xmlctx;
 
743
 
 
744
  svn_ra_serf__response_handler_t response_handler;
 
745
  void *response_baton;
 
746
 
 
747
  /* The partial errors to construct the final error from */
 
748
  apr_array_header_t *items;
 
749
 
 
750
  /* The hooked handler */
 
751
  svn_ra_serf__handler_t *handler;
884
752
};
885
753
 
886
 
 
887
754
/*
888
755
 * Handler that discards the entire @a response body associated with a
889
756
 * @a request.  Implements svn_ra_serf__response_handler_t.
940
807
 
941
808
 
942
809
/*
943
 
 * This function will feed the RESPONSE body into XMLP.  When parsing is
944
 
 * completed (i.e. an EOF is received), *DONE is set to TRUE.
945
 
 * Implements svn_ra_serf__response_handler_t.
946
 
 *
947
 
 * If an error occurs during processing RESP_ERR is invoked with the
948
 
 * RESP_ERR_BATON.
949
 
 *
950
 
 * Temporary allocations are made in POOL.
951
 
 */
952
 
svn_error_t *
953
 
svn_ra_serf__handle_xml_parser(serf_request_t *request,
954
 
                               serf_bucket_t *response,
955
 
                               void *handler_baton,
956
 
                               apr_pool_t *pool);
 
810
 * This function sets up error parsing for an existing request
 
811
 */
 
812
svn_error_t *
 
813
svn_ra_serf__setup_error_parsing(svn_ra_serf__server_error_t **server_err,
 
814
                                 svn_ra_serf__handler_t *handler,
 
815
                                 svn_boolean_t expect_207_only,
 
816
                                 apr_pool_t *result_pool,
 
817
                                 apr_pool_t *scratch_pool);
 
818
 
 
819
/*
 
820
 * Forwards response data to the server error parser
 
821
 */
 
822
svn_error_t *
 
823
svn_ra_serf__handle_server_error(svn_ra_serf__server_error_t *server_error,
 
824
                                 svn_ra_serf__handler_t *handler,
 
825
                                 serf_request_t *request,
 
826
                                 serf_bucket_t *response,
 
827
                                 apr_status_t *serf_status,
 
828
                                 apr_pool_t *scratch_pool);
 
829
 
 
830
/*
 
831
 * Creates the svn_error_t * instance from the error recorded in
 
832
 * HANDLER->server_error
 
833
 */
 
834
svn_error_t *
 
835
svn_ra_serf__server_error_create(svn_ra_serf__handler_t *handler,
 
836
                                 apr_pool_t *scratch_pool);
957
837
 
958
838
/* serf_response_handler_t implementation that completely discards
959
839
 * the response.
967
847
                                      apr_pool_t *pool);
968
848
 
969
849
 
970
 
/** XML helper functions. **/
971
 
 
972
 
/*
973
 
 * Advance the internal XML @a parser to the @a state.
974
 
 */
975
 
void
976
 
svn_ra_serf__xml_push_state(svn_ra_serf__xml_parser_t *parser,
977
 
                            int state);
978
 
 
979
 
/*
980
 
 * Return to the previous internal XML @a parser state.
981
 
 */
982
 
void
983
 
svn_ra_serf__xml_pop_state(svn_ra_serf__xml_parser_t *parser);
984
 
 
985
 
 
986
 
svn_error_t *
987
 
svn_ra_serf__process_pending(svn_ra_serf__xml_parser_t *parser,
988
 
                             svn_boolean_t *network_eof,
989
 
                             apr_pool_t *scratch_pool);
990
 
 
991
 
 
992
850
/*
993
851
 * Add the appropriate serf buckets to @a agg_bucket represented by
994
852
 * the XML * @a tag and @a value.
1028
886
svn_ra_serf__add_open_tag_buckets(serf_bucket_t *agg_bucket,
1029
887
                                  serf_bucket_alloc_t *bkt_alloc,
1030
888
                                  const char *tag,
1031
 
                                  ...);
 
889
                                  ...) SVN_NEEDS_SENTINEL_NULL;
1032
890
 
1033
891
/*
1034
892
 * Add the appropriate serf buckets to AGG_BUCKET representing xml tag close
1041
899
                                   serf_bucket_alloc_t *bkt_alloc,
1042
900
                                   const char *tag);
1043
901
 
 
902
/* Add the appropriate serf buckets to AGG_BUCKET representing the XML
 
903
 * open tag with name TAG, and then immediately closes the tag using the />
 
904
 * notation
 
905
 */
 
906
void
 
907
svn_ra_serf__add_empty_tag_buckets(serf_bucket_t *agg_bucket,
 
908
                                   serf_bucket_alloc_t *bkt_alloc,
 
909
                                   const char *tag,
 
910
                                   ...) SVN_NEEDS_SENTINEL_NULL;
 
911
 
1044
912
/*
1045
913
 * Add the appropriate serf buckets to AGG_BUCKET with xml-escaped
1046
914
 * version of DATA.
1051
919
svn_ra_serf__add_cdata_len_buckets(serf_bucket_t *agg_bucket,
1052
920
                                   serf_bucket_alloc_t *bkt_alloc,
1053
921
                                   const char *data, apr_size_t len);
1054
 
/*
1055
 
 * Look up the @a attrs array for namespace definitions and add each one
1056
 
 * to the @a ns_list of namespaces.
1057
 
 *
1058
 
 * New namespaces will be allocated in RESULT_POOL.
1059
 
 */
1060
 
void
1061
 
svn_ra_serf__define_ns(svn_ra_serf__ns_t **ns_list,
1062
 
                       const char *const *attrs,
1063
 
                       apr_pool_t *result_pool);
1064
 
 
1065
 
/*
1066
 
 * Look up @a name in the @a ns_list list for previously declared namespace
1067
 
 * definitions.
1068
 
 *
1069
 
 * Return (in @a *returned_prop_name) a #svn_ra_serf__dav_props_t tuple
1070
 
 * representing the expanded name.
1071
 
 */
1072
 
void
1073
 
svn_ra_serf__expand_ns(svn_ra_serf__dav_props_t *returned_prop_name,
1074
 
                       const svn_ra_serf__ns_t *ns_list,
1075
 
                       const char *name);
1076
922
 
1077
923
 
1078
924
/** PROPFIND-related functions **/
1079
925
 
1080
 
/*
1081
 
 * This function will deliver a PROP_CTX PROPFIND request in the SESS
1082
 
 * serf context for the properties listed in LOOKUP_PROPS at URL for
1083
 
 * DEPTH ("0","1","infinity").
1084
 
 *
1085
 
 * This function will not block waiting for the response. Callers are
1086
 
 * expected to call svn_ra_serf__wait_for_props().
1087
 
 */
1088
 
svn_error_t *
1089
 
svn_ra_serf__deliver_props(svn_ra_serf__handler_t **propfind_handler,
1090
 
                           apr_hash_t *prop_vals,
1091
 
                           svn_ra_serf__session_t *sess,
1092
 
                           svn_ra_serf__connection_t *conn,
1093
 
                           const char *url,
1094
 
                           svn_revnum_t rev,
1095
 
                           const char *depth,
1096
 
                           const svn_ra_serf__dav_props_t *lookup_props,
1097
 
                           svn_ra_serf__list_t **done_list,
1098
 
                           apr_pool_t *pool);
1099
 
 
1100
 
/*
1101
 
 * This helper function will block until PROPFIND_HANDLER indicates that is
1102
 
 * done or another error is returned.
1103
 
 */
1104
 
svn_error_t *
1105
 
svn_ra_serf__wait_for_props(svn_ra_serf__handler_t *handler,
1106
 
                            apr_pool_t *scratch_pool);
1107
 
 
1108
 
/* This is a blocking version of deliver_props.
1109
 
 
1110
 
   The properties are fetched and placed into RESULTS, allocated in
1111
 
   RESULT_POOL.
1112
 
 
1113
 
   ### more docco about the other params.
1114
 
 
1115
 
   Temporary allocations are made in SCRATCH_POOL.
1116
 
*/
1117
 
svn_error_t *
1118
 
svn_ra_serf__retrieve_props(apr_hash_t **results,
1119
 
                            svn_ra_serf__session_t *sess,
1120
 
                            svn_ra_serf__connection_t *conn,
1121
 
                            const char *url,
1122
 
                            svn_revnum_t rev,
1123
 
                            const char *depth,
1124
 
                            const svn_ra_serf__dav_props_t *props,
1125
 
                            apr_pool_t *result_pool,
1126
 
                            apr_pool_t *scratch_pool);
1127
 
 
1128
 
 
1129
 
/* Using CONN, fetch the properties specified by WHICH_PROPS using CONN
 
926
/* Removes all non regular properties from PROPS */
 
927
void
 
928
svn_ra_serf__keep_only_regular_props(apr_hash_t *props,
 
929
                                     apr_pool_t *scratch_pool);
 
930
 
 
931
 
 
932
/* Callback used via svn_ra_serf__deliver_props2 */
 
933
typedef svn_error_t *
 
934
(*svn_ra_serf__prop_func_t)(void *baton,
 
935
                            const char *path,
 
936
                            const char *ns,
 
937
                            const char *name,
 
938
                            const svn_string_t *value,
 
939
                            apr_pool_t *scratch_pool);
 
940
 
 
941
/*
 
942
 * Implementation of svn_ra_serf__prop_func_t that just delivers svn compatible
 
943
 * properties  in the apr_hash_t * that is used as baton.
 
944
 */
 
945
svn_error_t *
 
946
svn_ra_serf__deliver_svn_props(void *baton,
 
947
                               const char *path,
 
948
                               const char *ns,
 
949
                               const char *name,
 
950
                               const svn_string_t *value,
 
951
                               apr_pool_t *scratch_pool);
 
952
 
 
953
/*
 
954
 * This function will create a handler for a PROPFIND request, which will deliver
 
955
 * properties to PROP_FUNC() with PROP_BATON for the properties listed in LOOKUP_PROPS
 
956
 * at URL for DEPTH ("0","1","infinity").
 
957
 */
 
958
svn_error_t *
 
959
svn_ra_serf__create_propfind_handler(svn_ra_serf__handler_t **handler,
 
960
                                     svn_ra_serf__session_t *session,
 
961
                                     const char *path,
 
962
                                     svn_revnum_t rev,
 
963
                                     const char *depth,
 
964
                                     const svn_ra_serf__dav_props_t *find_props,
 
965
                                     svn_ra_serf__prop_func_t prop_func,
 
966
                                     void *prop_func_baton,
 
967
                                     apr_pool_t *result_pool);
 
968
 
 
969
 
 
970
/* Using SESSION, fetch the properties specified by WHICH_PROPS using CONN
1130
971
   for URL at REVISION. The resulting properties are placed into a 2-level
1131
972
   hash in RESULTS, mapping NAMESPACE -> hash<PROPNAME, PROPVALUE>, which
1132
973
   is allocated in RESULT_POOL.
1139
980
   Temporary allocations are made in SCRATCH_POOL.  */
1140
981
svn_error_t *
1141
982
svn_ra_serf__fetch_node_props(apr_hash_t **results,
1142
 
                              svn_ra_serf__connection_t *conn,
 
983
                              svn_ra_serf__session_t *session,
1143
984
                              const char *url,
1144
985
                              svn_revnum_t revision,
1145
986
                              const svn_ra_serf__dav_props_t *which_props,
1147
988
                              apr_pool_t *scratch_pool);
1148
989
 
1149
990
 
1150
 
/* Using CONN, fetch a DAV: property from the resource identified by URL
 
991
/* Using SESSION, fetch a DAV: property from the resource identified by URL
1151
992
   within REVISION. The PROPNAME may be one of:
1152
993
 
1153
994
     "checked-in"
1161
1002
   Temporary allocations are made in SCRATCH_POOL.  */
1162
1003
svn_error_t *
1163
1004
svn_ra_serf__fetch_dav_prop(const char **value,
1164
 
                            svn_ra_serf__connection_t *conn,
 
1005
                            svn_ra_serf__session_t *session,
1165
1006
                            const char *url,
1166
1007
                            svn_revnum_t revision,
1167
1008
                            const char *propname,
1168
1009
                            apr_pool_t *result_pool,
1169
1010
                            apr_pool_t *scratch_pool);
1170
1011
 
1171
 
 
1172
 
/* Set PROPS for PATH at REV revision with a NS:NAME VAL.
1173
 
 *
1174
 
 * The POOL governs allocation.
1175
 
 */
1176
 
void
1177
 
svn_ra_serf__set_ver_prop(apr_hash_t *props,
1178
 
                          const char *path, svn_revnum_t rev,
1179
 
                          const char *ns, const char *name,
1180
 
                          const svn_string_t *val, apr_pool_t *pool);
1181
 
#define svn_ra_serf__set_rev_prop svn_ra_serf__set_ver_prop
1182
 
 
1183
 
/** Property walker functions **/
1184
 
 
1185
 
typedef svn_error_t *
1186
 
(*svn_ra_serf__walker_visitor_t)(void *baton,
1187
 
                                 const char *ns,
1188
 
                                 const char *name,
1189
 
                                 const svn_string_t *val,
1190
 
                                 apr_pool_t *pool);
1191
 
 
1192
 
svn_error_t *
1193
 
svn_ra_serf__walk_all_props(apr_hash_t *props,
1194
 
                            const char *name,
1195
 
                            svn_revnum_t rev,
1196
 
                            svn_ra_serf__walker_visitor_t walker,
1197
 
                            void *baton,
1198
 
                            apr_pool_t *pool);
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
 
 
1209
 
typedef svn_error_t *
1210
 
(*svn_ra_serf__path_rev_walker_t)(void *baton,
1211
 
                                  const char *path, apr_ssize_t path_len,
1212
 
                                  const char *ns, apr_ssize_t ns_len,
1213
 
                                  const char *name, apr_ssize_t name_len,
1214
 
                                  const svn_string_t *val,
1215
 
                                  apr_pool_t *pool);
1216
 
svn_error_t *
1217
 
svn_ra_serf__walk_all_paths(apr_hash_t *props,
1218
 
                            svn_revnum_t rev,
1219
 
                            svn_ra_serf__path_rev_walker_t walker,
1220
 
                            void *baton,
1221
 
                            apr_pool_t *pool);
1222
 
 
1223
 
 
1224
1012
/* Map a property name, as passed over the wire, into its corresponding
1225
1013
   Subversion-internal name. The returned name will be a static value,
1226
1014
   or allocated within RESULT_POOL.
1232
1020
                                   const char *name,
1233
1021
                                   apr_pool_t *result_pool);
1234
1022
 
1235
 
 
1236
 
/* Select the basic revision properties from the set of "all" properties.
1237
 
   Return these in *REVPROPS, allocated from RESULT_POOL.  */
1238
 
svn_error_t *
1239
 
svn_ra_serf__select_revprops(apr_hash_t **revprops,
1240
 
                             const char *name,
1241
 
                             svn_revnum_t rev,
1242
 
                             apr_hash_t *all_revprops,
1243
 
                             apr_pool_t *result_pool,
1244
 
                             apr_pool_t *scratch_pool);
1245
 
 
1246
 
 
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
1249
 
   names to VALUE. The names are composed of NS:NAME, with specific
1250
 
   rewrite from wire names (DAV) to SVN names. This mapping is managed
1251
 
   by the svn_ra_serf__set_baton_props() function.
1252
 
 
1253
 
   FLAT_PROPS is allocated in RESULT_POOL.
1254
 
   ### right now, we do a shallow copy from PROPS to FLAT_PROPS. therefore,
1255
 
   ### the names and values in PROPS must be in the proper pool.
1256
 
 
1257
 
   Temporary allocations are made in SCRATCH_POOL.  */
1258
 
svn_error_t *
1259
 
svn_ra_serf__flatten_props(apr_hash_t **flat_props,
1260
 
                           apr_hash_t *props,
1261
 
                           apr_pool_t *result_pool,
1262
 
                           apr_pool_t *scratch_pool);
1263
 
 
1264
 
 
1265
 
/* Return the property value for PATH at REV revision with a NS:NAME.
1266
 
 * PROPS is a four-level nested hash: (svn_revnum_t => char *path =>
1267
 
 * char *ns => char *name => svn_string_t *). */
1268
 
const svn_string_t *
1269
 
svn_ra_serf__get_ver_prop_string(apr_hash_t *props,
1270
 
                                 const char *path, svn_revnum_t rev,
1271
 
                                 const char *ns, const char *name);
1272
 
 
1273
 
/* Same as svn_ra_serf__get_ver_prop_string(), but returns a C string. */
1274
 
const char *
1275
 
svn_ra_serf__get_ver_prop(apr_hash_t *props,
1276
 
                          const char *path, svn_revnum_t rev,
1277
 
                          const char *ns, const char *name);
1278
 
 
1279
 
/* Same as svn_ra_serf__get_ver_prop_string(), but for the unknown revision. */
1280
 
const svn_string_t *
1281
 
svn_ra_serf__get_prop_string(apr_hash_t *props,
1282
 
                             const char *path,
1283
 
                             const char *ns,
1284
 
                             const char *name);
1285
 
 
1286
 
/* Same as svn_ra_serf__get_ver_prop(), but for the unknown revision. */
1287
 
const char *
1288
 
svn_ra_serf__get_prop(apr_hash_t *props,
1289
 
                      const char *path,
1290
 
                      const char *ns,
1291
 
                      const char *name);
1292
 
 
1293
 
/* Same as svn_ra_serf__set_rev_prop(), but for the unknown revision. */
1294
 
void
1295
 
svn_ra_serf__set_prop(apr_hash_t *props, const char *path,
1296
 
                      const char *ns, const char *name,
1297
 
                      const svn_string_t *val, apr_pool_t *pool);
1298
 
 
1299
 
svn_error_t *
1300
 
svn_ra_serf__get_resource_type(svn_node_kind_t *kind,
1301
 
                               apr_hash_t *props);
1302
 
 
1303
 
 
1304
1023
/** MERGE-related functions **/
1305
1024
 
1306
 
void
1307
 
svn_ra_serf__merge_lock_token_list(apr_hash_t *lock_tokens,
1308
 
                                   const char *parent,
1309
 
                                   serf_bucket_t *body,
1310
 
                                   serf_bucket_alloc_t *alloc,
1311
 
                                   apr_pool_t *pool);
1312
 
 
1313
1025
/* Create an MERGE request aimed at the SESSION url, requesting the
1314
1026
   merge of the resource identified by MERGE_RESOURCE_URL.
1315
1027
   LOCK_TOKENS is a hash mapping paths to lock tokens owned by the
1317
1029
   locks set on the paths included in this commit.  */
1318
1030
svn_error_t *
1319
1031
svn_ra_serf__run_merge(const svn_commit_info_t **commit_info,
1320
 
                       int *response_code,
1321
1032
                       svn_ra_serf__session_t *session,
1322
 
                       svn_ra_serf__connection_t *conn,
1323
1033
                       const char *merge_resource_url,
1324
1034
                       apr_hash_t *lock_tokens,
1325
1035
                       svn_boolean_t keep_locks,
1347
1057
   All temporary allocations will be made in SCRATCH_POOL.  */
1348
1058
svn_error_t *
1349
1059
svn_ra_serf__v2_get_youngest_revnum(svn_revnum_t *youngest,
1350
 
                                    svn_ra_serf__connection_t *conn,
 
1060
                                    svn_ra_serf__session_t *session,
1351
1061
                                    apr_pool_t *scratch_pool);
1352
1062
 
1353
1063
 
1362
1072
   All temporary allocations will be made in SCRATCH_POOL.  */
1363
1073
svn_error_t *
1364
1074
svn_ra_serf__v1_get_activity_collection(const char **activity_url,
1365
 
                                        svn_ra_serf__connection_t *conn,
 
1075
                                        svn_ra_serf__session_t *session,
1366
1076
                                        apr_pool_t *result_pool,
1367
1077
                                        apr_pool_t *scratch_pool);
1368
1078
 
1369
1079
 
1370
1080
/* Set @a VCC_URL to the default VCC for our repository based on @a
1371
1081
 * ORIG_PATH for the session @a SESSION, ensuring that the VCC URL and
1372
 
 * repository root URLs are cached in @a SESSION.  Use @a CONN for any
1373
 
 * required network communications if it is non-NULL; otherwise use the
1374
 
 * default connection.
 
1082
 * repository root URLs are cached in @a SESSION.
1375
1083
 *
1376
 
 * All temporary allocations will be made in @a POOL. */
 
1084
 * All temporary allocations will be made in @a SCRATCH_POOL. */
1377
1085
svn_error_t *
1378
1086
svn_ra_serf__discover_vcc(const char **vcc_url,
1379
1087
                          svn_ra_serf__session_t *session,
1380
 
                          svn_ra_serf__connection_t *conn,
1381
 
                          apr_pool_t *pool);
 
1088
                          apr_pool_t *scratch_pool);
1382
1089
 
1383
1090
/* Set @a REPORT_TARGET to the URI of the resource at which generic
1384
 
 * (path-agnostic) REPORTs should be aimed for @a SESSION.  Use @a
1385
 
 * CONN for any required network communications if it is non-NULL;
1386
 
 * otherwise use the default connection.
 
1091
 * (path-agnostic) REPORTs should be aimed for @a SESSION.
1387
1092
 *
1388
1093
 * All temporary allocations will be made in @a POOL.
1389
1094
 */
1390
1095
svn_error_t *
1391
1096
svn_ra_serf__report_resource(const char **report_target,
1392
1097
                             svn_ra_serf__session_t *session,
1393
 
                             svn_ra_serf__connection_t *conn,
1394
1098
                             apr_pool_t *pool);
1395
1099
 
1396
1100
/* Set @a REL_PATH to a path (not URI-encoded) relative to the root of
1402
1106
svn_ra_serf__get_relative_path(const char **rel_path,
1403
1107
                               const char *orig_path,
1404
1108
                               svn_ra_serf__session_t *session,
1405
 
                               svn_ra_serf__connection_t *conn,
1406
1109
                               apr_pool_t *pool);
1407
1110
 
1408
1111
 
1429
1132
   The DAV RA provider(s) solve this by generating a URL that is specific
1430
1133
   to a revision by using a URL into a "baseline collection".
1431
1134
 
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.
 
1135
   For a specified SESSION, generate a revision-stable URL for URL at
 
1136
   REVISION. If REVISION is    SVN_INVALID_REVNUM, then the stable URL will
 
1137
   refer to the youngest revision at the time this function was called.
1437
1138
 
1438
1139
   If URL is NULL, then the session root will be used.
1439
1140
 
1452
1153
svn_ra_serf__get_stable_url(const char **stable_url,
1453
1154
                            svn_revnum_t *latest_revnum,
1454
1155
                            svn_ra_serf__session_t *session,
1455
 
                            svn_ra_serf__connection_t *conn,
1456
1156
                            const char *url,
1457
1157
                            svn_revnum_t revision,
1458
1158
                            apr_pool_t *result_pool,
1461
1161
 
1462
1162
/** RA functions **/
1463
1163
 
 
1164
/* Implements svn_ra__vtable_t.reparent(). */
 
1165
svn_error_t *
 
1166
svn_ra_serf__reparent(svn_ra_session_t *ra_session,
 
1167
                      const char *url,
 
1168
                      apr_pool_t *pool);
 
1169
 
 
1170
/* Implements svn_ra__vtable_t.rev_prop(). */
 
1171
svn_error_t *
 
1172
svn_ra_serf__rev_prop(svn_ra_session_t *session,
 
1173
                      svn_revnum_t rev,
 
1174
                      const char *name,
 
1175
                      svn_string_t **value,
 
1176
                      apr_pool_t *pool);
 
1177
 
1464
1178
/* Implements svn_ra__vtable_t.get_log(). */
1465
1179
svn_error_t *
1466
1180
svn_ra_serf__get_log(svn_ra_session_t *session,
1476
1190
                     void *receiver_baton,
1477
1191
                     apr_pool_t *pool);
1478
1192
 
 
1193
/* Implements svn_ra__vtable_t.check_path(). */
 
1194
svn_error_t *
 
1195
svn_ra_serf__check_path(svn_ra_session_t *ra_session,
 
1196
                        const char *rel_path,
 
1197
                        svn_revnum_t revision,
 
1198
                        svn_node_kind_t *kind,
 
1199
                        apr_pool_t *pool);
 
1200
 
 
1201
/* Implements svn_ra__vtable_t.stat(). */
 
1202
svn_error_t *
 
1203
svn_ra_serf__stat(svn_ra_session_t *ra_session,
 
1204
                  const char *rel_path,
 
1205
                  svn_revnum_t revision,
 
1206
                  svn_dirent_t **dirent,
 
1207
                  apr_pool_t *pool);
 
1208
 
1479
1209
/* Implements svn_ra__vtable_t.get_locations(). */
1480
1210
svn_error_t *
1481
1211
svn_ra_serf__get_locations(svn_ra_session_t *session,
1572
1302
                                apr_time_t tm,
1573
1303
                                apr_pool_t *pool);
1574
1304
 
1575
 
/* Implements svn_ra__vtable_t.get_commit_editor(). */
 
1305
/* Implements svn_ra__vtable_t.get_commit_editor().
 
1306
 *
 
1307
 * Note: Like other commit editors, the returned editor requires that the
 
1308
 * @c copyfrom_path parameter passed to its @c add_file and @c add_directory
 
1309
 * methods is a URL, not a relative path.
 
1310
 */
1576
1311
svn_error_t *
1577
1312
svn_ra_serf__get_commit_editor(svn_ra_session_t *session,
1578
1313
                               const svn_delta_editor_t **editor,
1594
1329
                      apr_hash_t **props,
1595
1330
                      apr_pool_t *pool);
1596
1331
 
 
1332
/* Implements svn_ra__vtable_t.get_dir(). */
 
1333
svn_error_t *
 
1334
svn_ra_serf__get_dir(svn_ra_session_t *ra_session,
 
1335
                     apr_hash_t **dirents,
 
1336
                     svn_revnum_t *fetched_rev,
 
1337
                     apr_hash_t **ret_props,
 
1338
                     const char *rel_path,
 
1339
                     svn_revnum_t revision,
 
1340
                     apr_uint32_t dirent_fields,
 
1341
                     apr_pool_t *result_pool);
 
1342
 
1597
1343
/* Implements svn_ra__vtable_t.change_rev_prop(). */
1598
1344
svn_error_t *
1599
1345
svn_ra_serf__change_rev_prop(svn_ra_session_t *session,
1688
1434
svn_error_t *
1689
1435
svn_ra_serf__exchange_capabilities(svn_ra_serf__session_t *serf_sess,
1690
1436
                                   const char **corrected_url,
1691
 
                                   apr_pool_t *pool);
 
1437
                                   apr_pool_t *result_pool,
 
1438
                                   apr_pool_t *scratch_pool);
1692
1439
 
1693
1440
/* Implements svn_ra__vtable_t.has_capability(). */
1694
1441
svn_error_t *
1745
1492
 * Convert an HTTP STATUS_CODE resulting from a WebDAV request against
1746
1493
 * PATH to the relevant error code.  Use the response-supplied LOCATION
1747
1494
 * where it necessary.
 
1495
 *
 
1496
 * Returns SVN_NO_ERROR if sline doesn't specify an error condition
1748
1497
 */
1749
1498
svn_error_t *
1750
1499
svn_ra_serf__error_on_status(serf_status_line sline,
1751
1500
                             const char *path,
1752
1501
                             const char *location);
1753
1502
 
 
1503
/**
 
1504
 * Convert an unexpected HTTP STATUS_CODE from a request to the relevant error
 
1505
 * code. Unlike svn_ra_serf__error_on_status() this function creates an error
 
1506
 * for any result
 
1507
 */
 
1508
svn_error_t *
 
1509
svn_ra_serf__unexpected_status(svn_ra_serf__handler_t *handler);
 
1510
 
 
1511
 
1754
1512
/* ###? */
1755
1513
svn_error_t *
1756
1514
svn_ra_serf__copy_into_spillbuf(svn_spillbuf_t **spillbuf,
1773
1531
                      const char *fmt,
1774
1532
                      ...);
1775
1533
 
 
1534
/* Create a bucket that just returns DATA (with length LEN) and then returns
 
1535
   the APR_EAGAIN status */
 
1536
serf_bucket_t *
 
1537
svn_ra_serf__create_bucket_with_eagain(const char *data,
 
1538
                                       apr_size_t len,
 
1539
                                       serf_bucket_alloc_t *allocator);
 
1540
 
 
1541
 
1776
1542
 
1777
1543
#if defined(SVN_DEBUG)
1778
1544
/* Wrapper macros to collect file and line information */