Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/libsvn_ra_serf/property.c view on Meta::CPAN
status_line[4] == '/' &&
(status_line[5] >= '0' && status_line[5] <= '9') &&
status_line[6] == '.' &&
(status_line[7] >= '0' && status_line[7] <= '9') &&
status_line[8] == ' ')
{
char *reason;
return apr_strtoi64(status_line + 8, &reason, 10);
}
return 0;
}
/* Conforms to svn_ra_serf__path_rev_walker_t */
static svn_error_t *
copy_into_ret_props(void *baton,
const char *path, apr_ssize_t path_len,
const char *ns, apr_ssize_t ns_len,
const char *name, apr_ssize_t name_len,
const svn_string_t *val,
apr_pool_t *pool)
{
propfind_context_t *ctx = baton;
svn_ra_serf__set_ver_prop(ctx->ret_props, path, ctx->rev, ns, name,
val, ctx->pool);
return SVN_NO_ERROR;
}
/* Conforms to svn_ra_serf__xml_opened_t */
static svn_error_t *
propfind_opened(svn_ra_serf__xml_estate_t *xes,
void *baton,
int entered_state,
const svn_ra_serf__dav_props_t *tag,
apr_pool_t *scratch_pool)
{
propfind_context_t *ctx = baton;
if (entered_state == PROPVAL)
{
svn_ra_serf__xml_note(xes, PROPVAL, "ns", tag->namespace);
svn_ra_serf__xml_note(xes, PROPVAL, "name", tag->name);
}
else if (entered_state == PROPSTAT)
{
ctx->ps_props = apr_hash_make(ctx->pool);
}
return SVN_NO_ERROR;
}
/* Conforms to svn_ra_serf__xml_closed_t */
static svn_error_t *
propfind_closed(svn_ra_serf__xml_estate_t *xes,
void *baton,
int leaving_state,
const svn_string_t *cdata,
apr_hash_t *attrs,
apr_pool_t *scratch_pool)
{
propfind_context_t *ctx = baton;
if (leaving_state == MULTISTATUS)
{
/* We've gathered all the data from the reponse. Add this item
onto the "done list". External callers will then know this
request has been completed (tho stray response bytes may still
arrive). */
if (ctx->done_list)
{
ctx->done_item.data = ctx->handler;
ctx->done_item.next = *ctx->done_list;
*ctx->done_list = &ctx->done_item;
}
}
else if (leaving_state == HREF)
{
const char *path;
const svn_string_t *val_str;
if (strcmp(ctx->depth, "1") == 0)
path = svn_urlpath__canonicalize(cdata->data, scratch_pool);
else
path = ctx->path;
svn_ra_serf__xml_note(xes, RESPONSE, "path", path);
/* Copy the value into the right pool, then save the HREF. */
val_str = svn_string_dup(cdata, ctx->pool);
svn_ra_serf__set_ver_prop(ctx->ret_props,
path, ctx->rev, D_, "href", val_str,
ctx->pool);
}
else if (leaving_state == COLLECTION)
{
svn_ra_serf__xml_note(xes, PROPVAL, "altvalue", "collection");
}
else if (leaving_state == HREF_VALUE)
{
svn_ra_serf__xml_note(xes, PROPVAL, "altvalue", cdata->data);
}
else if (leaving_state == STATUS)
{
/* Parse the status field, and remember if this is a property
that we wish to ignore. (Typically, if it's not a 200, the
status will be 404 to indicate that a property we
specifically requested from the server doesn't exist.) */
int status = parse_status_code(cdata->data);
if (status != 200)
svn_ra_serf__xml_note(xes, PROPSTAT, "ignore-prop", "*");
}
else if (leaving_state == PROPVAL)
{
const char *encoding = svn_hash_gets(attrs, "V:encoding");
const svn_string_t *val_str;
apr_hash_t *gathered;
const char *path;
const char *ns;
const char *name;
const char *altvalue;
if (encoding)
{
if (strcmp(encoding, "base64") != 0)
return svn_error_createf(SVN_ERR_RA_DAV_MALFORMED_DATA,
NULL,
_("Got unrecognized encoding '%s'"),
encoding);
/* Decode into the right pool. */
val_str = svn_base64_decode_string(cdata, ctx->pool);
}
else
{
/* Copy into the right pool. */
val_str = svn_string_dup(cdata, ctx->pool);
}
/* The current path sits on the RESPONSE state. Gather up all the
state from this PROPVAL to the (grandparent) RESPONSE state,
and grab the path from there.
Now, it would be nice if we could, at this point, know that
the status code for this property indicated a problem -- then
we could simply bail out here and ignore the property.
Sadly, though, we might get the status code *after* we get
the property value. So we'll carry on with our processing
here, setting the property and value as expected. Once we
know for sure the status code associate with the property,
we'll decide its fate. */
gathered = svn_ra_serf__xml_gather_since(xes, RESPONSE);
/* These will be dup'd into CTX->POOL, as necessary. */
path = svn_hash_gets(gathered, "path");
if (path == NULL)
path = ctx->path;
ns = svn_hash_gets(attrs, "ns");
name = apr_pstrdup(ctx->pool,
svn_hash_gets(attrs, "name"));
altvalue = svn_hash_gets(attrs, "altvalue");
if (altvalue != NULL)
val_str = svn_string_create(altvalue, ctx->pool);
svn_ra_serf__set_ver_prop(ctx->ps_props,
path, ctx->rev, ns, name, val_str,
ctx->pool);
}
else
{
apr_hash_t *gathered;
SVN_ERR_ASSERT(leaving_state == PROPSTAT);
gathered = svn_ra_serf__xml_gather_since(xes, PROPSTAT);
/* If we've squirreled away a note that says we want to ignore
these properties, we'll do so. Otherwise, we need to copy
them from the temporary hash into the ctx->ret_props hash. */
if (! svn_hash_gets(gathered, "ignore-prop"))
{
SVN_ERR(svn_ra_serf__walk_all_paths(ctx->ps_props, ctx->rev,
copy_into_ret_props, ctx,
scratch_pool));
}
ctx->ps_props = NULL;
}
return SVN_NO_ERROR;
}
const svn_string_t *
svn_ra_serf__get_ver_prop_string(apr_hash_t *props,
( run in 1.723 second using v1.01-cache-2.11-cpan-39bf76dae61 )