Sun, 06 May 2012 10:09:27 +0200
added logging
/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 2011 Olaf Wintermann. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef WEBDAV_H #define WEBDAV_H #include "../public/nsapi.h" #include <sys/file.h> #include <sys/stat.h> #include "../ucx/map.h" #include "../ucx/dlist.h" #include "../util/strbuf.h" #ifdef __cplusplus extern "C" { #endif #define DAV_FOREACH(elem, list) \ for (UcxDlist *elem = list ; elem != NULL ; elem = elem->next) typedef struct PropfindResponse PropfindResponse; typedef struct DAVPropertyBackend DAVPropertyBackend; typedef struct PropfindRequest PropfindRequest; typedef struct DavProperty DavProperty; struct PropfindRequest { Session *sn; Request *rq; UcxDlist *properties; /* DavProperty list, requested props */ int8_t allprop; int8_t propname; int8_t prop; UcxDlist *notFoundProps; UcxDlist *forbiddenProps; DAVPropertyBackend *propertyBackend; char *path; char *uri; sbuf_t *out; }; struct DavProperty { char *xmlns; char *name; }; /* * dav_res_propfind_f * * Gets all requested properties of a WebDAV resource(file). This function * should add properties with dav_propfind_add_str_prop or * dav_prop_add_xml_prop. Unavailable properties should be added with * * * arg0: property backend * arg1: current PropfindRequest object * arg2: the webdav resource path */ typedef void(*dav_res_propfind_f)(DAVPropertyBackend*,PropfindRequest*,char*); struct DAVPropertyBackend { dav_res_propfind_f propfind; }; int webdav_service(pblock *pb, Session *sn, Request *rq); int webdav_put(pblock *pb, Session *sn, Request *rq); int webdav_propfind(pblock *pb, Session *sn, Request *rq); void dav_resource_response(PropfindRequest *rq, sstr_t path, sstr_t uri); /* * dav_propfind_add_str_prop * * Adds a string property to the current WebDAV resource response */ void dav_propfind_add_str_prop( PropfindRequest *rq, DavProperty* prop, char *str, size_t len); //void dav_propfind_add_xml_prop(); /* * dav_propfind_add_prop_error * * Adds a unavailable property to the response * * rq: propfind request object * prop: unavailable property * error: HTTP status code */ void dav_propfind_add_prop_error( PropfindRequest *rq, DavProperty *prop, int error); DAVPropertyBackend* create_property_backend(); void dav_rq_propfind(DAVPropertyBackend *b,PropfindRequest *rq ,char *path); #ifdef __cplusplus } #endif #endif /* WEBDAV_H */