Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/mod_dav_svn/reports/get-location-segments.c view on Meta::CPAN
apr_err = ap_fprintf(b->output, b->bb,
"<S:location-segment path=\"%s\" "
"range-start=\"%ld\" range-end=\"%ld\"/>" DEBUG_CR,
path_quoted,
segment->range_start, segment->range_end);
}
else
{
apr_err = ap_fprintf(b->output, b->bb,
"<S:location-segment "
"range-start=\"%ld\" range-end=\"%ld\"/>" DEBUG_CR,
segment->range_start, segment->range_end);
}
if (apr_err)
return svn_error_create(apr_err, 0, NULL);
return SVN_NO_ERROR;
}
dav_error *
dav_svn__get_location_segments_report(const dav_resource *resource,
const apr_xml_doc *doc,
ap_filter_t *output)
{
svn_error_t *serr;
dav_error *derr = NULL;
apr_bucket_brigade *bb;
int ns;
apr_xml_elem *child;
const char *abs_path = NULL;
svn_revnum_t peg_revision = SVN_INVALID_REVNUM;
svn_revnum_t start_rev = SVN_INVALID_REVNUM;
svn_revnum_t end_rev = SVN_INVALID_REVNUM;
dav_svn__authz_read_baton arb;
struct location_segment_baton location_segment_baton;
/* Sanity check. */
if (!resource->info->repos_path)
return dav_svn__new_error(resource->pool, HTTP_BAD_REQUEST, 0,
"The request does not specify a repository path");
ns = dav_svn__find_ns(doc->namespaces, SVN_XML_NAMESPACE);
if (ns == -1)
{
return dav_svn__new_error_tag(resource->pool, HTTP_BAD_REQUEST, 0,
"The request does not contain the 'svn:' "
"namespace, so it is not going to have "
"certain required elements.",
SVN_DAV_ERROR_NAMESPACE,
SVN_DAV_ERROR_TAG);
}
/* Gather the parameters. */
for (child = doc->root->first_child; child != NULL; child = child->next)
{
/* If this element isn't one of ours, then skip it. */
if (child->ns != ns)
continue;
if (strcmp(child->name, "peg-revision") == 0)
{
peg_revision = SVN_STR_TO_REV(dav_xml_get_cdata(child,
resource->pool, 1));
}
else if (strcmp(child->name, "start-revision") == 0)
{
start_rev = SVN_STR_TO_REV(dav_xml_get_cdata(child,
resource->pool, 1));
}
else if (strcmp(child->name, "end-revision") == 0)
{
end_rev = SVN_STR_TO_REV(dav_xml_get_cdata(child,
resource->pool, 1));
}
else if (strcmp(child->name, "path") == 0)
{
const char *rel_path = dav_xml_get_cdata(child, resource->pool, 0);
if ((derr = dav_svn__test_canonical(rel_path, resource->pool)))
return derr;
/* Force REL_PATH to be a relative path, not an fspath. */
rel_path = svn_relpath_canonicalize(rel_path, resource->pool);
/* Append the REL_PATH to the base FS path to get an
absolute repository path. */
abs_path = svn_fspath__join(resource->info->repos_path, rel_path,
resource->pool);
}
}
/* Check that all parameters are present and valid. */
if (! abs_path)
return dav_svn__new_error_tag(resource->pool, HTTP_BAD_REQUEST, 0,
"Not all parameters passed.",
SVN_DAV_ERROR_NAMESPACE,
SVN_DAV_ERROR_TAG);
if (SVN_IS_VALID_REVNUM(start_rev)
&& SVN_IS_VALID_REVNUM(end_rev)
&& (end_rev > start_rev))
return dav_svn__new_error_tag(resource->pool, HTTP_BAD_REQUEST, 0,
"End revision must not be younger than "
"start revision",
SVN_DAV_ERROR_NAMESPACE,
SVN_DAV_ERROR_TAG);
if (SVN_IS_VALID_REVNUM(peg_revision)
&& SVN_IS_VALID_REVNUM(start_rev)
&& (start_rev > peg_revision))
return dav_svn__new_error_tag(resource->pool, HTTP_BAD_REQUEST, 0,
"Start revision must not be younger than "
"peg revision",
SVN_DAV_ERROR_NAMESPACE,
SVN_DAV_ERROR_TAG);
/* Build an authz read baton. */
arb.r = resource->info->r;
arb.repos = resource->info->repos;
/* Build the bucket brigade we'll use for output. */
bb = apr_brigade_create(resource->pool, output->c->bucket_alloc);
/* Do what we came here for. */
location_segment_baton.sent_opener = FALSE;
location_segment_baton.output = output;
location_segment_baton.bb = bb;
if ((serr = svn_repos_node_location_segments(resource->info->repos->repos,
abs_path, peg_revision,
start_rev, end_rev,
location_segment_receiver,
&location_segment_baton,
dav_svn__authz_read_func(&arb),
&arb, resource->pool)))
{
derr = dav_svn__convert_err(serr, HTTP_BAD_REQUEST, serr->message,
resource->pool);
goto cleanup;
}
( run in 0.532 second using v1.01-cache-2.11-cpan-0b5f733616e )