Back to index

avfs  1.0.1
dav_207.h
Go to the documentation of this file.
00001 /* 
00002    WebDAV 207 multi-status response handling
00003    Copyright (C) 1999-2001, Joe Orton <joe@light.plus.com>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009    
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public
00016    License along with this library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00018    MA 02111-1307, USA
00019 
00020 */
00021 
00022 #ifndef DAV207_H
00023 #define DAV207_H
00024 
00025 #include "hip_xml.h"
00026 #include "http_request.h" /* for http_req */
00027 
00028 BEGIN_NEON_DECLS
00029 
00030 #define DAV_ELM_207_first (HIP_ELM_UNUSED)
00031 
00032 #define DAV_ELM_multistatus (DAV_ELM_207_first)
00033 #define DAV_ELM_response (DAV_ELM_207_first + 1)
00034 #define DAV_ELM_responsedescription (DAV_ELM_207_first + 2)
00035 #define DAV_ELM_href (DAV_ELM_207_first + 3)
00036 #define DAV_ELM_propstat (DAV_ELM_207_first + 4)
00037 #define DAV_ELM_prop (DAV_ELM_207_first + 5)
00038 #define DAV_ELM_status (DAV_ELM_207_first + 6)
00039 
00040 #define DAV_ELM_207_UNUSED (HIP_ELM_UNUSED + 100)
00041 
00042 struct dav_207_parser_s;
00043 typedef struct dav_207_parser_s dav_207_parser;
00044 
00045 /* The name of a WebDAV property. */
00046 typedef struct {
00047     const char *nspace, *name;
00048 } dav_propname;
00049 
00050 /* The handler structure: you provide a set of callbacks.
00051  * They are called in the order they are listed... start/end_prop
00052  * multiple times before end_prop, start/end_propstat multiple times
00053  * before an end_response, start/end_response multiple times.
00054  */
00055 
00056 /* TODO: do we need to pass userdata to ALL of these? We could get away with
00057  * only passing the userdata to the start_'s and relying on the caller
00058  * to send it through as the _start return value if they need it. */
00059 
00060 typedef void *(*dav_207_start_response)(void *userdata, const char *href);
00061 typedef void (*dav_207_end_response)(
00062     void *userdata, void *response, const char *status_line,
00063     const http_status *status, const char *description);
00064 
00065 typedef void *(*dav_207_start_propstat)(void *userdata, void *response);
00066 typedef void (*dav_207_end_propstat)(
00067     void *userdata, void *propstat, const char *status_line, 
00068     const http_status *status, const char *description);
00069 
00070 /* Create a 207 parser */
00071 
00072 dav_207_parser *dav_207_create(hip_xml_parser *parser, void *userdata);
00073 
00074 /* Set the callbacks for the parser */
00075 
00076 void dav_207_set_response_handlers(
00077     dav_207_parser *p, dav_207_start_response start, dav_207_end_response end);
00078 
00079 void dav_207_set_propstat_handlers(
00080     dav_207_parser *p, dav_207_start_propstat start, dav_207_end_propstat end);
00081 
00082 void dav_207_destroy(dav_207_parser *p);
00083 
00084 /* An acceptance function which only accepts 207 responses */
00085 int dav_accept_207(void *userdata, http_req *req, http_status *status);
00086 
00087 void *dav_207_get_current_propstat(dav_207_parser *p);
00088 void *dav_207_get_current_response(dav_207_parser *p);
00089 
00090 /* Call this as the LAST thing before beginning parsing, to install a
00091  * catch-all handler which means all unknown XML returned in the 207
00092  * response is ignored gracefully.  */
00093 void dav_207_ignore_unknown(dav_207_parser *p);
00094 
00095 END_NEON_DECLS
00096 
00097 #endif /* DAV207_H */