Mon, 10 Jul 2023 18:40:37 +0200
update ucx
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
365
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
4 | * Copyright 2018 Olaf Wintermann. All rights reserved. |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #include <stdio.h> |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | #include <stdlib.h> |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | #include <string.h> |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
32 | #include <inttypes.h> |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
34 | #include <cx/utils.h> |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
35 | #include <cx/map.h> |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
36 | #include <cx/hash_map.h> |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
37 | #include <cx/printf.h> |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
38 | #include <cx/basic_mempool.h> |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
39 | |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | #include "davqlexec.h" |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
41 | #include "utils.h" |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
42 | #include "methods.h" |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
43 | #include "session.h" |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
44 | #include "resource.h" |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
45 | |
365
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
46 | DavQLArgList* dav_ql_get_args(DavQLStatement *st, va_list ap) { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
47 | DavQLArgList *args = malloc(sizeof(DavQLArgList)); |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
48 | if(!args) { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
49 | return NULL; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
50 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
51 | args->first = NULL; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
52 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
53 | if(!st->args) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
54 | args->first = NULL; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
55 | args->current = NULL; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
56 | return args; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
57 | } |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
58 | |
365
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
59 | DavQLArg *cur = NULL; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
60 | CxIterator i = cxListIterator(st->args); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
61 | cx_foreach(void*, data, i) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
62 | intptr_t type = (intptr_t)data; |
365
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
63 | DavQLArg *arg = calloc(1, sizeof(DavQLArg)); |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
64 | if(!arg) { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
65 | dav_ql_free_arglist(args); |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
66 | return NULL; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
67 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
68 | arg->type = type; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
69 | switch(type) { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
70 | case 'd': { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
71 | arg->value.d = va_arg(ap, int); |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
72 | break; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
73 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
74 | case 'u': { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
75 | arg->value.u = va_arg(ap, unsigned int); |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
76 | break; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
77 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
78 | case 's': { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
79 | arg->value.s = va_arg(ap, char*); |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
80 | break; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
81 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
82 | case 't': { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
83 | arg->value.t = va_arg(ap, time_t); |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
84 | break; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
85 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
86 | default: { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
87 | free(arg); |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
88 | dav_ql_free_arglist(args); |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
89 | return NULL; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
90 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
91 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
92 | if(cur) { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
93 | cur->next = arg; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
94 | } else { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
95 | args->first = arg; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
96 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
97 | cur = arg; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
98 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
99 | args->current = args->first; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
100 | return args; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
101 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
102 | |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
103 | void dav_ql_free_arglist(DavQLArgList *args) { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
104 | DavQLArg *arg = args->first; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
105 | while(arg) { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
106 | DavQLArg *next = arg->next; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
107 | free(arg); |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
108 | arg = next; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
109 | } |
387
92f8a2a243fc
fixes dav_ql_free_arglist() not freeing the list container
Mike Becker <universe@uap-core.de>
parents:
365
diff
changeset
|
110 | free(args); |
365
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
111 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
112 | |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
113 | static DavQLArg* arglist_get(DavQLArgList *args) { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
114 | DavQLArg *a = args->current; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
115 | if(a) { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
116 | args->current = a->next; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
117 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
118 | return a; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
119 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
120 | |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
121 | int dav_ql_getarg_int(DavQLArgList *args) { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
122 | DavQLArg *a = arglist_get(args); |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
123 | if(a && a->type == 'd') { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
124 | return a->value.d; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
125 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
126 | return 0; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
127 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
128 | |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
129 | unsigned int dav_ql_getarg_uint(DavQLArgList *args) { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
130 | DavQLArg *a = arglist_get(args); |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
131 | if(a && a->type == 'u') { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
132 | return a->value.u; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
133 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
134 | return 0; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
135 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
136 | |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
137 | char* dav_ql_getarg_str(DavQLArgList *args) { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
138 | DavQLArg *a = arglist_get(args); |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
139 | if(a && a->type == 's') { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
140 | return a->value.s; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
141 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
142 | return ""; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
143 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
144 | |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
145 | time_t dav_ql_getarg_time(DavQLArgList *args) { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
146 | DavQLArg *a = arglist_get(args); |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
147 | if(a && a->type == 't') { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
148 | return a->value.t; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
149 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
150 | return 0; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
151 | } |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
152 | |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
153 | |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
154 | DavResult dav_statement_exec(DavSession *sn, DavQLStatement *st, ...) { |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
155 | va_list ap; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
156 | va_start(ap, st); |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
157 | DavResult result = dav_statement_execv(sn, st, ap); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
158 | va_end(ap); |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
159 | return result; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
160 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
161 | |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
162 | DavResult dav_statement_execv(DavSession *sn, DavQLStatement *st, va_list ap) { |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
163 | DavResult result; |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
164 | result.result = NULL; |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
165 | result.status = 1; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
166 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
167 | // make sure the statement was successfully parsed |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
168 | if(st->type == DAVQL_ERROR) { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
169 | return result; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
170 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
171 | |
127
7072a2b4ae35
renamed GET to SELECT in davql syntax
Mike Becker <universe@uap-core.de>
parents:
126
diff
changeset
|
172 | if(st->type == DAVQL_SELECT) { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
173 | return dav_exec_select(sn, st, ap); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
174 | } else { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
175 | // TODO |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
176 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
177 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
178 | return result; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
179 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
180 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
181 | cxmutstr dav_format_string(const CxAllocator *a, cxstring fstr, DavQLArgList *ap, davqlerror_t *error) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
182 | CxBuffer buf; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
183 | cxBufferInit(&buf, NULL, 128, a, CX_BUFFER_AUTO_EXTEND); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
184 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
185 | int placeholder = 0; |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
186 | for(int i=0;i<fstr.length;i++) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
187 | char c = fstr.ptr[i]; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
188 | if(placeholder) { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
189 | if(c == '%') { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
190 | // no placeholder, %% transposes to % |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
191 | cxBufferPut(&buf, c); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
192 | } else { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
193 | // detect placeholder type and insert arg |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
194 | int err = 0; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
195 | switch(c) { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
196 | case 's': { |
365
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
197 | char *arg = dav_ql_getarg_str(ap); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
198 | cxBufferPutString(&buf, arg); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
199 | break; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
200 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
201 | case 'd': { |
365
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
202 | int arg = dav_ql_getarg_int(ap); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
203 | cx_bprintf(&buf, "%d", arg); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
204 | break; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
205 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
206 | case 'u': { |
365
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
207 | unsigned int arg = dav_ql_getarg_uint(ap); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
208 | cx_bprintf(&buf, "%u", arg); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
209 | break; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
210 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
211 | case 't': { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
212 | // time arguments not supported for strings |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
213 | err = 1; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
214 | break; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
215 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
216 | default: { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
217 | *error = DAVQL_UNKNOWN_FORMATCHAR; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
218 | err = 1; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
219 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
220 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
221 | if(err) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
222 | cxBufferDestroy(&buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
223 | return (cxmutstr){NULL,0}; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
224 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
225 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
226 | placeholder = 0; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
227 | } else { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
228 | if(c == '%') { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
229 | placeholder = 1; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
230 | } else { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
231 | cxBufferPut(&buf, c); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
232 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
233 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
234 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
235 | if(cxBufferPut(&buf, '\0')) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
236 | *error = DAVQL_OOM; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
237 | cxBufferDestroy(&buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
238 | return (cxmutstr){NULL, 0}; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
239 | } |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
240 | *error = DAVQL_OK; |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
241 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
242 | return cx_mutstrn(buf.space, buf.size-1); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
243 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
244 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
245 | static int fl_add_properties(DavSession *sn, const CxAllocator *a, CxMap *map, DavQLExpression *expression) { |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
246 | if(!expression) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
247 | return 0; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
248 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
249 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
250 | if(expression->type == DAVQL_IDENTIFIER) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
251 | DavProperty *property = cxMalloc(a, sizeof(DavProperty)); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
252 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
253 | char *name; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
254 | DavNamespace *ns = dav_get_property_namespace( |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
255 | sn->context, |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
256 | cx_strdup_a(a, expression->srctext).ptr, |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
257 | &name); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
258 | if(!ns) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
259 | return -1; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
260 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
261 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
262 | property->ns = ns; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
263 | property->name = name; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
264 | property->value = NULL; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
265 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
266 | cxMapPut(map, cx_hash_key(expression->srctext.ptr, expression->srctext.length), property); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
267 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
268 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
269 | if(expression->left) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
270 | if(fl_add_properties(sn, a, map, expression->left)) { |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
271 | return -1; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
272 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
273 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
274 | if(expression->right) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
275 | if(fl_add_properties(sn, a, map, expression->right)) { |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
276 | return -1; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
277 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
278 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
279 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
280 | return 0; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
281 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
282 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
283 | static CxBuffer* fieldlist2propfindrequest(DavSession *sn, const CxAllocator *a, CxList *fields, int *isallprop) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
284 | CxMap *properties = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 32); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
285 | *isallprop = 0; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
286 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
287 | CxIterator i = cxListIterator(fields); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
288 | cx_foreach(DavQLField*, field, i) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
289 | if(!cx_strcmp(field->name, CX_STR("*"))) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
290 | cxMapDestroy(properties); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
291 | *isallprop = 1; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
292 | return create_allprop_propfind_request(); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
293 | } else if(!cx_strcmp(field->name, CX_STR("-"))) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
294 | cxMapDestroy(properties); |
475
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
387
diff
changeset
|
295 | return create_propfind_request(sn, NULL, "propfind", 0); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
296 | } else { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
297 | if(fl_add_properties(sn, a, properties, field->expr)) { |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
298 | // TODO: set error |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
299 | cxMapDestroy(properties); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
300 | return NULL; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
301 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
302 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
303 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
304 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
305 | i = cxMapIteratorValues(properties); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
306 | CxList *list = cxLinkedListCreateSimple(CX_STORE_POINTERS); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
307 | cx_foreach(DavProperty*, value, i) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
308 | cxListAdd(list, value); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
309 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
310 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
311 | CxBuffer *reqbuf = create_propfind_request(sn, list, "propfind", 0); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
312 | cxListDestroy(list); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
313 | cxMapDestroy(properties); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
314 | return reqbuf; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
315 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
316 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
317 | static int reset_properties(DavSession *sn, DavResult *result, DavResource *res, CxList *fields) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
318 | CxMap *new_properties = cxHashMapCreate(sn->mp->allocator, CX_STORE_POINTERS, 32); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
319 | DavResourceData *data = (DavResourceData*)res->data; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
320 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
321 | // add basic properties |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
538
diff
changeset
|
322 | void *value; |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
323 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
324 | cxmutstr cl_keystr = dav_property_key("DAV:", "getcontentlength"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
325 | CxHashKey cl_key = cx_hash_key(cl_keystr.ptr, cl_keystr.length); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
326 | value = cxMapGet(data->properties, cl_key); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
327 | if(value) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
328 | cxMapPut(new_properties, cl_key, value); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
329 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
330 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
331 | cxmutstr cd_keystr = dav_property_key("DAV:", "creationdate"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
332 | CxHashKey cd_key = cx_hash_key(cd_keystr.ptr, cd_keystr.length); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
333 | value = cxMapGet(data->properties, cd_key); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
334 | if(value) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
335 | cxMapPut(new_properties, cd_key, value); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
336 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
337 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
338 | cxmutstr lm_keystr = dav_property_key("DAV:", "getlastmodified"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
339 | CxHashKey lm_key = cx_hash_key(lm_keystr.ptr, lm_keystr.length); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
340 | value = cxMapGet(data->properties, lm_key); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
341 | if(value) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
342 | cxMapPut(new_properties, lm_key, value); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
343 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
344 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
345 | cxmutstr ct_keystr = dav_property_key("DAV:", "getcontenttype"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
346 | CxHashKey ct_key = cx_hash_key(ct_keystr.ptr, ct_keystr.length); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
347 | value = cxMapGet(data->properties, ct_key); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
348 | if(value) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
349 | cxMapPut(new_properties, ct_key, value); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
350 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
351 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
352 | cxmutstr rt_keystr = dav_property_key("DAV:", "resourcetype"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
353 | CxHashKey rt_key = cx_hash_key(rt_keystr.ptr, rt_keystr.length); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
354 | value = cxMapGet(data->properties, rt_key); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
355 | if(value) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
356 | cxMapPut(new_properties, rt_key, value); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
357 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
358 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
359 | cxmutstr cn_keystr = dav_property_key(DAV_NS, "crypto-name"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
360 | CxHashKey cn_key = cx_hash_key(cn_keystr.ptr, cn_keystr.length); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
361 | value = cxMapGet(data->properties, cn_key); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
362 | if(value) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
363 | cxMapPut(new_properties, cn_key, value); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
364 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
365 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
366 | cxmutstr ck_keystr = dav_property_key(DAV_NS, "crypto-key"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
367 | CxHashKey ck_key = cx_hash_key(ck_keystr.ptr, ck_keystr.length); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
368 | value = cxMapGet(data->properties, ck_key); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
369 | if(value) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
370 | cxMapPut(new_properties, ck_key, value); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
371 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
372 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
373 | cxmutstr ch_keystr = dav_property_key(DAV_NS, "crypto-hash"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
374 | CxHashKey ch_key = cx_hash_key(ch_keystr.ptr, ch_keystr.length); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
375 | value = cxMapGet(data->properties, ch_key); |
150
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
376 | if(value) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
377 | cxMapPut(new_properties, ch_key, value); |
150
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
378 | } |
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
379 | |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
380 | // add properties from field list |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
381 | if(fields) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
382 | CxIterator i = cxListIterator(fields); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
383 | cx_foreach(DavCompiledField*, field, i) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
384 | DavQLStackObj field_result; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
385 | if(!dav_exec_expr(field->code, res, &field_result)) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
386 | cxmutstr str; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
387 | str.ptr = NULL; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
388 | str.length = 0; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
389 | DavXmlNode *node = NULL; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
390 | if(field_result.type == 0) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
391 | str = cx_asprintf_a( |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
392 | sn->mp->allocator, |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
393 | "%" PRId64, |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
394 | field_result.data.integer); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
395 | } else if(field_result.type == 1) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
396 | if(field_result.data.string) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
397 | str = cx_strdup_a(sn->mp->allocator, cx_strn( |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
398 | field_result.data.string, |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
399 | field_result.length)); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
400 | } |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
401 | } else if(field_result.type == 2) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
402 | node = dav_copy_node(field_result.data.node); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
403 | } else { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
404 | // unknown type |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
405 | // TODO: error |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
406 | resource_free_properties(sn, new_properties); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
407 | return -1; |
136
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
408 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
409 | if(str.ptr) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
410 | node = dav_session_malloc(sn, sizeof(DavXmlNode)); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
411 | memset(node, 0, sizeof(DavXmlNode)); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
412 | node->type = DAV_XML_TEXT; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
413 | node->content = str.ptr; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
414 | node->contentlength = str.length; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
415 | } |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
416 | if(node) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
417 | cxmutstr key = dav_property_key(field->ns, field->name); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
418 | |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
419 | DavNamespace *namespace = dav_session_malloc(sn, sizeof(DavNamespace)); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
420 | namespace->prefix = NULL; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
421 | namespace->name = dav_session_strdup(sn, field->ns); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
422 | |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
423 | DavProperty *prop = dav_session_malloc(sn, sizeof(DavProperty)); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
424 | prop->name = dav_session_strdup(sn, field->name); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
425 | prop->ns = namespace; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
426 | prop->value = node; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
427 | |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
428 | cxMapPut(new_properties, cx_hash_key(key.ptr, key.length), prop); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
429 | free(key.ptr); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
430 | } |
348
b79fb94f9e0a
davqlexec handles xml properties now (not really, but it doesn't destroy everything)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
431 | } else { |
b79fb94f9e0a
davqlexec handles xml properties now (not really, but it doesn't destroy everything)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
432 | // TODO: error |
b79fb94f9e0a
davqlexec handles xml properties now (not really, but it doesn't destroy everything)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
433 | resource_free_properties(sn, new_properties); |
b79fb94f9e0a
davqlexec handles xml properties now (not really, but it doesn't destroy everything)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
434 | return -1; |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
435 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
436 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
437 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
438 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
439 | cxMapRemove(data->properties, cl_key); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
440 | cxMapRemove(data->properties, cd_key); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
441 | cxMapRemove(data->properties, lm_key); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
442 | cxMapRemove(data->properties, ct_key); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
443 | cxMapRemove(data->properties, rt_key); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
444 | cxMapRemove(data->properties, cn_key); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
445 | cxMapRemove(data->properties, ck_key); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
446 | cxMapRemove(data->properties, ch_key); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
447 | |
137
01cb9aabff05
fixed horrible bugs, davql hopefully just works now (without order by yet)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
448 | resource_free_properties(sn, data->properties); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
449 | data->properties = new_properties; |
136
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
450 | |
505 | 451 | free(cl_keystr.ptr); |
452 | free(cd_keystr.ptr); | |
453 | free(lm_keystr.ptr); | |
454 | free(ct_keystr.ptr); | |
455 | free(rt_keystr.ptr); | |
456 | free(cn_keystr.ptr); | |
457 | free(ck_keystr.ptr); | |
458 | free(ch_keystr.ptr); | |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
459 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
460 | return 0; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
461 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
462 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
463 | /* |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
464 | * execute a davql select statement |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
465 | */ |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
466 | DavResult dav_exec_select(DavSession *sn, DavQLStatement *st, va_list ap) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
467 | CxMempool *mp = cxBasicMempoolCreate(128); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
468 | DavResult result; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
469 | result.result = NULL; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
470 | result.status = 1; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
471 | |
365
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
472 | DavQLArgList *args = dav_ql_get_args(st, ap); |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
473 | if(!args) { |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
474 | return result; |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
475 | } |
775 | 476 | cxMempoolRegister(mp, args, (cx_destructor_func)dav_ql_free_arglist); |
365
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
477 | |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
478 | int isallprop; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
479 | CxBuffer *rqbuf = fieldlist2propfindrequest(sn, mp->allocator, st->fields, &isallprop); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
480 | if(!rqbuf) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
481 | cxMempoolDestroy(mp); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
482 | return result; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
483 | } |
775 | 484 | cxMempoolRegister(mp, rqbuf, (cx_destructor_func)cxBufferFree); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
485 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
486 | // compile field list |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
487 | CxList *cfieldlist = cxLinkedListCreate(mp->allocator, NULL, CX_STORE_POINTERS); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
488 | if(st->fields) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
489 | CxIterator i = cxListIterator(st->fields); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
490 | cx_foreach(DavQLField*, field, i) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
491 | if(cx_strcmp(field->name, CX_STR("*")) && cx_strcmp(field->name, CX_STR("-"))) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
492 | // compile field expression |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
493 | CxBuffer *code = dav_compile_expr( |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
494 | sn->context, |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
495 | mp->allocator, |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
496 | field->expr, |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
497 | args); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
498 | if(!code) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
499 | // TODO: set error string |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
500 | return result; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
501 | } |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
502 | DavCompiledField *cfield = cxMalloc( |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
503 | mp->allocator, |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
504 | sizeof(DavCompiledField)); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
505 | |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
506 | char *ns; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
507 | char *name; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
508 | dav_get_property_namespace_str( |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
509 | sn->context, |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
510 | cx_strdup_a(mp->allocator, field->name).ptr, |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
511 | &ns, |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
512 | &name); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
513 | if(!ns || !name) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
514 | // TODO: set error string |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
515 | return result; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
516 | } |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
517 | cfield->ns = ns; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
518 | cfield->name = name; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
519 | cfield->code = code; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
520 | cxListAdd(cfieldlist, cfield); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
521 | } |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
522 | } |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
523 | } |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
524 | |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
525 | // get path string |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
526 | davqlerror_t error; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
527 | cxmutstr path = dav_format_string(mp->allocator, st->path, args, &error); |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
528 | if(error) { |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
529 | // TODO: cleanup |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
530 | cxMempoolDestroy(mp); |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
531 | return result; |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
532 | } |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
533 | |
365
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
534 | int depth = st->depth == DAV_DEPTH_PLACEHOLDER ? |
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
535 | dav_ql_getarg_int(args) : st->depth; |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
536 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
537 | CxBuffer *where = dav_compile_expr(sn->context, mp->allocator, st->where, args); |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
538 | if(st->where && !where) { |
148
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
539 | // TODO: cleanup |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
540 | cxMempoolDestroy(mp); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
541 | return result; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
542 | } |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
543 | |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
544 | // compile order criterion |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
545 | CxList *ordercr = NULL; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
546 | if(st->orderby) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
547 | ordercr = cxLinkedListCreate(mp->allocator, NULL, sizeof(DavOrderCriterion)); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
548 | CxIterator i = cxListIterator(st->orderby); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
549 | cx_foreach(DavQLOrderCriterion*, oc, i) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
550 | DavQLExpression *column = oc->column; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
551 | //printf("%.*s %s\n", column->srctext.length, column->srctext.ptr, oc->descending ? "desc" : "asc"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
552 | if(column->type == DAVQL_IDENTIFIER) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
553 | // TODO: remove code duplication (add_cmd) |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
554 | davqlresprop_t resprop; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
555 | cxstring propertyname = cx_strchr(column->srctext, ':'); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
556 | if(propertyname.length > 0) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
557 | char *ns; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
558 | char *name; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
559 | dav_get_property_namespace_str( |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
560 | sn->context, |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
561 | cx_strdup_a(mp->allocator, column->srctext).ptr, |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
562 | &ns, |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
563 | &name); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
564 | if(ns && name) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
565 | DavOrderCriterion cr; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
566 | cr.type = 1; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
567 | cxmutstr keystr = dav_property_key_a(mp->allocator, ns, name); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
568 | cr.column.property = cx_hash_key(keystr.ptr, keystr.length); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
569 | cr.descending = oc->descending; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
570 | cxListAdd(ordercr, &cr); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
571 | } else { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
572 | // error |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
573 | // TODO: cleanup |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
574 | cxMempoolDestroy(mp); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
575 | return result; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
576 | } |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
577 | } else if(dav_identifier2resprop(column->srctext, &resprop)) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
578 | DavOrderCriterion cr; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
579 | cr.type = 0; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
580 | cr.column.resprop = resprop; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
581 | cr.descending = oc->descending; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
582 | cxListAdd(ordercr, &cr); |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
583 | } else { |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
584 | // error |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
585 | // TODO: cleanup |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
586 | cxMempoolDestroy(mp); |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
587 | return result; |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
588 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
589 | |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
590 | } else if(column->type == DAVQL_NUMBER) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
591 | // TODO: implement |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
592 | fprintf(stderr, "order by number not supported\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
593 | return result; |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
594 | } else { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
595 | // something is broken |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
596 | // TODO: cleanup |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
597 | cxMempoolDestroy(mp); |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
598 | return result; |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
599 | } |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
600 | } |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
601 | } |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
602 | |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
603 | DavResource *selroot = dav_resource_new(sn, path.ptr); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
604 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
605 | CxList *stack = cxLinkedListCreateSimple(sizeof(DavQLRes)); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
606 | // initialize the stack with the requested resource |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
607 | DavQLRes res; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
608 | res.resource = selroot; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
609 | res.depth = 0; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
610 | cxListInsert(stack, 0, &res); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
611 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
612 | // reuseable response buffer |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
613 | CxBuffer *rpbuf = cxBufferCreate(NULL, 4096, mp->allocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); |
148
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
614 | if(!rpbuf) { |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
615 | // TODO: cleanup |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
616 | cxMempoolDestroy(mp); |
148
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
617 | return result; |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
618 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
619 | |
137
01cb9aabff05
fixed horrible bugs, davql hopefully just works now (without order by yet)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
620 | result.result = selroot; |
01cb9aabff05
fixed horrible bugs, davql hopefully just works now (without order by yet)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
621 | result.status = 0; |
01cb9aabff05
fixed horrible bugs, davql hopefully just works now (without order by yet)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
622 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
623 | // do a propfind request for each resource on the stack |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
624 | while(stack->size > 0) { |
755
283d3d7a657a
fix UAF in davql select exec
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
747
diff
changeset
|
625 | DavQLRes *sr_ptr = cxListAt(stack, 0); // get first element from the stack |
283d3d7a657a
fix UAF in davql select exec
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
747
diff
changeset
|
626 | DavResource *root = sr_ptr->resource; |
283d3d7a657a
fix UAF in davql select exec
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
747
diff
changeset
|
627 | int res_depth = sr_ptr->depth; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
628 | cxListRemove(stack, 0); // remove first element |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
629 | |
755
283d3d7a657a
fix UAF in davql select exec
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
747
diff
changeset
|
630 | util_set_url(sn, dav_resource_get_href(root)); |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
351
diff
changeset
|
631 | CURLcode ret = do_propfind_request(sn, rqbuf, rpbuf); |
205
bf756f6c3581
fixed some warnings and wrong usage of curl_easy_getinfo
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
632 | long http_status = 0; |
bf756f6c3581
fixed some warnings and wrong usage of curl_easy_getinfo
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
633 | curl_easy_getinfo(sn->handle, CURLINFO_RESPONSE_CODE, &http_status); |
137
01cb9aabff05
fixed horrible bugs, davql hopefully just works now (without order by yet)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
634 | //printf("rpbuf: %s %s\n%.*s\n\n", sr->resource->path, sr->resource->href, rpbuf->pos, rpbuf->space); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
635 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
636 | if(ret == CURLE_OK && http_status == 207) { |
478
baa63fef5c5c
fixes redirects
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
475
diff
changeset
|
637 | // in case of an redirect we have to adjust resource->href |
baa63fef5c5c
fixes redirects
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
475
diff
changeset
|
638 | dav_set_effective_href(sn, root); |
baa63fef5c5c
fixes redirects
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
475
diff
changeset
|
639 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
640 | // propfind request successful, now parse the response |
739
bba6a6e221b4
use sys_* io functions in dav put
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
738
diff
changeset
|
641 | char *url = "http://url/"; |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
642 | PropfindParser *parser = create_propfind_parser(rpbuf, url); |
738
b62ea7f31593
fix crash in davql exec, if the server response can't be parsed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
610
diff
changeset
|
643 | if(!parser) { |
b62ea7f31593
fix crash in davql exec, if the server response can't be parsed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
610
diff
changeset
|
644 | result.status = -1; |
b62ea7f31593
fix crash in davql exec, if the server response can't be parsed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
610
diff
changeset
|
645 | break; |
b62ea7f31593
fix crash in davql exec, if the server response can't be parsed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
610
diff
changeset
|
646 | } |
b62ea7f31593
fix crash in davql exec, if the server response can't be parsed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
610
diff
changeset
|
647 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
648 | ResponseTag response; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
649 | int r; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
650 | while((r = get_propfind_response(parser, &response)) != 0) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
651 | if(r == -1) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
652 | // error |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
653 | result.status = -1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
654 | // TODO: free resources |
148
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
655 | cleanup_response(&response); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
656 | break; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
657 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
658 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
659 | // the propfind multistatus response contains responses |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
660 | // for the requested resource and all childs |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
661 | // determine if the response is a child or not |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
662 | if(hrefeq(sn, root->href, response.href)) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
663 | // response is the currently requested resource |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
664 | // and not a child |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
665 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
666 | // add properties |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
667 | add_properties(root, &response); |
148
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
668 | cleanup_response(&response); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
669 | |
150
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
670 | if(root == selroot) { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
671 | // The current root is the root of the select query. |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
672 | // In this case we have to check the where clause. |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
673 | // If root is not selroot, the where clause was |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
674 | // already checked for the resource before it was |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
675 | // added to the stack. |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
676 | DavQLStackObj where_result; |
150
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
677 | if(!dav_exec_expr(where, root, &where_result)) { |
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
678 | if(where_result.data.integer != 0) { |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
679 | if(!reset_properties(sn, &result, root, cfieldlist)) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
680 | continue; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
681 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
682 | result.status = -1; |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
683 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
684 | } |
143
d8b01bed3d83
fixed get command and davql exec
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
685 | result.result = NULL; |
d8b01bed3d83
fixed get command and davql exec
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
686 | result.status = -1; |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
687 | dav_resource_free_all(selroot); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
688 | cxListDestroy(stack); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
689 | break; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
690 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
691 | } else { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
692 | DavResource *child = response2resource( |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
693 | sn, |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
694 | &response, |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
695 | root->path); |
148
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
696 | cleanup_response(&response); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
697 | // check where clause |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
698 | DavQLStackObj where_result; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
699 | if(!dav_exec_expr(where, child, &where_result)) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
700 | if(where_result.data.integer != 0) { |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
701 | if(!reset_properties(sn, &result, child, cfieldlist)) { |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
702 | //resource_add_child(root, child); |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
703 | resource_add_ordered_child(root, child, ordercr); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
704 | if(child->iscollection && |
755
283d3d7a657a
fix UAF in davql select exec
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
747
diff
changeset
|
705 | (depth < 0 || depth > res_depth+1)) |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
706 | { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
707 | DavQLRes rs; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
708 | rs.resource = child; |
755
283d3d7a657a
fix UAF in davql select exec
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
747
diff
changeset
|
709 | rs.depth = res_depth + 1; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
710 | cxListInsert(stack, 0, &rs); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
711 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
712 | } else { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
713 | dav_resource_free(child); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
714 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
715 | } else { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
716 | dav_resource_free(child); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
717 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
718 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
719 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
720 | } |
148
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
721 | destroy_propfind_parser(parser); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
722 | } else { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
723 | dav_session_set_error(sn, ret, http_status); |
137
01cb9aabff05
fixed horrible bugs, davql hopefully just works now (without order by yet)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
724 | result.result = NULL; |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
725 | result.status = -1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
726 | dav_resource_free_all(selroot); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
727 | break; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
728 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
729 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
730 | // reset response buffer |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
731 | cxBufferSeek(rpbuf, SEEK_SET, 0); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
732 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
733 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
734 | cxMempoolDestroy(mp); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
735 | return result; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
736 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
737 | |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
738 | static int count_func_args(DavQLExpression *expr) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
739 | int count = 0; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
740 | DavQLExpression *arg = expr->right; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
741 | while(arg) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
742 | count++; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
743 | if(arg->op == DAVQL_ARGLIST) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
744 | arg = arg->right; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
745 | } else { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
746 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
747 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
748 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
749 | return count; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
750 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
751 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
752 | int dav_identifier2resprop(cxstring src, davqlresprop_t *prop) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
753 | if(!cx_strcmp(src, CX_STR("name"))) { |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
754 | *prop = DAVQL_RES_NAME; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
755 | } else if(!cx_strcmp(src, CX_STR("path"))) { |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
756 | *prop = DAVQL_RES_PATH; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
757 | } else if(!cx_strcmp(src, CX_STR("href"))) { |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
758 | *prop = DAVQL_RES_HREF; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
759 | } else if(!cx_strcmp(src, CX_STR("contentlength"))) { |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
760 | *prop = DAVQL_RES_CONTENTLENGTH; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
761 | } else if(!cx_strcmp(src, CX_STR("contenttype"))) { |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
762 | *prop = DAVQL_RES_CONTENTTYPE; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
763 | } else if(!cx_strcmp(src, CX_STR("creationdate"))) { |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
764 | *prop = DAVQL_RES_CREATIONDATE; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
765 | } else if(!cx_strcmp(src, CX_STR("lastmodified"))) { |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
766 | *prop = DAVQL_RES_LASTMODIFIED; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
767 | } else if(!cx_strcmp(src, CX_STR("iscollection"))) { |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
768 | *prop = DAVQL_RES_ISCOLLECTION; |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
769 | } else { |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
770 | return 0; |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
771 | } |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
772 | return 1; |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
773 | } |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
774 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
775 | static int add_cmd(DavContext *ctx, const CxAllocator *a, CxBuffer *bcode, DavQLExpression *expr, DavQLArgList *ap) { |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
776 | if(!expr) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
777 | return 0; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
778 | } |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
779 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
780 | int numcmd = 1; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
781 | DavQLCmd cmd; |
538
a7402e35ad87
fixes wrong memset
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
505
diff
changeset
|
782 | memset(&cmd, 0, sizeof(DavQLCmd)); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
783 | davqlerror_t error; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
784 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
785 | cxstring src = expr->srctext; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
786 | switch(expr->type) { |
145
82475dc12dd4
improved dav-sync data-loss prevention
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
144
diff
changeset
|
787 | default: break; |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
788 | case DAVQL_NUMBER: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
789 | cmd.type = DAVQL_CMD_INT; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
790 | if(src.ptr[0] == '%') { |
365
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
791 | cmd.data.integer = dav_ql_getarg_int(ap); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
792 | } else if(util_strtoint(src.ptr, &cmd.data.integer)) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
793 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
794 | } else { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
795 | // error |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
796 | return -1; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
797 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
798 | |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
799 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
800 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
801 | case DAVQL_STRING: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
802 | cmd.type = DAVQL_CMD_STRING; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
803 | cmd.data.string = dav_format_string(a, src, ap, &error); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
804 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
805 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
806 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
807 | case DAVQL_TIMESTAMP: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
808 | if(src.ptr[0] == '%') { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
809 | cmd.type = DAVQL_CMD_TIMESTAMP; |
365
f04ab0420512
fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
810 | cmd.data.timestamp = dav_ql_getarg_time(ap); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
811 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
812 | } else { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
813 | // error |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
814 | return -1; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
815 | } |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
816 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
817 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
818 | case DAVQL_IDENTIFIER: { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
819 | cxstring propertyname = cx_strchr(src, ':'); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
820 | cmd.type = DAVQL_CMD_RES_IDENTIFIER; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
821 | if(propertyname.length > 0) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
822 | cmd.type = DAVQL_CMD_PROP_IDENTIFIER; |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
823 | char *ns; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
824 | char *name; |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
825 | dav_get_property_namespace_str( |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
826 | ctx, |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
827 | cx_strdup_a(a, src).ptr, |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
828 | &ns, |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
829 | &name); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
830 | if(ns && name) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
831 | cmd.data.property.ns = ns; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
832 | cmd.data.property.name = name; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
833 | } else { |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
834 | // error |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
835 | return -1; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
836 | } |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
837 | } else if(!dav_identifier2resprop(src, &cmd.data.resprop)) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
838 | if(!cx_strcmp(src, CX_STR("true"))) { |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
839 | cmd.type = DAVQL_CMD_INT; |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
840 | cmd.data.integer = 1; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
841 | } else if(!cx_strcmp(src, CX_STR("false"))) { |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
842 | cmd.type = DAVQL_CMD_INT; |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
843 | cmd.data.integer = 0; |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
844 | } else { |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
845 | // error, unknown identifier |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
846 | return -1; |
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
847 | } |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
848 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
849 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
850 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
851 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
852 | case DAVQL_UNARY: { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
853 | numcmd += add_cmd(ctx, a, bcode, expr->left, ap); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
854 | switch(expr->op) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
855 | case DAVQL_ADD: { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
856 | // noop |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
857 | numcmd = 0; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
858 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
859 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
860 | case DAVQL_SUB: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
861 | cmd.type = DAVQL_CMD_OP_UNARY_SUB; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
862 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
863 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
864 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
865 | case DAVQL_NEG: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
866 | cmd.type = DAVQL_CMD_OP_UNARY_NEG; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
867 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
868 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
869 | } |
144
c2c02c9b3be4
dav-sync detects broken uploads
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
870 | default: break; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
871 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
872 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
873 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
874 | case DAVQL_BINARY: { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
875 | numcmd += add_cmd(ctx, a, bcode, expr->left, ap); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
876 | numcmd += add_cmd(ctx, a, bcode, expr->right, ap); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
877 | switch(expr->op) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
878 | case DAVQL_ADD: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
879 | cmd.type = DAVQL_CMD_OP_BINARY_ADD; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
880 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
881 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
882 | case DAVQL_SUB: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
883 | cmd.type = DAVQL_CMD_OP_BINARY_SUB; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
884 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
885 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
886 | case DAVQL_MUL: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
887 | cmd.type = DAVQL_CMD_OP_BINARY_MUL; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
888 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
889 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
890 | case DAVQL_DIV: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
891 | cmd.type = DAVQL_CMD_OP_BINARY_DIV; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
892 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
893 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
894 | case DAVQL_AND: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
895 | cmd.type = DAVQL_CMD_OP_BINARY_AND; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
896 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
897 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
898 | case DAVQL_OR: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
899 | cmd.type = DAVQL_CMD_OP_BINARY_OR; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
900 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
901 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
902 | case DAVQL_XOR: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
903 | cmd.type = DAVQL_CMD_OP_BINARY_XOR; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
904 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
905 | } |
144
c2c02c9b3be4
dav-sync detects broken uploads
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
906 | default: break; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
907 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
908 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
909 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
910 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
911 | case DAVQL_LOGICAL: { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
912 | if(expr->left && expr->right && expr->op != DAVQL_LOR) { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
913 | numcmd += add_cmd(ctx, a, bcode, expr->left, ap); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
914 | numcmd += add_cmd(ctx, a, bcode, expr->right, ap); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
915 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
916 | |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
917 | switch(expr->op) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
918 | case DAVQL_NOT: { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
919 | numcmd += add_cmd(ctx, a, bcode, expr->left, ap); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
920 | cmd.type = DAVQL_CMD_OP_LOGICAL_NOT; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
921 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
922 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
923 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
924 | case DAVQL_LAND: { |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
925 | cmd.type = DAVQL_CMD_OP_LOGICAL_AND; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
926 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
927 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
928 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
929 | case DAVQL_LOR: { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
930 | int nleft = add_cmd(ctx, a, bcode, expr->left, ap); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
931 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
932 | cmd.type = DAVQL_CMD_OP_LOGICAL_OR_L; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
933 | DavQLCmd *or_l = (DavQLCmd*)(bcode->space + bcode->pos); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
934 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
935 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
936 | int nright = add_cmd(ctx, a, bcode, expr->right, ap); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
937 | or_l->data.integer = nright + 1; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
938 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
939 | cmd.type = DAVQL_CMD_OP_LOGICAL_OR; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
940 | cmd.data.integer = 0; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
941 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
942 | |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
943 | numcmd += nleft + nright; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
944 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
945 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
946 | case DAVQL_LXOR: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
947 | cmd.type = DAVQL_CMD_OP_LOGICAL_XOR; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
948 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
949 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
950 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
951 | case DAVQL_EQ: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
952 | cmd.type = DAVQL_CMD_OP_EQ; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
953 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
954 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
955 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
956 | case DAVQL_NEQ: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
957 | cmd.type = DAVQL_CMD_OP_NEQ; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
958 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
959 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
960 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
961 | case DAVQL_LT: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
962 | cmd.type = DAVQL_CMD_OP_LT; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
963 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
964 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
965 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
966 | case DAVQL_GT: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
967 | cmd.type = DAVQL_CMD_OP_GT; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
968 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
969 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
970 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
971 | case DAVQL_LE: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
972 | cmd.type = DAVQL_CMD_OP_LE; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
973 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
974 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
975 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
976 | case DAVQL_GE: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
977 | cmd.type = DAVQL_CMD_OP_GE; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
978 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
979 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
980 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
981 | case DAVQL_LIKE: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
982 | cmd.type = DAVQL_CMD_OP_LIKE; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
983 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
984 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
985 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
986 | case DAVQL_UNLIKE: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
987 | cmd.type = DAVQL_CMD_OP_UNLIKE; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
988 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
989 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
990 | } |
144
c2c02c9b3be4
dav-sync detects broken uploads
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
991 | default: break; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
992 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
993 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
994 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
995 | case DAVQL_FUNCCALL: { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
996 | switch(expr->op) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
997 | case DAVQL_CALL: { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
998 | int nright = add_cmd(ctx, a, bcode, expr->right, ap); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
999 | // TODO: count args |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1000 | DavQLExpression *funcid = expr->left; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1001 | if(!funcid && funcid->type != DAVQL_IDENTIFIER) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1002 | // fail |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1003 | return -1; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1004 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1005 | |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
1006 | // numargs |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
1007 | cmd.type = DAVQL_CMD_INT; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
1008 | cmd.data.integer = count_func_args(expr); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1009 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
1010 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
1011 | // TODO: resolve function name |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
1012 | cmd.type = DAVQL_CMD_CALL; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
1013 | cmd.data.func = NULL; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1014 | cxBufferWrite(&cmd, sizeof(cmd), 1, bcode); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
1015 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
1016 | numcmd = 2; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1017 | numcmd += nright; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1018 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1019 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1020 | case DAVQL_ARGLIST: { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1021 | numcmd = 0; |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
1022 | numcmd += add_cmd(ctx, a, bcode, expr->left, ap); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
1023 | numcmd += add_cmd(ctx, a, bcode, expr->right, ap); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1024 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1025 | } |
144
c2c02c9b3be4
dav-sync detects broken uploads
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
1026 | default: break; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1027 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1028 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1029 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1030 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1031 | return numcmd; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1032 | } |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1033 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1034 | CxBuffer* dav_compile_expr(DavContext *ctx, const CxAllocator *a, DavQLExpression *lexpr, DavQLArgList *ap) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1035 | CxBuffer *bcode = cxBufferCreate(NULL, 512, a, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1036 | if(!bcode) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1037 | return NULL; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1038 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1039 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
1040 | if(add_cmd(ctx, a, bcode, lexpr, ap) <= 0) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1041 | cxBufferFree(bcode); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
1042 | return NULL; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
1043 | } |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1044 | |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1045 | return bcode; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
1046 | } |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
1047 | |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1048 | static int cmd_str_cmp(DavQLStackObj obj1, DavQLStackObj obj2, davqlcmdtype_t cmd) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1049 | cxmutstr s1m = obj1.type == 1 ? |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1050 | cx_mutstrn(obj1.data.string, obj1.length) : |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1051 | cx_asprintf("%" PRId64, obj1.data.integer); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1052 | cxmutstr s2m = obj1.type == 1 ? |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1053 | cx_mutstrn(obj2.data.string, obj2.length) : |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1054 | cx_asprintf("%" PRId64, obj2.data.integer); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1055 | |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1056 | cxstring s1 = cx_strcast(s1m); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1057 | cxstring s2 = cx_strcast(s2m); |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1058 | |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1059 | int res = 0; |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1060 | switch(cmd) { |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1061 | case DAVQL_CMD_OP_EQ: { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1062 | res = cx_strcmp(s1, s2) == 0; |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1063 | break; |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1064 | } |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1065 | case DAVQL_CMD_OP_NEQ: { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1066 | res = cx_strcmp(s1, s2) != 0; |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1067 | break; |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1068 | } |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1069 | case DAVQL_CMD_OP_LT: { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1070 | res = cx_strcmp(s1, s2) < 0; |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1071 | break; |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1072 | } |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1073 | case DAVQL_CMD_OP_GT: { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1074 | res = cx_strcmp(s1, s2) > 0; |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1075 | break; |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1076 | } |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1077 | case DAVQL_CMD_OP_LE: { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1078 | res = cx_strcmp(s1, s2) <= 0; |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1079 | break; |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1080 | } |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1081 | case DAVQL_CMD_OP_GE: { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1082 | res = cx_strcmp(s1, s2) >= 0; |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1083 | break; |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1084 | } |
351
11789a88d0b0
fixes some warnings
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
348
diff
changeset
|
1085 | default: break; |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1086 | } |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1087 | |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1088 | if(obj1.type == 0) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1089 | free(s1m.ptr); |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1090 | } |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1091 | if(obj2.type == 0) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1092 | free(s2m.ptr); |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1093 | } |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1094 | |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1095 | return res; |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1096 | } |
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1097 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
739
diff
changeset
|
1098 | int dav_exec_expr(CxBuffer *bcode, DavResource *res, DavQLStackObj *result) { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1099 | if(!bcode) { |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1100 | result->type = 0; |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1101 | result->length = 0; |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1102 | result->data.integer = 1; |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1103 | return 0; |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1104 | } |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1105 | |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1106 | size_t count = bcode->pos / sizeof(DavQLCmd); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1107 | DavQLCmd *cmds = (DavQLCmd*)bcode->space; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1108 | |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1109 | // create execution stack |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1110 | size_t stsize = 64; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1111 | size_t stpos = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1112 | DavQLStackObj *stack = calloc(stsize, sizeof(DavQLStackObj)); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1113 | #define DAVQL_PUSH(obj) \ |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1114 | if(stpos == stsize) { \ |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1115 | stsize += 64; \ |
290
1e3e374d9386
adds clean handling in case the stack of dav_exec_expr() runs out of memory
Mike Becker <universe@uap-core.de>
parents:
289
diff
changeset
|
1116 | DavQLStackObj *stack_newptr; \ |
1e3e374d9386
adds clean handling in case the stack of dav_exec_expr() runs out of memory
Mike Becker <universe@uap-core.de>
parents:
289
diff
changeset
|
1117 | stack_newptr = realloc(stack, stsize * sizeof(DavQLStackObj)); \ |
1e3e374d9386
adds clean handling in case the stack of dav_exec_expr() runs out of memory
Mike Becker <universe@uap-core.de>
parents:
289
diff
changeset
|
1118 | if(stack_newptr) { \ |
1e3e374d9386
adds clean handling in case the stack of dav_exec_expr() runs out of memory
Mike Becker <universe@uap-core.de>
parents:
289
diff
changeset
|
1119 | stack = stack_newptr; \ |
1e3e374d9386
adds clean handling in case the stack of dav_exec_expr() runs out of memory
Mike Becker <universe@uap-core.de>
parents:
289
diff
changeset
|
1120 | } else { \ |
1e3e374d9386
adds clean handling in case the stack of dav_exec_expr() runs out of memory
Mike Becker <universe@uap-core.de>
parents:
289
diff
changeset
|
1121 | free(stack); \ |
1e3e374d9386
adds clean handling in case the stack of dav_exec_expr() runs out of memory
Mike Becker <universe@uap-core.de>
parents:
289
diff
changeset
|
1122 | return -1; \ |
1e3e374d9386
adds clean handling in case the stack of dav_exec_expr() runs out of memory
Mike Becker <universe@uap-core.de>
parents:
289
diff
changeset
|
1123 | }\ |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1124 | } \ |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1125 | stack[stpos++] = obj; |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1126 | #define DAVQL_PUSH_INT(intval) \ |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1127 | { \ |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1128 | DavQLStackObj intobj; \ |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1129 | intobj.type = 0; \ |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1130 | intobj.length = 0; \ |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1131 | intobj.data.integer = intval; \ |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1132 | DAVQL_PUSH(intobj); \ |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1133 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1134 | #define DAVQL_POP() stack[--stpos] |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1135 | |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1136 | DavQLStackObj obj; |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1137 | int ret = 0; |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1138 | for(size_t i=0;i<count;i++) { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1139 | DavQLCmd cmd = cmds[i]; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1140 | switch(cmd.type) { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1141 | case DAVQL_CMD_INT: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1142 | //printf("int %lld\n", cmd.data.integer); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1143 | obj.type = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1144 | obj.length = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1145 | obj.data.integer = cmd.data.integer; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1146 | DAVQL_PUSH(obj); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1147 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1148 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1149 | case DAVQL_CMD_STRING: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1150 | //printf("string \"%.*s\"\n", cmd.data.string.length, cmd.data.string.ptr); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1151 | obj.type = 1; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1152 | obj.length = cmd.data.string.length; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1153 | obj.data.string = cmd.data.string.ptr; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1154 | DAVQL_PUSH(obj); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1155 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1156 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1157 | case DAVQL_CMD_TIMESTAMP: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1158 | //printf("timestamp %d\n", cmd.data.timestamp); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1159 | obj.type = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1160 | obj.length = 0; |
136
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
1161 | obj.data.integer = (int64_t)cmd.data.timestamp; |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1162 | DAVQL_PUSH(obj); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1163 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1164 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1165 | case DAVQL_CMD_RES_IDENTIFIER: { |
139
c6424aebcf5e
implemented davql order by
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
1166 | //char *rid[8] = {"name", "path", "href", "contentlength", "contenttype", "creationdate", "lastmodified", "iscollection"}; |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1167 | //printf("resprop %s\n", rid[cmd.data.resprop]); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1168 | switch(cmd.data.resprop) { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1169 | case DAVQL_RES_NAME: { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1170 | obj.type = 1; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1171 | obj.length = strlen(res->name); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1172 | obj.data.string = res->name; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1173 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1174 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1175 | case DAVQL_RES_PATH: { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1176 | obj.type = 1; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1177 | obj.length = strlen(res->path); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1178 | obj.data.string = res->path; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1179 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1180 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1181 | case DAVQL_RES_HREF: { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1182 | obj.type = 1; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1183 | obj.length = strlen(res->href); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1184 | obj.data.string = res->href; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1185 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1186 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1187 | case DAVQL_RES_CONTENTLENGTH: { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1188 | obj.type = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1189 | obj.length = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1190 | obj.data.integer = res->contentlength; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1191 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1192 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1193 | case DAVQL_RES_CONTENTTYPE: { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1194 | obj.type = 1; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1195 | obj.length = strlen(res->contenttype); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1196 | obj.data.string = res->contenttype; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1197 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1198 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1199 | case DAVQL_RES_CREATIONDATE: { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1200 | obj.type = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1201 | obj.length = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1202 | obj.data.integer = res->creationdate; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1203 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1204 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1205 | case DAVQL_RES_LASTMODIFIED: { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1206 | obj.type = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1207 | obj.length = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1208 | obj.data.integer = res->lastmodified; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1209 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1210 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1211 | case DAVQL_RES_ISCOLLECTION: { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1212 | obj.type = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1213 | obj.length = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1214 | obj.data.integer = res->iscollection; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1215 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1216 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1217 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1218 | DAVQL_PUSH(obj); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1219 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1220 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1221 | case DAVQL_CMD_PROP_IDENTIFIER: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1222 | //printf("property %s:%s\n", cmd.data.property.ns, cmd.data.property.name); |
361
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
1223 | //char *value = dav_get_string_property_ns(res, cmd.data.property.ns, cmd.data.property.name); |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
1224 | DavXmlNode *value = dav_get_property_ns(res, cmd.data.property.ns, cmd.data.property.name); |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
1225 | if(dav_xml_isstring(value)) { |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
1226 | obj.type = 1; |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
1227 | obj.length = (uint32_t)value->contentlength; |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
1228 | obj.data.string = value->content; |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
1229 | } else { |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
1230 | obj.type = 2; |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
1231 | obj.length = 0; |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
1232 | obj.data.node = value; |
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
1233 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1234 | DAVQL_PUSH(obj); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1235 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1236 | } |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1237 | //case DAVQL_CMD_OP_UNARY_ADD: { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1238 | // printf("uadd\n"); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1239 | // break; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1240 | //} |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1241 | case DAVQL_CMD_OP_UNARY_SUB: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1242 | //printf("usub\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1243 | obj = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1244 | if(obj.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1245 | obj.data.integer = -obj.data.integer; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1246 | DAVQL_PUSH(obj); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1247 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1248 | ret = -1; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1249 | i = count; // end loop |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1250 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1251 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1252 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1253 | case DAVQL_CMD_OP_UNARY_NEG: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1254 | //printf("uneg\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1255 | obj = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1256 | if(obj.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1257 | obj.data.integer = obj.data.integer == 0 ? 1 : 0; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1258 | DAVQL_PUSH(obj); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1259 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1260 | ret = -1; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1261 | i = count; // end loop |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1262 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1263 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1264 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1265 | case DAVQL_CMD_OP_BINARY_ADD: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1266 | //printf("add\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1267 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1268 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1269 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1270 | DAVQL_PUSH_INT(obj1.data.integer + obj2.data.integer); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1271 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1272 | // TODO: string concat |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1273 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1274 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1275 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1276 | case DAVQL_CMD_OP_BINARY_SUB: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1277 | //printf("sub\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1278 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1279 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1280 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1281 | DAVQL_PUSH_INT(obj1.data.integer - obj2.data.integer); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1282 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1283 | // error |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1284 | ret = -1; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1285 | i = count; // end loop |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1286 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1287 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1288 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1289 | case DAVQL_CMD_OP_BINARY_MUL: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1290 | //printf("mul\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1291 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1292 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1293 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1294 | DAVQL_PUSH_INT(obj1.data.integer * obj2.data.integer); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1295 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1296 | // error |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1297 | ret = -1; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1298 | i = count; // end loop |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1299 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1300 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1301 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1302 | case DAVQL_CMD_OP_BINARY_DIV: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1303 | //printf("div\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1304 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1305 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1306 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1307 | DAVQL_PUSH_INT(obj1.data.integer / obj2.data.integer); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1308 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1309 | // error |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1310 | ret = -1; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1311 | i = count; // end loop |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1312 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1313 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1314 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1315 | case DAVQL_CMD_OP_BINARY_AND: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1316 | //printf("and\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1317 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1318 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1319 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1320 | DAVQL_PUSH_INT(obj1.data.integer & obj2.data.integer); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1321 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1322 | // error |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1323 | ret = -1; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1324 | i = count; // end loop |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1325 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1326 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1327 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1328 | case DAVQL_CMD_OP_BINARY_OR: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1329 | //printf("or\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1330 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1331 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1332 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1333 | DAVQL_PUSH_INT(obj1.data.integer | obj2.data.integer); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1334 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1335 | // error |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1336 | ret = -1; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1337 | i = count; // end loop |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1338 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1339 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1340 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1341 | case DAVQL_CMD_OP_BINARY_XOR: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1342 | //printf("xor\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1343 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1344 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1345 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1346 | DAVQL_PUSH_INT(obj1.data.integer ^ obj2.data.integer); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1347 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1348 | // error |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1349 | ret = -1; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1350 | i = count; // end loop |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1351 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1352 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1353 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1354 | case DAVQL_CMD_OP_LOGICAL_NOT: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1355 | //printf("not\n"); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1356 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1357 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1358 | case DAVQL_CMD_OP_LOGICAL_AND: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1359 | //printf("land\n"); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1360 | DavQLStackObj obj2 = DAVQL_POP(); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1361 | DavQLStackObj obj1 = DAVQL_POP(); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1362 | int v1 = obj1.type == 0 ? (int)obj1.data.integer : (obj1.data.string ? 1 : 0); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1363 | int v2 = obj2.type == 0 ? (int)obj2.data.integer : (obj2.data.string ? 1 : 0); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1364 | DAVQL_PUSH_INT(v1 && v2); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1365 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1366 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1367 | case DAVQL_CMD_OP_LOGICAL_OR_L: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1368 | //printf("or_l %d\n", cmd.data.integer); |
235
0468df02e18f
fixed dav get with -u option
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
1369 | DavQLStackObj obj1 = stack[stpos]; |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1370 | if((obj1.type == 0 && obj1.data.integer) || (obj1.type == 1 && obj1.data.string)) { |
235
0468df02e18f
fixed dav get with -u option
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
1371 | stpos--; |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1372 | DAVQL_PUSH_INT(1); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1373 | i += cmd.data.integer; // jump, skip right subtree of 'or' |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1374 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1375 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1376 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1377 | case DAVQL_CMD_OP_LOGICAL_OR: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1378 | //printf("or\n"); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1379 | DavQLStackObj obj2 = DAVQL_POP(); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1380 | DavQLStackObj obj1 = DAVQL_POP(); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1381 | int v1 = obj1.type == 0 ? (int)obj1.data.integer : (obj1.data.string ? 1 : 0); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1382 | int v2 = obj2.type == 0 ? (int)obj2.data.integer : (obj2.data.string ? 1 : 0); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1383 | DAVQL_PUSH_INT(v1 || v2); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1384 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1385 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1386 | case DAVQL_CMD_OP_LOGICAL_XOR: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1387 | //printf("lxor\n"); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1388 | DavQLStackObj obj2 = DAVQL_POP(); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1389 | DavQLStackObj obj1 = DAVQL_POP(); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1390 | int v1 = obj1.type == 0 ? (int)obj1.data.integer : (obj1.data.string ? 1 : 0); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1391 | int v2 = obj2.type == 0 ? (int)obj2.data.integer : (obj2.data.string ? 1 : 0); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1392 | DAVQL_PUSH_INT(!v1 != !v2); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1393 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1394 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1395 | case DAVQL_CMD_OP_EQ: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1396 | //printf("eq\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1397 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1398 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1399 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1400 | DAVQL_PUSH_INT(obj1.data.integer == obj2.data.integer); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1401 | } else { |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1402 | DAVQL_PUSH_INT(cmd_str_cmp(obj1, obj2, cmd.type)); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1403 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1404 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1405 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1406 | case DAVQL_CMD_OP_NEQ: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1407 | //printf("neq\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1408 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1409 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1410 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1411 | DAVQL_PUSH_INT(obj1.data.integer != obj2.data.integer); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1412 | } else { |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1413 | DAVQL_PUSH_INT(cmd_str_cmp(obj1, obj2, cmd.type)); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1414 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1415 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1416 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1417 | case DAVQL_CMD_OP_LT: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1418 | //printf("lt\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1419 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1420 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1421 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1422 | DAVQL_PUSH_INT(obj1.data.integer < obj2.data.integer); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1423 | } else { |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1424 | DAVQL_PUSH_INT(cmd_str_cmp(obj1, obj2, cmd.type)); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1425 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1426 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1427 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1428 | case DAVQL_CMD_OP_GT: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1429 | //printf("gt\n"); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1430 | DavQLStackObj obj2 = DAVQL_POP(); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1431 | DavQLStackObj obj1 = DAVQL_POP(); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1432 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1433 | DAVQL_PUSH_INT(obj1.data.integer > obj2.data.integer); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1434 | } else { |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1435 | DAVQL_PUSH_INT(cmd_str_cmp(obj1, obj2, cmd.type)); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1436 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1437 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1438 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1439 | case DAVQL_CMD_OP_LE: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1440 | //printf("le\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1441 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1442 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1443 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1444 | DAVQL_PUSH_INT(obj1.data.integer <= obj2.data.integer); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1445 | } else { |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1446 | DAVQL_PUSH_INT(cmd_str_cmp(obj1, obj2, cmd.type)); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1447 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1448 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1449 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1450 | case DAVQL_CMD_OP_GE: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1451 | //printf("ge\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1452 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1453 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1454 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1455 | DAVQL_PUSH_INT(obj1.data.integer >= obj2.data.integer); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1456 | } else { |
249
50fb9c9f6671
implemented string functionality for some davql operators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
1457 | DAVQL_PUSH_INT(cmd_str_cmp(obj1, obj2, cmd.type)); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1458 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1459 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1460 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1461 | case DAVQL_CMD_OP_LIKE: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1462 | //printf("like\n"); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1463 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1464 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1465 | case DAVQL_CMD_OP_UNLIKE: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1466 | //printf("unlike\n"); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1467 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1468 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1469 | case DAVQL_CMD_CALL: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1470 | //printf("call %x\n", cmd.data.func); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1471 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1472 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1473 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1474 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1475 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
1476 | if(stpos == 1) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
1477 | *result = stack[0]; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
1478 | } else { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
1479 | ret = -1; |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1480 | } |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
1481 | free(stack); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
1482 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
1483 | return ret; |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1484 | } |