| 1 |
/* |
| 2 |
WebDAV 207 multi-status response handling |
| 3 |
Copyright (C) 1999-2006, Joe Orton <[email protected]> |
| 4 |
|
| 5 |
This library is free software; you can redistribute it and/or |
| 6 |
modify it under the terms of the GNU Library General Public |
| 7 |
License as published by the Free Software Foundation; either |
| 8 |
version 2 of the License, or (at your option) any later version. |
| 9 |
|
| 10 |
This library is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
Library General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU Library General Public |
| 16 |
License along with this library; if not, write to the Free |
| 17 |
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
| 18 |
MA 02111-1307, USA |
| 19 |
|
| 20 |
*/ |
| 21 |
|
| 22 |
#ifndef NE_207_H |
| 23 |
#define NE_207_H |
| 24 |
|
| 25 |
#include "ne_xml.h" |
| 26 |
#include "ne_request.h" /* for ne_request */ |
| 27 |
#include "ne_uri.h" /* for ne_uri */ |
| 28 |
|
| 29 |
NE_BEGIN_DECLS |
| 30 |
|
| 31 |
/* The defined state integer for the '{DAV:}prop' element. */ |
| 32 |
#define NE_207_STATE_PROP (50) |
| 33 |
/* This interface reserves the state integers 'x' where 0 < x < 100 */ |
| 34 |
#define NE_207_STATE_TOP (100) |
| 35 |
|
| 36 |
/* Handling of 207 multistatus XML documents. A "multistatus" |
| 37 |
* document is made up of a set of responses, each concerned with a |
| 38 |
* particular resource. Each response may have an associated result |
| 39 |
* status and failure description. A response is made up of a set of |
| 40 |
* propstats, each of which again may have an associated result status |
| 41 |
* and failure description. */ |
| 42 |
|
| 43 |
/* Start and end response callbacks trigger at the start and end of |
| 44 |
* each "response" within the multistatus body. 'uri' gives the URI |
| 45 |
* of the resource which is subject of this response. The return |
| 46 |
* value of a 'start_response' callback is passed as the 'response' |
| 47 |
* parameter to the corresponding 'end_response' parameter. */ |
| 48 |
typedef void *ne_207_start_response(void *userdata, const ne_uri *uri); |
| 49 |
typedef void ne_207_end_response(void *userdata, void *response, |
| 50 |
const ne_status *status, |
| 51 |
const char *description); |
| 52 |
|
| 53 |
/* Similarly, start and end callbacks for each propstat within the |
| 54 |
* response. The return value of the 'start_response' callback for |
| 55 |
* the response in which this propstat is contains is passed as the |
| 56 |
* 'response' parameter. The return value of each 'start_propstat' is |
| 57 |
* passed as the 'propstat' parameter' to the corresponding |
| 58 |
* 'end_propstat' callback. If the start_propstat callback returns |
| 59 |
* NULL, parsing is aborted (the XML parser error must be set by the |
| 60 |
* callback). */ |
| 61 |
typedef void *ne_207_start_propstat(void *userdata, void *response); |
| 62 |
typedef void ne_207_end_propstat(void *userdata, void *propstat, |
| 63 |
const ne_status *status, |
| 64 |
const char *description); |
| 65 |
|
| 66 |
typedef struct ne_207_parser_s ne_207_parser; |
| 67 |
|
| 68 |
/* Create 207 parser an add the handlers the the given parser's |
| 69 |
* handler stack. URI references in the 207 response will be resolved |
| 70 |
* relative to the base URI 'base'. */ |
| 71 |
ne_207_parser *ne_207_create(ne_xml_parser *parser, const ne_uri *base, |
| 72 |
void *userdata); |
| 73 |
|
| 74 |
/* Register response handling callbacks. */ |
| 75 |
void ne_207_set_response_handlers(ne_207_parser *p, |
| 76 |
ne_207_start_response *start, |
| 77 |
ne_207_end_response *end); |
| 78 |
|
| 79 |
/* Register propstat handling callbacks. */ |
| 80 |
void ne_207_set_propstat_handlers(ne_207_parser *p, |
| 81 |
ne_207_start_propstat *start, |
| 82 |
ne_207_end_propstat *end); |
| 83 |
|
| 84 |
/* Destroy the parser */ |
| 85 |
void ne_207_destroy(ne_207_parser *p); |
| 86 |
|
| 87 |
/* An acceptance function which only accepts 207 responses */ |
| 88 |
int ne_accept_207(void *userdata, ne_request *req, const ne_status *status); |
| 89 |
|
| 90 |
void *ne_207_get_current_propstat(ne_207_parser *p); |
| 91 |
void *ne_207_get_current_response(ne_207_parser *p); |
| 92 |
|
| 93 |
/* Dispatch request 'req', returning: |
| 94 |
* NE_ERROR: for a dispatch error, or a non-2xx response, or a |
| 95 |
* 207 response which contained a non-2xx propstat |
| 96 |
* NE_OK: for a 2xx response or a 207 response which contained |
| 97 |
* only 2xx-class propstats. |
| 98 |
* The request object is destroyed in both cases. */ |
| 99 |
int ne_simple_request(ne_session *sess, ne_request *req); |
| 100 |
|
| 101 |
NE_END_DECLS |
| 102 |
|
| 103 |
#endif /* NE_207_H */ |