Back to index

avfs  1.0.1
Classes | Functions | Variables
dav_207.c File Reference
#include "config.h"
#include "http_utils.h"
#include "hip_xml.h"
#include "dav_207.h"
#include "uri.h"
#include "ne_alloc.h"
#include "neon_i18n.h"

Go to the source code of this file.

Classes

struct  dav_207_parser_s

Functions

void dav_207_set_response_handlers (dav_207_parser *p, dav_207_start_response start, dav_207_end_response end)
void dav_207_set_propstat_handlers (dav_207_parser *p, dav_207_start_propstat start, dav_207_end_propstat end)
void * dav_207_get_current_response (dav_207_parser *p)
void * dav_207_get_current_propstat (dav_207_parser *p)
static int start_element (void *userdata, const struct hip_xml_elm *elm, const char **atts)
static int end_element (void *userdata, const struct hip_xml_elm *elm, const char *cdata)
static int check_context (hip_xml_elmid parent, hip_xml_elmid child)
static int ignore_cc (hip_xml_elmid parent, hip_xml_elmid child)
void dav_207_ignore_unknown (dav_207_parser *p)
dav_207_parser * dav_207_create (hip_xml_parser *parser, void *userdata)
void dav_207_destroy (dav_207_parser *p)
int dav_accept_207 (void *userdata, http_req *req, http_status *status)

Variables

static const struct hip_xml_elm []

Class Documentation

struct dav_207_parser_s

Definition at line 38 of file dav_207.c.

Collaboration diagram for dav_207_parser_s:
Class Members
char * description
dav_207_end_propstat end_propstat
dav_207_end_response end_response
char * href
hip_xml_parser * parser
void * propstat
void * response
dav_207_start_propstat start_propstat
dav_207_start_response start_response
http_status status
char * status_line
void * userdata

Function Documentation

static int check_context ( hip_xml_elmid  parent,
hip_xml_elmid  child 
) [static]

Definition at line 171 of file dav_207.c.

{
    DEBUG(DEBUG_XML, "207cc: %d in %d\n", child, parent);
    switch (parent) {
    case HIP_ELM_root:
       switch (child) {
       case DAV_ELM_multistatus:
       case DAV_ELM_response: /* not sure why this is here... */
           return HIP_XML_VALID;
       default:
           break;
       }
       break;
    case DAV_ELM_multistatus:
       /* <!ELEMENT multistatus (response+, responsedescription?) > */
       switch (child) {
       case DAV_ELM_response:
       case DAV_ELM_responsedescription:
           return HIP_XML_VALID;
       default:
           break;
       }
       break;
    case DAV_ELM_response:
       /* <!ELEMENT response (href, ((href*, status)|(propstat+)),
          responsedescription?) > */
       switch (child) {
       case DAV_ELM_href:
       case DAV_ELM_status:
       case DAV_ELM_propstat:
       case DAV_ELM_responsedescription:
           return HIP_XML_VALID;
       default:
           break;
       }
       break;
    case DAV_ELM_propstat:
       /* <!ELEMENT propstat (prop, status, responsedescription?) > */
       switch (child) {
       case DAV_ELM_prop: 
       case DAV_ELM_status:
       case DAV_ELM_responsedescription:
           return HIP_XML_VALID;
       default:
           break;
       }
       break;
    default:
       break;
    }

    return HIP_XML_DECLINE;
}

Here is the caller graph for this function:

dav_207_parser* dav_207_create ( hip_xml_parser *  parser,
void *  userdata 
)

Definition at line 247 of file dav_207.c.

{
    dav_207_parser *p = ne_calloc(sizeof *p);

    p->parser = parser;
    p->userdata = userdata;
    
    /* Add handler for the standard 207 elements */
    hip_xml_push_handler(parser, elements, check_context, 
                      start_element, end_element, p);
    
    return p;
}

Here is the call graph for this function:

void dav_207_destroy ( dav_207_parser *  p)

Definition at line 261 of file dav_207.c.

{
    free(p);
}
void* dav_207_get_current_propstat ( dav_207_parser *  p)

Definition at line 86 of file dav_207.c.

{
    return p->propstat;
}
void* dav_207_get_current_response ( dav_207_parser *  p)

Definition at line 81 of file dav_207.c.

{
    return p->response;
}
void dav_207_ignore_unknown ( dav_207_parser *  p)

Definition at line 235 of file dav_207.c.

{
    static const struct hip_xml_elm any_elms[] = {
       { "", "", HIP_ELM_unknown, HIP_XML_COLLECT },
       { NULL }
    };
    
    hip_xml_push_handler(p->parser, any_elms,
                      ignore_cc, NULL, NULL, NULL);
    
}

Here is the call graph for this function:

void dav_207_set_propstat_handlers ( dav_207_parser *  p,
dav_207_start_propstat  start,
dav_207_end_propstat  end 
)

Definition at line 73 of file dav_207.c.

{
    p->start_propstat = start;
    p->end_propstat = end;
}
void dav_207_set_response_handlers ( dav_207_parser *  p,
dav_207_start_response  start,
dav_207_end_response  end 
)

Definition at line 65 of file dav_207.c.

{
    p->start_response = start;
    p->end_response = end;
}
int dav_accept_207 ( void *  userdata,
http_req *  req,
http_status status 
)

Definition at line 266 of file dav_207.c.

{
    return (status->code == 207);
}
static int end_element ( void *  userdata,
const struct hip_xml_elm elm,
const char *  cdata 
) [static]

Definition at line 111 of file dav_207.c.

{
    dav_207_parser *p = userdata;

    switch (elm->id) {
    case DAV_ELM_responsedescription:
       if (cdata != NULL) {
           HTTP_FREE(p->description);
           p->description = ne_strdup(cdata);
       }
       break;
    case DAV_ELM_href:
       /* Now we have the href, begin the response */
       if (p->start_response && cdata != NULL) {
           p->response = (*p->start_response)(p->userdata, cdata);
       }
       break;
    case DAV_ELM_status:
       if (cdata) {
           HTTP_FREE(p->status_line);
           p->status_line = ne_strdup(cdata);
           if (http_parse_statusline(p->status_line, &p->status)) {
              char buf[500];
              DEBUG(DEBUG_HTTP, "Status line: %s\n", cdata);
              snprintf(buf, 500, 
                      _("Invalid HTTP status line in status element at line %d of response:\nStatus line was: %s"),
                      hip_xml_currentline(p->parser), p->status_line);
              hip_xml_set_error(p->parser, buf);
              HTTP_FREE(p->status_line);
              return -1;
           } else {
              DEBUG(DEBUG_XML, "Decoded status line: %s\n", p->status_line);
           }
       }
       break;
    case DAV_ELM_propstat:
       if (p->end_propstat) {
           (*p->end_propstat)(p->userdata, p->propstat, p->status_line,
                            p->status_line?&p->status:NULL, p->description);
       }
       p->propstat = NULL;
       HTTP_FREE(p->description);
       HTTP_FREE(p->status_line);
       break;
    case DAV_ELM_response:
       if (p->end_response) {
           (*p->end_response)(p->userdata, p->response, p->status_line,
                            p->status_line?&p->status:NULL, p->description);
       }
       p->response = NULL;
       HTTP_FREE(p->status_line);
       HTTP_FREE(p->description);
       break;
    }
    return 0;
}

Here is the caller graph for this function:

static int ignore_cc ( hip_xml_elmid  parent,
hip_xml_elmid  child 
) [static]

Definition at line 225 of file dav_207.c.

{
    if (child == HIP_ELM_unknown || parent == HIP_ELM_unknown) {
       DEBUG(DEBUG_XML, "207 catch-all caught %d in %d\n", child, parent);
       return HIP_XML_VALID;
    }

    return HIP_XML_DECLINE;
}

Here is the caller graph for this function:

static int start_element ( void *  userdata,
const struct hip_xml_elm elm,
const char **  atts 
) [static]

Definition at line 92 of file dav_207.c.

{
    dav_207_parser *p = userdata;
    
    switch (elm->id) {
    case DAV_ELM_response:
       /* Create new response delayed until we get HREF */
       break;
    case DAV_ELM_propstat:
       if (p->start_propstat) {
           p->propstat = (*p->start_propstat)(p->userdata, p->response);
       }
       break;
    }
    return 0;
}

Here is the caller graph for this function:


Variable Documentation

const struct hip_xml_elm[] [static]
Initial value:
 {
    { "DAV:", "multistatus", DAV_ELM_multistatus, 0 },
    { "DAV:", "response", DAV_ELM_response, 0 },
    { "DAV:", "responsedescription", DAV_ELM_responsedescription, 
      HIP_XML_CDATA },
    { "DAV:", "href", DAV_ELM_href, HIP_XML_CDATA },
    { "DAV:", "propstat", DAV_ELM_propstat, 0 },
    { "DAV:", "prop", DAV_ELM_prop, 0 },
    { "DAV:", "status", DAV_ELM_status, HIP_XML_CDATA },
    { NULL }
}

Definition at line 52 of file dav_207.c.