631
652
See libsvn_ra_serf/util.c */
632
653
struct svn_ra_serf__pending_t *pending;
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 */
657
/* v2 of the XML parsing functions */
659
/* The XML parsing context. */
660
typedef struct svn_ra_serf__xml_context_t svn_ra_serf__xml_context_t;
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;
666
/* Called just after the parser moves into ENTERED_STATE. The tag causing
667
the transition is passed in TAG.
669
This callback is applied to a parsing context by using the
670
svn_ra_serf__xml_context_customize() function.
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,
680
const svn_ra_serf__dav_props_t *tag,
681
apr_pool_t *scratch_pool);
684
/* Called just before the parser leaves LEAVING_STATE.
686
If cdata collection was enabled for this state, then CDATA will be
687
non-NULL and contain the collected cdata.
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().
693
Use svn_ra_serf__xml_gather_since() to gather up data from outer states.
695
ATTRS is char* -> char*.
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,
702
const svn_string_t *cdata,
704
apr_pool_t *scratch_pool);
707
/* Called for all states that are not using the builtin cdata collection.
708
This callback is (only) appropriate for unbounded-size cdata content.
710
CURRENT_STATE may be used to decide what to do with the data.
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,
719
apr_pool_t *scratch_pool);
722
/* State transition table.
724
When the XML Context is constructed, it is in state 0. User states are
727
In a list of transitions, use { 0 } to indicate the end. Specifically,
728
the code looks for NS == NULL.
732
typedef struct svn_ra_serf__xml_transition_t {
733
/* This transition applies when in this state */
736
/* And when this tag is observed */
740
/* Moving to this state */
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;
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.
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];
755
/* When NAME is closed, should the callback be invoked? */
756
svn_boolean_t custom_close;
758
} svn_ra_serf__xml_transition_t;
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.
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.
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.
774
The same BATON value will be passed to all three callbacks.
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,
784
apr_pool_t *result_pool);
786
/* Destroy all subpools for this structure. */
788
svn_ra_serf__xml_context_destroy(
789
svn_ra_serf__xml_context_t *xmlctx);
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.
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);
801
/* Allocated within XES->STATE_POOL. Changes are not allowd (callers
802
should make a deep copy if they need to make changes).
804
The resulting hash maps char* names to char* values. */
806
svn_ra_serf__xml_gather_since(svn_ra_serf__xml_estate_t *xes,
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.
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().
816
Typically, this function is used by a child state's close callback,
817
or within an opening callback to store additional data.
819
Note: if the state is not found, then a programmer error has occurred,
820
so the function will invoke SVN_ERR_MALFUNCTION(). */
822
svn_ra_serf__xml_note(svn_ra_serf__xml_estate_t *xes,
828
/* Returns XES->STATE_POOL for allocating structures that should live
829
as long as the state identified by XES.
831
Note: a state pool is created upon demand, so only use this function
832
when memory is required for a given state. */
834
svn_ra_serf__xml_state_pool(svn_ra_serf__xml_estate_t *xes);
837
/* Any XML parser may be used. When an opening tag is seen, call this
838
function to feed the information into XMLCTX. */
840
svn_ra_serf__xml_cb_start(svn_ra_serf__xml_context_t *xmlctx,
841
const char *raw_name,
842
const char *const *attrs);
845
/* When a close tag is seen, call this function to feed the information
848
svn_ra_serf__xml_cb_end(svn_ra_serf__xml_context_t *xmlctx,
849
const char *raw_name);
852
/* When cdata is parsed by the wrapping XML parser, call this function to
853
feed the cdata into the XMLCTX. */
855
svn_ra_serf__xml_cb_cdata(svn_ra_serf__xml_context_t *xmlctx,
641
861
* Parses a server-side error message into a local Subversion error.
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;
647
/* Have we checked to see if there's an XML error in this response? */
650
/* Was there an XML error response? */
651
svn_boolean_t has_xml_response;
653
867
/* Are we done with the response? */
654
868
svn_boolean_t done;
719
900
apr_pool_t *pool);
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.
726
* All temporary allocations will be made in a @a pool.
729
svn_ra_serf__handle_server_error(serf_request_t *request,
730
serf_bucket_t *response,
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.
736
907
* Implements svn_ra_serf__response_handler_t.
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.
740
* All temporary allocations will be made in a @a pool.
912
* All temporary allocations will be made in a @a scratch_pool.
743
915
svn_ra_serf__handle_multistatus_only(serf_request_t *request,
744
916
serf_bucket_t *response,
918
apr_pool_t *scratch_pool);
921
/* Handler that expects an empty body.
923
If a body IS present, and it is text/xml, then it will be parsed for
926
BATON should be the svn_ra_serf__handler_t running REQUEST.
928
Status line information will be in HANDLER->SLINE.
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
934
All temporary allocations will be made in SCRATCH_POOL. */
936
svn_ra_serf__expect_empty_body(serf_request_t *request,
937
serf_bucket_t *response,
939
apr_pool_t *scratch_pool);
749
943
* This function will feed the RESPONSE body into XMLP. When parsing is
959
1125
apr_pool_t *result_pool,
960
1126
apr_pool_t *scratch_pool);
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.
1134
If REVISION is SVN_INVALID_REVNUM, then the properties are fetched
1137
This function performs the request synchronously.
1139
Temporary allocations are made in SCRATCH_POOL. */
1141
svn_ra_serf__fetch_node_props(apr_hash_t **results,
1142
svn_ra_serf__connection_t *conn,
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);
1150
/* Using CONN, fetch a DAV: property from the resource identified by URL
1151
within REVISION. The PROPNAME may be one of:
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).
1159
This function performs the request synchronously.
1161
Temporary allocations are made in SCRATCH_POOL. */
1163
svn_ra_serf__fetch_dav_prop(const char **value,
1164
svn_ra_serf__connection_t *conn,
1166
svn_revnum_t revision,
1167
const char *propname,
1168
apr_pool_t *result_pool,
1169
apr_pool_t *scratch_pool);
962
1172
/* Set PROPS for PATH at REV revision with a NS:NAME VAL.
964
1174
* The POOL governs allocation.
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. */
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,
1319
svn_ra_serf__run_merge(const svn_commit_info_t **commit_info,
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);
1124
1330
/** OPTIONS-related functions **/
1126
typedef struct svn_ra_serf__options_context_t svn_ra_serf__options_context_t;
1128
/* Is this OPTIONS-request done yet? */
1130
svn_ra_serf__get_options_done_ptr(svn_ra_serf__options_context_t *ctx);
1133
svn_ra_serf__options_get_activity_collection(svn_ra_serf__options_context_t *ctx);
1136
svn_ra_serf__options_get_youngest_rev(svn_ra_serf__options_context_t *ctx);
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. */
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,
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. */
1336
svn_ra_serf__probe_proxy(svn_ra_serf__session_t *serf_sess,
1337
apr_pool_t *scratch_pool);
1340
/* On HTTPv2 connections, run an OPTIONS request over CONN to fetch the
1341
current youngest revnum, returning it in *YOUNGEST.
1343
(the revnum is headers of the OPTIONS response)
1345
This function performs the request synchronously.
1347
All temporary allocations will be made in SCRATCH_POOL. */
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);
1354
/* On HTTPv1 connections, run an OPTIONS request over CONN to fetch the
1355
activity collection set and return it in *ACTIVITY_URL, allocated
1358
(the activity-collection-set is in the body of the OPTIONS response)
1360
This function performs the request synchronously.
1362
All temporary allocations will be made in SCRATCH_POOL. */
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);
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);
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.
1191
* REVISION may be SVN_INVALID_REVNUM (to mean "the current HEAD
1192
* revision"). If URL is NULL, use SESSION's session url.
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
1198
* If non-NULL, use CONN for communications with the server;
1199
* otherwise, use the default connection.
1201
* Use POOL for all allocations.
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,
1209
svn_revnum_t revision,
1210
svn_revnum_t *latest_revnum,
1409
/* Using the default connection in SESSION (conns[0]), get the youngest
1410
revnum from the server, returning it in *YOUNGEST.
1412
This function operates synchronously.
1414
All temporary allocations are performed in SCRATCH_POOL. */
1416
svn_ra_serf__get_youngest_revnum(svn_revnum_t *youngest,
1417
svn_ra_serf__session_t *session,
1418
apr_pool_t *scratch_pool);
1421
/* Generate a revision-stable URL.
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.
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".
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.
1438
If URL is NULL, then the session root will be used.
1440
The stable URL will be placed into *STABLE_URL, allocated from RESULT_POOL.
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.
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.
1450
All temporary allocations are performed in SCRATCH_POOL. */
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,
1457
svn_revnum_t revision,
1458
apr_pool_t *result_pool,
1459
apr_pool_t *scratch_pool);
1213
1462
/** RA functions **/
1464
/* Implements svn_ra__vtable_t.get_log(). */
1216
1466
svn_ra_serf__get_log(svn_ra_session_t *session,
1217
1467
const apr_array_header_t *paths,