dav/davql.h

changeset 27
e584c351b402
parent 17
11dffb40cd91
equal deleted inserted replaced
26:146171b57e69 27:e584c351b402
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 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 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "webdav.h"
30
29 #ifndef DAVQL_H 31 #ifndef DAVQL_H
30 #define DAVQL_H 32 #define DAVQL_H
31 33
32 #include <ucx/string.h> 34 #include <ucx/string.h>
35 #include <ucx/list.h>
36 #include <inttypes.h>
33 #include <stdarg.h> 37 #include <stdarg.h>
34 38
35 #ifdef __cplusplus 39 #ifdef __cplusplus
36 extern "C" { 40 extern "C" {
37 #endif 41 #endif
39 enum DavQueryType { 43 enum DavQueryType {
40 DAV_QUERY_ERROR = 0, 44 DAV_QUERY_ERROR = 0,
41 DAV_QUERY_GET 45 DAV_QUERY_GET
42 }; 46 };
43 typedef enum DavQueryType DavQueryType; 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;
44 61
45 typedef struct { 62 typedef struct {
46 DavQueryType command; 63 DavQueryType command;
47 void *command_data; 64 void *command_data;
48 } DavQuery; 65 } DavQuery;
49 66
50 typedef struct { 67 typedef struct {
51 sstr_t properties; 68 sstr_t properties;
52 sstr_t from; 69 sstr_t from;
53 // TODO: condition 70 DavQOp *condition;
71 size_t condlen;
54 } DavGetQuery; 72 } DavGetQuery;
55 73
56 DavQuery dav_ql_parse(char *query, va_list ap); 74 DavQuery dav_ql_parse(char *query, va_list ap);
57 DavGetQuery* dav_ql_parse_get(sstr_t q, va_list ap); 75 DavGetQuery* dav_ql_parse_get(sstr_t q, va_list ap);
58 void free_get_query(DavGetQuery *q); 76 void free_get_query(DavGetQuery *q);
59 77
60 int parse_path_query(sstr_t query, char **path, int *depth); 78 int parse_path_query(sstr_t query, char **path, int *depth);
61 79
80 int dav_parse_condition(UcxList **ops, sstr_t cond, va_list ap);
81 sstr_t condition_parser_next_token(sstr_t *str);
82 int condition_operator_type(sstr_t token, int64_t *type);
83
84 int condition_eval(DavResource *res, DavQOp *cond, size_t len);
85 DavQOp compare_intint(int op, int64_t v1, int64_t v2);
86 DavQOp compare_strint(int op, DavQOp v1, DavQOp v2);
87 DavQOp compare_intstr(int op, DavQOp v1, DavQOp v2);
88 DavQOp compare_strstr(int op, DavQOp v1, DavQOp v2);
62 89
63 #ifdef __cplusplus 90 #ifdef __cplusplus
64 } 91 }
65 #endif 92 #endif
66 93

mercurial