2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * Copyright 2018 Olaf Wintermann. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
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.
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.
32 #include "davqlparser.h"
35 #include <ucx/buffer.h>
41 typedef struct DavQLCmd DavQLCmd;
42 typedef struct DavQLStackObj DavQLStackObj;
43 typedef struct DavQLRes DavQLRes;
45 typedef struct DavQLArg DavQLArg;
46 typedef struct DavQLArgList DavQLArgList;
48 typedef void*(*davql_func)(); // TODO: interface?
68 DAVQL_UNSUPPORTED_FORMATCHAR,
69 DAVQL_UNKNOWN_FORMATCHAR
76 DAVQL_CMD_RES_IDENTIFIER,
77 DAVQL_CMD_PROP_IDENTIFIER,
78 //DAVQL_CMD_OP_UNARY_ADD,
79 DAVQL_CMD_OP_UNARY_SUB,
80 DAVQL_CMD_OP_UNARY_NEG,
81 DAVQL_CMD_OP_BINARY_ADD,
82 DAVQL_CMD_OP_BINARY_SUB,
83 DAVQL_CMD_OP_BINARY_MUL,
84 DAVQL_CMD_OP_BINARY_DIV,
85 DAVQL_CMD_OP_BINARY_AND,
86 DAVQL_CMD_OP_BINARY_OR,
87 DAVQL_CMD_OP_BINARY_XOR,
88 DAVQL_CMD_OP_LOGICAL_NOT,
89 DAVQL_CMD_OP_LOGICAL_AND,
90 DAVQL_CMD_OP_LOGICAL_OR_L,
91 DAVQL_CMD_OP_LOGICAL_OR,
92 DAVQL_CMD_OP_LOGICAL_XOR,
108 DAVQL_RES_CONTENTLENGTH,
109 DAVQL_RES_CONTENTTYPE,
110 DAVQL_RES_CREATIONDATE,
111 DAVQL_RES_LASTMODIFIED,
112 DAVQL_RES_ISCOLLECTION
121 davqlresprop_t resprop;
122 DavPropName property;
127 struct DavQLStackObj {
128 int32_t type; // 0: int, 1: string, 2: xml
130 union DavQLStackData {
138 DavResource *resource;
142 typedef struct DavCompiledField {
148 typedef struct DavOrderCriterion {
149 int type; // 0: resprop, 1: property
151 davqlresprop_t resprop;
157 DavQLArgList* dav_ql_get_args(DavQLStatement *st, va_list ap);
158 void dav_ql_free_arglist(DavQLArgList *args);
160 int dav_ql_getarg_int(DavQLArgList *args);
161 unsigned int dav_ql_getarg_uint(DavQLArgList *args);
162 char* dav_ql_getarg_str(DavQLArgList *args);
163 time_t dav_ql_getarg_time(DavQLArgList *args);
165 DavResult dav_statement_exec(DavSession *sn, DavQLStatement *st, ...);
166 DavResult dav_statement_execv(DavSession *sn, DavQLStatement *st, va_list ap);
168 UcxBuffer* dav_path_string(sstr_t src, DavQLArgList *args, davqlerror_t *error);
169 sstr_t dav_format_string(UcxAllocator *a, sstr_t fstr, DavQLArgList *ap, davqlerror_t *error);
171 DavResult dav_exec_select(DavSession *sn, DavQLStatement *st, va_list ap);
173 int dav_identifier2resprop(sstr_t src, davqlresprop_t *prop);
175 UcxBuffer* dav_compile_expr(DavContext *ctx, UcxAllocator *a, DavQLExpression *lexpr, DavQLArgList *ap);
177 int dav_exec_expr(UcxBuffer *bcode, DavResource *res, DavQLStackObj *result);
185 #endif /* DAVQLEXEC_H */