[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [neon] notes about using Neon

From: Joe Orton <joe_at_light.plus.com>
Date: 2000-09-09 19:37:09 CEST

On Sat, Sep 09, 2000 at 04:36:02AM -0700, Greg Stein wrote:
> > Ah, I think I am reproducing this bug now... working on it: you get a
> > SEGV when adding the ELEM_href handling to the SVN fetch code?

Okay, tracked it... the problem was that the hip_xml interface in neon
is totally vague, and the SVN code didn't happen to match it, so, my
bad:

1) the check_validate call must return one of:

 - HIP_XML_VALID if you want to handle the element
 - HIP_XML_INVALID if you know this is invalid XML, and parsing
    will stop
 - HIP_XML_DECLINE if you don't know anything about this element,
    so ignore it (and let another handler handle it)

2) using element ID's of 0,1,2 probably didn't help, these should be up
somewhere else so as not to conflict with anything else. I'm going stick
a magic constant in neon so you can add to these.

This patch should add handling of DAV:href within the DAV:target
property correctly. I'll work on fixing up the interface and documenting
it.

Index: fetch.c
===================================================================
RCS file: /cvs/subversion/subversion/libsvn_ra_dav/fetch.c,v
retrieving revision 1.7
diff -u -p -r1.7 fetch.c
--- fetch.c 2000/09/08 18:10:05 1.7
+++ fetch.c 2000/09/09 17:31:47
@@ -74,7 +74,7 @@
 
 
 enum {
- ELEM_resourcetype,
+ ELEM_resourcetype = 0x1000,
   ELEM_collection,
   ELEM_target
 };
@@ -85,11 +85,13 @@ static const dav_propname fetch_props[]
   { "DAV:", "target" },
   { NULL }
 };
+
 static const struct hip_xml_elm fetch_elems[] =
 {
   { "DAV:", "resourcetype", ELEM_resourcetype, 0 },
   { "DAV:", "collection", ELEM_collection, HIP_XML_CDATA },
   { "DAV:", "target", ELEM_target, 0 },
+ { "DAV:", "href", DAV_ELM_href, HIP_XML_CDATA },
   { NULL }
 };
 
@@ -211,13 +213,35 @@ static int
 validate_element (hip_xml_elmid parent, hip_xml_elmid child)
 {
   /* printf("validate_element: #%d as child of #%d\n", child, parent); */
+
+ switch (parent)
+ {
+ case DAV_ELM_prop:
+ switch (child)
+ {
+ case ELEM_target:
+ case ELEM_resourcetype:
+ return HIP_XML_VALID;
+ default:
+ return HIP_XML_DECLINE;
+ }
+
+ case ELEM_target:
+ if (child == DAV_ELM_href)
+ return HIP_XML_VALID;
+ else
+ return HIP_XML_INVALID;
+
+ case ELEM_resourcetype:
+ if (child == ELEM_collection)
+ return HIP_XML_VALID;
+ else
+ return HIP_XML_INVALID;
+
+ default:
+ return HIP_XML_DECLINE;
+ }
 
- if (parent == ELEM_target && child != DAV_ELM_href)
- return HIP_XML_INVALID;
- if (child == ELEM_collection && parent != ELEM_resourcetype)
- return HIP_XML_INVALID;
-
- return HIP_XML_VALID;
 }
 
 static int
Received on Sat Oct 21 14:36:08 2006

This is an archived mail posted to the Subversion Dev mailing list.