1 /* |
|
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
|
3 * |
|
4 * Copyright 2015 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 #include "webdav.h" |
|
30 |
|
31 #ifndef DAVQL_H |
|
32 #define DAVQL_H |
|
33 |
|
34 #include <ucx/string.h> |
|
35 #include <ucx/list.h> |
|
36 #include <inttypes.h> |
|
37 #include <stdarg.h> |
|
38 |
|
39 #ifdef __cplusplus |
|
40 extern "C" { |
|
41 #endif |
|
42 |
|
43 enum DavQueryType { |
|
44 DAV_QUERY_ERROR = 0, |
|
45 DAV_QUERY_GET |
|
46 }; |
|
47 typedef enum DavQueryType DavQueryType; |
|
48 |
|
49 #define DAVQOP_OPERATOR 0 |
|
50 #define DAVQOP_STRING 1 |
|
51 #define DAVQOP_INTEGER 2 |
|
52 #define DAVQOP_TIME 3 |
|
53 #define DAVQOP_PROPERTY 4 |
|
54 #define DAVQOP_RESPROP 5 |
|
55 |
|
56 typedef struct { |
|
57 int type; |
|
58 void *val; |
|
59 int64_t intval; |
|
60 } DavQOp; |
|
61 |
|
62 typedef struct { |
|
63 DavQueryType command; |
|
64 void *command_data; |
|
65 } DavQuery; |
|
66 |
|
67 typedef struct { |
|
68 sstr_t properties; |
|
69 sstr_t from; |
|
70 DavQOp *condition; |
|
71 size_t condlen; |
|
72 int depth; |
|
73 } DavGetQuery; |
|
74 |
|
75 DavQuery dav_ql_parse(char *query, va_list ap); |
|
76 DavGetQuery* dav_ql_parse_get(sstr_t q, va_list ap); |
|
77 void free_get_query(DavGetQuery *q); |
|
78 |
|
79 int parse_path_query(sstr_t query, char **path, int *depth); |
|
80 |
|
81 int dav_parse_with(sstr_t with, int *depth, va_list ap); |
|
82 int dav_parse_condition(UcxList **ops, sstr_t cond, va_list ap); |
|
83 sstr_t condition_parser_next_token(sstr_t *str); |
|
84 int condition_operator_type(sstr_t token, int64_t *type); |
|
85 |
|
86 int condition_eval(DavResource *res, DavQOp *cond, size_t len); |
|
87 DavQOp compare_intint(int op, int64_t v1, int64_t v2); |
|
88 DavQOp compare_strint(int op, DavQOp v1, DavQOp v2); |
|
89 DavQOp compare_intstr(int op, DavQOp v1, DavQOp v2); |
|
90 DavQOp compare_strstr(int op, DavQOp v1, DavQOp v2); |
|
91 |
|
92 #ifdef __cplusplus |
|
93 } |
|
94 #endif |
|
95 |
|
96 #endif /* DAVQL_H */ |
|
97 |
|