src/server/plugins/postgresql/webdav.h

changeset 385
a1f4cb076d2f
parent 377
c011bc2b3143
child 415
d938228c382e
equal deleted inserted replaced
210:21274e5950af 385:a1f4cb076d2f
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 2022 Olaf Wintermann. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef WS_PG_WEBDAV_H
30 #define WS_PG_WEBDAV_H
31
32 #include "../../public/nsapi.h"
33 #include "../../public/webdav.h"
34
35 #include "config.h"
36
37 #include <libpq-fe.h>
38 #include <ucx/buffer.h>
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 #define PG_MAX_PATH_LEN 0x8000
45
46 typedef struct PgWebdavBackend {
47 ResourceData *pg_resource;
48 PGconn *connection;
49 PgRepository *repository;
50 char root_resource_id_str[32];
51 } PgWebdavBackend;
52
53 typedef struct PgPropfindExtCol {
54 /*
55 * property extension config
56 */
57 PgPropertyStoreExt *ext;
58 /*
59 * Result field number
60 */
61 int field_num;
62 } PgPropfindExtCol;
63
64 typedef struct PgPropfind {
65 const char *path;
66 int64_t resource_id;
67 WebdavVFSProperties vfsproperties;
68 PGresult *result;
69 PgPropfindExtCol *ext;
70 size_t numext;
71 int nrows;
72 } PgPropfind;
73
74 typedef struct {
75 PgPropertyStoreExt *column;
76 WebdavProperty *property;
77 } PgProppatchExtProp;
78
79 typedef struct {
80 UcxList *set; /* list of PgProppatchExtProp* */
81 UcxList *remove; /* list of PgProppatchExtProp* */
82 WSBool isused;
83 } PgProppatchExt;
84
85 typedef struct {
86 int64_t resource_id;
87 PgProppatchExt *ext;
88 size_t numext;
89 WSBool extensions_used;
90 } PgProppatch;
91
92 void* pg_webdav_init(ServerConfiguration *cfg, pool_handle_t *pool, WSConfigNode *config);
93 WebdavBackend* pg_webdav_create(Session *sn, Request *rq, pblock *pb, void *initData);
94 WebdavBackend* pg_webdav_create_from_resdata(Session *sn, Request *rq, PgRepository *repo, ResourceData *resdata);
95
96 WebdavBackend* pg_webdav_prop_create(Session *sn, Request *rq, pblock *pb);
97
98 int pg_create_property_param_arrays(WebdavPList *plist, UcxBuffer *xmlns, UcxBuffer *pname);
99
100 /* ----------------- webdav backend functions ----------------- */
101 int pg_dav_propfind_init(
102 WebdavPropfindRequest *rq,
103 const char *path,
104 const char *href,
105 WebdavPList **outplist);
106
107 int pg_dav_propfind_do(
108 WebdavPropfindRequest *rq,
109 WebdavResponse *response,
110 VFS_DIR parent,
111 WebdavResource *resource,
112 struct stat *s);
113
114 int pg_dav_propfind_finish(WebdavPropfindRequest *rq);
115
116 int pg_dav_proppatch_do(
117 WebdavProppatchRequest *request,
118 WebdavResource *response,
119 VFSFile *file,
120 WebdavPList **out_set,
121 WebdavPList **out_remove);
122
123 int pg_dav_proppatch_finish(
124 WebdavProppatchRequest *request,
125 WebdavResource *response,
126 VFSFile *file,
127 WSBool commit);
128
129 #ifdef __cplusplus
130 }
131 #endif
132
133 #endif /* PG_WEBDAV_H */
134

mercurial